Procházet zdrojové kódy

1、消息中心的完善,还缺公共跳转

2、Android 启动优化
tags/0.0.1
PH2 před 4 roky
rodič
revize
b5cb67157c
12 změnil soubory, kde provedl 648 přidání a 291 odebrání
  1. +4
    -3
      example/android/app/src/main/AndroidManifest.xml
  2. +1
    -1
      example/android/app/src/main/res/drawable/launch_background.xml
  3. +5
    -0
      example/android/app/src/main/res/drawable/normal_background.xml
  4. +4
    -0
      example/android/app/src/main/res/values/styles.xml
  5. +31
    -7
      lib/pages/message_notice_page/bloc/message_notice_bloc.dart
  6. +53
    -6
      lib/pages/message_notice_page/bloc/message_notice_repository.dart
  7. +7
    -5
      lib/pages/message_notice_page/bloc/message_notice_state.dart
  8. +351
    -268
      lib/pages/message_notice_page/message_notice_page.dart
  9. +58
    -0
      lib/pages/message_notice_page/message_notice_page_sk.dart
  10. +121
    -0
      lib/pages/message_notice_page/model/message_notice_data_model.dart
  11. +12
    -0
      lib/pages/message_notice_page/model/message_notice_style_model.dart
  12. +1
    -1
      lib/register.dart

+ 4
- 3
example/android/app/src/main/AndroidManifest.xml Zobrazit soubor

@@ -39,12 +39,13 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background" />
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
</activity>
<!--
Don't delete the meta-data below.


+ 1
- 1
example/android/app/src/main/res/drawable/launch_background.xml Zobrazit soubor

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- <item android:drawable="@android:color/white" />-->
<item android:drawable="@android:color/white" />

<!-- You can insert your own image assets here -->
<item>


+ 5
- 0
example/android/app/src/main/res/drawable/normal_background.xml Zobrazit soubor

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
</layer-list>

+ 4
- 0
example/android/app/src/main/res/values/styles.xml Zobrazit soubor

@@ -5,4 +5,8 @@
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Base application theme. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@drawable/normal_background</item>
</style>
</resources>

+ 31
- 7
lib/pages/message_notice_page/bloc/message_notice_bloc.dart Zobrazit soubor

