Browse Source

更新弹窗逻辑

tags/0.0.2+8
Weller 4 years ago
parent
commit
4dbf092788
3 changed files with 32 additions and 34 deletions
  1. +1
    -1
      .dart_tool/package_config.json
  2. +30
    -14
      lib/pages/home_page/home_page.dart
  3. +1
    -19
      lib/pages/main_page/main_page.dart

+ 1
- 1
.dart_tool/package_config.json View File

@@ -650,7 +650,7 @@
"languageVersion": "2.8"
}
],
"generated": "2020-11-18T05:43:02.817433Z",
"generated": "2020-11-18T06:55:44.422288Z",
"generator": "pub",
"generatorVersion": "2.8.2"
}

+ 30
- 14
lib/pages/home_page/home_page.dart View File

@@ -6,6 +6,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';
import 'package:zhiying_base_widget/dialog/global_dialog/intellect_search_goods_dialog/intellect_create.dart';
import 'package:zhiying_base_widget/dialog/global_dialog/notification_setting_dialog/notification_setting_dialog.dart';
import 'package:zhiying_base_widget/dialog/global_dialog/policy_dialog/policy_dialog.dart';
import 'package:zhiying_base_widget/utils/contants.dart';
@@ -22,12 +23,13 @@ class HomePage extends StatefulWidget {
_HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
int _currentIndex = 0;
List<Map<String, dynamic>> _data = List();

@override
void initState() {
WidgetsBinding.instance.addObserver(this);
String data = BaseSettingModel.setting.tab['data'];
try {
List list = convert.jsonDecode(data);
@@ -42,19 +44,23 @@ class _HomePageState extends State<HomePage> {
AppUpdateUtil.updateApp(context);
TaobaoAuth.initAuth(context);

SharedPreferencesUtil.getStringValue(Constants.isShowPolicy).then((value) {
Logger.debug(value);
if (value == null || value == '') {
_showPolicy();
}
});

_showPolicy();
super.initState();
}

@override
void didChangeDependencies() {
super.didChangeDependencies();
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}

@override
void didChangeAppLifecycleState(AppLifecycleState state) async {
///智能粘贴板

IntellectCreate.checkAndCreate(state, context);

super.didChangeAppLifecycleState(state);
}

@override
@@ -155,10 +161,18 @@ class _HomePageState extends State<HomePage> {
return true;
}

void _showPolicy() async {
bool isAccept = await PolicyDialog.show(context);
if (!isAccept) {
exit(0);
Future _showPolicy() async {
String isShowPolicy =
await SharedPreferencesUtil.getStringValue(Constants.isShowPolicy);
isShowPolicy = '';
Logger.debug(isShowPolicy);
if (isShowPolicy == null || isShowPolicy != '1') {
bool isAccept = await PolicyDialog.show(context);
if (!isAccept) {
exit(0);
} else {
await SharedPreferencesUtil.setStringValue(Constants.isShowPolicy, "1");
}
}

PermissionStatus status = await Permission.notification.status;
@@ -166,5 +180,7 @@ class _HomePageState extends State<HomePage> {
await showCupertinoDialog(
context: context, builder: (_) => NotificationSettingDialog());
}

IntellectCreate.checkAndCreateFirst(context);
}
}

+ 1
- 19
lib/pages/main_page/main_page.dart View File

@@ -4,7 +4,6 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:zhiying_base_widget/dialog/global_dialog/intellect_search_goods_dialog/intellect_create.dart';
import 'package:zhiying_base_widget/pages/main_page/main_page_bloc.dart';
import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_bg_notifier.dart';
import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier.dart';
@@ -51,8 +50,7 @@ class _MainPageContainer extends StatefulWidget {
_MainPageContainerState createState() => _MainPageContainerState();
}

class _MainPageContainerState extends State<_MainPageContainer>
with WidgetsBindingObserver {
class _MainPageContainerState extends State<_MainPageContainer> {
bool _isEnded = false;
ScrollController _controller = ScrollController();
MainPageBloc _bloc;
@@ -76,23 +74,10 @@ class _MainPageContainerState extends State<_MainPageContainer>
}
}

@override
void didChangeAppLifecycleState(AppLifecycleState state) async {
///智能粘贴板
String indentifier = widget.data['skip_identifier'];
if (indentifier.startsWith('pub.flutter.index')) {
// 只在首页弹窗
IntellectCreate.checkAndCreate(state, context);
}

super.didChangeAppLifecycleState(state);
}

@override
void dispose() {
_controller.dispose();
_refreshController.dispose();
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}

@@ -117,9 +102,6 @@ class _MainPageContainerState extends State<_MainPageContainer>
}
});

///监听app生命周期变化
WidgetsBinding.instance.addObserver(this);
IntellectCreate.checkAndCreateFirst(context);
super.initState();
}



Loading…
Cancel
Save