51 lines
1.7 KiB
Dart
51 lines
1.7 KiB
Dart
// 功能:装配用户端主题与路由,并让桌面 Web 预览保持产品图手机画布宽度。
|
||
// 版本:1.1.0。
|
||
import 'package:flutter/foundation.dart';
|
||
import 'package:flutter/material.dart';
|
||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||
|
||
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: '瓶安芯',
|
||
// 首期面向中文用户,系统日期与时间控件统一使用简体中文。
|
||
locale: const Locale('zh', 'CN'),
|
||
supportedLocales: const [Locale('zh', 'CN')],
|
||
localizationsDelegates: GlobalMaterialLocalizations.delegates,
|
||
debugShowCheckedModeBanner: false,
|
||
theme: AppTheme.light(),
|
||
darkTheme: AppTheme.dark(),
|
||
themeMode: ThemeMode.system,
|
||
routerConfig: _router,
|
||
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),
|
||
),
|
||
),
|
||
);
|
||
},
|
||
);
|
||
}
|