@@ -3,6 +3,7 @@ import 'dart:async';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:zhiying_base_widget/pages/message_notice_page/bloc/message_notice_repository.dart';
import 'package:zhiying_base_widget/pages/message_notice_page/model/message_notice_data_model.dart';
import 'package:zhiying_base_widget/pages/message_notice_page/model/message_notice_style_model.dart';
import 'package:zhiying_comm/util/empty_util.dart';
import 'package:zhiying_comm/util/log/let_log.dart';
@@ -44,20 +45,43 @@ class MessageNoticeBloc extends Bloc<MessageNoticeEvent, MessageNoticeState> {
/// 初始化
Stream<MessageNoticeState> _mapInitEventToState(MessageNoticeInitEvent event) async* {
var cacheStyle = await repository.fetchCachedStyle();
if(!EmptyUtil.isEmpty(cacheStyle)){
yield MessageNoticeLoadedState(cacheStyle);
if (!EmptyUtil.isEmpty(cacheStyle)) {
// yield MessageNoticeLoadedState(styleModel: cacheStyle);
}
var netStyle = await repository.fetchNetStyle();
if(!EmptyUtil.isEmpty(netStyle)){
yield MessageNoticeLoadedState(netStyle);
if (!EmptyUtil.isEmpty(netStyle)) {
// yield MessageNoticeLoadedState(styleModel: netStyle);
Logger.log(netStyle.toJson().toString());
}

var data = await repository.fetchInitData();
if (!EmptyUtil.isEmpty(data) && (!EmptyUtil.isEmpty(netStyle) || !EmptyUtil.isEmpty(cacheStyle))) {
yield MessageNoticeLoadedState(dataModel: data, styleModel: !EmptyUtil.isEmpty(netStyle) ? netStyle : cacheStyle);
} else {
yield MessageNoticeInitErrorState();
}
}

/// 下拉刷新
Stream<MessageNoticeState> _mapOnRefreshEventToState(MessageNoticeOnRefreshEvent event) async* {}
Stream<MessageNoticeState> _mapOnRefreshEventToState(MessageNoticeOnRefreshEvent event) async* {
var style = repository.getStyleModel();
var data = await repository.fetchRefreshData();
if (!EmptyUtil.isEmpty(data)) {
yield MessageNoticeOnRefreshSuccessState();
yield MessageNoticeLoadedState(styleModel: style, dataModel: data);
} else {
yield MessageNoticeOnRefreshErrorState();
}
}

/// 上拉更多
Stream<MessageNoticeState> _mapOnLoadEventToState(MessageNoticeOnLoadEvent event) async* {}
Stream<MessageNoticeState> _mapOnLoadEventToState(MessageNoticeOnLoadEvent event) async* {
var style = repository.getStyleModel();
var data = await repository.fetchLoadData();
if (!EmptyUtil.isEmpty(data)) {
yield MessageNoticeOnLoadSuccessState();
yield MessageNoticeLoadedState(styleModel: style, dataModel: data);
} else {
yield MessageNoticeOnLoadErrorState();
}
}
}

+ 53
- 6
lib/pages/message_notice_page/bloc/message_notice_repository.dart Zobrazit soubor

@@ -1,5 +1,6 @@
import 'dart:convert';

import 'package:zhiying_base_widget/pages/message_notice_page/model/message_notice_data_model.dart';
import 'package:zhiying_base_widget/pages/message_notice_page/model/message_notice_style_model.dart';
import 'package:zhiying_comm/util/empty_util.dart';
import 'package:zhiying_comm/util/global_config.dart';
@@ -7,11 +8,28 @@ import 'package:zhiying_comm/util/log/let_log.dart';
import 'package:zhiying_comm/util/net_util.dart';

class MessageNoticeRepository {
String _type;
String _title;

final int _maxSize = 5;
int _currentPage = 1;
bool _hasMoreData = true;
MessageNoticeStyleModel _styleModel;
List<dynamic> _oldData = [];
List<MessageNoticeDataItemModel> _oldData = [];

MessageNoticeRepository(final Map<String, dynamic> data) {
try {
_type = !EmptyUtil.isEmpty(data) ? data.containsKey('type') ? data['type'] : 'main' : 'main';
_title = !EmptyUtil.isEmpty(data) ? data.containsKey('title') ? data['title'] : '消息中心' : '消息中心';
} catch (e, s) {
_type = 'main';
}
}

/// 获取样式数据
MessageNoticeStyleModel getStyleModel() {
return _styleModel;
}

/// 样式初始化(获取网络)
Future<MessageNoticeStyleModel> fetchNetStyle() async {
@@ -21,6 +39,13 @@ class MessageNoticeRepository {
var modListData = result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]['mod_list'][0]['data'];
if (!EmptyUtil.isEmpty(modListData)) {
_styleModel = MessageNoticeStyleModel.fromJson(jsonDecode(modListData.toString()));
if (_type == 'main') {
_styleModel.isFist = true;
} else {
_styleModel.isFist = false;
}
_styleModel.styleType = _type;
_styleModel.styleTitle = _title ?? _styleModel.app_bar_name;
return _styleModel;
}
}
@@ -38,6 +63,13 @@ class MessageNoticeRepository {
var modListData = result['mod_list'][0]['data'];
if (!EmptyUtil.isEmpty(modListData)) {
_styleModel = MessageNoticeStyleModel.fromJson(jsonDecode(modListData.toString()));
if (_type == 'main') {
_styleModel.isFist = true;
} else {
_styleModel.isFist = false;
}
_styleModel.styleType = _type;
_styleModel.styleTitle = _title ?? _styleModel.app_bar_name;
return _styleModel;
}
}
@@ -48,12 +80,12 @@ class MessageNoticeRepository {
}

/// 下拉刷新
Future<dynamic> fetchRefreshData() async {
Future<MessageNoticeDataModel> fetchRefreshData() async {
return fetchInitData();
}

/// 上拉更多
Future<dynamic> fetchLoadData() async {
Future<MessageNoticeDataModel> fetchLoadData() async {
if (_hasMoreData) {
return _baseRequest();
}
@@ -61,7 +93,7 @@ class MessageNoticeRepository {
}

/// 数据初始化
Future<dynamic> fetchInitData() async {
Future<MessageNoticeDataModel> fetchInitData() async {
_currentPage = 1;
_hasMoreData = true;
_oldData.clear();
@@ -69,8 +101,23 @@ class MessageNoticeRepository {
}

/// 基础请求
Future<dynamic> _baseRequest() async {
try {} catch (e, s) {
Future<MessageNoticeDataModel> _baseRequest() async {
try {
var result = await NetUtil.post('/api/v1/user/notice/$_type?page=${_currentPage.toString()}', method: NetMethod.GET);
if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) {
MessageNoticeDataModel dataModel = MessageNoticeDataModel.fromJson(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]);
if (!EmptyUtil.isEmpty(dataModel) && !EmptyUtil.isEmpty(dataModel.list)) {
// if (dataModel.list.length >= _maxSize) {
++_currentPage;
_hasMoreData = true;
dataModel.list.insertAll(0, _oldData);
// }
_oldData.addAll(dataModel.list);
return dataModel;
}
}
_hasMoreData = false;
} catch (e, s) {
Logger.error(e, s);
}
return null;


+ 7
- 5
lib/pages/message_notice_page/bloc/message_notice_state.dart Zobrazit soubor

@@ -1,10 +1,10 @@
part of 'message_notice_bloc.dart';

abstract class MessageNoticeState extends Equatable {
abstract class MessageNoticeState {
const MessageNoticeState();

@override
List<Object> get props => [];
// @override
// List<Object> get props => [];
}

class MessageNoticeInitial extends MessageNoticeState {}
@@ -12,10 +12,11 @@ class MessageNoticeInitial extends MessageNoticeState {}
/// 数据加载成功
class MessageNoticeLoadedState extends MessageNoticeState {
MessageNoticeStyleModel styleModel;
MessageNoticeLoadedState(this.styleModel);
MessageNoticeDataModel dataModel;
MessageNoticeLoadedState({this.dataModel, this.styleModel});

@override
List<Object> get props => [this.styleModel];
List<Object> get props => [this.styleModel, this.dataModel];
}

/// 初始化失败
@@ -32,5 +33,6 @@ class MessageNoticeOnLoadErrorState extends MessageNoticeState {}

/// 上拉更多成功
class MessageNoticeOnLoadSuccessState extends MessageNoticeState{}

/// 数据初始化加载失败
class MessageNoticeErrorState extends MessageNoticeState {}

+ 351
- 268
lib/pages/message_notice_page/message_notice_page.dart Zobrazit soubor

@@ -4,9 +4,11 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:zhiying_base_widget/pages/message_notice_page/bloc/message_notice_bloc.dart';
import 'package:zhiying_base_widget/pages/message_notice_page/bloc/message_notice_repository.dart';
import 'package:zhiying_base_widget/pages/message_notice_page/model/message_notice_data_model.dart';
import 'package:zhiying_base_widget/widgets/empty/empty_widget.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

import 'message_notice_page_sk.dart';
import 'model/message_notice_style_model.dart';

///
@@ -20,13 +22,17 @@ class MessageNoticePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocProvider<MessageNoticeBloc>(
create: (_) => MessageNoticeBloc(MessageNoticeRepository()),
child: _MessageNoticePageContainer(),
create: (_) => MessageNoticeBloc(MessageNoticeRepository(data)),
child: _MessageNoticePageContainer(
key: UniqueKey(),
),
);
}
}

class _MessageNoticePageContainer extends StatefulWidget {
_MessageNoticePageContainer({Key key}) : super(key: key);

@override
__MessageNoticePageContainerState createState() => __MessageNoticePageContainerState();
}
@@ -35,10 +41,25 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine
RefreshController _refreshController;

/// 刷新
void _onRefresh() async {}
void _onRefresh() async {
BlocProvider.of<MessageNoticeBloc>(context).add(MessageNoticeOnRefreshEvent());
}

/// 下拉更多
void _onLoad() async {}
void _onLoad() async {
BlocProvider.of<MessageNoticeBloc>(context).add(MessageNoticeOnLoadEvent());
}

/// 子item点击事件
void _onMainItemClick(MainNotificationStyleItem styleModel) {
/// 如果是消息中心,则重新打开页面加载
Navigator.push(context, CupertinoPageRoute(builder: (_) => MessageNoticePage({'type': styleModel?.type, 'title': styleModel?.name})));
}

/// TODO 需要实现 子widget点击事件,公共跳转
void _onItemClick(){

}

@override
void initState() {
@@ -49,6 +70,12 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine
super.initState();
}

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

@override
Widget build(BuildContext context) {
return BlocConsumer<MessageNoticeBloc, MessageNoticeState>(
@@ -87,7 +114,7 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine
builder: (context, state) {
/// 数据加载成功
if (state is MessageNoticeLoadedState) {
return _buildDataListWidget(state?.styleModel);
return _buildDataListWidget(state?.styleModel, state?.dataModel);
}

/// 数据初始化失败
@@ -102,21 +129,52 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine
}

/// 有数据
Widget _buildDataListWidget(MessageNoticeStyleModel styleModel) {
Widget _buildDataListWidget(MessageNoticeStyleModel styleModel, MessageNoticeDataModel dataModel) {
return Scaffold(
appBar: _buildAppBarWidget(),
appBar: _buildAppBarWidget(styleModel),
body: SmartRefresher(
controller: _refreshController,
onRefresh: _onRefresh,
onLoading: _onLoad,
enablePullDown: true,
enablePullUp: true,
enablePullUp: styleModel.isFist ? false : true,
child: ListView.builder(
padding: const EdgeInsets.only(left: 12.5, right: 12.5, top: 8),
itemCount: styleModel?.main_notification?.list?.length ?? 0,
itemCount: dataModel?.list?.length ?? 0,
itemBuilder: (context, index) {
/// 子视图的样式类型
String styleType = styleModel?.styleType ?? 'main';
MessageNoticeDataItemModel itemDataModel = !EmptyUtil.isEmpty(dataModel.list) ? dataModel.list[index] : null;

/// 官方活动
if (styleType == 'official_activity') {
return _buildOfficialActivitiesStyleWidget(styleModel?.official_activity, itemDataModel);
}

///官方通知
if (styleType == 'official_notification') {
return _buildOfficialNoticeStyleWidget(styleModel?.official_notification, itemDataModel);
}

/// 交易通知
if (styleType == 'transaction_notification') {
return _buildTradeNoticeStyleWidget(styleModel?.transaction_notification, itemDataModel);
}

/// 推广通知
if (styleType == 'promotion_notification') {
return _buildPromoteNoticeStyleWidget(styleModel?.promotion_notification, itemDataModel);
}

/// 反馈通知
if (styleType == 'feedback_notification') {
return _buildFeedbackNoticeStyleWidget(styleModel?.feedback_notification, itemDataModel);
}

/// 默认返回消息中心样式
return _buildMessageCenterStyleWidget(
styleModel?.main_notification?.list[index],
dataModel.list[index],
index,
styleModel?.main_notification?.list?.length,
styleModel?.main_notification?.unread_text_color,
@@ -130,13 +188,14 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine
/// 没有数据
Widget _buildEmptyWidget() {
return Scaffold(
appBar: _buildAppBarWidget(),
appBar: _buildAppBarWidget(null),
body: SmartRefresher(
controller: _refreshController,
onRefresh: _onRefresh,
enablePullDown: true,
enablePullUp: false,
child: ListView(
padding: const EdgeInsets.only(top: 30),
children: <Widget>[
EmptyWidget(),
],
@@ -148,298 +207,325 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine
/// 骨架图
Widget _buildSkeletonWidget() {
return Scaffold(
appBar: _buildAppBarWidget(),
body: Container(),
appBar: _buildAppBarWidget(null),
body: MessageNoticePageSkeleton(),
);
}

/// 消息中心样式
Widget _buildMessageCenterStyleWidget(MainNotificationStyleItem styleModel, int index, int length, String unreadTextColor, String unreadBgColor) {
Widget _buildMessageCenterStyleWidget(
MainNotificationStyleItem styleModel, MessageNoticeDataItemModel dataModel, int index, int length, String unreadTextColor, String unreadBgColor) {
var borderRadius = index == 0
? BorderRadius.only(topLeft: Radius.circular(7.5), topRight: Radius.circular(7.5))
: index == length - 1 ? BorderRadius.only(bottomRight: Radius.circular(7.5), bottomLeft: Radius.circular(7.5)) : BorderRadius.only();

return Container(
decoration: BoxDecoration(color: HexColor.fromHex(styleModel?.bg_color ?? '#FFFFFF'), borderRadius: borderRadius),
padding: const EdgeInsets.only(left: 15, right: 15, top: 16),
child: Column(
children: <Widget>[
Container(
height: 30,
width: double.infinity,
child: Row(
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => _onMainItemClick(styleModel),
child: Container(
decoration: BoxDecoration(color: HexColor.fromHex(styleModel?.bg_color ?? '#FFFFFF'), borderRadius: borderRadius),
padding: const EdgeInsets.only(left: 15, right: 15, top: 16),
child: Column(
children: <Widget>[
Container(
height: 30,
width: double.infinity,
child: Row(
children: <Widget>[
_buildCustomerAvatarWidget(icon: styleModel?.icon, unreadBgColor: unreadBgColor, unreadTextColor: unreadTextColor, value: dataModel?.unread_count),
const SizedBox(width: 10),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
/// 官方活动
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
styleModel?.name ?? '官方活动',
style: TextStyle(color: HexColor.fromHex(styleModel?.name_color ?? '#333333'), fontWeight: FontWeight.bold, fontSize: 13),
),
Text(dataModel?.date_time ?? '', style: TextStyle(color: HexColor.fromHex(styleModel?.time_color ?? '#D8D8D8'), fontSize: 12)),
],
),
Padding(
padding: const EdgeInsets.only(right: 22),
child: Text(
//'2020年6月23日4:00至6月30日4:00关闭提现aaa',
dataModel?.main_preview ?? '',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: HexColor.fromHex(styleModel?.value_color ?? '#999999'), fontSize: 12),
),
),
],
),
)
],
),
),
Padding(padding: const EdgeInsets.only(top: 14.5), child: Divider(height: 0.5, color: HexColor.fromHex('#EFEFEF')))
],
),
),
);
}

/// 官方通知样式
Widget _buildOfficialNoticeStyleWidget(OfficialNotificationStyle styleModel, MessageNoticeDataItemModel dataModel) {
return GestureDetector(
onTap: ()=> _onItemClick(),
behavior: HitTestBehavior.opaque,
child: Container(
padding: const EdgeInsets.only(left: 15, right: 15, top: 12.5, bottom: 10),
margin: const EdgeInsets.only(bottom: 7.5),
decoration: BoxDecoration(
color: HexColor.fromHex(styleModel?.bg_color ?? '#FFFFFF'),
borderRadius: BorderRadius.circular(7.5),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
_buildCustomerAvatarWidget(icon: styleModel?.icon, unreadBgColor: unreadBgColor, unreadTextColor: unreadTextColor),
_buildCustomerAvatarWidget(icon: styleModel?.icon),
const SizedBox(width: 10),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
/// 官方活动
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
styleModel?.name ?? '官方活动',
style: TextStyle(color: HexColor.fromHex(styleModel?.name_color ?? '#333333'), fontWeight: FontWeight.bold, fontSize: 13),
),
Text('04-20 16:00', style: TextStyle(color: HexColor.fromHex(styleModel?.time_color ?? '#D8D8D8'), fontSize: 12)),
],
),
Padding(
padding: const EdgeInsets.only(right: 22),
child: Text(
'2020年6月23日4:00至6月30日4:00关闭提现aaa',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: HexColor.fromHex(styleModel?.value_color ?? '#999999'), fontSize: 12),
),
/// 标题
Text(
dataModel?.title ?? '',
style: TextStyle(color: HexColor.fromHex(styleModel?.title_value_color ?? '#333333'), fontSize: 14, fontWeight: FontWeight.bold),
),
const SizedBox(height: 5),

/// 内容
Text(
dataModel?.subtitle ?? '',
maxLines: 3,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: HexColor.fromHex(styleModel?.message_value_color ?? '#999999'), fontSize: 11),
)
],
),
)
],
),
),
Padding(padding: const EdgeInsets.only(top: 14.5), child: Divider(height: 0.5, color: HexColor.fromHex('#EFEFEF')))
],
),
);
}

/// 官方通知样式
Widget _buildOfficialNoticeStyleWidget(OfficialNotificationStyle styleModel) {
return Container(
padding: const EdgeInsets.only(left: 15, right: 15, top: 12.5, bottom: 10),
margin: const EdgeInsets.only(bottom: 7.5),
decoration: BoxDecoration(
color: HexColor.fromHex(styleModel?.bg_color ?? '#FFFFFF'),
borderRadius: BorderRadius.circular(7.5),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
_buildCustomerAvatarWidget(icon: styleModel?.icon),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
/// 标题
Text(
'关于关闭提现功能通知',
style: TextStyle(color: HexColor.fromHex(styleModel?.title_value_color ?? '#333333'), fontSize: 14, fontWeight: FontWeight.bold),
),
const SizedBox(height: 5),

/// 内容
Text(
'由于微信官方的限制,我们暂时将嗨如意小程序内的提现功能进行关闭并进行维护,关闭功能时间为2020年6月23日4:00至6月30日4:00,请谅解',
maxLines: 3,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: HexColor.fromHex(styleModel?.message_value_color ?? '#999999'), fontSize: 11),
)
],
),
)
],
),

/// 时间
Padding(
padding: const EdgeInsets.only(top: 16),
child: Text(
'2020-06-23 01:00:06',
style: TextStyle(color: HexColor.fromHex(styleModel?.time_color ?? '#D8D8D8'), fontSize: 11),
))
],
/// 时间
Padding(
padding: const EdgeInsets.only(top: 16),
child: Text(
dataModel?.date_time ?? '',
style: TextStyle(color: HexColor.fromHex(styleModel?.time_color ?? '#D8D8D8'), fontSize: 11),
))
],
),
),
);
}

