main_page.dart 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import 'package:cs_resources/theme/theme_config.dart';
  2. import 'package:flutter/services.dart';
  3. import 'package:flutter/src/widgets/framework.dart';
  4. import 'package:hooks_riverpod/hooks_riverpod.dart';
  5. import 'package:auto_route/auto_route.dart';
  6. import 'package:flutter/material.dart';
  7. import 'package:shared/utils/ext_dart.dart';
  8. import '../../../router/page/main_page_router.dart';
  9. import 'package:router/ext/auto_router_extensions.dart';
  10. @RoutePage()
  11. class MainPage extends HookConsumerWidget {
  12. const MainPage({super.key});
  13. //启动当前页面
  14. static void startInstance({BuildContext? context}) {
  15. if (context != null) {
  16. context.router.popUntilRoot();
  17. context.router.replace(const MainPageRoute());
  18. } else {
  19. appRouter.popUntilRoot();
  20. appRouter.replace(const MainPageRoute());
  21. }
  22. }
  23. @override
  24. Widget build(BuildContext context, WidgetRef ref) {
  25. // return AutoTabsRouter(
  26. // routes: const [
  27. // HomePageRoute(),
  28. // VisitorPageRoute(),
  29. // FeedbackPageRoute(),
  30. // MePageRoute(),
  31. // ],
  32. // transitionBuilder: (context, child, animation) => FadeTransition(
  33. // opacity: animation,
  34. // child: child,
  35. // ),
  36. // builder: (context, child) {
  37. // final tabsRouter = AutoTabsRouter.of(context);
  38. // return AnnotatedRegion<SystemUiOverlayStyle>(
  39. // value: ThemeConfig.getSystemUiOverlayStyleByTheme(context),
  40. // child: Scaffold(
  41. // body: child,
  42. // bottomNavigationBar: BottomNavigationBar(
  43. // backgroundColor: context.theme.primaryColor,
  44. // selectedItemColor: context.theme.colorScheme.secondary,
  45. // unselectedItemColor: Colors.grey[500],
  46. // elevation: 20,
  47. // type: BottomNavigationBarType.fixed,
  48. // items: const <BottomNavigationBarItem>[
  49. // BottomNavigationBarItem(
  50. // icon: Icon(Icons.home),
  51. // label: 'Home',
  52. // ),
  53. // BottomNavigationBarItem(
  54. // icon: Icon(Icons.card_giftcard),
  55. // label: 'Visitor',
  56. // ),
  57. // BottomNavigationBarItem(
  58. // icon: Icon(Icons.feed),
  59. // label: 'Feedback',
  60. // ),
  61. // BottomNavigationBarItem(
  62. // icon: Icon(Icons.person),
  63. // label: 'Me',
  64. // ),
  65. // ],
  66. // onTap: tabsRouter.setActiveIndex,
  67. // currentIndex: tabsRouter.activeIndex,
  68. // ),
  69. // ));
  70. // },
  71. // );
  72. return AutoTabsScaffold(
  73. routes: const [
  74. HomePageRoute(),
  75. VisitorPageRoute(),
  76. FeedbackPageRoute(),
  77. MePageRoute(),
  78. ],
  79. transitionBuilder: (context, child, animation) => FadeTransition(
  80. opacity: animation,
  81. child: child,
  82. ),
  83. bottomNavigationBuilder: (context, tabsRouter) {
  84. return BottomNavigationBar(
  85. unselectedItemColor: Colors.grey[500],
  86. elevation: 20,
  87. type: BottomNavigationBarType.fixed,
  88. currentIndex: tabsRouter.activeIndex,
  89. onTap: tabsRouter.setActiveIndex,
  90. items: const [
  91. BottomNavigationBarItem(
  92. icon: Icon(Icons.home),
  93. label: 'Home',
  94. ),
  95. BottomNavigationBarItem(
  96. icon: Icon(Icons.card_giftcard),
  97. label: 'Visitor',
  98. ),
  99. BottomNavigationBarItem(
  100. icon: Icon(Icons.feed),
  101. label: 'Feedback',
  102. ),
  103. BottomNavigationBarItem(
  104. icon: Icon(Icons.person),
  105. label: 'Me',
  106. ),
  107. ],
  108. );
  109. },
  110. );
  111. }
  112. }