@@ -1,7 +1,5 @@ | |||||
import 'dart:async'; | import 'dart:async'; | ||||
import 'dart:convert' as convert; | import 'dart:convert' as convert; | ||||
import 'dart:convert'; | |||||
import 'dart:io'; | |||||
import 'package:cached_network_image/cached_network_image.dart'; | import 'package:cached_network_image/cached_network_image.dart'; | ||||
import 'package:flutter/cupertino.dart'; | import 'package:flutter/cupertino.dart'; | ||||
@@ -10,16 +8,10 @@ import 'package:flutter/material.dart'; | |||||
import 'package:flutter/services.dart'; | import 'package:flutter/services.dart'; | ||||
import 'package:flutter/widgets.dart'; | import 'package:flutter/widgets.dart'; | ||||
import 'package:moblink/moblink.dart'; | import 'package:moblink/moblink.dart'; | ||||
import 'package:mobpush_plugin/mobpush_custom_message.dart'; | |||||
import 'package:mobpush_plugin/mobpush_notify_message.dart'; | |||||
import 'package:mobpush_plugin/mobpush_plugin.dart'; | |||||
import 'package:provider/provider.dart'; | import 'package:provider/provider.dart'; | ||||
import 'package:zhiying_base_widget/dialog/global_dialog/activity_dialog/activity_dialog.dart'; | |||||
import 'package:zhiying_base_widget/dialog/global_dialog/advertising_dialog/advertising_dialog.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/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/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/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/pages/custom_page/event/reload_event.dart'; | ||||
import 'package:zhiying_base_widget/utils/contants.dart'; | import 'package:zhiying_base_widget/utils/contants.dart'; | ||||
@@ -35,10 +27,6 @@ import 'package:zhiying_comm/zhiying_comm.dart'; | |||||
import 'package:zhiying_comm/util/event_util/login_success_event.dart'; | import 'package:zhiying_comm/util/event_util/login_success_event.dart'; | ||||
import 'package:zhiying_comm/util/event_util/event_util.dart'; | 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:zhiying_comm/util/event_util/login_success_event.dart'; | |||||
import 'package:zhiying_comm/util/event_util/event_util.dart'; | |||||
import 'package:zhiying_comm/util/event_util/log_out.dart'; | |||||
import 'package:package_info/package_info.dart'; | |||||
class HomeCenterPage extends StatefulWidget { | class HomeCenterPage extends StatefulWidget { | ||||
@override | @override | ||||
@@ -293,7 +281,59 @@ class _HomePageState extends LifeState<HomePage> with WidgetsBindingObserver, Ti | |||||
// Widget createBottomNavigationBarNew(List<Map<String, dynamic>> tabs) { | // Widget createBottomNavigationBarNew(List<Map<String, dynamic>> tabs) { | ||||
// | // | ||||
// return ConvexAppBar(items: null, initialActiveIndex: _currentIndex, style: TabStyle.titled,); | |||||
// List<TabItem> items = List<TabItem>(); | |||||
// for (int i = 0; i < tabs.length; i++) { | |||||
// BaseTabModel model = BaseTabModel.fromJson(tabs[i]); | |||||
// String icon = ImageUtil.getUrl(model.icon); | |||||
// String selectedIcon = ImageUtil.getUrl(model.chooseIcon ?? model.icon); | |||||
// String textColor = model.fontColor; | |||||
// String chooseColor = model.chooseColor ?? textColor; | |||||
// | |||||
// if (model.isShow == "1") { | |||||
// items.add(TabItem<Image>( | |||||
// icon: Image.network(icon ?? ''), | |||||
// activeIcon: Image.network(selectedIcon ?? ''), | |||||
// title: model.name ?? '' | |||||
// )); | |||||
// } | |||||
// } | |||||
// | |||||
// if (items.length < 2) { | |||||
// return Container(); | |||||
// } | |||||
// String bgColor = '#ffffff'; | |||||
// String textColor = '#999999'; | |||||
// String activeColor = '#FF4242'; | |||||
// if (tabs.first != null) { | |||||
// BaseTabModel model = BaseTabModel.fromJson(tabs.first); | |||||
// bgColor = model.bgColor ?? bgColor; | |||||
// textColor = model?.fontColor ?? textColor; | |||||
// activeColor = model?.chooseColor ?? activeColor; | |||||
// } | |||||
// | |||||
// return ConvexAppBar( | |||||
// elevation: 0, | |||||
// backgroundColor: HexColor.fromHex(bgColor), | |||||
// items: items, | |||||
// height: 50, | |||||
// color: HexColor.fromHex(textColor), | |||||
// activeColor: HexColor.fromHex(activeColor), | |||||
// initialActiveIndex: _currentIndex, | |||||
// style: TabStyle.react, | |||||
// onTap: (int index) async { | |||||
// BaseTabModel model = BaseTabModel.fromJson(tabs[index]); | |||||
// if (await _checkLimit(model)) { | |||||
// ///避免同一个页面多次点击多次重绘 | |||||
// if (_currentIndex == index) { | |||||
// return; | |||||
// } else { | |||||
// setState(() { | |||||
// _currentIndex = index; | |||||
// }); | |||||
// } | |||||
// } | |||||
// }, | |||||
// ); | |||||
// } | // } | ||||
Future<bool> _checkLimit(BaseTabModel model) async { | Future<bool> _checkLimit(BaseTabModel model) async { | ||||
@@ -29,7 +29,7 @@ class OrderTabbarWidget extends StatelessWidget { | |||||
Expanded( | Expanded( | ||||
child: TabBar( | child: TabBar( | ||||
controller: controller, | controller: controller, | ||||
isScrollable: false, | |||||
isScrollable: (controller?.length ?? 0) >=4 ? true : false, | |||||
indicatorSize: TabBarIndicatorSize.label, | indicatorSize: TabBarIndicatorSize.label, | ||||
// tabs: widgets, | // tabs: widgets, | ||||
indicatorColor: | indicatorColor: | ||||
@@ -41,6 +41,7 @@ import 'package:zhiying_base_widget/widgets/custom/goods/custom_goods_creater.da | |||||
import 'package:zhiying_base_widget/widgets/custom/multi_nav/custom_quick_entry.dart'; | import 'package:zhiying_base_widget/widgets/custom/multi_nav/custom_quick_entry.dart'; | ||||
import 'package:zhiying_base_widget/widgets/custom/notice/custom_notice_widget.dart'; | import 'package:zhiying_base_widget/widgets/custom/notice/custom_notice_widget.dart'; | ||||
import 'package:zhiying_base_widget/widgets/custom/search/custom_search_widget.dart'; | import 'package:zhiying_base_widget/widgets/custom/search/custom_search_widget.dart'; | ||||
import 'package:zhiying_base_widget/widgets/custom/share_content/share_content_widget.dart'; | |||||
import 'package:zhiying_base_widget/widgets/custom/slide_banner/custom_slide_banner_creater.dart'; | import 'package:zhiying_base_widget/widgets/custom/slide_banner/custom_slide_banner_creater.dart'; | ||||
import 'package:zhiying_base_widget/widgets/goods_details/footer/goods_details_footer_widget.dart'; | import 'package:zhiying_base_widget/widgets/goods_details/footer/goods_details_footer_widget.dart'; | ||||
import 'package:zhiying_base_widget/widgets/goods_details/price/goods_details_price_widget.dart'; | import 'package:zhiying_base_widget/widgets/goods_details/price/goods_details_price_widget.dart'; | ||||
@@ -410,5 +411,7 @@ class BaseWidgetRegister { | |||||
WidgetFactory.regist('placard', DefaultWidgetCreater((model) => CustomNoticeWidget(model))); | WidgetFactory.regist('placard', DefaultWidgetCreater((model) => CustomNoticeWidget(model))); | ||||
// 授权 | // 授权 | ||||
WidgetFactory.regist('audit_tip', DefaultWidgetCreater((model) => HomeAuth(model))); | WidgetFactory.regist('audit_tip', DefaultWidgetCreater((model) => HomeAuth(model))); | ||||
// 分享内容组件 | |||||
WidgetFactory.regist('share_content', DefaultWidgetCreater((model) => CustomShareContentWidget(model))); | |||||
} | } | ||||
} | } |
@@ -74,11 +74,11 @@ class CustomSearchWidget extends StatelessWidget { | |||||
mainAxisAlignment: MainAxisAlignment.center, | mainAxisAlignment: MainAxisAlignment.center, | ||||
children: [ | children: [ | ||||
GestureDetector( | GestureDetector( | ||||
onTap: () => _onClickListener(context, model?.listStyle?.rightCss), | |||||
onTap: () => _onClickListener(context, model?.listStyle?.leftCss), | |||||
child: CachedNetworkImage( | child: CachedNetworkImage( | ||||
width: 30, | width: 30, | ||||
height: 30, | height: 30, | ||||
imageUrl: model?.listStyle?.rightCss?.image ?? '', | |||||
imageUrl: model?.listStyle?.leftCss?.image ?? '', | |||||
)), | )), | ||||
// 图标1 | // 图标1 | ||||
SizedBox(width: 10), | SizedBox(width: 10), | ||||
@@ -118,70 +118,63 @@ class CustomSearchWidget extends StatelessWidget { | |||||
); | ); | ||||
} | } | ||||
/// 左1右2图标 | |||||
Widget _buildStyle5Widget(BuildContext context) { | |||||
return Row( | |||||
mainAxisAlignment: MainAxisAlignment.center, | |||||
children: [ | |||||
GestureDetector( | |||||
onTap: () => _onClickListener(context, model?.listStyle?.rightCss), | |||||
child: CachedNetworkImage( | |||||
width: 30, | |||||
height: 30, | |||||
imageUrl: model?.listStyle?.rightCss?.image ?? '', | |||||
/// 右按钮 | |||||
Widget _buildStyle4Widget(BuildContext context) { | |||||
return GestureDetector( | |||||
onTap: () => _onClickListener(context, model?.listStyle?.rightBtnCss), | |||||
child: Container( | |||||
height: 38, | |||||
padding: EdgeInsets.only(left: 10.5), | |||||
decoration: BoxDecoration( | |||||
border: Border.all(color: HexColor.fromHex(model?.listStyle?.searchCss?.borderColor ?? "")), | |||||
borderRadius: BorderRadius.only( | |||||
bottomRight: Radius.circular(ParseUtil.stringParseDouble(model?.bottomRightRadius)), | |||||
bottomLeft: Radius.circular(ParseUtil.stringParseDouble(model?.bottomLeftRadius)), | |||||
topLeft: Radius.circular(ParseUtil.stringParseDouble(model?.topLeftRadius)), | |||||
topRight: Radius.circular(ParseUtil.stringParseDouble(model?.topRightRadius)), | |||||
)), | )), | ||||
// 图标1 | |||||
SizedBox(width: 10), | |||||
// 中间 | |||||
Expanded( | |||||
child: GestureDetector( | |||||
onTap: () => _onClickListener(context, model?.listStyle?.searchCss), | |||||
behavior: HitTestBehavior.opaque, | |||||
child: Container( | |||||
// height: 30, | |||||
width: double.infinity, | |||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 9), | |||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(60 / 2), color: HexColor.fromHex(model?.listStyle?.searchCss?.bgColor)), | |||||
child: Row( | |||||
children: <Widget>[ | |||||
CachedNetworkImage( | |||||
width: 15, | |||||
height: 15, | |||||
imageUrl: model?.listStyle?.searchCss?.image ?? '', | |||||
), | |||||
SizedBox(width: 4), | |||||
Text(model?.listStyle?.searchCss?.text ?? '输入搜索内容,领券省钱', style: TextStyle(fontSize: 13, color: HexColor.fromHex(model?.listStyle?.searchCss?.textColor??"#FFFFFF"))) | |||||
], | |||||
), | |||||
child: Row( | |||||
mainAxisAlignment: MainAxisAlignment.start, | |||||
crossAxisAlignment: CrossAxisAlignment.center, | |||||
children: <Widget>[ | |||||
///搜索图标 | |||||
CachedNetworkImage( | |||||
imageUrl: model?.listStyle?.searchCss?.image ?? '', | |||||
width: 16, | |||||
fit: BoxFit.fitWidth, | |||||
), | |||||
SizedBox( | |||||
width: 4, | |||||
), | |||||
Expanded( | |||||
child: TextField( | |||||
style: TextStyle(fontSize: 13), | |||||
decoration: InputDecoration( | |||||
isDense: true, | |||||
enabled: false, | |||||
border: InputBorder.none, | |||||
hintText: model?.listStyle?.searchCss?.text ?? "", | |||||
hintStyle: TextStyle(color: HexColor.fromHex(model?.listStyle?.searchCss?.textColor ?? ""))), | |||||
), | ), | ||||
)), | |||||
SizedBox(width: 10), | |||||
// 图标2 | |||||
GestureDetector( | |||||
onTap: () => _onClickListener(context, model?.listStyle?.rightCss), | |||||
child: CachedNetworkImage( | |||||
width: 30, | |||||
height: 30, | |||||
imageUrl: model?.listStyle?.rightCss?.image ?? '', | |||||
)), | |||||
SizedBox(width: 10), | |||||
// 图标2 | |||||
GestureDetector( | |||||
onTap: () => _onClickListener(context, model?.listStyle?.rightCss), | |||||
child: CachedNetworkImage( | |||||
width: 30, | |||||
height: 30, | |||||
imageUrl: model?.listStyle?.rightCss?.image ?? '', | |||||
)), | |||||
], | |||||
), | |||||
Container( | |||||
padding: EdgeInsets.only(left: 16, right: 16), | |||||
decoration: BoxDecoration( | |||||
image: DecorationImage(image: CachedNetworkImageProvider(model?.listStyle?.rightBtnCss?.bgImg ?? ""), fit: BoxFit.fitHeight), | |||||
borderRadius: BorderRadius.circular(2)), | |||||
height: double.infinity, | |||||
child: Center( | |||||
child: Text( | |||||
model?.listStyle?.rightBtnCss?.text ?? "", | |||||
style: TextStyle(color: HexColor.fromHex(model?.listStyle?.rightBtnCss?.textColor ?? "#FFFFFF"), fontWeight: FontWeight.w500, fontSize: 13), | |||||
)), | |||||
) | |||||
], | |||||
), | |||||
), | |||||
); | ); | ||||
} | } | ||||
/// 右按钮 | |||||
Widget _buildStyle4Widget(BuildContext context) { | |||||
return Container(); | |||||
} | |||||
/// 右1图标 | /// 右1图标 | ||||
Widget _buildStyle1Widget(BuildContext context) { | Widget _buildStyle1Widget(BuildContext context) { | ||||
return Row( | return Row( | ||||
@@ -83,12 +83,16 @@ class CustomSearchModel { | |||||
class ListStyle { | class ListStyle { | ||||
SearchCss searchCss; | SearchCss searchCss; | ||||
RightCss rightCss; | RightCss rightCss; | ||||
RightCss leftCss; | |||||
RightBtnCss rightBtnCss; | |||||
ListStyle({this.searchCss, this.rightCss}); | |||||
ListStyle({this.searchCss, this.rightCss, this.leftCss, this.rightBtnCss}); | |||||
ListStyle.fromJson(Map<String, dynamic> json) { | ListStyle.fromJson(Map<String, dynamic> json) { | ||||
searchCss = json['search_css'] != null ? new SearchCss.fromJson(json['search_css']) : null; | searchCss = json['search_css'] != null ? new SearchCss.fromJson(json['search_css']) : null; | ||||
rightCss = json['right_css'] != null ? new RightCss.fromJson(json['right_css']) : null; | rightCss = json['right_css'] != null ? new RightCss.fromJson(json['right_css']) : null; | ||||
leftCss = json['left_css'] != null ? new RightCss.fromJson(json['left_css']) : null; | |||||
rightBtnCss = json['right_btn_css'] != null ? new RightBtnCss.fromJson(json['right_btn_css']) : null; | |||||
} | } | ||||
Map<String, dynamic> toJson() { | Map<String, dynamic> toJson() { | ||||
@@ -99,6 +103,12 @@ class ListStyle { | |||||
if (this.rightCss != null) { | if (this.rightCss != null) { | ||||
data['right_css'] = this.rightCss.toJson(); | data['right_css'] = this.rightCss.toJson(); | ||||
} | } | ||||
if (this.leftCss != null) { | |||||
data['left_css'] = this.leftCss.toJson(); | |||||
} | |||||
if (this.rightBtnCss != null) { | |||||
data['right_btn_css'] = this.rightBtnCss.toJson(); | |||||
} | |||||
return data; | return data; | ||||
} | } | ||||
} | } | ||||
@@ -112,19 +122,21 @@ class SearchCss extends SkipModel { | |||||
String requiredLogin; | String requiredLogin; | ||||
String requiredTaobaoAuth; | String requiredTaobaoAuth; | ||||
String skipIdentifier; | String skipIdentifier; | ||||
String borderColor; | |||||
SearchCss({this.name, this.text, this.image, this.bgColor, this.textColor, this.requiredLogin, this.requiredTaobaoAuth, this.skipIdentifier}); | |||||
SearchCss({this.name, this.text, this.image, this.bgColor, this.textColor, this.requiredLogin, this.requiredTaobaoAuth, this.skipIdentifier, this.borderColor}); | |||||
SearchCss.fromJson(Map<String, dynamic> json) { | SearchCss.fromJson(Map<String, dynamic> json) { | ||||
super.fromJson(json); | super.fromJson(json); | ||||
name = json['name']; | |||||
text = json['text']; | |||||
image = json['image']; | |||||
bgColor = json['bg_color']; | |||||
textColor = json['text_color']; | |||||
requiredLogin = json['required_login']; | |||||
requiredTaobaoAuth = json['required_taobao_auth']; | |||||
skipIdentifier = json['skip_identifier']; | |||||
name = json['name']?.toString(); | |||||
text = json['text']?.toString(); | |||||
image = json['image']?.toString(); | |||||
bgColor = json['bg_color']?.toString(); | |||||
textColor = json['text_color']?.toString(); | |||||
requiredLogin = json['required_login']?.toString(); | |||||
requiredTaobaoAuth = json['required_taobao_auth']?.toString(); | |||||
skipIdentifier = json['skip_identifier']?.toString(); | |||||
borderColor = json['border_color']?.toString(); | |||||
} | } | ||||
Map<String, dynamic> toJson() { | Map<String, dynamic> toJson() { | ||||
@@ -137,6 +149,7 @@ class SearchCss extends SkipModel { | |||||
data['required_login'] = this.requiredLogin; | data['required_login'] = this.requiredLogin; | ||||
data['required_taobao_auth'] = this.requiredTaobaoAuth; | data['required_taobao_auth'] = this.requiredTaobaoAuth; | ||||
data['skip_identifier'] = this.skipIdentifier; | data['skip_identifier'] = this.skipIdentifier; | ||||
data['border_color'] = this.borderColor; | |||||
return data; | return data; | ||||
} | } | ||||
} | } | ||||
@@ -175,3 +188,61 @@ class RightCss extends SkipModel { | |||||
return data; | return data; | ||||
} | } | ||||
} | } | ||||
class RightBtnCss extends SkipModel { | |||||
String name; | |||||
String text; | |||||
String textColor; | |||||
String bgImg; | |||||
String bgImgUrl; | |||||
String skipIdentifier; | |||||
String skipName; | |||||
String requiredLogin; | |||||
String requiredTaobaoAuth; | |||||
String isJump; | |||||
String cateTag; | |||||
RightBtnCss( | |||||
{this.name, | |||||
this.text, | |||||
this.textColor, | |||||
this.bgImg, | |||||
this.bgImgUrl, | |||||
this.skipIdentifier, | |||||
this.skipName, | |||||
this.requiredLogin, | |||||
this.requiredTaobaoAuth, | |||||
this.isJump, | |||||
this.cateTag}); | |||||
RightBtnCss.fromJson(Map<String, dynamic> json) { | |||||
super.fromJson(json); | |||||
name = json['name']; | |||||
text = json['text']; | |||||
textColor = json['text_color']; | |||||
bgImg = json['bg_img']; | |||||
bgImgUrl = json['bg_img_url']; | |||||
skipIdentifier = json['skip_identifier']; | |||||
skipName = json['skip_name']; | |||||
requiredLogin = json['required_login']; | |||||
requiredTaobaoAuth = json['required_taobao_auth']; | |||||
isJump = json['is_jump']; | |||||
cateTag = json['cate_tag']; | |||||
} | |||||
Map<String, dynamic> toJson() { | |||||
final Map<String, dynamic> data = super.toJson(); | |||||
data['name'] = this.name; | |||||
data['text'] = this.text; | |||||
data['text_color'] = this.textColor; | |||||
data['bg_img'] = this.bgImg; | |||||
data['bg_img_url'] = this.bgImgUrl; | |||||
data['skip_identifier'] = this.skipIdentifier; | |||||
data['skip_name'] = this.skipName; | |||||
data['required_login'] = this.requiredLogin; | |||||
data['required_taobao_auth'] = this.requiredTaobaoAuth; | |||||
data['is_jump'] = this.isJump; | |||||
data['cate_tag'] = this.cateTag; | |||||
return data; | |||||
} | |||||
} |
@@ -0,0 +1,39 @@ | |||||
import 'dart:async'; | |||||
import 'package:bloc/bloc.dart'; | |||||
import 'package:meta/meta.dart'; | |||||
import 'package:zhiying_base_widget/widgets/custom/share_content/model/custom_share_content_model.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||||
import 'custom_share_content_repository.dart'; | |||||
part 'custom_share_content_event.dart'; | |||||
part 'custom_share_content_state.dart'; | |||||
class CustomShareContentBloc extends Bloc<CustomShareContentEvent, CustomShareContentState> { | |||||
CustomShareContentBloc({this.repository}) : super(CustomShareContentInitial()); | |||||
CustomShareContentRepository repository; | |||||
@override | |||||
Stream<CustomShareContentState> mapEventToState( | |||||
CustomShareContentEvent event, | |||||
) async* { | |||||
/// 初始化 | |||||
if (event is CustomShareContentInitEvent) { | |||||
yield* _mapInitEventToState(event); | |||||
} | |||||
} | |||||
/// 初始化事件 | |||||
Stream<CustomShareContentState> _mapInitEventToState(CustomShareContentInitEvent event) async* { | |||||
var parentData = await repository.fetchParentStyle(event.model); | |||||
if (!EmptyUtil.isEmpty(parentData)) { | |||||
yield CustomShareContentLoadedState(model: parentData); | |||||
var netData = await repository.fetchNetData(event.model); | |||||
if (!EmptyUtil.isEmpty(netData)) { | |||||
parentData..text = netData?.toString(); | |||||
yield CustomShareContentLoadedState(model: parentData); | |||||
} | |||||
} else { | |||||
yield CustomShareContentErrorState(); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,10 @@ | |||||
part of 'custom_share_content_bloc.dart'; | |||||
@immutable | |||||
abstract class CustomShareContentEvent {} | |||||
/// 初始化事件 | |||||
class CustomShareContentInitEvent extends CustomShareContentEvent { | |||||
final Map<String, dynamic> model; | |||||
CustomShareContentInitEvent({this.model}); | |||||
} |
@@ -0,0 +1,42 @@ | |||||
import 'dart:convert'; | |||||
import 'package:zhiying_base_widget/widgets/custom/share_content/model/custom_share_content_model.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||||
class CustomShareContentRepository { | |||||
/// | |||||
/// 获取缓存的数据 | |||||
/// | |||||
Future<CustomShareContentModel> fetchParentStyle(Map<String, dynamic> model) async { | |||||
try { | |||||
if (!EmptyUtil.isEmpty(model)) { | |||||
return CustomShareContentModel.fromJson(jsonDecode(model['data'])); | |||||
} | |||||
} catch (e, s) { | |||||
Logger.error(e, s); | |||||
} | |||||
return null; | |||||
} | |||||
/// | |||||
/// 获取网络的数据 | |||||
/// | |||||
Future<String> fetchNetData(Map<String, dynamic> model) async { | |||||
try { | |||||
if (!EmptyUtil.isEmpty(model)) { | |||||
var result = await NetUtil.post('/api/v1/third_party/content/${model['mod_id']?.toString()}', method: NetMethod.GET ); | |||||
if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { | |||||
var data = result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]['content']; | |||||
if (!EmptyUtil.isEmpty(data)) { | |||||
return data; | |||||
} | |||||
} | |||||
} | |||||
} catch (e, s) { | |||||
Logger.error(e, s); | |||||
} | |||||
return null; | |||||
} | |||||
} |
@@ -0,0 +1,16 @@ | |||||
part of 'custom_share_content_bloc.dart'; | |||||
@immutable | |||||
abstract class CustomShareContentState {} | |||||
/// 初始化 | |||||
class CustomShareContentInitial extends CustomShareContentState {} | |||||
/// 数据加载成功 | |||||
class CustomShareContentLoadedState extends CustomShareContentState { | |||||
CustomShareContentModel model; | |||||
CustomShareContentLoadedState({this.model}); | |||||
} | |||||
/// 数据加载失败 | |||||
class CustomShareContentErrorState extends CustomShareContentState {} |
@@ -0,0 +1,139 @@ | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||||
class CustomShareContentModel extends SkipModel{ | |||||
String name; | |||||
String desc; | |||||
String text; | |||||
String moduleType; | |||||
String moduleKey; | |||||
String isTopMargin; | |||||
String isLeftRightMargin; | |||||
String isShow; | |||||
String topMargin; | |||||
String leftRightMargin; | |||||
String topLeftRadius; | |||||
String topRightRadius; | |||||
String bottomLeftRadius; | |||||
String bottomRightRadius; | |||||
String bgColor; | |||||
String isShowShareFriend; | |||||
String bgImage; | |||||
String bgImageUrl; | |||||
String titleImage; | |||||
String titleImageUrl; | |||||
String copyImage; | |||||
String copyImageUrl; | |||||
String copyLongImage; | |||||
String copyLongImageUrl; | |||||
String shareImage; | |||||
String shareImageUrl; | |||||
String textColor; | |||||
String skipName; | |||||
String cateTag; | |||||
CustomShareContentModel( | |||||
{this.name, | |||||
this.desc, | |||||
this.text, | |||||
this.moduleType, | |||||
this.moduleKey, | |||||
this.isTopMargin, | |||||
this.isLeftRightMargin, | |||||
this.isShow, | |||||
this.topMargin, | |||||
this.leftRightMargin, | |||||
this.topLeftRadius, | |||||
this.topRightRadius, | |||||
this.bottomLeftRadius, | |||||
this.bottomRightRadius, | |||||
this.bgColor, | |||||
this.isShowShareFriend, | |||||
this.bgImage, | |||||
this.bgImageUrl, | |||||
this.titleImage, | |||||
this.titleImageUrl, | |||||
this.copyImage, | |||||
this.copyImageUrl, | |||||
this.copyLongImage, | |||||
this.copyLongImageUrl, | |||||
this.shareImage, | |||||
this.shareImageUrl, | |||||
this.textColor, | |||||
this.skipName, | |||||
this.cateTag}); | |||||
CustomShareContentModel.fromJson(Map<String, dynamic> json) { | |||||
super.fromJson(json); | |||||
name = json['name']; | |||||
desc = json['desc']; | |||||
text = json['text']; | |||||
moduleType = json['module_type']; | |||||
moduleKey = json['module_key']; | |||||
isTopMargin = json['is_top_margin']; | |||||
isLeftRightMargin = json['is_left_right_margin']; | |||||
isShow = json['is_show']; | |||||
topMargin = json['top_margin']; | |||||
leftRightMargin = json['left_right_margin']; | |||||
topLeftRadius = json['top_left_radius']; | |||||
topRightRadius = json['top_right_radius']; | |||||
bottomLeftRadius = json['bottom_left_radius']; | |||||
bottomRightRadius = json['bottom_right_radius']; | |||||
bgColor = json['bg_color']; | |||||
isShowShareFriend = json['is_show_share_friend']; | |||||
bgImage = json['bg_image']; | |||||
bgImageUrl = json['bg_image_url']; | |||||
titleImage = json['title_image']; | |||||
titleImageUrl = json['title_image_url']; | |||||
copyImage = json['copy_image']; | |||||
copyImageUrl = json['copy_image_url']; | |||||
copyLongImage = json['copy_long_image']; | |||||
copyLongImageUrl = json['copy_long_image_url']; | |||||
shareImage = json['share_image']; | |||||
shareImageUrl = json['share_image_url']; | |||||
textColor = json['text_color']; | |||||
skipIdentifier = json['skip_identifier']; | |||||
skipName = json['skip_name']; | |||||
requiredLogin = json['required_login']; | |||||
requiredTaobaoAuth = json['required_taobao_auth']; | |||||
isJump = json['is_jump']; | |||||
cateTag = json['cate_tag']; | |||||
} | |||||
Map<String, dynamic> toJson() { | |||||
final Map<String, dynamic> data = super.toJson(); | |||||
data['name'] = this.name; | |||||
data['desc'] = this.desc; | |||||
data['text'] = this.text; | |||||
data['module_type'] = this.moduleType; | |||||
data['module_key'] = this.moduleKey; | |||||
data['is_top_margin'] = this.isTopMargin; | |||||
data['is_left_right_margin'] = this.isLeftRightMargin; | |||||
data['is_show'] = this.isShow; | |||||
data['top_margin'] = this.topMargin; | |||||
data['left_right_margin'] = this.leftRightMargin; | |||||
data['top_left_radius'] = this.topLeftRadius; | |||||
data['top_right_radius'] = this.topRightRadius; | |||||
data['bottom_left_radius'] = this.bottomLeftRadius; | |||||
data['bottom_right_radius'] = this.bottomRightRadius; | |||||
data['bg_color'] = this.bgColor; | |||||
data['is_show_share_friend'] = this.isShowShareFriend; | |||||
data['bg_image'] = this.bgImage; | |||||
data['bg_image_url'] = this.bgImageUrl; | |||||
data['title_image'] = this.titleImage; | |||||
data['title_image_url'] = this.titleImageUrl; | |||||
data['copy_image'] = this.copyImage; | |||||
data['copy_image_url'] = this.copyImageUrl; | |||||
data['copy_long_image'] = this.copyLongImage; | |||||
data['copy_long_image_url'] = this.copyLongImageUrl; | |||||
data['share_image'] = this.shareImage; | |||||
data['share_image_url'] = this.shareImageUrl; | |||||
data['text_color'] = this.textColor; | |||||
data['skip_identifier'] = this.skipIdentifier; | |||||
data['skip_name'] = this.skipName; | |||||
data['required_login'] = this.requiredLogin; | |||||
data['required_taobao_auth'] = this.requiredTaobaoAuth; | |||||
data['is_jump'] = this.isJump; | |||||
data['cate_tag'] = this.cateTag; | |||||
return data; | |||||
} | |||||
} |
@@ -0,0 +1,22 @@ | |||||
import 'package:flutter/material.dart'; | |||||
import 'package:zhiying_base_widget/widgets/custom/share_content/share_content_sk.dart'; | |||||
import 'package:zhiying_base_widget/widgets/custom/share_content/share_content_widget.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||||
/// | |||||
/// 可以滚动Banner | |||||
/// | |||||
class CustomShareContentCreater extends WidgetCreater { | |||||
@override | |||||
List<Widget> createSkeleton(Map<String, dynamic> model) { | |||||
return [CustomShareContentSkeleton()]; | |||||
} | |||||
@override | |||||
List<Widget> createWidgets(Map<String, dynamic> model) { | |||||
return [ | |||||
CustomShareContentWidget(model), | |||||
]; | |||||
} | |||||
} |
@@ -0,0 +1,8 @@ | |||||
import 'package:flutter/material.dart'; | |||||
class CustomShareContentSkeleton extends StatelessWidget { | |||||
@override | |||||
Widget build(BuildContext context) { | |||||
return Container(); | |||||
} | |||||
} |
@@ -0,0 +1,142 @@ | |||||
import 'package:flutter/material.dart'; | |||||
import 'package:flutter/services.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'; | |||||
import 'package:zhiying_base_widget/widgets/share/models/share_alert_model.dart'; | |||||
import 'package:zhiying_base_widget/widgets/share/models/share_data_model.dart'; | |||||
import 'package:zhiying_base_widget/widgets/share/share_alert.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||||
import 'package:flutter_bloc/flutter_bloc.dart'; | |||||
import 'bloc/custom_share_content_bloc.dart'; | |||||
import 'bloc/custom_share_content_repository.dart'; | |||||
import 'package:flutter/cupertino.dart'; | |||||
/// | |||||
/// 分享内容组件 | |||||
/// | |||||
class CustomShareContentWidget extends StatelessWidget { | |||||
final Map<String, dynamic> model; | |||||
const CustomShareContentWidget(this.model, {Key key}) : super(key: key); | |||||
@override | |||||
Widget build(BuildContext context) { | |||||
return BlocProvider( | |||||
create: (_) => CustomShareContentBloc(repository: CustomShareContentRepository())..add(CustomShareContentInitEvent(model: model)), | |||||
child: _CustomShareContentContainerWidget(), | |||||
); | |||||
} | |||||
} | |||||
class _CustomShareContentContainerWidget extends StatefulWidget { | |||||
@override | |||||
_CustomShareContentContainerWidgetState createState() => _CustomShareContentContainerWidgetState(); | |||||
} | |||||
class _CustomShareContentContainerWidgetState extends State<_CustomShareContentContainerWidget> { | |||||
/// 分享方法 | |||||
void _clickShareButton(val) { | |||||
showCupertinoModalPopup( | |||||
context: context, | |||||
builder: (context) => ShareAlert(ShareDataModel(content: val), 'pub.flutter.share_icon', isContentShow: false), | |||||
); | |||||
} | |||||
/// 复制方法 | |||||
void _clickCopyButton(String val) { | |||||
if (!EmptyUtil.isEmpty(val)) { | |||||
Clipboard.setData(ClipboardData(text: val)); | |||||
Fluttertoast.showToast(msg: '复制成功'); | |||||
} | |||||
} | |||||
@override | |||||
Widget build(BuildContext context) { | |||||
return BlocConsumer<CustomShareContentBloc, CustomShareContentState>( | |||||
listener: (prev, next) {}, | |||||
buildWhen: (context, state) { | |||||
return true; | |||||
}, | |||||
builder: (context, state) { | |||||
Logger.log('商品详情刷新了 builder state = ' + state?.toString()); | |||||
/// 数据加载完毕 | |||||
if (state is CustomShareContentLoadedState) { | |||||
return _getMainWidget(state?.model); | |||||
} | |||||
/// 异常 | |||||
if (state is CustomShareContentErrorState) { | |||||
return _errorWidget(); | |||||
} | |||||
/// 骨架图 | |||||
return _getSkeletonWidget(); | |||||
}, | |||||
); | |||||
} | |||||
/// 主视图 | |||||
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( | |||||
padding: const EdgeInsets.only(left: 12, right: 12, top: 12, bottom: 14), | |||||
height: 200, | |||||
width: double.infinity, | |||||
decoration: BoxDecoration( | |||||
image: DecorationImage( | |||||
image: CachedNetworkImageProvider(model?.bgImageUrl ?? '') | |||||
) | |||||
), | |||||
child: Column( | |||||
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |||||
children: [ | |||||
// 标题 | |||||
CachedNetworkImage(imageUrl: model?.titleImageUrl, width: 90,), | |||||
// SizedBox(height: 20), | |||||
// 文案 | |||||
Text(model?.text?? '', style: TextStyle(color: HexColor.fromHex(model?.textColor), fontSize: 15),), | |||||
// 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,))) | |||||
], | |||||
)) | |||||
], | |||||
), | |||||
) | |||||
); | |||||
} | |||||
/// 骨架图 | |||||
Widget _getSkeletonWidget() { | |||||
return CustomShareContentSkeleton(); | |||||
} | |||||
/// 无数据视图 or 异常 | |||||
Widget _errorWidget() { | |||||
return Container(); | |||||
} | |||||
} | |||||
@@ -278,9 +278,9 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { | |||||
} else { | } else { | ||||
var type = SSDKContentTypes.auto; | var type = SSDKContentTypes.auto; | ||||
if (widget?.model?.image?.length != 0 && widget.model?.url != null) { | |||||
if ((widget?.model?.image?.length ?? 0) != 0 && widget.model?.url != null) { | |||||
type = SSDKContentTypes.webpage; | type = SSDKContentTypes.webpage; | ||||
} else if (widget?.model?.image?.length != 0) { | |||||
} else if ((widget?.model?.image?.length ?? 0) != 0) { | |||||
type = SSDKContentTypes.image; | type = SSDKContentTypes.image; | ||||
} else if (widget?.model?.title != null || widget.model?.content != null) { | } else if (widget?.model?.title != null || widget.model?.content != null) { | ||||
type = SSDKContentTypes.text; | type = SSDKContentTypes.text; | ||||