/// 官方活动样式
Widget _buildOfficialActivitiesStyleWidget(OfficialActivityStyle styleModel) {
return Container(
padding: const EdgeInsets.only(left: 15, right: 15, top: 12.5, bottom: 10),
margin: const EdgeInsets.only(bottom: 7.5),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(7.5), color: HexColor.fromHex(styleModel?.bg_color ?? '#FFFFFF')),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
/// 标题
Text(
'8.8淘宝会员节大促',
style: TextStyle(color: HexColor.fromHex(styleModel?.title_value_color ?? '#333333'), fontWeight: FontWeight.bold, fontSize: 14),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 6),

/// 图片海报
ClipRRect(
borderRadius: BorderRadius.circular(7.5),
child: CachedNetworkImage(
imageUrl: 'http://ossq.izhyin.cn/index_carousel_1.png',
width: double.infinity,
)),
const SizedBox(height: 6.5),

/// 活动内容
Text(
'京东家电815周年庆,全场家电最低五折起,买一送一等超多优惠活动,点击查看活动详情',
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 11, color: HexColor.fromHex(styleModel?.message_value_color ?? '#999999')),
),
Widget _buildOfficialActivitiesStyleWidget(OfficialActivityStyle styleModel, MessageNoticeDataItemModel dataModel) {
return GestureDetector(
onTap: ()=> _onItemClick(),
behavior: HitTestBehavior.opaque,
child: Container(
padding: const EdgeInsets.only(left: 15, right: 15, top: 12.5, bottom: 10),
margin: const EdgeInsets.only(bottom: 7.5),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(7.5), color: HexColor.fromHex(styleModel?.bg_color ?? '#FFFFFF')),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
/// 标题
Text(
dataModel?.title ?? '',
style: TextStyle(color: HexColor.fromHex(styleModel?.title_value_color ?? '#333333'), fontWeight: FontWeight.bold, fontSize: 14),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 6),

/// 图片海报
ClipRRect(
borderRadius: BorderRadius.circular(7.5),
child: CachedNetworkImage(
imageUrl: dataModel?.img ?? '',
width: double.infinity,
)),
const SizedBox(height: 6.5),

/// 活动内容
Text(
dataModel?.subtitle ?? '',
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 11, color: HexColor.fromHex(styleModel?.message_value_color ?? '#999999')),
),

/// 时间
const SizedBox(height: 7),
Text('2020-06-23 01:00:06', style: TextStyle(color: HexColor.fromHex(styleModel?.time_color ?? '#D8D8D8'), fontSize: 11))
],
/// 时间
const SizedBox(height: 7),
Text(dataModel?.date_time ?? '', style: TextStyle(color: HexColor.fromHex(styleModel?.time_color ?? '#D8D8D8'), fontSize: 11))
],
),
),
);
}

