feat:重构模块

This commit is contained in:
2026-06-27 17:12:38 +08:00
parent a5e788eee6
commit a340ba424e
31 changed files with 919 additions and 623 deletions

View File

@@ -16,24 +16,30 @@ import 'package:food_hub_app/views/recipe_form.dart';
import 'package:food_hub_app/views/record_form.dart';
import 'package:food_hub_app/views/recipe_detail.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:liquid_glass_widgets/liquid_glass_setup.dart';
import 'package:provider/provider.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
FormBuilderLocalizations.delegate.load(const Locale('zh', 'CN'));
await SPUtil.init();
await initLogger();
// await initLogger();
// 预编译 shader防止首帧白闪
await LiquidGlassWidgets.initialize();
// wrap() 安装无障碍桥接、全局主题、自适应质量
runApp(
MultiProvider(
providers: [
ChangeNotifierProvider(create: (context) => FoodProvider()),
ChangeNotifierProvider(create: (context) => ThemeProvider()),
ChangeNotifierProvider(create: (context) => UserProvider()),
ChangeNotifierProvider(create: (context) => AppProvider()),
],
child: MyApp(),
LiquidGlassWidgets.wrap(
child: MultiProvider(
providers: [
ChangeNotifierProvider(create: (context) => FoodProvider()),
ChangeNotifierProvider(create: (context) => ThemeProvider()),
ChangeNotifierProvider(create: (context) => UserProvider()),
ChangeNotifierProvider(create: (context) => AppProvider()),
],
child: const MyApp(),
),
),
);
}
@@ -45,10 +51,52 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
final themeProvider = context.watch<ThemeProvider>();
final brightness = MediaQuery.of(context).platformBrightness;
themeProvider.isDarkMode = brightness == Brightness.dark;
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: themeProvider.currentThemeData,
theme: ThemeData(
scaffoldBackgroundColor: const Color(0xFFFAF6F0),
colorScheme: ColorScheme(
brightness: Brightness.light,
primary: const Color(0xFFE89F71),
secondary: const Color(0xFFE89F71),
surface: const Color(0xFFFFFFFF),
error: const Color(0xFFE76F51),
onPrimary: Colors.white,
onSecondary: Colors.white,
onSurface: const Color(0xFF3A332C),
onError: Colors.white,
),
textTheme: TextTheme(
titleLarge: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w600,
color: const Color(0xFF3A332C),
),
titleMedium: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: const Color(0xFF3A332C),
),
bodyLarge: TextStyle(
fontSize: 15,
color: const Color(0xFF3A332C),
),
bodyMedium: TextStyle(
fontSize: 14,
color: const Color(0xFF8C8379),
),
bodySmall: TextStyle(
fontSize: 12,
color: const Color(0xFF8C8379),
),
),
fontFamily: 'CustomFont',
useMaterial3: true,
),
supportedLocales: const [
Locale('en', 'US'), // 英语
Locale('zh', 'CN'), // 中文
@@ -71,13 +119,13 @@ class MyApp extends StatelessWidget {
home: LoginPage(),
routes: {
'/home': (context) => HomePage(),
'/recordForm': (context) => RecordFormPage(),
'/recordForm': (context) => RecordForm(),
'/recipeForm': (context) => RecipeFormPage(),
'/recipeDetail': (context) => RecipeDetailPage(),
'/momentForm': (context) => MomentFormPage(),
'/momentForm': (context) => MomentForm(),
'/moment': (context) => MomentPage(),
'/momentUser': (context) => MomentUserPage(),
'/ProfileUser': (context) => ProfileUserPage()
'/ProfileUser': (context) => ProfileUserPage(),
},
);
}