@@ -53,8 +53,8 @@ android { | |||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||||
ndk { | ndk { | ||||
//选择要添加的对应cpu类型的.so库。 | //选择要添加的对应cpu类型的.so库。 | ||||
abiFilters 'armeabi', 'armeabi-v7a', 'x86', 'x86_64', 'mips', 'mips64', 'arm64-v8a' | |||||
//abiFilters 'armeabi-v7a','x86_64' | |||||
abiFilters 'armeabi', 'armeabi-v7a', 'x86', 'x86_64', 'mips', 'mips64', 'arm64-v8a' | |||||
// abiFilters 'armeabi-v7a','x86_64' | |||||
} | } | ||||
} | } | ||||
@@ -113,9 +113,9 @@ android { | |||||
// // 智夜生活 | // // 智夜生活 | ||||
// zhiying { | // zhiying { | ||||
// applicationId "cn.zhios.zhiying" | // applicationId "cn.zhios.zhiying" | ||||
// versionCode 53 | |||||
// versionCode 55 | |||||
// dimension "app" | // dimension "app" | ||||
// versionName '1.3.13' | |||||
// versionName '1.3.15' | |||||
// // 签名信息 | // // 签名信息 | ||||
// signingConfig signingConfigs.zhiying | // signingConfig signingConfigs.zhiying | ||||
// } | // } | ||||
@@ -429,7 +429,7 @@ SPEC CHECKSUMS: | |||||
flutter_webview_plugin: ed9e8a6a96baf0c867e90e1bce2673913eeac694 | flutter_webview_plugin: ed9e8a6a96baf0c867e90e1bce2673913eeac694 | ||||
flutter_xupdate: bdb588f0fe4f6c5e45436b8b0de08d505a50c04e | flutter_xupdate: bdb588f0fe4f6c5e45436b8b0de08d505a50c04e | ||||
fluttertoast: b644586ef3b16f67fae9a1f8754cef6b2d6b634b | fluttertoast: b644586ef3b16f67fae9a1f8754cef6b2d6b634b | ||||
fluwx: 07a55ed66bf3a4961e836a2a411b02dcada32902 | |||||
fluwx: 8d47bee15c7fed07b94c2a12fb2381677232431a | |||||
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a | FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a | ||||
image_cropper: 3c16d7651730ffe85897f5a1c4e2547e6b54989a | image_cropper: 3c16d7651730ffe85897f5a1c4e2547e6b54989a | ||||
image_picker: 9c3312491f862b28d21ecd8fdf0ee14e601b3f09 | image_picker: 9c3312491f862b28d21ecd8fdf0ee14e601b3f09 | ||||
@@ -22,6 +22,7 @@ import 'package:zhiying_moments/register.dart'; | |||||
import 'package:zhiying_member_upgrade/register.dart'; | import 'package:zhiying_member_upgrade/register.dart'; | ||||
import 'package:zhiying_equity_card/zhiying_equity_card.dart'; | import 'package:zhiying_equity_card/zhiying_equity_card.dart'; | ||||
import 'package:zhiying_official/register.dart'; | import 'package:zhiying_official/register.dart'; | ||||
import 'package:zhiying_base_widget/zhiying_base_widget.dart'; | |||||
void main() { | void main() { | ||||
FlutterError.onError = (FlutterErrorDetails details) { | FlutterError.onError = (FlutterErrorDetails details) { | ||||
@@ -38,21 +39,16 @@ class MyApp extends StatefulWidget { | |||||
} | } | ||||
class _MyAppState extends State<MyApp> { | class _MyAppState extends State<MyApp> { | ||||
Widget getErrorWidget(BuildContext context, FlutterErrorDetails error) { | Widget getErrorWidget(BuildContext context, FlutterErrorDetails error) { | ||||
var erroStr=''; | |||||
var erroStr = ''; | |||||
const bool inProduction = const bool.fromEnvironment("dart.vm.product"); | const bool inProduction = const bool.fromEnvironment("dart.vm.product"); | ||||
if ( !inProduction) { | |||||
erroStr=error.exceptionAsString(); | |||||
if (!inProduction) { | |||||
erroStr = error.exceptionAsString(); | |||||
} | } | ||||
return Center( | return Center( | ||||
child: Text( | child: Text( | ||||
""+erroStr, | |||||
style: Theme | |||||
.of(context) | |||||
.textTheme | |||||
.title | |||||
.copyWith(color: Colors.grey[200]), | |||||
"" + erroStr, | |||||
style: Theme.of(context).textTheme.title.copyWith(color: Colors.grey[200]), | |||||
), | ), | ||||
); | ); | ||||
} | } | ||||
@@ -75,12 +71,12 @@ class _MyAppState extends State<MyApp> { | |||||
}); | }); | ||||
MobPushUtil.setCanPush(); | MobPushUtil.setCanPush(); | ||||
EventUtil.instance.on().listen((event) {}); | |||||
// app更新插件 | // app更新插件 | ||||
AppUpdateUtil.initXUpdate(); | AppUpdateUtil.initXUpdate(); | ||||
} | } | ||||
@override | @override | ||||
Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
ErrorWidget.builder = (FlutterErrorDetails errorDetails) { | ErrorWidget.builder = (FlutterErrorDetails errorDetails) { | ||||
@@ -91,15 +87,15 @@ class _MyAppState extends State<MyApp> { | |||||
ChangeNotifierProvider.value(value: UserInfoNotifier()), | ChangeNotifierProvider.value(value: UserInfoNotifier()), | ||||
], | ], | ||||
child: GestureDetector( | child: GestureDetector( | ||||
onTap: (){ | |||||
onTap: () { | |||||
FocusScopeNode currentFocus = FocusScope.of(context); | FocusScopeNode currentFocus = FocusScope.of(context); | ||||
if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) { | if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) { | ||||
FocusManager.instance.primaryFocus.unfocus(); | FocusManager.instance.primaryFocus.unfocus(); | ||||
} | } | ||||
}, | }, | ||||
child: MaterialApp( | child: MaterialApp( | ||||
builder: (context,child){ | |||||
return MediaQuery( | |||||
builder: (context, child) { | |||||
return MediaQuery( | |||||
//设置文字大小不随系统设置改变 | //设置文字大小不随系统设置改变 | ||||
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0), | data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0), | ||||
child: child, | child: child, | ||||
@@ -111,7 +107,7 @@ class _MyAppState extends State<MyApp> { | |||||
accentColor: HexColor.fromHex('#FF4242'), | accentColor: HexColor.fromHex('#FF4242'), | ||||
), | ), | ||||
routes: <String, WidgetBuilder>{ | routes: <String, WidgetBuilder>{ | ||||
'/homePage': (BuildContext context) => HomePage(), | |||||
'/homePage': (BuildContext context) => HomeCenterPage(), | |||||
}, | }, | ||||
navigatorKey: navigatorKey, | navigatorKey: navigatorKey, | ||||
localizationsDelegates: [ | localizationsDelegates: [ | ||||
@@ -129,8 +125,8 @@ class _MyAppState extends State<MyApp> { | |||||
return locale; | return locale; | ||||
}, | }, | ||||
home: LaunchPage( | home: LaunchPage( | ||||
// builder: (context) => HomePage(), | |||||
), | |||||
// builder: (context) => HomePage(), | |||||
), | |||||
), | ), | ||||
), | ), | ||||
); | ); | ||||
@@ -140,4 +136,4 @@ class _MyAppState extends State<MyApp> { | |||||
// FocusScopeNode currentFocus = FocusScope.of(context); | // FocusScopeNode currentFocus = FocusScope.of(context); | ||||
// if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) { | // if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) { | ||||
// FocusManager.instance.primaryFocus.unfocus(); | // FocusManager.instance.primaryFocus.unfocus(); | ||||
// } | |||||
// } |
@@ -1,3 +1,6 @@ | |||||
import 'dart:async'; | |||||
import 'package:zhiying_base_widget/pages/custom_page/event/reload_event.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | import 'package:zhiying_comm/zhiying_comm.dart'; | ||||
class CustomItemPageRepository { | class CustomItemPageRepository { | ||||
@@ -15,10 +18,16 @@ class CustomItemPageRepository { | |||||
if (!EmptyUtil.isEmpty(reqUrl)) { | if (!EmptyUtil.isEmpty(reqUrl)) { | ||||
var result = await NetUtil.post(reqUrl, method: NetMethod.GET, cache: true); | var result = await NetUtil.post(reqUrl, method: NetMethod.GET, cache: true); | ||||
if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { | if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { | ||||
List mobList = !EmptyUtil.isEmpty(data) ? List.from(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA][tabIndex.toString()]) : List.from(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]); | |||||
List mobList = | |||||
!EmptyUtil.isEmpty(data) ? List.from(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA][tabIndex.toString()]) : List.from(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]); | |||||
if (!EmptyUtil.isEmpty(mobList)) { | if (!EmptyUtil.isEmpty(mobList)) { | ||||
ReloadEvent.com = 0; | |||||
return mobList.map((e) => Map<String, dynamic>.from(e)).toList(); | return mobList.map((e) => Map<String, dynamic>.from(e)).toList(); | ||||
} | } | ||||
} else { | |||||
Timer(Duration(milliseconds: 1000), () { | |||||
EventUtil.instance.fire(ReloadEvent()); | |||||
}); | |||||
} | } | ||||
} | } | ||||
} catch (e, s) { | } catch (e, s) { | ||||
@@ -1,5 +1,8 @@ | |||||
import 'dart:async'; | |||||
import 'dart:convert'; | import 'dart:convert'; | ||||
import 'package:zhiying_base_widget/dialog/loading/loading.dart'; | |||||
import 'package:zhiying_base_widget/pages/custom_page/event/reload_event.dart'; | |||||
import 'package:zhiying_base_widget/pages/main_page/model/background_model.dart'; | import 'package:zhiying_base_widget/pages/main_page/model/background_model.dart'; | ||||
import 'package:zhiying_comm/zhiying_comm.dart'; | import 'package:zhiying_comm/zhiying_comm.dart'; | ||||
@@ -37,6 +40,12 @@ class CustomPageRepository { | |||||
} | } | ||||
return customPageData; | return customPageData; | ||||
} | } | ||||
}else{ | |||||
Timer(Duration(milliseconds: 1000), (){ | |||||
EventUtil.instance.fire(ReloadEvent()); | |||||
}); | |||||
} | } | ||||
} | } | ||||
} catch (e, s) { | } catch (e, s) { | ||||
@@ -92,7 +92,6 @@ class __CustomItemPageContainerState extends State<_CustomItemPageContainer> wit | |||||
_eventBus = EventBus(); | _eventBus = EventBus(); | ||||
_refreshController = RefreshController(initialRefresh: false); | _refreshController = RefreshController(initialRefresh: false); | ||||
_initEvent();_controller.addListener(() { | _initEvent();_controller.addListener(() { | ||||
print(_controller.offset.toString()); | |||||
if(widget.scroller!=null){ | if(widget.scroller!=null){ | ||||
widget?.scroller(_controller.offset); | widget?.scroller(_controller.offset); | ||||
} | } | ||||
@@ -60,7 +60,7 @@ class _CommonPageContainer extends StatefulWidget { | |||||
__CommonPageContainerState createState() => __CommonPageContainerState(); | __CommonPageContainerState createState() => __CommonPageContainerState(); | ||||
} | } | ||||
class __CommonPageContainerState extends State<_CommonPageContainer> with SingleTickerProviderStateMixin ,AutomaticKeepAliveClientMixin{ | |||||
class __CommonPageContainerState extends State<_CommonPageContainer> with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin { | |||||
TabController _tabController; | TabController _tabController; | ||||
// 是否有AppBar | // 是否有AppBar | ||||
@@ -80,7 +80,7 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single | |||||
@override | @override | ||||
void initState() { | void initState() { | ||||
backgroundBloc=BackgroundBloc(); | |||||
backgroundBloc = BackgroundBloc(); | |||||
super.initState(); | super.initState(); | ||||
} | } | ||||
@@ -94,40 +94,38 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single | |||||
@override | @override | ||||
Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark); | SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark); | ||||
return MediaQuery.removePadding( | |||||
context: context, | |||||
child: BlocConsumer<CustomPageBloc, CustomPageState>( | |||||
listener: (context, state) {}, | |||||
buildWhen: (prev, current) { | |||||
if (current is CustomPageErrorState) { | |||||
return false; | |||||
} | |||||
if (current is CustomPageRefreshSuccessState) { | |||||
// _refreshController.refreshCompleted(resetFooterState: true); | |||||
return false; | |||||
} | |||||
if (current is CustomPageRefreshErrorState) { | |||||
// _refreshController.refreshFailed(); | |||||
return false; | |||||
} | |||||
return true; | |||||
}, | |||||
builder: (context, state) { | |||||
/// 有数据 | |||||
if (state is CustomPageLoadedState) { | |||||
if (EmptyUtil.isEmpty(state.model)) return _buildEmptyWidget(); | |||||
return _buildMainWidget(state.model, state.backgroundModel); | |||||
} | |||||
/// 初始化失败 | |||||
if (state is CustomPageInitErrorState) { | |||||
return _buildEmptyWidget(); | |||||
} | |||||
/// 骨架图 | |||||
return _buildSkeletonWidget(); | |||||
}, | |||||
), | |||||
return BlocConsumer<CustomPageBloc, CustomPageState>( | |||||
listener: (context, state) {}, | |||||
buildWhen: (prev, current) { | |||||
if (current is CustomPageErrorState) { | |||||
return false; | |||||
} | |||||
if (current is CustomPageRefreshSuccessState) { | |||||
// _refreshController.refreshCompleted(resetFooterState: true); | |||||
return false; | |||||
} | |||||
if (current is CustomPageRefreshErrorState) { | |||||
// _refreshController.refreshFailed(); | |||||
return false; | |||||
} | |||||
return true; | |||||
}, | |||||
builder: (context, state) { | |||||
/// 有数据 | |||||
if (state is CustomPageLoadedState) { | |||||
if (EmptyUtil.isEmpty(state.model)) return _buildEmptyWidget(); | |||||
Logger.log("通用模板数据", state.model); | |||||
return _buildMainWidget(state.model, state.backgroundModel); | |||||
} | |||||
/// 初始化失败 | |||||
if (state is CustomPageInitErrorState) { | |||||
return _buildEmptyWidget(); | |||||
} | |||||
/// 骨架图 | |||||
return _buildSkeletonWidget(); | |||||
}, | |||||
); | ); | ||||
} | } | ||||
@@ -271,7 +269,11 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single | |||||
onPressed: () => Navigator.maybePop(context), | onPressed: () => Navigator.maybePop(context), | ||||
), | ), | ||||
title: Text( | title: Text( | ||||
null != data && data.containsKey('app_bar_name') ? data['app_bar_name'] != '自定义页面' ? data['app_bar_name'] : parentTitle : parentTitle, | |||||
null != data && data.containsKey('app_bar_name') | |||||
? data['app_bar_name'] != '自定义页面' | |||||
? data['app_bar_name'] | |||||
: parentTitle | |||||
: parentTitle, | |||||
style: TextStyle( | style: TextStyle( | ||||
color: HexColor.fromHex(null != data ? data['app_bar_name_color'] ?? '#333333' : '#333333'), | color: HexColor.fromHex(null != data ? data['app_bar_name_color'] ?? '#333333' : '#333333'), | ||||
fontSize: 16, | fontSize: 16, | ||||
@@ -370,16 +372,15 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single | |||||
return result; | return result; | ||||
} | } | ||||
_buildBackground(BackgroundModel backgroundModel) { | _buildBackground(BackgroundModel backgroundModel) { | ||||
if (backgroundModel != null) { | if (backgroundModel != null) { | ||||
var headerBg = backgroundModel.headerBg; | var headerBg = backgroundModel.headerBg; | ||||
return StreamBuilder( | return StreamBuilder( | ||||
stream: backgroundBloc.outData, | stream: backgroundBloc.outData, | ||||
builder: (context,asncy){ | |||||
return Container( | |||||
builder: (context, asncy) { | |||||
return Container( | |||||
constraints: BoxConstraints(minHeight: 0), | constraints: BoxConstraints(minHeight: 0), | ||||
height: (double.tryParse(headerBg?.height)??0)+backgroundTopMargin ?? 0, | |||||
height: (double.tryParse(headerBg?.height) ?? 0) + backgroundTopMargin ?? 0, | |||||
width: double.infinity, | width: double.infinity, | ||||
decoration: BoxDecoration( | decoration: BoxDecoration( | ||||
gradient: LinearGradient( | gradient: LinearGradient( | ||||
@@ -389,7 +390,6 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single | |||||
); | ); | ||||
}, | }, | ||||
); | ); | ||||
} else { | } else { | ||||
return Container(); | return Container(); | ||||
} | } | ||||
@@ -423,7 +423,7 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single | |||||
@override | @override | ||||
// TODO: implement wantKeepAlive | // TODO: implement wantKeepAlive | ||||
bool get wantKeepAlive =>true; | |||||
bool get wantKeepAlive => true; | |||||
} | } | ||||
/// 回到顶部的icon | /// 回到顶部的icon | ||||
@@ -0,0 +1,12 @@ | |||||
// | |||||
import 'dart:async'; | |||||
class ReloadEvent { | |||||
static int com = 0; | |||||
final String id; | |||||
ReloadEvent({this.id}) { | |||||
com++; | |||||
} | |||||
} |
@@ -22,8 +22,10 @@ import 'package:zhiying_base_widget/dialog/global_dialog/notification_setting_di | |||||
import 'package:zhiying_base_widget/dialog/global_dialog/policy_dialog/policy_dialog.dart'; | import 'package:zhiying_base_widget/dialog/global_dialog/policy_dialog/policy_dialog.dart'; | ||||
import 'package:zhiying_base_widget/dialog/tip_dialog/tip_dialog.dart'; | import 'package:zhiying_base_widget/dialog/tip_dialog/tip_dialog.dart'; | ||||
import 'package:zhiying_base_widget/models/app_config_model.dart'; | import 'package:zhiying_base_widget/models/app_config_model.dart'; | ||||
import 'package:zhiying_base_widget/pages/custom_page/event/reload_event.dart'; | |||||
import 'package:zhiying_base_widget/utils/contants.dart'; | import 'package:zhiying_base_widget/utils/contants.dart'; | ||||
import 'package:zhiying_base_widget/utils/mob_push_util.dart'; | import 'package:zhiying_base_widget/utils/mob_push_util.dart'; | ||||
import 'package:zhiying_base_widget/widgets/restart_widget/restart_widget.dart'; | |||||
import 'package:zhiying_comm/models/base/base_tab_model.dart'; | import 'package:zhiying_comm/models/base/base_tab_model.dart'; | ||||
import 'package:zhiying_comm/util/image_util.dart'; | import 'package:zhiying_comm/util/image_util.dart'; | ||||
import 'package:zhiying_comm/util/mob_util/mob_util.dart'; | import 'package:zhiying_comm/util/mob_util/mob_util.dart'; | ||||
@@ -39,6 +41,18 @@ import 'package:zhiying_comm/util/event_util/event_util.dart'; | |||||
import 'package:zhiying_comm/util/event_util/log_out.dart'; | import 'package:zhiying_comm/util/event_util/log_out.dart'; | ||||
import 'package:package_info/package_info.dart'; | import 'package:package_info/package_info.dart'; | ||||
class HomeCenterPage extends StatefulWidget { | |||||
@override | |||||
_HomeCenterPageState createState() => _HomeCenterPageState(); | |||||
} | |||||
class _HomeCenterPageState extends State<HomeCenterPage> { | |||||
@override | |||||
Widget build(BuildContext context) { | |||||
return RestartWidget(child: HomePage()); | |||||
} | |||||
} | |||||
class HomePage extends StatefulWidget { | class HomePage extends StatefulWidget { | ||||
HomePage({Key key}) : super(key: key); | HomePage({Key key}) : super(key: key); | ||||
@@ -52,21 +66,33 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver, Ticker | |||||
static const EventChannel _eventChannel = const EventChannel('JAVA_TO_FLUTTER'); | static const EventChannel _eventChannel = const EventChannel('JAVA_TO_FLUTTER'); | ||||
StreamSubscription streamSubscription; | StreamSubscription streamSubscription; | ||||
StreamSubscription reloadSubscription; | |||||
StreamSubscription aliasSubscription; | |||||
StreamSubscription logOutSubscription; | |||||
StreamSubscription loginSubscription; | |||||
StreamSubscription eventChannelSubscription; | |||||
@override | @override | ||||
void initState() { | void initState() { | ||||
///初始化一些数据 | ///初始化一些数据 | ||||
initAsync(); | initAsync(); | ||||
//如果登出则重新打开首页 | //如果登出则重新打开首页 | ||||
streamSubscription = EventUtil.instance.on<LogOut>().listen((event) async{ | |||||
UserInfoModel user = | |||||
await Provider.of<UserInfoNotifier>(context, listen: false) | |||||
.getUserInfoModel(); | |||||
user.token=''; | |||||
streamSubscription = EventUtil.instance.on<LogOut>().listen((event) async { | |||||
UserInfoModel user = await Provider.of<UserInfoNotifier>(context, listen: false).getUserInfoModel(); | |||||
user.token = ''; | |||||
Navigator.maybePop(context); | Navigator.maybePop(context); | ||||
print("重启1"); | |||||
Navigator.pushReplacementNamed(context, "/homePage"); | Navigator.pushReplacementNamed(context, "/homePage"); | ||||
}); | }); | ||||
reloadSubscription = EventUtil.instance.on<ReloadEvent>().listen((event) async { | |||||
print("重启2"); | |||||
await BaseSettingModel.init(isGetCache: false); | |||||
RestartWidget.restartApp(context); | |||||
}); | |||||
super.initState(); | super.initState(); | ||||
} | } | ||||
@@ -82,16 +108,9 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver, Ticker | |||||
NativeUtil.notifyInitSuccess(); | NativeUtil.notifyInitSuccess(); | ||||
}); | }); | ||||
}); | }); | ||||
String data = BaseSettingModel.setting.tab['data']; | |||||
try { | |||||
List list = convert.jsonDecode(data); | |||||
_data = list.map((item) { | |||||
return Map<String, dynamic>.from(item); | |||||
}).toList(); | |||||
Logger.debug(_data); | |||||
} catch (error) { | |||||
Logger.error(error); | |||||
} | |||||
initBaseSet(); | |||||
Constants.isShowIntellectDialog = false; | Constants.isShowIntellectDialog = false; | ||||
TaobaoAuth.initAuth(context); | TaobaoAuth.initAuth(context); | ||||
@@ -108,10 +127,10 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver, Ticker | |||||
//app后台杀死时候的还原 | //app后台杀死时候的还原 | ||||
Moblink.restoreScene(_restore); | Moblink.restoreScene(_restore); | ||||
// 监听开始(传递监听到原生端,用户监听场景还原的数据回传回来) | // 监听开始(传递监听到原生端,用户监听场景还原的数据回传回来) | ||||
_eventChannel.receiveBroadcastStream().listen(_onEvent, onError: _onError); | |||||
eventChannelSubscription= _eventChannel.receiveBroadcastStream().listen(_onEvent, onError: _onError); | |||||
MobPushUtil.addPushReceiver(); | MobPushUtil.addPushReceiver(); | ||||
EventUtil.instance.on<LoginSuccessEvent>().listen((event) async { | |||||
aliasSubscription = EventUtil.instance.on<LoginSuccessEvent>().listen((event) async { | |||||
UserInfoModel userInfo = UserInfoNotifier?.staitcUserInfo; | UserInfoModel userInfo = UserInfoNotifier?.staitcUserInfo; | ||||
var setting = await NativeUtil.getSetting(); | var setting = await NativeUtil.getSetting(); | ||||
String masterId = setting['master_id']; | String masterId = setting['master_id']; | ||||
@@ -121,12 +140,12 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver, Ticker | |||||
} | } | ||||
}); | }); | ||||
EventUtil.instance.on<LogOut>().listen((event) { | |||||
logOutSubscription = EventUtil.instance.on<LogOut>().listen((event) { | |||||
MobPushUtil.deleteAlias(); | MobPushUtil.deleteAlias(); | ||||
}); | }); | ||||
super.initState(); | |||||
MobPushUtil.addPushReceiver(); | MobPushUtil.addPushReceiver(); | ||||
EventUtil.instance.on<LoginSuccessEvent>().listen((event) async { | |||||
loginSubscription = EventUtil.instance.on<LoginSuccessEvent>().listen((event) async { | |||||
UserInfoModel userInfo = UserInfoNotifier?.staitcUserInfo; | UserInfoModel userInfo = UserInfoNotifier?.staitcUserInfo; | ||||
var setting = await NativeUtil.getSetting(); | var setting = await NativeUtil.getSetting(); | ||||
String masterId = setting['master_id']; | String masterId = setting['master_id']; | ||||
@@ -136,19 +155,36 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver, Ticker | |||||
} | } | ||||
}); | }); | ||||
EventUtil.instance.on<LogOut>().listen((event) { | |||||
MobPushUtil.deleteAlias(); | |||||
}); | |||||
} catch (e, s) { | } catch (e, s) { | ||||
print(e); | print(e); | ||||
print(s); | print(s); | ||||
} | } | ||||
} | |||||
initBaseSet() { | |||||
String data = BaseSettingModel.setting.tab['data']; | |||||
try { | |||||
List list = convert.jsonDecode(data); | |||||
_data = list.map((item) { | |||||
return Map<String, dynamic>.from(item); | |||||
}).toList(); | |||||
Logger.debug(_data); | |||||
} catch (error) { | |||||
Logger.error(error); | |||||
} | |||||
} | } | ||||
@override | @override | ||||
void dispose() { | void dispose() { | ||||
WidgetsBinding.instance.removeObserver(this); | WidgetsBinding.instance.removeObserver(this); | ||||
streamSubscription.cancel(); | streamSubscription.cancel(); | ||||
reloadSubscription?.cancel(); | |||||
aliasSubscription?.cancel(); | |||||
logOutSubscription?.cancel(); | |||||
loginSubscription?.cancel(); | |||||
eventChannelSubscription?.cancel(); | |||||
super.dispose(); | super.dispose(); | ||||
} | } | ||||
@@ -40,14 +40,12 @@ class LaunchPage extends StatefulWidget { | |||||
class _LaunchPageState extends State<LaunchPage> with TickerProviderStateMixin { | class _LaunchPageState extends State<LaunchPage> with TickerProviderStateMixin { | ||||
final GlobalKey navigatorKey = new GlobalKey(); | final GlobalKey navigatorKey = new GlobalKey(); | ||||
///闪屏动画 | |||||
AnimationController animationController; | |||||
int showTime = 0; | int showTime = 0; | ||||
@override | @override | ||||
void initState() { | void initState() { | ||||
animationController = AnimationController(vsync: this); | |||||
validateInit(); | validateInit(); | ||||
super.initState(); | super.initState(); | ||||
} | } | ||||
@@ -30,6 +30,8 @@ class _SecurityPasswordState extends State<SecurityPassword> { | |||||
bool _canConfirm = false; | bool _canConfirm = false; | ||||
String _phone; | String _phone; | ||||
Timer timer; | |||||
@override | @override | ||||
void initState() { | void initState() { | ||||
Logger.debug(widget.model.toString()); | Logger.debug(widget.model.toString()); | ||||
@@ -143,9 +145,7 @@ class _SecurityPasswordState extends State<SecurityPassword> { | |||||
} | } | ||||
void _verifiy() { | void _verifiy() { | ||||
bool canConfirm = _passwordController.text.length >= 6 && | |||||
_confirmController.text.length >= 6 && | |||||
_codeController.text.length == 6; | |||||
bool canConfirm = _passwordController.text.length >= 6 && _confirmController.text.length >= 6 && _codeController.text.length == 6; | |||||
if (canConfirm != _canConfirm) { | if (canConfirm != _canConfirm) { | ||||
setState(() { | setState(() { | ||||
_canConfirm = canConfirm; | _canConfirm = canConfirm; | ||||
@@ -153,20 +153,26 @@ class _SecurityPasswordState extends State<SecurityPassword> { | |||||
} | } | ||||
} | } | ||||
@override | |||||
void dispose() { | |||||
timer?.cancel(); | |||||
super.dispose(); | |||||
} | |||||
/// 获取验证码 | /// 获取验证码 | ||||
void _sendCode() async { | void _sendCode() async { | ||||
bool result = await MobUtil.getTextCode(_phone, smsCodeType: SMSCodeType.NORMAL); | |||||
if(result){ | |||||
bool result = await MobUtil.getTextCode(_phone, smsCodeType: SMSCodeType.NORMAL); | |||||
if (result) { | |||||
Fluttertoast.showToast(msg: '发送成功'); | Fluttertoast.showToast(msg: '发送成功'); | ||||
_second = 60; | _second = 60; | ||||
Timer.periodic(Duration(seconds: 1), (timer) { | |||||
timer = Timer.periodic(Duration(seconds: 1), (timer) { | |||||
_second--; | _second--; | ||||
if (_second <= 0) { | if (_second <= 0) { | ||||
timer.cancel(); | timer.cancel(); | ||||
} | } | ||||
setState(() {}); | setState(() {}); | ||||
}); | }); | ||||
}else{ | |||||
} else { | |||||
// Fluttertoast.showToast(msg: '获取验证码失败'); | // Fluttertoast.showToast(msg: '获取验证码失败'); | ||||
} | } | ||||
@@ -187,13 +193,8 @@ class _SecurityPasswordState extends State<SecurityPassword> { | |||||
void _confirm() async { | void _confirm() async { | ||||
NetUtil.request('/api/v1/settings/account/security/password', | NetUtil.request('/api/v1/settings/account/security/password', | ||||
params: Map<String, dynamic>.from({ | |||||
'new_password': _passwordController.text, | |||||
'new_password_ack': _confirmController.text, | |||||
'valid_code': _codeController.text, | |||||
'phone': _phone, | |||||
'zone': '86' | |||||
}), | |||||
params: Map<String, dynamic>.from( | |||||
{'new_password': _passwordController.text, 'new_password_ack': _confirmController.text, 'valid_code': _codeController.text, 'phone': _phone, 'zone': '86'}), | |||||
method: NetMethod.POST, onSuccess: (result) { | method: NetMethod.POST, onSuccess: (result) { | ||||
Logger.debug(result); | Logger.debug(result); | ||||
Fluttertoast.showToast(msg: '设置成功'); | Fluttertoast.showToast(msg: '设置成功'); | ||||
@@ -605,7 +605,7 @@ class CustomQuickCateEntry extends StatefulWidget { | |||||
class _CustomQuickCateEntryState extends State<CustomQuickCateEntry> with TickerProviderStateMixin, AutomaticKeepAliveClientMixin { | class _CustomQuickCateEntryState extends State<CustomQuickCateEntry> with TickerProviderStateMixin, AutomaticKeepAliveClientMixin { | ||||
TabController tabController; | TabController tabController; | ||||
PrimaryPageController primaryPageController; | |||||
bool isOnTap = false; | bool isOnTap = false; | ||||
@@ -617,32 +617,22 @@ class _CustomQuickCateEntryState extends State<CustomQuickCateEntry> with Ticker | |||||
@override | @override | ||||
void initState() { | void initState() { | ||||
// primaryPageController = PrimaryPageController(keepPage: true); | |||||
if (widget?.model != null) { | if (widget?.model != null) { | ||||
tabController = TabController(length: widget?.model?.typeList?.length ?? 0, vsync: this); | tabController = TabController(length: widget?.model?.typeList?.length ?? 0, vsync: this); | ||||
tabController.addListener(() {}); | tabController.addListener(() {}); | ||||
} | } | ||||
_controller = SwiperController(); | _controller = SwiperController(); | ||||
// primaryPageController.addListener(() { | |||||
// if (isOnTap) { | |||||
// return; | |||||
// } | |||||
// if ((primaryPageController.page - tabController.index).abs() > 0.9) { | |||||
// tabController.animateTo(primaryPageController.page.floor()); | |||||
// } | |||||
// }); | |||||
super.initState(); | super.initState(); | ||||
} | } | ||||
@override | @override | ||||
void dispose() { | void dispose() { | ||||
tabController?.dispose(); | tabController?.dispose(); | ||||
primaryPageController?.dispose(); | |||||
for (var item in widget.model?.typeList) { | |||||
item.primaryPageController?.dispose(); | |||||
item.primaryPageController = null; | |||||
} | |||||
_controller?.dispose(); | |||||
super.dispose(); | super.dispose(); | ||||
} | } | ||||
@@ -665,9 +655,7 @@ class _CustomQuickCateEntryState extends State<CustomQuickCateEntry> with Ticker | |||||
if (model.typeList != null) { | if (model.typeList != null) { | ||||
for (var item in model?.typeList) { | for (var item in model?.typeList) { | ||||
item.listStyle = List(); | item.listStyle = List(); | ||||
if (item.primaryPageController == null) { | |||||
item.primaryPageController = PrimaryPageController(keepPage: true); | |||||
} | |||||
for (var listItem in model?.listStyle) { | for (var listItem in model?.listStyle) { | ||||
if (listItem?.typeListKey == item.key) { | if (listItem?.typeListKey == item.key) { | ||||
item.listStyle.add(listItem); | item.listStyle.add(listItem); | ||||
@@ -975,7 +963,7 @@ class _CustomQuickCateEntryState extends State<CustomQuickCateEntry> with Ticker | |||||
// 当前元素的下表 = 当前的列数 + 当前的行数 * 列数 + 当前的页数 * 当前的行数 + 当前的列数 | // 当前元素的下表 = 当前的列数 + 当前的行数 * 列数 + 当前的页数 * 当前的行数 + 当前的列数 | ||||
int currentIndex = currentColum + currentRow * columSize; | int currentIndex = currentColum + currentRow * columSize; | ||||
print("当前页" + currentPage.toString() + "当前点" + currentIndex.toString()); | |||||
//print("当前页" + currentPage.toString() + "当前点" + currentIndex.toString()); | |||||
// print('current Index sss = $currentIndex'); | // print('current Index sss = $currentIndex'); | ||||
@@ -18,7 +18,9 @@ class CustomNoticeWidget extends StatelessWidget { | |||||
@override | @override | ||||
Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
return BlocProvider<CustomNoticeBloc>( | return BlocProvider<CustomNoticeBloc>( | ||||
create: (_) => CustomNoticeBloc(repository: CustomNoticeRepository())..add(CustomNoticeInitEvent(model: model)), | |||||
create: (_) => | |||||
CustomNoticeBloc(repository: CustomNoticeRepository()) | |||||
..add(CustomNoticeInitEvent(model: model)), | |||||
child: _CustomNoticeWidgetContainer(), | child: _CustomNoticeWidgetContainer(), | ||||
); | ); | ||||
} | } | ||||
@@ -79,9 +81,9 @@ class _CustomNoticeWidgetContainerState extends State<_CustomNoticeWidgetContain | |||||
top: ParseUtil.stringParseDouble(model?.topMargin), | top: ParseUtil.stringParseDouble(model?.topMargin), | ||||
left: ParseUtil.stringParseDouble(model?.leftRightMargin), | left: ParseUtil.stringParseDouble(model?.leftRightMargin), | ||||
right: ParseUtil.stringParseDouble(model?.leftRightMargin)), | right: ParseUtil.stringParseDouble(model?.leftRightMargin)), | ||||
padding: EdgeInsets.symmetric(horizontal:7.5, vertical: 7.5), | |||||
padding: EdgeInsets.symmetric(horizontal: 7.5, vertical: 7.5), | |||||
child: Container( | child: Container( | ||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(7.5), color: HexColor.fromHex(model?.outsideBgColor??'#F6F6F6')), | |||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(7.5), color: HexColor.fromHex(model?.outsideBgColor ?? '#F6F6F6')), | |||||
padding: const EdgeInsets.only(top: 8, bottom: 8, left: 12, right: 8), | padding: const EdgeInsets.only(top: 8, bottom: 8, left: 12, right: 8), | ||||
width: double.infinity, | width: double.infinity, | ||||
child: _getChildWidget(model), | child: _getChildWidget(model), | ||||
@@ -97,6 +99,7 @@ class _CustomNoticeWidgetContainerState extends State<_CustomNoticeWidgetContain | |||||
behavior: HitTestBehavior.opaque, | behavior: HitTestBehavior.opaque, | ||||
child: Row( | child: Row( | ||||
children: <Widget>[ | children: <Widget>[ | ||||
/// 图片 | /// 图片 | ||||
// Container(width: 52, height: 13, color: Colors.red), | // Container(width: 52, height: 13, color: Colors.red), | ||||
CachedNetworkImage( | CachedNetworkImage( | ||||
@@ -114,7 +117,7 @@ class _CustomNoticeWidgetContainerState extends State<_CustomNoticeWidgetContain | |||||
// color: Colors.yellowAccent, | // color: Colors.yellowAccent, | ||||
child: MarqueeWidget( | child: MarqueeWidget( | ||||
model?.listStyle?.length ?? 0, | model?.listStyle?.length ?? 0, | ||||
(BuildContext context, int index) { | |||||
(BuildContext context, int index) { | |||||
NoticeListStyle item = model.listStyle[index]; | NoticeListStyle item = model.listStyle[index]; | ||||
return Align(alignment: Alignment.centerLeft, child: Text('${item?.contentText}', style: TextStyle(color: HexColor.fromHex(model?.textColor), fontSize: 12))); | return Align(alignment: Alignment.centerLeft, child: Text('${item?.contentText}', style: TextStyle(color: HexColor.fromHex(model?.textColor), fontSize: 12))); | ||||
}, | }, | ||||
@@ -161,10 +164,14 @@ class _MarqueeWidgetState extends State<MarqueeWidget> { | |||||
_controller = PageController(); | _controller = PageController(); | ||||
_timer = Timer.periodic(Duration(seconds: 5), (timer) { | _timer = Timer.periodic(Duration(seconds: 5), (timer) { | ||||
// 如果当前位于最后一页,则直接跳转到第一页,两者内容相同,跳转时视觉上无感知 | // 如果当前位于最后一页,则直接跳转到第一页,两者内容相同,跳转时视觉上无感知 | ||||
if (_controller.page.round() >= widget.count) { | |||||
_controller.jumpToPage(0); | |||||
try { | |||||
if (_controller.page.round() >= widget.count) { | |||||
_controller.jumpToPage(0); | |||||
} | |||||
_controller.nextPage(duration: Duration(seconds: 1), curve: Curves.linear); | |||||
} catch (e){ | |||||
_timer?.cancel(); | |||||
} | } | ||||
_controller.nextPage(duration: Duration(seconds: 1), curve: Curves.linear); | |||||
}); | }); | ||||
} | } | ||||
} | } | ||||
@@ -56,6 +56,7 @@ class _CustomSlideBannerContainerState extends State<CustomSlideBannerContainer> | |||||
@override | @override | ||||
void dispose() { | void dispose() { | ||||
_swiperController.stopAutoplay(); | |||||
_swiperController?.dispose(); | _swiperController?.dispose(); | ||||
super.dispose(); | super.dispose(); | ||||
} | } | ||||
@@ -0,0 +1,91 @@ | |||||
import 'dart:async'; | |||||
import 'package:flutter/material.dart'; | |||||
import 'package:zhiying_base_widget/dialog/loading/loading.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||||
class RestartWidget extends StatefulWidget { | |||||
RestartWidget({this.child}); | |||||
final Widget child; | |||||
static void restartApp(BuildContext context) { | |||||
//查找顶层_RestartWidgetState并重启 | |||||
context.findAncestorStateOfType<_RestartWidgetState>().restartApp(); | |||||
} | |||||
@override | |||||
_RestartWidgetState createState() => _RestartWidgetState(); | |||||
} | |||||
class _RestartWidgetState extends State<RestartWidget> { | |||||
bool reStart = false; | |||||
int com = 0; | |||||
Timer timer1; | |||||
Timer timer2; | |||||
StreamController streamController=StreamController(); | |||||
Stream outData; | |||||
bool isFirst=true; | |||||
void restartApp() async { | |||||
if (reStart) { | |||||
return; | |||||
} | |||||
com++; | |||||
///刷新3次后不再刷新 | |||||
if (com > 3) { | |||||
if (com < 7) { | |||||
Fluttertoast.showToast(msg: "网络服务不可用"); | |||||
} | |||||
return; | |||||
} | |||||
Loading.show(context, msg: "更新数据中..."); | |||||
streamController.add(null); | |||||
timer1 = Timer(Duration(milliseconds: 1000), () async { | |||||
print("重启"); | |||||
streamController.add("restart"); | |||||
}); | |||||
timer2 = Timer(Duration(milliseconds: 1500), () { | |||||
Loading.dismiss(); | |||||
}); | |||||
} | |||||
@override | |||||
void initState() { | |||||
outData=streamController.stream; | |||||
super.initState(); | |||||
} | |||||
@override | |||||
Widget build(BuildContext context) { | |||||
return StreamBuilder(stream: outData,builder: (context,asyn){ | |||||
if(asyn.data==null&&!isFirst){ | |||||
return Scaffold( | |||||
body: Container(), | |||||
); | |||||
}else{ | |||||
isFirst=false; | |||||
return widget?.child; | |||||
} | |||||
}); | |||||
} | |||||
@override | |||||
void dispose() { | |||||
timer1?.cancel(); | |||||
timer2?.cancel(); | |||||
super.dispose(); | |||||
} | |||||
} |
@@ -5,4 +5,5 @@ export 'package:flutter_swiper/flutter_swiper.dart'; | |||||
export 'package:zhiying_base_widget/pages/main_page/model/background_model.dart'; | export 'package:zhiying_base_widget/pages/main_page/model/background_model.dart'; | ||||
export 'package:zhiying_base_widget/pages/custom_page/bloc/background_bloc.dart'; | export 'package:zhiying_base_widget/pages/custom_page/bloc/background_bloc.dart'; | ||||
export 'package:pull_to_refresh/pull_to_refresh.dart'; | export 'package:pull_to_refresh/pull_to_refresh.dart'; | ||||
export 'package:flutter_user_agent/flutter_user_agent.dart'; | |||||
export 'package:flutter_user_agent/flutter_user_agent.dart'; | |||||
export 'package:zhiying_base_widget/widgets/restart_widget/restart_widget.dart'; |