/// 交易通知样式
Widget _buildTradeNoticeStyleWidget(TransactionNotificationStyle styleModel) {
return Container(
padding: const EdgeInsets.only(left: 15, right: 15, top: 12.5, bottom: 10),
margin: const EdgeInsets.only(bottom: 7.5),
decoration: BoxDecoration(
color: HexColor.fromHex(styleModel?.bg_color ?? '#FFFFFF'),
borderRadius: BorderRadius.circular(7.5),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
_buildCustomerAvatarWidget(icon: styleModel?.icon),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
/// 标题
Text('自购订单收益', style: TextStyle(color: HexColor.fromHex(styleModel?.title_value_color ?? '#333333'), fontSize: 14, fontWeight: FontWeight.bold)),
const SizedBox(height: 5),

/// 内容
_buildCustomerTradeContentWidget(styleModel),
],
),
)
],
),
Widget _buildTradeNoticeStyleWidget(TransactionNotificationStyle styleModel, MessageNoticeDataItemModel dataModel) {
return GestureDetector(
onTap: ()=> _onItemClick(),
behavior: HitTestBehavior.opaque,
child: Container(
padding: const EdgeInsets.only(left: 15, right: 15, top: 12.5, bottom: 10),
margin: const EdgeInsets.only(bottom: 7.5),
decoration: BoxDecoration(
color: HexColor.fromHex(styleModel?.bg_color ?? '#FFFFFF'),
borderRadius: BorderRadius.circular(7.5),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
_buildCustomerAvatarWidget(icon: styleModel?.icon),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
/// 标题
Text(dataModel?.title ?? '', style: TextStyle(color: HexColor.fromHex(styleModel?.title_value_color ?? '#333333'), fontSize: 14, fontWeight: FontWeight.bold)),
const SizedBox(height: 5),

/// 时间
Padding(
padding: const EdgeInsets.only(top: 16),
child: Text('2020-06-23 01:00:06', style: TextStyle(color: HexColor.fromHex(styleModel?.time_color ?? '#D8D8D8'), fontSize: 11)))
],
/// 内容
_buildCustomerTradeContentWidget(styleModel, dataModel?.transactions),
],
),
)
],
),

