| | |
| | | import 'package:locations/ui/mine/permission.dart'; |
| | | import 'package:locations/ui/widget/dialog.dart'; |
| | | import 'package:locations/utils/ad_util.dart'; |
| | | import 'package:locations/utils/event_bus_util.dart'; |
| | | import 'package:locations/utils/pageutils.dart'; |
| | | import 'package:locations/utils/ui_constant.dart'; |
| | | import 'package:locations/utils/ui_utils.dart'; |
| | |
| | | TabController(length: _pages.length, initialIndex: 1, vsync: this); |
| | | super.initState(); |
| | | |
| | | AdUtil.getAdInfo(AdPosition.homeInterstitial).then((value) { |
| | | AdUtil.loadInterstitial(value, (success, msg) {}); |
| | | Timer(const Duration(seconds: 1), () { |
| | | AdUtil.getAdInfo(AdPosition.homeInterstitial).then((value) { |
| | | AdUtil.loadInterstitial(value, (success, msg) {}); |
| | | }); |
| | | }); |
| | | |
| | | UserUtil.updateUserInfo(context); |
| | | } |
| | | |
| | | int lastCenterClick = 0; |
| | | |
| | | //设置选中的导航栏 |
| | | void setSelectIndex(int i) { |
| | | if (i == selectIndex) { |
| | | if (selectIndex == 1) { |
| | | if (DateTime.now().millisecondsSinceEpoch - lastCenterClick < 400) { |
| | | //双击 |
| | | eventBus.fire(RequestLocationEventBus(true, false)); |
| | | print("双击"); |
| | | } else { |
| | | //单击 |
| | | Future.delayed(const Duration(milliseconds: 400), () { |
| | | if (DateTime.now().millisecondsSinceEpoch - lastCenterClick < |
| | | 400) { |
| | | return; |
| | | } |
| | | eventBus.fire(RequestLocationEventBus(true, true)); |
| | | print("单击"); |
| | | }); |
| | | |
| | | |
| | | } |
| | | lastCenterClick = DateTime.now().millisecondsSinceEpoch; |
| | | } |
| | | return; |
| | | } |
| | | setState(() { |
| | |
| | | _tabController!.animateTo(i); |
| | | } |
| | | |
| | | int lastBack = 0; |
| | | |
| | | @override |
| | | Widget build(BuildContext context) { |
| | | return Scaffold( |
| | | backgroundColor: Colors.white, |
| | | resizeToAvoidBottomInset: false, |
| | | body: Container( |
| | | child: Stack( |
| | | children: [ |
| | | //内容栏 |
| | | Container( |
| | | color: Colors.white, |
| | | child: Flex( |
| | | direction: Axis.vertical, |
| | | children: [ |
| | | Expanded( |
| | | child: TabBarView( |
| | | controller: _tabController, |
| | | children: _pages, |
| | | physics: const NeverScrollableScrollPhysics(), |
| | | )), |
| | | Container( |
| | | height: 60, |
| | | ) |
| | | ], |
| | | ), |
| | | ), |
| | | return WillPopScope( |
| | | onWillPop: () async { |
| | | if (DateTime.now().millisecondsSinceEpoch - lastBack > 1000 * 5) { |
| | | lastBack = DateTime.now().millisecondsSinceEpoch; |
| | | ToastUtil.toast("再按一次退出应用"); |
| | | return false; |
| | | } else { |
| | | return true; |
| | | } |
| | | }, |
| | | child: Scaffold( |
| | | backgroundColor: Colors.white, |
| | | resizeToAvoidBottomInset: false, |
| | | body: Container( |
| | | child: Stack( |
| | | children: [ |
| | | //内容栏 |
| | | Container( |
| | | color: Colors.white, |
| | | child: Flex( |
| | | direction: Axis.vertical, |
| | | children: [ |
| | | Expanded( |
| | | child: TabBarView( |
| | | controller: _tabController, |
| | | children: _pages, |
| | | physics: const NeverScrollableScrollPhysics(), |
| | | )), |
| | | Container( |
| | | height: 60, |
| | | ) |
| | | ], |
| | | ), |
| | | ), |
| | | |
| | | //底部导航栏 |
| | | Positioned( |
| | | bottom: 0, |
| | | child: Container( |
| | | child: Stack( |
| | | alignment: Alignment.bottomCenter, |
| | | children: [ |
| | | Container( |
| | | height: 60, |
| | | width: MediaQuery.of(context).size.width, |
| | | alignment: Alignment.center, |
| | | decoration: |
| | | BoxDecoration(color: Colors.white, boxShadow: [ |
| | | BoxShadow( |
| | | blurRadius: 10, |
| | | spreadRadius: 1, |
| | | color: Color(0x4D0E96FF), |
| | | ) |
| | | ]), |
| | | child: Flex( |
| | | direction: Axis.horizontal, |
| | | children: [ |
| | | Expanded( |
| | | child: getNavItem( |
| | | icon: Image.asset( |
| | | "assets/images/main/icon_main_nav_history.png", |
| | | width: 31, |
| | | ), |
| | | iconHighlight: Image.asset( |
| | | "assets/images/main/icon_main_nav_history_highlight.png", |
| | | width: 31, |
| | | ), |
| | | text: "轨迹", |
| | | index: 0)), |
| | | Container( |
| | | width: 54, |
| | | //底部导航栏 |
| | | Positioned( |
| | | bottom: 0, |
| | | child: Container( |
| | | child: Stack( |
| | | alignment: Alignment.bottomCenter, |
| | | children: [ |
| | | Container( |
| | | height: 60, |
| | | width: MediaQuery.of(context).size.width, |
| | | alignment: Alignment.center, |
| | | decoration: |
| | | BoxDecoration(color: Colors.white, boxShadow: [ |
| | | BoxShadow( |
| | | blurRadius: 10, |
| | | spreadRadius: 1, |
| | | color: Color(0x4D0E96FF), |
| | | ) |
| | | ]), |
| | | child: Flex( |
| | | direction: Axis.horizontal, |
| | | children: [ |
| | | Expanded( |
| | | child: getNavItem( |
| | | icon: Image.asset( |
| | | "assets/images/main/icon_main_nav_history.png", |
| | | width: 31, |
| | | ), |
| | | iconHighlight: Image.asset( |
| | | "assets/images/main/icon_main_nav_history_highlight.png", |
| | | width: 31, |
| | | ), |
| | | text: "轨迹", |
| | | index: 0)), |
| | | Container( |
| | | width: 54, |
| | | ), |
| | | Expanded( |
| | | child: getNavItem( |
| | | icon: Image.asset( |
| | | "assets/images/main/icon_main_nav_mine.png", |
| | | width: 31), |
| | | iconHighlight: Image.asset( |
| | | "assets/images/main/icon_main_nav_mine_highlight.png", |
| | | width: 31), |
| | | text: "我的", |
| | | index: 2)), |
| | | ], |
| | | ), |
| | | Expanded( |
| | | child: getNavItem( |
| | | icon: Image.asset( |
| | | "assets/images/main/icon_main_nav_mine.png", |
| | | width: 31), |
| | | iconHighlight: Image.asset( |
| | | "assets/images/main/icon_main_nav_mine_highlight.png", |
| | | width: 31), |
| | | text: "我的", |
| | | index: 2)), |
| | | ], |
| | | ), |
| | | ), |
| | | Positioned( |
| | | child: Container( |
| | | height: 72, |
| | | width: 72, |
| | | decoration: BoxDecoration( |
| | | color: Colors.white, |
| | | borderRadius: BorderRadius.circular(36), |
| | | boxShadow: [ |
| | | BoxShadow( |
| | | blurRadius: 10, |
| | | spreadRadius: 1, |
| | | color: Color(0x4D0E96FF)) |
| | | ]), |
| | | ), |
| | | ), |
| | | Container( |
| | | height: 60, |
| | | width: 100, |
| | | color: Colors.white, |
| | | ), |
| | | Container( |
| | | height: 72, |
| | | width: 72, |
| | | alignment: Alignment.center, |
| | | child: getNavLocationItem(), |
| | | ) |
| | | ], |
| | | ))) |
| | | ], |
| | | ), |
| | | ), |
| | | ); |
| | | ), |
| | | Positioned( |
| | | child: Container( |
| | | height: 72, |
| | | width: 72, |
| | | decoration: BoxDecoration( |
| | | color: Colors.white, |
| | | borderRadius: BorderRadius.circular(36), |
| | | boxShadow: [ |
| | | BoxShadow( |
| | | blurRadius: 10, |
| | | spreadRadius: 1, |
| | | color: Color(0x4D0E96FF)) |
| | | ]), |
| | | ), |
| | | ), |
| | | Container( |
| | | height: 60, |
| | | width: 100, |
| | | color: Colors.white, |
| | | ), |
| | | Container( |
| | | height: 72, |
| | | width: 72, |
| | | alignment: Alignment.center, |
| | | child: getNavLocationItem(), |
| | | ) |
| | | ], |
| | | ))) |
| | | ], |
| | | ), |
| | | ), |
| | | )); |
| | | } |
| | | |
| | | Widget getNavItem( |
| | |
| | | Container( |
| | | height: 3, |
| | | ), |
| | | Text( |
| | | const Text( |
| | | "定位", |
| | | style: TextStyle(color: Colors.white, fontSize: 9), |
| | | ) |