2026-09-13 00:57:32 +08:00
|
|
|
|
// 功能:装配用户端主题与路由,并让桌面 Web 预览保持产品图手机画布宽度。
|
|
|
|
|
|
// 版本:1.1.0。
|
|
|
|
|
|
import 'package:flutter/foundation.dart';
|
2026-07-30 21:47:41 +08:00
|
|
|
|
import 'package:flutter/material.dart';
|
2026-09-13 00:57:32 +08:00
|
|
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
2026-07-30 21:47:41 +08:00
|
|
|
|
|
|
|
|
|
|
import '../ui/core/app_theme.dart';
|
|
|
|
|
|
import 'dependencies.dart';
|
|
|
|
|
|
import 'router.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class UserClientApp extends StatefulWidget {
|
|
|
|
|
|
const UserClientApp({required this.dependencies, super.key});
|
|
|
|
|
|
|
|
|
|
|
|
final AppDependencies dependencies;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
State<UserClientApp> createState() => _UserClientAppState();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _UserClientAppState extends State<UserClientApp> {
|
|
|
|
|
|
late final _router = createRouter(widget.dependencies);
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) => MaterialApp.router(
|
|
|
|
|
|
title: '瓶安芯',
|
2026-09-13 00:57:32 +08:00
|
|
|
|
// 首期面向中文用户,系统日期与时间控件统一使用简体中文。
|
|
|
|
|
|
locale: const Locale('zh', 'CN'),
|
|
|
|
|
|
supportedLocales: const [Locale('zh', 'CN')],
|
|
|
|
|
|
localizationsDelegates: GlobalMaterialLocalizations.delegates,
|
2026-07-30 21:47:41 +08:00
|
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
|
|
theme: AppTheme.light(),
|
2026-08-10 23:31:44 +08:00
|
|
|
|
darkTheme: AppTheme.dark(),
|
|
|
|
|
|
themeMode: ThemeMode.system,
|
2026-07-30 21:47:41 +08:00
|
|
|
|
routerConfig: _router,
|
2026-09-13 00:57:32 +08:00
|
|
|
|
builder: (context, child) {
|
|
|
|
|
|
if (!kIsWeb) return child ?? const SizedBox.shrink();
|
|
|
|
|
|
// 产品设计宽853像素按2倍密度绘制;Web预览以427 CSS像素展示同一手机画布。
|
|
|
|
|
|
return ColoredBox(
|
|
|
|
|
|
color: const Color(0xFFEFF2F7),
|
|
|
|
|
|
child: Align(
|
|
|
|
|
|
alignment: Alignment.topCenter,
|
|
|
|
|
|
child: ConstrainedBox(
|
|
|
|
|
|
constraints: const BoxConstraints(maxWidth: 427),
|
|
|
|
|
|
child: SizedBox(width: double.infinity, child: child),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
2026-07-30 21:47:41 +08:00
|
|
|
|
);
|
|
|
|
|
|
}
|