/// 时间
Padding(
padding: const EdgeInsets.only(top: 16),
child: Text(dataModel?.date_time ?? '', style: TextStyle(color: HexColor.fromHex(styleModel?.time_color ?? '#D8D8D8'), fontSize: 11)))
],
),
),
);
}

/// 推广通知样式
Widget _buildPromoteNoticeStyleWidget(PromotionNotificationStyle styleModel) {
return Container(
padding: const EdgeInsets.only(left: 15, right: 15, top: 12.5, bottom: 10),
margin: const EdgeInsets.only(bottom: 7.5),
decoration: BoxDecoration(
color: HexColor.fromHex(styleModel?.bg_color ?? '#FFFFFF'),
borderRadius: BorderRadius.circular(7.5),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
_buildCustomerAvatarWidget(icon: styleModel?.icon),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
/// 标题
Text(
'新增直推粉丝',
style: TextStyle(color: HexColor.fromHex(styleModel?.title_value_color ?? '#333333'), fontSize: 14, fontWeight: FontWeight.bold),
),
const SizedBox(height: 5),

/// 内容
Text(
'恭喜您成功邀请152****5887加入您的团队,快带领小伙伴走向致富之路吧!',
maxLines: 3,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: HexColor.fromHex(styleModel?.message_value_color ?? '#999999'), fontSize: 11),
)
],
),
)
],
),
Widget _buildPromoteNoticeStyleWidget(PromotionNotificationStyle styleModel, MessageNoticeDataItemModel dataModel) {
return GestureDetector(
onTap: ()=> _onItemClick(),
behavior: HitTestBehavior.opaque,
child: Container(
padding: const EdgeInsets.only(left: 15, right: 15, top: 12.5, bottom: 10),
margin: const EdgeInsets.only(bottom: 7.5),
decoration: BoxDecoration(
color: HexColor.fromHex(styleModel?.bg_color ?? '#FFFFFF'),
borderRadius: BorderRadius.circular(7.5),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
_buildCustomerAvatarWidget(icon: styleModel?.icon),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
/// 标题
Text(
dataModel?.title ?? '',
style: TextStyle(color: HexColor.fromHex(styleModel?.title_value_color ?? '#333333'), fontSize: 14, fontWeight: FontWeight.bold),
),
const SizedBox(height: 5),

/// 内容
Text(
dataModel?.subtitle ?? '恭喜您成功邀请152****5887加入您的团队,快带领小伙伴走向致富之路吧!',
maxLines: 3,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: HexColor.fromHex(styleModel?.message_value_color ?? '#999999'), fontSize: 11),
)
],
),
)
],
),

