|
|
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:bot_toast/bot_toast.dart';
|
|
|
|
|
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
|
|
|
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
@ -14,6 +15,7 @@ import 'package:aku_new_community/ui/market/market_page.dart';
|
|
|
|
|
import 'package:aku_new_community/utils/websocket/web_socket_util.dart';
|
|
|
|
|
import 'package:aku_new_community/widget/bee_scaffold.dart';
|
|
|
|
|
import 'package:aku_new_community/widget/others/user_tool.dart';
|
|
|
|
|
import '../utils/updater_page.dart';
|
|
|
|
|
import 'home/home_page.dart';
|
|
|
|
|
import 'opening_code_page/opening_code_page.dart';
|
|
|
|
|
import 'personal/personal_page.dart';
|
|
|
|
@ -40,10 +42,18 @@ class _TabNavigatorState extends State<TabNavigator>
|
|
|
|
|
List<Widget> _pages = <Widget>[];
|
|
|
|
|
|
|
|
|
|
EasyRefreshController _refreshController = EasyRefreshController();
|
|
|
|
|
late FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
|
|
|
|
|
var android = new AndroidInitializationSettings('@mipmap/ic_launcher');
|
|
|
|
|
var iOS = new IOSInitializationSettings();
|
|
|
|
|
var initSettings = new InitializationSettings(android: android,iOS: iOS);
|
|
|
|
|
flutterLocalNotificationsPlugin.initialize(initSettings);
|
|
|
|
|
//showNotification();
|
|
|
|
|
|
|
|
|
|
final appProvider = Provider.of<AppProvider>(Get.context!);
|
|
|
|
|
Future.delayed(Duration(milliseconds: 0), () async {
|
|
|
|
|
await appProvider.getMyAddress(); //设置默认地址
|
|
|
|
@ -181,41 +191,69 @@ class _TabNavigatorState extends State<TabNavigator>
|
|
|
|
|
4,
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
return BeeScaffold(
|
|
|
|
|
body: WillPopScope(
|
|
|
|
|
onWillPop: () async {
|
|
|
|
|
if (_lastPressed == null ||
|
|
|
|
|
DateTime.now().difference(_lastPressed!) > Duration(seconds: 1)) {
|
|
|
|
|
//两次点击间隔超过1秒重新计算
|
|
|
|
|
_lastPressed = DateTime.now();
|
|
|
|
|
BotToast.showText(text: '再点击一次返回退出');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
//否则关闭app
|
|
|
|
|
WebSocketUtil().closeWebSocket();
|
|
|
|
|
return true;
|
|
|
|
|
},
|
|
|
|
|
child: TabBarView(
|
|
|
|
|
children: _pages,
|
|
|
|
|
controller: _tabController,
|
|
|
|
|
physics: NeverScrollableScrollPhysics(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
bottomNavi: ConstrainedBox(
|
|
|
|
|
constraints: BoxConstraints(maxWidth: 750.w, maxHeight: 146.w),
|
|
|
|
|
child: Container(
|
|
|
|
|
margin:
|
|
|
|
|
return UpdaterPage(
|
|
|
|
|
BeeScaffold(
|
|
|
|
|
body: WillPopScope(
|
|
|
|
|
onWillPop: () async {
|
|
|
|
|
if (_lastPressed == null ||
|
|
|
|
|
DateTime.now().difference(_lastPressed!) > Duration(seconds: 1)) {
|
|
|
|
|
//两次点击间隔超过1秒重新计算
|
|
|
|
|
_lastPressed = DateTime.now();
|
|
|
|
|
BotToast.showText(text: '再点击一次返回退出');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
//否则关闭app
|
|
|
|
|
WebSocketUtil().closeWebSocket();
|
|
|
|
|
return true;
|
|
|
|
|
},
|
|
|
|
|
child: TabBarView(
|
|
|
|
|
children: _pages,
|
|
|
|
|
controller: _tabController,
|
|
|
|
|
physics: NeverScrollableScrollPhysics(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
bottomNavi: ConstrainedBox(
|
|
|
|
|
constraints: BoxConstraints(maxWidth: 750.w, maxHeight: 146.w),
|
|
|
|
|
child: Container(
|
|
|
|
|
margin:
|
|
|
|
|
EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
image: DecorationImage(
|
|
|
|
|
image: Assets.home.imgTabdi, fit: BoxFit.fitWidth),
|
|
|
|
|
color: Colors.transparent),
|
|
|
|
|
child: Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
children: _bottomNav.cast<Widget>().toList(),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
image: DecorationImage(
|
|
|
|
|
image: Assets.home.imgTabdi, fit: BoxFit.fitWidth),
|
|
|
|
|
color: Colors.transparent),
|
|
|
|
|
child: Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
children: _bottomNav.cast<Widget>().toList(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future onSelectNotification(String payload) async {
|
|
|
|
|
if (payload != null) {
|
|
|
|
|
debugPrint('notification payload: ' + payload);
|
|
|
|
|
}
|
|
|
|
|
//payload 可作为通知的一个标记,区分点击的通知。
|
|
|
|
|
debugPrint('payload:$payload');
|
|
|
|
|
if(payload == "complete") {
|
|
|
|
|
await showDialog(context: context, builder: (_) => AlertDialog(
|
|
|
|
|
title: Text('Notification'),
|
|
|
|
|
content: Text('$payload'),
|
|
|
|
|
),);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showNotification() async {
|
|
|
|
|
var android = new AndroidNotificationDetails(
|
|
|
|
|
'channel id', 'channel NAME',
|
|
|
|
|
priority: Priority.high,
|
|
|
|
|
importance: Importance.max,);
|
|
|
|
|
var iOS = new IOSNotificationDetails();
|
|
|
|
|
var platform = new NotificationDetails(android: android, iOS: iOS);
|
|
|
|
|
await flutterLocalNotificationsPlugin.show(
|
|
|
|
|
0, 'New Video is out', 'Flutter Local Notification', platform,
|
|
|
|
|
payload: 'Nitish Kumar Singh is part time Youtuber');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|