소스 검색

1.优化开启消息弹窗提示,ios默认开启,去除服务端控制

tags/0.0.17+7
“yanghuaxuan” 3 년 전
부모
커밋
9eba0521e8
6개의 변경된 파일202개의 추가작업 그리고 77개의 파일을 삭제
  1. +9
    -2
      lib/pages/home_page/home_page.dart
  2. +81
    -4
      lib/pages/message_settings_page/message_settings_page.dart
  3. +12
    -1
      lib/utils/mob_push_util.dart
  4. +1
    -0
      lib/widgets/custom/bottom_pic/bottom_pic.dart
  5. +82
    -55
      lib/widgets/custom/share_content/share_content_widget.dart
  6. +17
    -15
      lib/widgets/team/fans_list/team_fans_item.dart

+ 9
- 2
lib/pages/home_page/home_page.dart 파일 보기

@@ -15,6 +15,7 @@ import 'package:provider/provider.dart';
import 'package:zhiying_base_widget/dialog/global_dialog/advertising_dialog/advertising_dialog.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/loading/loading.dart';
import 'package:zhiying_base_widget/dialog/notification_dialog/notification_dialog.dart';
import 'package:zhiying_base_widget/dialog/tip_dialog/tip_dialog.dart';
import 'package:zhiying_base_widget/models/app_config_model.dart';
@@ -139,6 +140,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver, Ticker
MobPushUtil.addPushReceiver();
loginSubscription = EventUtil.instance.on<LoginSuccessEvent>().listen((event) async {
setAlias();
Loading.dismiss();
});
} catch (e, s) {
print(e);
@@ -373,7 +375,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver, Ticker
///每打开5次检查一次权限
String showNotiPermissionTime = await SharedPreferencesUtil.getStringValue(Constants.showNotiPermissionTime, defaultVal: "5");
int timer = int.tryParse(showNotiPermissionTime) ?? 0;
if (timer % 5 == 0) {
if (timer % 5 == 0 && Platform.isAndroid) {
timer++;
SharedPreferencesUtil.setStringValue(Constants.showNotiPermissionTime, timer.toString());
if (!await Permission.storage.isGranted) {
@@ -405,6 +407,11 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver, Ticker
}
}

if (Platform.isIOS) {
///ios不显示弹窗,直接将同意值设置为1
SharedPreferencesUtil.setStringValue(Constants.notificationAgree, "1");
}

// 活动弹窗
await AdvertisingDialog.show(context);

@@ -499,7 +506,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver, Ticker
///设置定向推送
void setAlias() async {
///如果没有开启通知则设置别名
if (await SharedPreferencesUtil.getStringValue(Constants.notificationAgree, defaultVal: "0") == "1") {
if (await SharedPreferencesUtil.getStringValue(Constants.notificationAgree, defaultVal: "0") == "1" || Platform.isIOS) {
UserInfoModel userInfo = UserInfoNotifier?.staitcUserInfo;
var setting = await NativeUtil.getSetting();
String masterId = setting['master_id'];


+ 81
- 4
lib/pages/message_settings_page/message_settings_page.dart 파일 보기

@@ -1,7 +1,13 @@
import 'dart:async';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:zhiying_base_widget/dialog/notification_dialog/notification_dialog.dart';
import 'package:zhiying_base_widget/pages/message_settings_page/model/message_settings_data_model.dart';
import 'package:zhiying_base_widget/pages/message_settings_page/model/message_settings_style_model.dart';
import 'package:zhiying_base_widget/utils/contants.dart';
import 'package:zhiying_base_widget/utils/mob_push_util.dart';

import 'package:zhiying_comm/zhiying_comm.dart';
import 'bloc/message_settings_bloc.dart';
@@ -32,6 +38,8 @@ class _MessageSettingsPageContainer extends StatefulWidget {
}

class __MessageSettingsPageContainerState extends State<_MessageSettingsPageContainer> {
bool isOpen = false;

/// 列表点击
void _onClickListItem(Settings model, MessageSettingsDataModel dataModel) {
/// 跳转查看隐私协议
@@ -41,8 +49,70 @@ class __MessageSettingsPageContainerState extends State<_MessageSettingsPageCont
}

/// 隐私开关
void _switchOnChange(String key, bool value) {
BlocProvider.of<MessageSettingsBloc>(context).add(MessageSettingsUpdateEvent(value: value, key: key));
void _switchOnChange(bool value) async {
if (value) {
await SharedPreferencesUtil.setStringValue(Constants.notificationAgree, "1");
if (!await Permission.notification.isGranted) {
bool isGranted = await Permission.notification.isGranted;
if (!isGranted) {
var result = await showDialog(
context: context,
child: NotificationDialog(
isGranted: isGranted,
));
if (result != null && result) {
SharedPreferencesUtil.setStringValue(Constants.notificationAgree, "1");
if (!await Permission.notification.isGranted) {
if (Platform.isIOS) {
await openAppSettings().then((value) {
getState();
});
} else {
await NativeUtil.openAppSettings();
}
}
}
}
}
setAlias();
} else {
await SharedPreferencesUtil.setStringValue(Constants.notificationAgree, "0");
MobPushUtil.deleteAlias();
}
getState();
//BlocProvider.of<MessageSettingsBloc>(context).add(MessageSettingsUpdateEvent(value: value, key: key));
}

///设置定向推送
void setAlias() async {
///如果没有开启通知则设置别名
UserInfoModel userInfo = UserInfoNotifier?.staitcUserInfo;
var setting = await NativeUtil.getSetting();
String masterId = setting['master_id'];
Logger.log("我的Alias: " + masterId + "_" + userInfo?.userId);
if (!EmptyUtil.isEmpty(userInfo.userId) && !EmptyUtil.isEmpty(masterId)) {
print("设置标签" + masterId + "_" + userInfo.userId);
await MobPushUtil.restartPush();
await MobPushUtil.setAlias(masterId + "_" + userInfo.userId);
SharedPreferencesUtil.setStringValue(Constants.isSetTag, "1");
}
}

Timer timer;

@override
void initState() {
getState();
timer = Timer.periodic(Duration(seconds: 1), (timer) {
getState();
});
super.initState();
}

@override
void dispose() {
timer?.cancel();
super.dispose();
}

@override
@@ -139,11 +209,11 @@ class __MessageSettingsPageContainerState extends State<_MessageSettingsPageCont
width: 60,
height: 15,
child: Switch(
value: dataModel.data[element.dataKeys[0]] == '1',
value: isOpen,
activeColor: HexColor.fromHex('#FF4B4B'),
// trackColor: HexColor.fromHex('#F9F9F9') ,
onChanged: (bool value) {
_switchOnChange(element.dataKeys[0], value);
_switchOnChange(value);
},
),
),
@@ -227,4 +297,11 @@ class __MessageSettingsPageContainerState extends State<_MessageSettingsPageCont
elevation: 0,
);
}

void getState() async {
var result = await SharedPreferencesUtil.getStringValue(Constants.notificationAgree, defaultVal: "0");
var per = await Permission.notification.isGranted;
isOpen = (result == "1" && per) ? true : false;
setState(() {});
}
}

+ 12
- 1
lib/utils/mob_push_util.dart 파일 보기

@@ -38,7 +38,18 @@ class MobPushUtil {
break;
//接受到推送弹出通知事件
case 1:
MobPushNotifyMessage message = new MobPushNotifyMessage.fromJson(result);
try {
MobPushNotifyMessage message = new MobPushNotifyMessage.fromJson(result);
Map<String, dynamic> map = message.extrasMap;
if(map.containsKey("skip_identifier")){
//公共跳转
RouterUtil.route(SkipModel.fromJson(map), map, context);
}

} catch (e) {
Logger.log(e);
RouterUtil.goBackHomePage(context);
}
print("类型1: " + result.toString());
break;
//点击弹窗事件


+ 1
- 0
lib/widgets/custom/bottom_pic/bottom_pic.dart 파일 보기

@@ -6,6 +6,7 @@ import 'package:zhiying_comm/zhiying_comm.dart';

import 'bottom_pic_style.dart';

////自定义页面底部固定图片
class BottomPic extends StatelessWidget {
final Map<String, dynamic> model;



+ 82
- 55
lib/widgets/custom/share_content/share_content_widget.dart 파일 보기

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:zhiying_base_widget/widgets/base_state/base_state.dart';
import 'package:zhiying_base_widget/widgets/custom/multi_nav/cached_network_image_util.dart';
import 'package:zhiying_base_widget/widgets/custom/share_content/model/custom_share_content_model.dart';
import 'package:zhiying_base_widget/widgets/custom/share_content/share_content_sk.dart';
@@ -16,7 +17,6 @@ import 'package:flutter/cupertino.dart';
/// 分享内容组件
///
class CustomShareContentWidget extends StatelessWidget {

final Map<String, dynamic> model;

const CustomShareContentWidget(this.model, {Key key}) : super(key: key);
@@ -35,8 +35,7 @@ class _CustomShareContentContainerWidget extends StatefulWidget {
_CustomShareContentContainerWidgetState createState() => _CustomShareContentContainerWidgetState();
}

class _CustomShareContentContainerWidgetState extends State<_CustomShareContentContainerWidget> {

class _CustomShareContentContainerWidgetState extends BaseWidgetState<_CustomShareContentContainerWidget> {
/// 分享方法
void _clickShareButton(val) {
showCupertinoModalPopup(
@@ -62,6 +61,7 @@ class _CustomShareContentContainerWidgetState extends State<_CustomShareContentC
},
builder: (context, state) {
Logger.log('商品详情刷新了 builder state = ' + state?.toString());

/// 数据加载完毕
if (state is CustomShareContentLoadedState) {
return _getMainWidget(state?.model);
@@ -71,6 +71,7 @@ class _CustomShareContentContainerWidgetState extends State<_CustomShareContentC
if (state is CustomShareContentErrorState) {
return _errorWidget();
}

/// 骨架图
return _getSkeletonWidget();
},
@@ -80,59 +81,82 @@ class _CustomShareContentContainerWidgetState extends State<_CustomShareContentC
/// 主视图
Widget _getMainWidget(CustomShareContentModel model) {
return Container(
width: double.infinity,
// height: 98,
margin: EdgeInsets.only(top: ParseUtil.stringParseDouble(model?.topMargin), left: ParseUtil.stringParseDouble(model?.leftRightMargin, defVal: 12.5), right: ParseUtil.stringParseDouble(model?.leftRightMargin, defVal: 12.5)),
decoration: BoxDecoration(
// color: Colors.red,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(ParseUtil.stringParseDouble(model?.bottomLeftRadius)),
bottomRight: Radius.circular(ParseUtil.stringParseDouble(model?.bottomRightRadius)),
topLeft: Radius.circular(ParseUtil.stringParseDouble(model?.topLeftRadius)),
topRight: Radius.circular(ParseUtil.stringParseDouble(model?.topRightRadius)),
)),
child: Container(
width: double.infinity,
padding: const EdgeInsets.only(left: 12, right: 12, bottom: 14),
// height: 98,
margin: EdgeInsets.only(
top: ParseUtil.stringParseDouble(model?.topMargin),
left: ParseUtil.stringParseDouble(model?.leftRightMargin, defVal: 12.5),
right: ParseUtil.stringParseDouble(model?.leftRightMargin, defVal: 12.5)),
decoration: BoxDecoration(
color: HexColor.fromHex(model?.cardBgColor),
border: Border.all(color: HexColor.fromHex(model?.cardBorderColor), width: 1),
borderRadius: BorderRadius.all(Radius.circular(8))
),
child: Column(
children: [
// 标题
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
CachedNetworkImage(imageUrl: model?.scaleImageUrl, width: 36),
CachedNetworkImage(imageUrl: model?.titleImageUrl, width: 90),
SizedBox(width: 36,)
],
),
SizedBox(height: 20),
// 文案
Text(model?.text?? '', style: TextStyle(color: HexColor.fromHex(model?.textColor), fontSize: 15), maxLines: 4, overflow: TextOverflow.ellipsis,),
SizedBox(height: 22),
// 复制按钮 or 分享 按钮
Visibility(
visible: (model?.isShowShareFriend ?? '0') == '1',
// 仅仅复制按钮
replacement: GestureDetector( onTap: () => _clickCopyButton(model?.text) ,child: CachedNetworkImage(imageUrl: model?.copyLongImageUrl ?? '', width: double.infinity)),
child: Row(
children: [
// 复制按钮
Flexible(flex: 1, child: GestureDetector(onTap: () => _clickCopyButton(model?.text),child: CachedNetworkImage(imageUrl: model?.copyImageUrl, width: double.infinity,))),
SizedBox(width: 20),
// 分享按钮
Flexible(flex: 1,child: GestureDetector(onTap: ()=> _clickShareButton(model?.text), child: CachedNetworkImage(imageUrl: model?.shareImageUrl, width: double.infinity,)))
],
))
],
),
)
);
// color: Colors.red,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(ParseUtil.stringParseDouble(model?.bottomLeftRadius)),
bottomRight: Radius.circular(ParseUtil.stringParseDouble(model?.bottomRightRadius)),
topLeft: Radius.circular(ParseUtil.stringParseDouble(model?.topLeftRadius)),
topRight: Radius.circular(ParseUtil.stringParseDouble(model?.topRightRadius)),
)),
child: Container(
width: double.infinity,
padding: const EdgeInsets.only(left: 12, right: 12, bottom: 14),
decoration: BoxDecoration(
color: HexColor.fromHex(model?.cardBgColor),
border: Border.all(color: HexColor.fromHex(model?.cardBorderColor), width: 1),
borderRadius: BorderRadius.all(Radius.circular(8))),
child: Column(
children: [
// 标题
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
CachedNetworkImage(imageUrl: model?.scaleImageUrl, width: 36),
CachedNetworkImage(imageUrl: model?.titleImageUrl, width: 90),
SizedBox(
width: 36,
)
],
),
SizedBox(height: 20),
// 文案
Text(
model?.text ?? '',
style: TextStyle(color: HexColor.fromHex(model?.textColor), fontSize: 15),
maxLines: 4,
overflow: TextOverflow.ellipsis,
),
SizedBox(height: 22),
// 复制按钮 or 分享 按钮
Visibility(
visible: (model?.isShowShareFriend ?? '0') == '1',
// 仅仅复制按钮
replacement:
GestureDetector(onTap: () => _clickCopyButton(model?.text), child: CachedNetworkImage(imageUrl: model?.copyLongImageUrl ?? '', width: double.infinity)),
child: Row(
children: [
// 复制按钮
Flexible(
flex: 1,
child: GestureDetector(
onTap: () => _clickCopyButton(model?.text),
child: CachedNetworkImage(
imageUrl: model?.copyImageUrl,
width: double.infinity,
))),
SizedBox(width: 20),
// 分享按钮
Flexible(
flex: 1,
child: GestureDetector(
onTap: () => _clickShareButton(model?.text),
child: CachedNetworkImage(
imageUrl: model?.shareImageUrl,
width: double.infinity,
)))
],
))
],
),
));
}

/// 骨架图
@@ -145,5 +169,8 @@ class _CustomShareContentContainerWidgetState extends State<_CustomShareContentC
return Container();
}

@override
void refreshWidget(String value) {
setState(() {});
}
}