/// 时间
Padding(
padding: const EdgeInsets.only(top: 16),
child: Text('2020-06-23 01:00:06', style: TextStyle(color: HexColor.fromHex(styleModel?.time_color ?? '#D8D8D8'), fontSize: 11)))
],
/// 时间
Padding(
padding: const EdgeInsets.only(top: 16),
child: Text(dataModel?.date_time ?? '', style: TextStyle(color: HexColor.fromHex(styleModel?.time_color ?? '#D8D8D8'), fontSize: 11)))
],
),
),
);
}

/// 反馈通知样式
Widget _buildFeedbackNoticeStyleWidget(FeedbackNotificationStyle styleModel) {
return Container(
padding: const EdgeInsets.only(left: 15, right: 15, top: 14, bottom: 10),
margin: const EdgeInsets.only(bottom: 7.5),
decoration: BoxDecoration(
color: HexColor.fromHex(styleModel?.bg_color ?? '#FFFFFF'),
borderRadius: BorderRadius.circular(7.5),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
_buildCustomerAvatarWidget(icon: styleModel?.icon),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
/// 标题
Text('您的反馈有回复啦', style: TextStyle(color: HexColor.fromHex(styleModel?.title_value_color ?? '#333333'), fontSize: 14, fontWeight: FontWeight.bold)),
const SizedBox(height: 3),

/// 内容
Text('点击查看回复详情',
maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle(color: HexColor.fromHex(styleModel?.message_value_color ?? '#999999'), fontSize: 11))
],
),
)
],
),
Widget _buildFeedbackNoticeStyleWidget(FeedbackNotificationStyle styleModel, MessageNoticeDataItemModel dataModel) {
return GestureDetector(
onTap: ()=> _onItemClick(),
behavior: HitTestBehavior.opaque,
child: Container(
padding: const EdgeInsets.only(left: 15, right: 15, top: 14, bottom: 10),
margin: const EdgeInsets.only(bottom: 7.5),
decoration: BoxDecoration(
color: HexColor.fromHex(styleModel?.bg_color ?? '#FFFFFF'),
borderRadius: BorderRadius.circular(7.5),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
_buildCustomerAvatarWidget(icon: styleModel?.icon),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
/// 标题
Text(dataModel?.title ?? '', style: TextStyle(color: HexColor.fromHex(styleModel?.title_value_color ?? '#333333'), fontSize: 14, fontWeight: FontWeight.bold)),
const SizedBox(height: 3),

/// 时间
Padding(
padding: const EdgeInsets.only(top: 16),
child: Text(styleModel?.time_color ?? '2020-06-23 01:00:06', style: TextStyle(color: HexColor.fromHex('#D8D8D8'), fontSize: 11)))
],
/// 内容
Text(dataModel?.subtitle ?? '',
maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle(color: HexColor.fromHex(styleModel?.message_value_color ?? '#999999'), fontSize: 11))
],
),
)
],
),

