diff --git a/lib/app/bindings/initial_binding.dart b/lib/app/bindings/initial_binding.dart index c4b6468..9526088 100644 --- a/lib/app/bindings/initial_binding.dart +++ b/lib/app/bindings/initial_binding.dart @@ -20,12 +20,12 @@ class InitialBinding implements Bindings { void _registerCoreServices() { /// 立即注册所有的适配器 - Get.put(UpgraderService()); Get.put(GetStorage(), permanent: true); Get.put(Uuid(), permanent: true); Get.put(HttpProvider()); Get.put(SQLiteProvider()); Get.put(ConnectivityProvider()); + Get.put(UpgraderService()); } void _registerRepositories() { diff --git a/lib/main.dart b/lib/main.dart index 376f945..8aae613 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -11,11 +11,11 @@ import 'package:flutter_localizations/flutter_localizations.dart'; void main() async { // 确保 Flutter Binding 已初始化 WidgetsFlutterBinding.ensureInitialized(); - // 设置应用为竖屏模式 - SystemChrome.setPreferredOrientations([ - DeviceOrientation.portraitUp, - DeviceOrientation.portraitDown, - ]); + // // 设置应用为竖屏模式 + // SystemChrome.setPreferredOrientations([ + // DeviceOrientation.portraitUp, + // DeviceOrientation.portraitDown, + // ]); // 初始化 GetStorage,这是关键步骤 await GetStorage.init(); // Add this line diff --git a/lib/modules/auth/views/login_page.dart b/lib/modules/auth/views/login_page.dart index 22d2483..c8586ea 100644 --- a/lib/modules/auth/views/login_page.dart +++ b/lib/modules/auth/views/login_page.dart @@ -33,8 +33,8 @@ class LoginPage extends GetView { child: Image.asset( 'assets/images/label.png', width: 171.5.w, - height: 23.5.h, - fit: BoxFit.fitWidth, + // height: 23.5.h, + fit: BoxFit.cover, ), ), SizedBox(height: 15.5.h), @@ -43,8 +43,8 @@ class LoginPage extends GetView { child: Image.asset( 'assets/images/label1.png', width: 296.5.w, - height: 35.5.h, - fit: BoxFit.fitWidth, + // height: 35.5.h, + fit: BoxFit.cover, ), ), SizedBox(height: 56.5.h), diff --git a/lib/modules/home/views/home_page.dart b/lib/modules/home/views/home_page.dart index 4a8279b..105fc4d 100644 --- a/lib/modules/home/views/home_page.dart +++ b/lib/modules/home/views/home_page.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:problem_check_system/modules/home/controllers/home_controller.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; class HomePage extends GetView { const HomePage({super.key}); @@ -9,27 +10,87 @@ class HomePage extends GetView { Widget build(BuildContext context) { return Obx( () => Scaffold( - body: controller.pages[controller.selectedIndex.value], // 根据状态显示页面 - bottomNavigationBar: NavigationBar( - selectedIndex: controller.selectedIndex.value, - onDestinationSelected: controller.changeIndex, // 回调控制状态更新 - destinations: const [ - // NavigationDestination( - // icon: Icon(Icons.home_outlined), - // selectedIcon: Icon(Icons.home), - // label: '首页', - // ), - NavigationDestination( - icon: Icon(Icons.description_outlined), - selectedIcon: Icon(Icons.description), - label: '问题', - ), - NavigationDestination( - icon: Icon(Icons.person_outline), - selectedIcon: Icon(Icons.person), - label: '我的', - ), - ], + body: controller.pages[controller.selectedIndex.value], + bottomNavigationBar: _buildCustomBottomBar(), + ), + ); + } + + Widget _buildCustomBottomBar() { + return Container( + height: 60.h, // 自定义高度 + decoration: BoxDecoration( + color: Colors.white, + boxShadow: [ + BoxShadow( + color: Colors.grey.withAlpha(76), + blurRadius: 8, + offset: const Offset(0, -2), + ), + ], + ), + child: Row( + children: [ + // 首页项(已注释) + // _buildBottomBarItem( + // index: 0, + // icon: Icons.home_outlined, + // activeIcon: Icons.home, + // label: '首页', + // ), + _buildBottomBarItem( + index: 0, + icon: Icons.description_outlined, + activeIcon: Icons.description, + label: '问题', + ), + _buildBottomBarItem( + index: 1, + icon: Icons.person_outlined, + activeIcon: Icons.person, + label: '我的', + ), + ], + ), + ); + } + + Widget _buildBottomBarItem({ + required int index, + required IconData icon, + required IconData activeIcon, + required String label, + }) { + bool isSelected = controller.selectedIndex.value == index; + + return Expanded( + child: GestureDetector( + onTap: () => controller.changeIndex(index), + child: Container( + color: Colors.transparent, // 透明背景,无点击效果 + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + isSelected ? activeIcon : icon, + color: isSelected + ? const Color(0xFF418CFC) + : Colors.grey.shade600, + size: 24.w, + ), + SizedBox(width: 4.w), // 图标和文字之间的间距 + Text( + label, + style: TextStyle( + fontSize: 14.sp, + color: isSelected + ? const Color(0xFF418CFC) + : Colors.grey.shade600, + fontWeight: isSelected ? FontWeight.w500 : FontWeight.normal, + ), + ), + ], + ), ), ), );