| | |
| | | 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(); |
| | | |
| | | 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( |
| | | 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( |
| | |
| | | ], |
| | | ), |
| | | ), |
| | | ); |
| | | )); |
| | | } |
| | | |
| | | Widget getNavItem( |
| | |
| | | Container( |
| | | height: 3, |
| | | ), |
| | | Text( |
| | | const Text( |
| | | "定位", |
| | | style: TextStyle(color: Colors.white, fontSize: 9), |
| | | ) |