/// 时间
Padding(
padding: const EdgeInsets.only(top: 16),
child: Text(dataModel?.date_time ?? '', style: TextStyle(color: HexColor.fromHex(styleModel?.time_color ?? '#D8D8D8'), fontSize: 11)))
],
),
),
);
}

/// APPBar
Widget _buildAppBarWidget() {
Widget _buildAppBarWidget(MessageNoticeStyleModel styleModel) {
return AppBar(
leading: IconButton(
icon: Icon(
@@ -450,11 +536,11 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine
onPressed: () => Navigator.maybePop(context),
),
title: Text(
'消息中心',
style: TextStyle(color: HexColor.fromHex('#333333'), fontSize: 15, fontWeight: FontWeight.bold),
styleModel?.isFist ?? true ? styleModel?.app_bar_name ?? '消息中心' : styleModel?.styleTitle ?? '',
style: TextStyle(color: HexColor.fromHex(styleModel?.app_bar_name_color ?? '#333333'), fontSize: 15, fontWeight: FontWeight.bold),
),
centerTitle: true,
backgroundColor: HexColor.fromHex('#FFFFFF'),
backgroundColor: HexColor.fromHex(styleModel?.app_bar_bg_color ?? '#FFFFFF'),
elevation: 0,
);
}
@@ -477,7 +563,7 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine
),
),
Visibility(
visible: !EmptyUtil.isEmpty(value),
visible: !EmptyUtil.isEmpty(value) && value != '0',
child: Transform.translate(
offset: Offset(5, -4.5),
child: Container(
@@ -502,27 +588,24 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine
);
}

Widget _buildCustomerTradeContentWidget(TransactionNotificationStyle styleModel) {
Map<String, String> datas = {
'订单编号:': '154547896541651464788',
'订单类型:': '京东',
'预估收益:': '8.00',
'下单时间:': '2020-08-14 11:35:39',
'预估结算:': '次月25日结算',
};
Widget _buildCustomerTradeContentWidget(TransactionNotificationStyle styleModel, List<TransactionBodyItemModel> transactions) {
List<Widget> lists = [];
datas.forEach((key, value) {
transactions.forEach((element) {
bool isearnings = (element?.type ?? '') == 'earnings';
lists.add(Padding(
padding: const EdgeInsets.only(bottom: 5),
child: RichText(
textAlign: TextAlign.start,
text: TextSpan(children: [
TextSpan(text: key, style: TextStyle(fontSize: 11, color: HexColor.fromHex('#999999'))),
TextSpan(text: value, style: TextStyle(fontSize: 11, color: HexColor.fromHex('#999999'))),
TextSpan(text: element?.text ?? '', style: TextStyle(fontSize: 11, color: HexColor.fromHex( styleModel?.message_value_color ?? '#999999'))),
TextSpan(text: element?.data ?? '', style: TextStyle(fontSize: 11, color: HexColor.fromHex( isearnings ?
styleModel?.earnings ?? '#FF0100'
: styleModel?.message_value_color ?? '#999999'))),
]),
),
));
});

return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: lists,


+ 58
- 0
lib/pages/message_notice_page/message_notice_page_sk.dart Zobrazit soubor

@@ -0,0 +1,58 @@
import 'package:shimmer/shimmer.dart';
import 'package:flutter/material.dart';

class MessageNoticePageSkeleton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ListView.builder(
padding: const EdgeInsets.only(left: 12.5, right: 12.5, top: 8, bottom: 20),
itemBuilder: (context, index) {
return Container(
padding: const EdgeInsets.only(left: 15, right: 15, top: 12.5, bottom: 12.5),
margin: const EdgeInsets.only(bottom: 7.5),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(7.5),
color: Colors.white,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// 头像
_shimmerWidget(width: 40, height: 40, radius: 30),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
_shimmerWidget(width: 140, height: 18),
const SizedBox(height: 5),
_shimmerWidget(height: 30, width: double.infinity),
],
),
)
],
),

],
),
);
},
itemCount: 5,
);
}

