|
|
|
@ -9,6 +9,7 @@ import 'package:huixiang/home/main_home_page.dart';
|
|
|
|
|
import 'package:huixiang/main.dart'; |
|
|
|
|
import 'package:huixiang/mine/mine_page.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/base_data.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/user_info.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/retrofit_api.dart'; |
|
|
|
|
import 'package:huixiang/union/union_page.dart'; |
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
@ -17,6 +18,7 @@ import 'package:huixiang/utils/event_type.dart';
|
|
|
|
|
import 'package:huixiang/utils/native_event_handler.dart'; |
|
|
|
|
import 'package:permission_handler/permission_handler.dart'; |
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
|
import 'package:tpns_flutter_plugin/tpns_flutter_plugin.dart'; |
|
|
|
|
|
|
|
|
|
class MainPage extends StatefulWidget { |
|
|
|
|
@override |
|
|
|
@ -58,7 +60,6 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
|
|
|
|
|
super.initState(); |
|
|
|
|
WidgetsBinding.instance.addObserver(this); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EasyLoading.instance |
|
|
|
|
..indicatorType = EasyLoadingIndicatorType.circle |
|
|
|
|
// ..indicatorType = EasyLoadingIndicatorType.wave |
|
|
|
@ -71,7 +72,6 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
|
|
|
|
|
..userInteractions = false |
|
|
|
|
..dismissOnTap = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pushRoute(); |
|
|
|
|
|
|
|
|
|
_widgetOptions = <Widget>[ |
|
|
|
@ -122,12 +122,15 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
|
|
|
|
|
: (event["xg"]["msgtype"] == 1) && |
|
|
|
|
event[Platform.isAndroid ? "customMessage" : "custom"] != null) { |
|
|
|
|
SharedPreferences.getInstance().then((value) { |
|
|
|
|
value.setString("pushData", event[Platform.isAndroid ? "customMessage" : "custom"]); |
|
|
|
|
value.setString("pushData", |
|
|
|
|
event[Platform.isAndroid ? "customMessage" : "custom"]); |
|
|
|
|
}); |
|
|
|
|
if (ModalRoute.of(context).isActive && ModalRoute.of(context).isCurrent) { |
|
|
|
|
if (ModalRoute.of(context).isActive && |
|
|
|
|
ModalRoute.of(context).isCurrent) { |
|
|
|
|
pushRoute(); |
|
|
|
|
} else { |
|
|
|
|
Navigator.of(context).pushNamedAndRemoveUntil('/router/main_page', (route) => false); |
|
|
|
|
Navigator.of(context) |
|
|
|
|
.pushNamedAndRemoveUntil('/router/main_page', (route) => false); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return event; |
|
|
|
@ -192,10 +195,17 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
|
|
|
|
|
SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); |
|
|
|
|
if (sharedPreferences.getString("token") == null || |
|
|
|
|
sharedPreferences.getString("token") == "") return; |
|
|
|
|
BaseData baseDate = await ApiService(Dio(), |
|
|
|
|
BaseData<UserInfo> baseDate = await ApiService(Dio(), |
|
|
|
|
context: context, token: sharedPreferences.getString('token')) |
|
|
|
|
.queryInfo(); |
|
|
|
|
sharedPreferences.setString('user', jsonEncode(baseDate.data)); |
|
|
|
|
|
|
|
|
|
String mobile = baseDate.data.phone; |
|
|
|
|
if (mobile != null && mobile != "") { |
|
|
|
|
xgFlutterPlugin.setAccount(mobile, AccountType.UNKNOWN); |
|
|
|
|
xgFlutterPlugin.bindWithIdentifier( |
|
|
|
|
identify: mobile, bindType: XGBindType.account); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
requestPermission() async { |
|
|
|
@ -234,9 +244,8 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
|
|
|
|
|
spreadRadius: 0, |
|
|
|
|
) |
|
|
|
|
], |
|
|
|
|
borderRadius: BorderRadius.only( |
|
|
|
|
topRight: Radius.circular(4), |
|
|
|
|
topLeft: Radius.circular(4), |
|
|
|
|
borderRadius: BorderRadius.vertical( |
|
|
|
|
top: Radius.circular(4), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
height: 82.h, |
|
|
|
|