+ 17
- 15
lib/widgets/team/fans_list/team_fans_item.dart 파일 보기

@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:zhiying_base_widget/pages/team_page/model/team_style_model.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:zhiying_base_widget/widgets/base_state/base_state.dart';
import 'package:zhiying_base_widget/widgets/team/fans_list/model/team_fans_list_model.dart';
import 'package:zhiying_comm/zhiying_comm.dart';
import 'package:fluttertoast/fluttertoast.dart';
@@ -21,7 +22,7 @@ class TeamFansItem extends StatefulWidget {
_TeamFansItemState createState() => _TeamFansItemState();
}

class _TeamFansItemState extends State<TeamFansItem> {
class _TeamFansItemState extends BaseWidgetState<TeamFansItem> {
/// 跳去粉丝详情
void _openFansItemDetailsPage() {
// Navigator.push(context, CupertinoPageRoute(builder: (_) => TeamDetailsPage(null)));
@@ -30,10 +31,10 @@ class _TeamFansItemState extends State<TeamFansItem> {

/// 复制文字
void _copyText(text) {
if(!EmptyUtil.isEmpty(text)) {
if (!EmptyUtil.isEmpty(text)) {
Clipboard.setData(ClipboardData(text: text));
Fluttertoast.showToast(msg: '复制成功~');
}else{
} else {
Fluttertoast.showToast(msg: '内容不能为空');
}
}
@@ -79,7 +80,7 @@ class _TeamFansItemState extends State<TeamFansItem> {
// ),
child: CircleAvatar(
backgroundImage: CachedNetworkImageProvider(
widget?.dataModel?.avatar ?? '',
widget?.dataModel?.avatar ?? '',
),
),
)),
@@ -106,7 +107,10 @@ class _TeamFansItemState extends State<TeamFansItem> {
alignment: Alignment.center,
child: Row(
children: <Widget>[
CachedNetworkImage(imageUrl: widget?.dataModel?.levelIcon ?? '', width: 11,),
CachedNetworkImage(
imageUrl: widget?.dataModel?.levelIcon ?? '',
width: 11,
),
const SizedBox(width: 2.5),
Text(
widget?.dataModel?.levelName ?? '黑钻会员',
@@ -145,13 +149,10 @@ class _TeamFansItemState extends State<TeamFansItem> {
textAlign: TextAlign.center,
text: TextSpan(text: '', children: [
/// 手机号码
TextSpan(
text: widget?.styleModel?.phooneText ?? '手机号:',
style: TextStyle(color: HexColor.fromHex(widget?.styleModel?.phoneColor ?? '#333333'), fontSize: 11)),
TextSpan(text: widget?.styleModel?.phooneText ?? '手机号:', style: TextStyle(color: HexColor.fromHex(widget?.styleModel?.phoneColor ?? '#333333'), fontSize: 11)),
TextSpan(
text: widget?.dataModel?.blurMobile ?? '',
style: TextStyle(
color: HexColor.fromHex(widget?.styleModel?.phoneColor ?? '#333333'), fontSize: 11, fontFamily: 'Din', package: 'zhiying_comm')),
style: TextStyle(color: HexColor.fromHex(widget?.styleModel?.phoneColor ?? '#333333'), fontSize: 11, fontFamily: 'Din', package: 'zhiying_comm')),

/// 复制按钮
WidgetSpan(
@@ -234,11 +235,7 @@ class _TeamFansItemState extends State<TeamFansItem> {
)),
TextSpan(
text: widget?.dataModel?.lastLogin ?? '',
style: TextStyle(
color: HexColor.fromHex(widget?.styleModel?.infoBarLastLoginValueColor ?? '#909090'),
fontSize: 11,
fontFamily: 'Din',
package: 'zhiying_comm')),
style: TextStyle(color: HexColor.fromHex(widget?.styleModel?.infoBarLastLoginValueColor ?? '#909090'), fontSize: 11, fontFamily: 'Din', package: 'zhiying_comm')),
]),
)
],
@@ -377,4 +374,9 @@ class _TeamFansItemState extends State<TeamFansItem> {
],
);
}

@override
void refreshWidget(String value) {
setState(() {});
}
}

불러오는 중...
취소
저장