Widget _shimmerWidget({double width, double height, double radius = 0}) {
return Shimmer.fromColors(
baseColor: Colors.grey[300],
highlightColor: Colors.grey[100],
child: Container(
width: width,
height: height,
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(radius)),
),
);
}
}

+ 121
- 0
lib/pages/message_notice_page/model/message_notice_data_model.dart Zobrazit soubor

@@ -0,0 +1,121 @@
import 'dart:convert';

import 'package:zhiying_comm/util/empty_util.dart';

class MessageNoticeDataModel {
List<MessageNoticeDataItemModel> list;

MessageNoticeDataModel({this.list});

factory MessageNoticeDataModel.fromJson(Map<String, dynamic> json) {
return MessageNoticeDataModel(
list: json['list'] != null ? (json['list'] as List).map((i) => MessageNoticeDataItemModel.fromJson(i)).toList() : null,
);
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.list != null) {
data['list'] = this.list.map((v) => v.toJson()).toList();
}
return data;
}
}

class MessageNoticeDataItemModel {
String unread_count;
String receiver;
String body;
String date_time;
String id;
String img;
String main_preview;
String oid;
String sender;
String status;
String subtitle;
String title;
String type;
List<TransactionBodyItemModel> transactions;

MessageNoticeDataItemModel({
this.unread_count,
this.receiver,
this.body,
this.date_time,
this.id,
this.img,
this.main_preview,
this.oid,
this.sender,
this.status,
this.subtitle,
this.title,
this.type,
this.transactions,
});

factory MessageNoticeDataItemModel.fromJson(Map<String, dynamic> json) {
return MessageNoticeDataItemModel(
unread_count: json['unread_count']?.toString(),
receiver: json['receiver']?.toString(),
body: json['body']?.toString(),
date_time: json['date_time']?.toString(),
id: json['id']?.toString(),
img: json['img']?.toString(),
main_preview: json['main_preview']?.toString(),
oid: json['oid']?.toString(),
sender: json['sender']?.toString(),
status: json['status']?.toString(),
subtitle: json['subtitle']?.toString(),
title: json['title']?.toString(),
type: json['type']?.toString(),
transactions:
(!EmptyUtil.isEmpty(json['body']) && jsonDecode(json['body']) != null) ? (jsonDecode(json['body']) as List).map((e) => TransactionBodyItemModel.fromJson(e)).toList() : null,
);
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['receiver'] = this.receiver;
data['body'] = this.body;
data['date_time'] = this.date_time;
data['id'] = this.id;
data['img'] = this.img;
data['main_preview'] = this.main_preview;
data['oid'] = this.oid;
data['sender'] = this.sender;
data['status'] = this.status;
data['subtitle'] = this.subtitle;
data['title'] = this.title;
data['type'] = this.type;
if (null != this.transactions) {
data['transactions'] = this.transactions.map((e) => e.toJson()).toList();
}
return data;
}
}

class TransactionBodyItemModel {
String data;
String text;
String type;

TransactionBodyItemModel({this.data, this.text, this.type});

factory TransactionBodyItemModel.fromJson(Map<String, dynamic> json) {
return TransactionBodyItemModel(
data: json['data'],
text: json['text'],
type: json['type'],
);
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['data'] = this.data;
data['text'] = this.text;
data['type'] = this.type;
return data;
}
}

+ 12
- 0
lib/pages/message_notice_page/model/message_notice_style_model.dart Zobrazit soubor

@@ -1,4 +1,7 @@
class MessageNoticeStyleModel {
bool isFist;
String styleType;
String styleTitle;
String app_bar_bg_color;
String app_bar_bg_img;
String app_bar_name;
@@ -11,6 +14,9 @@ class MessageNoticeStyleModel {
TransactionNotificationStyle transaction_notification;

MessageNoticeStyleModel({
this.isFist,
this.styleTitle,
this.styleType,
this.app_bar_bg_color,
this.app_bar_bg_img,
this.app_bar_name,
@@ -25,6 +31,9 @@ class MessageNoticeStyleModel {

factory MessageNoticeStyleModel.fromJson(Map<String, dynamic> json) {
return MessageNoticeStyleModel(
isFist: json['isFist'],
styleTitle: json['styleTitle'],
styleType: json['styleType'],
app_bar_bg_color: json['app_bar_bg_color'],
app_bar_bg_img: json['app_bar_bg_img'],
app_bar_name: json['app_bar_name'],
@@ -40,6 +49,9 @@ class MessageNoticeStyleModel {

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['isFist'] = this.isFist;
data['styleTitle'] = this.styleTitle;
data['styleType'] = this.styleType;
data['app_bar_bg_color'] = this.app_bar_bg_color;
data['app_bar_bg_img'] = this.app_bar_bg_img;
data['app_bar_name'] = this.app_bar_name;


+ 1
- 1
lib/register.dart Zobrazit soubor

@@ -153,7 +153,7 @@ class BaseWidgetRegister {

/// 消息中心
PageFactory.regist(
'pub.flutter.message_notice', (model) => MessageNoticePage(model));
'pub.flutter.message_center', (model) => MessageNoticePage(model));
}

// 注册控件


Načítá se…
Zrušit
Uložit