@@ -5,6 +5,7 @@ import 'custom_page_event.dart'; | |||||
import 'custom_page_repository.dart'; | import 'custom_page_repository.dart'; | ||||
import 'custom_page_state.dart'; | import 'custom_page_state.dart'; | ||||
import 'package:zhiying_comm/util/empty_util.dart'; | import 'package:zhiying_comm/util/empty_util.dart'; | ||||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||||
class CustomPageBloc extends Bloc<CustomPageEvent, CustomPageState> { | class CustomPageBloc extends Bloc<CustomPageEvent, CustomPageState> { | ||||
// CommonBloc() : super(CommonInitial()); | // CommonBloc() : super(CommonInitial()); | ||||
@@ -52,12 +53,16 @@ class CustomPageBloc extends Bloc<CustomPageEvent, CustomPageState> { | |||||
} | } | ||||
// 获取网络数据 | // 获取网络数据 | ||||
var result = await repository.fetchInitData(); | var result = await repository.fetchInitData(); | ||||
List<Map<String, dynamic>> mdata = result; | |||||
for (int i = 0; i < mdata.length; i++) { | |||||
Logger.log("页面数据: " + mdata[i].toString()); | |||||
} | |||||
if (!EmptyUtil.isEmpty(result) && result is List) { | if (!EmptyUtil.isEmpty(result) && result is List) { | ||||
yield CustomPageLoadedState(model: result); | yield CustomPageLoadedState(model: result); | ||||
} else { | } else { | ||||
if(EmptyUtil.isEmpty(cache)) { | if (EmptyUtil.isEmpty(cache)) { | ||||
yield CustomPageInitErrorState(); | yield CustomPageInitErrorState(); | ||||
}else{ | } else { | ||||
yield CustomPageErrorState(); | yield CustomPageErrorState(); | ||||
} | } | ||||
} | } | ||||
@@ -34,6 +34,7 @@ class CustomPage extends StatefulWidget { | |||||
class _CustomPageState extends State<CustomPage> { | class _CustomPageState extends State<CustomPage> { | ||||
@override | @override | ||||
Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
Logger.log("数据: "+widget?.data.toString()); | |||||
return MultiProvider( | return MultiProvider( | ||||
providers: [ | providers: [ | ||||
ChangeNotifierProvider.value(value: MainPageBgNotifier()), | ChangeNotifierProvider.value(value: MainPageBgNotifier()), | ||||
@@ -20,6 +20,7 @@ class SearchPage extends StatelessWidget { | |||||
@override | @override | ||||
Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
Logger.log("数据: "+data.toString()); | |||||
return MultiProvider( | return MultiProvider( | ||||
providers: [ | providers: [ | ||||
ChangeNotifierProvider.value(value: SearchTagNotifier()) | ChangeNotifierProvider.value(value: SearchTagNotifier()) | ||||
@@ -358,10 +358,10 @@ class BaseWidgetRegister { | |||||
WidgetFactory.regist('product_detail_bottom', DefaultWidgetCreater((model) => GoodsDetailsFooterWidget(model))); | WidgetFactory.regist('product_detail_bottom', DefaultWidgetCreater((model) => GoodsDetailsFooterWidget(model))); | ||||
// ==================== 个人中心 | // ==================== 个人中心 | ||||
WidgetFactory.regist('profile_appbar', MineNavCreater()); | WidgetFactory.regist('appbar', MineNavCreater()); | ||||
WidgetFactory.regist('profile_background', DefaultWidgetCreater((model) => MineNavBg(model))); | WidgetFactory.regist('profile_background', DefaultWidgetCreater((model) => MineNavBg(model))); | ||||
WidgetFactory.regist('profile_header', DefaultWidgetCreater((model) => MineHeader(model))); | WidgetFactory.regist('member_info', DefaultWidgetCreater((model) => MineHeader(model))); | ||||
WidgetFactory.regist('profile_earning', DefaultWidgetCreater((model) => MineData(model))); | WidgetFactory.regist('earning', DefaultWidgetCreater((model) => MineData(model))); | ||||
WidgetFactory.regist('profile_functions', DefaultWidgetCreater((model) => MineQuickEntry(model))); | WidgetFactory.regist('profile_functions', DefaultWidgetCreater((model) => MineQuickEntry(model))); | ||||
WidgetFactory.regist('profile_my_functions', DefaultWidgetCreater((model) => MineQuickEntry(model))); | WidgetFactory.regist('profile_my_functions', DefaultWidgetCreater((model) => MineQuickEntry(model))); | ||||
// WidgetFactory.regist('profile_carousel', DefaultWidgetCreater((model) => HomeBannerWidget(model))); | // WidgetFactory.regist('profile_carousel', DefaultWidgetCreater((model) => HomeBannerWidget(model))); | ||||
@@ -146,10 +146,13 @@ class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer> | |||||
totalHeight = totalHeight + moduleTitleHeight; | totalHeight = totalHeight + moduleTitleHeight; | ||||
} | } | ||||
double marginLeftRight = model?.isLeftRightMargin == "1" ? double.tryParse(model?.leftRightMargin ?? "0") : 0; | |||||
double marginTop = model?.isTopMargin == "1" ? double.tryParse(model?.topMargin ?? "0") : 0; | |||||
return Container( | return Container( | ||||
margin: EdgeInsets.only(top: double.tryParse(model?.topMargin), | margin: EdgeInsets.only(top: marginTop, | ||||
left: ParseUtil.stringParseDouble(model?.leftRightMargin), | left: marginLeftRight, | ||||
right: ParseUtil.stringParseDouble(model?.leftRightMargin)), | right: marginLeftRight), | ||||
decoration: BoxDecoration( | decoration: BoxDecoration( | ||||
color: HexColor.fromHex(model?.bgColor ?? ''), | color: HexColor.fromHex(model?.bgColor ?? ''), | ||||
//color: Colors.green, | //color: Colors.green, | ||||
@@ -30,7 +30,7 @@ class _MineDataState extends State<MineData> { | |||||
MineDataModel style = | MineDataModel style = | ||||
MineDataModel.fromJson(Map<String, dynamic>.from(json)); | MineDataModel.fromJson(Map<String, dynamic>.from(json)); | ||||
List<MineProfileDataModel> list = style.gridView.map((item) { | List<MineProfileDataModel> list = style.listStyle.map((item) { | ||||
return MineProfileDataModel(name: item.name, value: '¥0'); | return MineProfileDataModel(name: item.name, value: '¥0'); | ||||
}).toList(); | }).toList(); | ||||
MineProfileModel profile = MineProfileModel( | MineProfileModel profile = MineProfileModel( | ||||
@@ -11,33 +11,35 @@ import 'package:zhiying_comm/util/shared_prefe_util.dart'; | |||||
class MineDataWidget extends StatefulWidget { | class MineDataWidget extends StatefulWidget { | ||||
final Map<String, dynamic> data; | final Map<String, dynamic> data; | ||||
final MineProfileModel profile; | final MineProfileModel profile; | ||||
// Map<String, dynamic> _json; | // Map<String, dynamic> _json; | ||||
// MineDataModel _style; | // MineDataModel _style; | ||||
MineDataWidget( | MineDataWidget( | ||||
this.profile, | this.profile, | ||||
this.data, { | this.data, { | ||||
Key key, | Key key, | ||||
}) : super(key: key) ; | }) : super(key: key); | ||||
@override | @override | ||||
_MineDataWidgetState createState() => _MineDataWidgetState(); | _MineDataWidgetState createState() => _MineDataWidgetState(); | ||||
} | } | ||||
class _MineDataWidgetState extends State<MineDataWidget> { | class _MineDataWidgetState extends State<MineDataWidget> { | ||||
Map<String, dynamic> _json; | Map<String, dynamic> _json; | ||||
MineDataModel _style; | MineDataModel _style; | ||||
bool _isiOSReview = false; | bool _isiOSReview = false; | ||||
void initState(){ | @override | ||||
void initState() { | |||||
_settingIosReview(); | _settingIosReview(); | ||||
_settingData(); | _settingData(); | ||||
super.initState(); | super.initState(); | ||||
} | } | ||||
void _settingIosReview() async { | void _settingIosReview() async { | ||||
String is_ios_review = await SharedPreferencesUtil.getStringValue( | String is_ios_review = await SharedPreferencesUtil.getStringValue(GlobalConfig.IS_IOS_REVIEW, defaultVal: '0'); | ||||
GlobalConfig.IS_IOS_REVIEW, defaultVal: '0'); | |||||
setState(() { | setState(() { | ||||
if (is_ios_review == '1') { | if (is_ios_review == '1') { | ||||
_isiOSReview = true; | _isiOSReview = true; | ||||
@@ -45,30 +47,41 @@ class _MineDataWidgetState extends State<MineDataWidget> { | |||||
} | } | ||||
}); | }); | ||||
} | } | ||||
void _settingData(){ | void _settingData() { | ||||
setState(() { | setState(() { | ||||
String d = widget.data['data']; | String d = widget.data['data']; | ||||
_json = convert.jsonDecode(d); | _json = convert.jsonDecode(d); | ||||
_style = MineDataModel.fromJson(Map<String, dynamic>.from(_json)); | _style = MineDataModel.fromJson(Map<String, dynamic>.from(_json)); | ||||
}); | }); | ||||
} | } | ||||
@override | @override | ||||
Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
double marginLeftRight = _style?.isLeftRightMargin == "1" ? double.tryParse(_style?.leftRightMargin ?? "0") : 0; | |||||
double marginTop = _style?.isTopMargin == "1" ? double.tryParse(_style?.topMargin ?? "0") : 0; | |||||
return Container( | return Container( | ||||
margin: EdgeInsets.only(left: 12.5, right: 12.5), | margin: EdgeInsets.only(left: marginLeftRight, right: marginLeftRight, top: marginTop), | ||||
decoration: BoxDecoration( | decoration: BoxDecoration( | ||||
color: HexColor.fromHex(_style.gridViewBgColor), | color: HexColor.fromHex(_style.bg_color), | ||||
borderRadius: BorderRadius.circular(7.5)), | borderRadius: BorderRadius.only( | ||||
topRight: Radius.circular(double.tryParse(_style?.topRightRadius ?? "0")), | |||||
topLeft: Radius.circular(double.tryParse(_style?.topLeftRadius ?? "0")), | |||||
bottomRight: Radius.circular(double.tryParse(_style?.bottomRightRadius ?? "0")), | |||||
bottomLeft: Radius.circular(double.tryParse(_style?.bottomLeftRadius ?? "0")), | |||||
)), | |||||
child: Column( | child: Column( | ||||
children: <Widget>[ | children: <Widget>[ | ||||
_createTop(context), | _createTop( | ||||
context, double.tryParse(_style?.topLeftRadius ?? "0"), double.tryParse(_style?.topRightRadius ?? "0")), | |||||
_createCenter(), | _createCenter(), | ||||
], | ], | ||||
), | ), | ||||
); | ); | ||||
} | } | ||||
Widget _createTop(BuildContext context) { | Widget _createTop(BuildContext context, double topLeft, double topRight) { | ||||
return Container( | return Container( | ||||
width: double.infinity, | width: double.infinity, | ||||
height: 62, | height: 62, | ||||
@@ -78,9 +91,7 @@ class _MineDataWidgetState extends State<MineDataWidget> { | |||||
width: double.infinity, | width: double.infinity, | ||||
height: double.infinity, | height: double.infinity, | ||||
child: ClipRRect( | child: ClipRRect( | ||||
borderRadius: BorderRadius.only( | borderRadius: BorderRadius.only(topLeft: Radius.circular(topLeft), topRight: Radius.circular(topRight)), | ||||
topLeft: Radius.circular(7.5), | |||||
topRight: Radius.circular(7.5)), | |||||
child: CachedNetworkImage( | child: CachedNetworkImage( | ||||
imageUrl: _style.accumulatedEarningsBgImg ?? '', | imageUrl: _style.accumulatedEarningsBgImg ?? '', | ||||
fit: BoxFit.cover, | fit: BoxFit.cover, | ||||
@@ -95,37 +106,41 @@ class _MineDataWidgetState extends State<MineDataWidget> { | |||||
crossAxisAlignment: CrossAxisAlignment.center, | crossAxisAlignment: CrossAxisAlignment.center, | ||||
children: <Widget>[ | children: <Widget>[ | ||||
Expanded( | Expanded( | ||||
child: Container( | child: GestureDetector( | ||||
margin: EdgeInsets.only(left: 15, right: 15), | onTap: () { | ||||
child: Column( | RouterUtil.route(_style.listStyle[0], _style.listStyle[0].toJson(), context); | ||||
mainAxisAlignment: MainAxisAlignment.center, | }, | ||||
crossAxisAlignment: CrossAxisAlignment.start, | behavior: HitTestBehavior.opaque, | ||||
children: <Widget>[ | child: Container( | ||||
Text( | margin: EdgeInsets.only(left: 15, right: 15), | ||||
_isiOSReview ? '' : '累计收益', | child: Column( | ||||
style: TextStyle( | mainAxisAlignment: MainAxisAlignment.center, | ||||
fontSize: 11, | crossAxisAlignment: CrossAxisAlignment.start, | ||||
fontWeight: FontWeight.w600, | children: <Widget>[ | ||||
color: HexColor.fromHex( | Text( | ||||
_style.accumulatedEarningsNameColor), | _isiOSReview ? '' : '累计收益', | ||||
style: TextStyle( | |||||
fontSize: 11, | |||||
fontWeight: FontWeight.w600, | |||||
color: HexColor.fromHex(_style?.listStyle[0]?.textColor ?? ""), | |||||
), | |||||
), | ), | ||||
), | Text( | ||||
Text( | '${widget.profile?.total ?? '0.00'}', | ||||
'${widget.profile?.total?? '0.00'}', | style: TextStyle( | ||||
style: TextStyle( | fontSize: 18, | ||||
fontSize: 18, | fontWeight: FontWeight.w800, | ||||
fontWeight: FontWeight.w800, | color: HexColor.fromHex(_style?.listStyle[0]?.numColor ?? ""), | ||||
color: HexColor.fromHex( | fontFamily: 'Din-Bold' | ||||
_style.accumulatedEarningsNameColor), | '' | ||||
fontFamily: 'Din-Bold' | '' | ||||
'' | '' | ||||
'' | '', | ||||
'' | package: 'zhiying_comm', | ||||
'', | ), | ||||
package: 'zhiying_comm', | |||||
), | ), | ||||
), | ], | ||||
], | ), | ||||
), | ), | ||||
), | ), | ||||
), | ), | ||||
@@ -137,22 +152,21 @@ class _MineDataWidgetState extends State<MineDataWidget> { | |||||
child: Stack( | child: Stack( | ||||
children: <Widget>[ | children: <Widget>[ | ||||
CachedNetworkImage( | CachedNetworkImage( | ||||
imageUrl: _style?.btnImg ?? '', | imageUrl: _style?.cashBtn?.image ?? '', | ||||
fit: BoxFit.cover, | fit: BoxFit.cover, | ||||
), | ), | ||||
Center( | Center( | ||||
child: Text( | child: Text( | ||||
_style.btnText, | _style.cashBtn.btnText, | ||||
style: TextStyle( | style: TextStyle(fontSize: 12, color: HexColor.fromHex(_style.cashBtn.btnTextColor)), | ||||
fontSize: 12, | |||||
color: HexColor.fromHex(_style.btnTextColor)), | |||||
), | ), | ||||
) | ) | ||||
], | ], | ||||
), | ), | ||||
), | ), | ||||
behavior: HitTestBehavior.opaque, | |||||
onTap: () { | onTap: () { | ||||
RouterUtil.route(_style, _style.toJson(), context); | RouterUtil.route(_style.cashBtn, _style.cashBtn.toJson(), context); | ||||
}, | }, | ||||
) | ) | ||||
], | ], | ||||
@@ -177,7 +191,7 @@ class _MineDataWidgetState extends State<MineDataWidget> { | |||||
int i = 0; | int i = 0; | ||||
for (; i < row; i++) { | for (; i < row; i++) { | ||||
rows.add( | rows.add( | ||||
_createrCenterItem(datas[i].name, datas[i].value), | _createrCenterItem(datas[i].name, datas[i].value, i), | ||||
); | ); | ||||
if (i % maxColumn == maxColumn - 1 || i == row - 1) { | if (i % maxColumn == maxColumn - 1 || i == row - 1) { | ||||
columns.add(Row( | columns.add(Row( | ||||
@@ -204,11 +218,9 @@ class _MineDataWidgetState extends State<MineDataWidget> { | |||||
for (; i < datas.length; i++) { | for (; i < datas.length; i++) { | ||||
rows.add( | rows.add( | ||||
_createBottomItem(datas[i].name, datas[i].value), | _createBottomItem(datas[i].name, datas[i].value, i), | ||||
); | ); | ||||
if ((i - row) % maxColumn == maxColumn - 1 || | if ((i - row) % maxColumn == maxColumn - 1 || i == row - 1 || i == datas.length - 1) { | ||||
i == row - 1 || | |||||
i == datas.length - 1) { | |||||
columns.add(Row( | columns.add(Row( | ||||
crossAxisAlignment: CrossAxisAlignment.center, | crossAxisAlignment: CrossAxisAlignment.center, | ||||
mainAxisAlignment: MainAxisAlignment.center, | mainAxisAlignment: MainAxisAlignment.center, | ||||
@@ -229,75 +241,84 @@ class _MineDataWidgetState extends State<MineDataWidget> { | |||||
children: columns, | children: columns, | ||||
), | ), | ||||
); | ); | ||||
}else{ | } else { | ||||
return Container(); | return Container(); | ||||
} | } | ||||
} | } | ||||
Widget _createrCenterItem(String name, String value) { | Widget _createrCenterItem(String name, String value, int i) { | ||||
return Expanded( | return Expanded( | ||||
child: Container( | child: GestureDetector( | ||||
padding: EdgeInsets.only(left: 15, right: 15), | onTap: () { | ||||
height: 72, | RouterUtil.route(_style.listStyle[i + 1], _style.listStyle[i + 1].toJson(), context); | ||||
child: Column( | }, | ||||
mainAxisAlignment: MainAxisAlignment.center, | behavior: HitTestBehavior.opaque, | ||||
crossAxisAlignment: CrossAxisAlignment.start, | child: Container( | ||||
children: <Widget>[ | padding: EdgeInsets.only(left: 15, right: 15), | ||||
Text( | height: 72, | ||||
name, | child: Column( | ||||
style: TextStyle( | mainAxisAlignment: MainAxisAlignment.center, | ||||
fontSize: 11, | crossAxisAlignment: CrossAxisAlignment.start, | ||||
color: HexColor.fromHex(_style.gridViewNameColor)), | children: <Widget>[ | ||||
), | Text( | ||||
Padding( | name, | ||||
padding: const EdgeInsets.only(top: 2), | style: TextStyle(fontSize: 11, color: HexColor.fromHex(_style.listStyle[i].textColor)), | ||||
child: Text( | |||||
value, | |||||
style: TextStyle( | |||||
fontSize: 18, | |||||
color: HexColor.fromHex(_style.gridViewValueColor), | |||||
fontFamily: 'Din-Bold', | |||||
package: 'zhiying_comm'), | |||||
), | ), | ||||
), | Padding( | ||||
], | padding: const EdgeInsets.only(top: 2), | ||||
child: Text( | |||||
value, | |||||
style: TextStyle( | |||||
fontSize: 18, | |||||
color: HexColor.fromHex(_style.listStyle[i].numColor), | |||||
fontFamily: 'Din-Bold', | |||||
package: 'zhiying_comm'), | |||||
), | |||||
), | |||||
], | |||||
), | |||||
), | ), | ||||
), | ), | ||||
); | ); | ||||
} | } | ||||
Widget _createBottomItem(String name, String value) { | Widget _createBottomItem(String name, String value, int i) { | ||||
return Expanded( | return Expanded( | ||||
child: Container( | child: GestureDetector( | ||||
padding: EdgeInsets.only(left: 15, right: 15), | onTap: () { | ||||
height: 46, | RouterUtil.route(_style.listStyle[i + 1], _style.listStyle[i + 1].toJson(), context); | ||||
child: Row( | }, | ||||
mainAxisAlignment: MainAxisAlignment.start, | behavior: HitTestBehavior.opaque, | ||||
crossAxisAlignment: CrossAxisAlignment.center, | child: Container( | ||||
children: <Widget>[ | padding: EdgeInsets.only(left: 15, right: 15), | ||||
Text( | height: 46, | ||||
name, | child: Row( | ||||
style: TextStyle( | mainAxisAlignment: MainAxisAlignment.start, | ||||
fontSize: 12, | crossAxisAlignment: CrossAxisAlignment.center, | ||||
color: HexColor.fromHex(_style.gridViewNameColor)), | children: <Widget>[ | ||||
), | Text( | ||||
Padding( | name, | ||||
padding: const EdgeInsets.only(left: 2), | style: TextStyle(fontSize: 12, color: HexColor.fromHex(_style.listStyle[i].textColor)), | ||||
child: Text( | |||||
value, | |||||
style: TextStyle( | |||||
fontSize: 12, | |||||
color: HexColor.fromHex(_style.gridViewValueColor), | |||||
fontFamily: 'Din-Bold', | |||||
package: 'zhiying_comm'), | |||||
), | ), | ||||
), | Padding( | ||||
], | padding: const EdgeInsets.only(left: 2), | ||||
child: Text( | |||||
value, | |||||
style: TextStyle( | |||||
fontSize: 12, | |||||
color: HexColor.fromHex(_style.listStyle[i].numColor), | |||||
fontFamily: 'Din-Bold', | |||||
package: 'zhiying_comm'), | |||||
), | |||||
), | |||||
], | |||||
), | |||||
), | ), | ||||
), | ), | ||||
); | ); | ||||
} | } | ||||
} | } | ||||
///***/// | ///***/// | ||||
// class MineDataWidget extends StatelessWidget { | // class MineDataWidget extends StatelessWidget { | ||||
// final Map<String, dynamic> data; | // final Map<String, dynamic> data; | ||||
@@ -1,69 +1,181 @@ | |||||
import 'package:zhiying_base_widget/widgets/mine/mine_header/model/mine_profile_model.dart'; | import 'package:zhiying_base_widget/widgets/mine/mine_header/model/mine_profile_model.dart'; | ||||
import 'package:zhiying_comm/models/base/skip_model.dart'; | import 'package:zhiying_comm/models/base/skip_model.dart'; | ||||
class MineDataModel extends SkipModel { | class MineDataModel extends SkipModel{ | ||||
String accumulatedEarningsNameColor; | |||||
String accumulatedEarningsColor; | |||||
String accumulatedEarningsBgImg; | String accumulatedEarningsBgImg; | ||||
String btnText; | String bottomLeftRadius; | ||||
String btnTextColor; | String bottomRightRadius; | ||||
String btnImg; | CashBtn cashBtn; | ||||
String gridViewBgColor; | String desc; | ||||
String gridViewNameColor; | String isLeftRightMargin; | ||||
String gridViewValueColor; | String isNeedDownloadApp; | ||||
List<MineProfileDataModel> gridView; | String isShow; | ||||
String isTopMargin; | |||||
String leftRightMargin; | |||||
List<ListStyle> listStyle; | |||||
String moduleKey; | |||||
String moduleType; | |||||
String name; | |||||
String topLeftRadius; | |||||
String topMargin; | |||||
String topRightRadius; | |||||
String bg_color; | |||||
MineDataModel( | MineDataModel( | ||||
{this.accumulatedEarningsNameColor, | {this.accumulatedEarningsBgImg, | ||||
this.accumulatedEarningsColor, | this.bottomLeftRadius, | ||||
this.accumulatedEarningsBgImg, | this.bottomRightRadius, | ||||
this.btnText, | this.cashBtn, | ||||
this.btnTextColor, | this.desc, | ||||
this.btnImg, | this.isLeftRightMargin, | ||||
this.gridViewBgColor, | this.isNeedDownloadApp, | ||||
this.gridViewNameColor, | this.isShow, | ||||
this.gridViewValueColor, | this.isTopMargin, | ||||
this.gridView}); | this.leftRightMargin, | ||||
this.listStyle, | |||||
this.moduleKey, | |||||
this.moduleType, | |||||
this.name, | |||||
this.topLeftRadius, | |||||
this.topMargin, | |||||
this.topRightRadius, | |||||
this.bg_color, | |||||
}); | |||||
MineDataModel.fromJson(Map<String, dynamic> json) { | MineDataModel.fromJson(Map<String, dynamic> json) { | ||||
super.fromJson(json); | |||||
accumulatedEarningsNameColor = json['accumulated_earnings_name_color']; | |||||
accumulatedEarningsColor = json['accumulated_earnings_color']; | |||||
accumulatedEarningsBgImg = json['accumulated_earnings_bg_img']; | accumulatedEarningsBgImg = json['accumulated_earnings_bg_img']; | ||||
bottomLeftRadius = json['bottom_left_radius']; | |||||
bottomRightRadius = json['bottom_right_radius']; | |||||
cashBtn = json['cash_btn'] != null | |||||
? new CashBtn.fromJson(json['cash_btn']) | |||||
: null; | |||||
desc = json['desc']; | |||||
isLeftRightMargin = json['is_left_right_margin']; | |||||
isNeedDownloadApp = json['is_need_download_app']; | |||||
isShow = json['is_show']; | |||||
isTopMargin = json['is_top_margin']; | |||||
leftRightMargin = json['left_right_margin']; | |||||
if (json['list_style'] != null) { | |||||
listStyle = new List<ListStyle>(); | |||||
json['list_style'].forEach((v) { | |||||
listStyle.add(new ListStyle.fromJson(v)); | |||||
}); | |||||
} | |||||
moduleKey = json['module_key']; | |||||
moduleType = json['module_type']; | |||||
name = json['name']; | |||||
topLeftRadius = json['top_left_radius']; | |||||
topMargin = json['top_margin']; | |||||
topRightRadius = json['top_right_radius']; | |||||
bg_color = json['bg_color']; | |||||
} | |||||
Map<String, dynamic> toJson() { | |||||
final Map<String, dynamic> data = new Map<String, dynamic>(); | |||||
data['accumulated_earnings_bg_img'] = this.accumulatedEarningsBgImg; | |||||
data['bottom_left_radius'] = this.bottomLeftRadius; | |||||
data['bottom_right_radius'] = this.bottomRightRadius; | |||||
if (this.cashBtn != null) { | |||||
data['cash_btn'] = this.cashBtn.toJson(); | |||||
} | |||||
data['desc'] = this.desc; | |||||
data['is_left_right_margin'] = this.isLeftRightMargin; | |||||
data['is_need_download_app'] = this.isNeedDownloadApp; | |||||
data['is_show'] = this.isShow; | |||||
data['is_top_margin'] = this.isTopMargin; | |||||
data['left_right_margin'] = this.leftRightMargin; | |||||
if (this.listStyle != null) { | |||||
data['list_style'] = this.listStyle.map((v) => v.toJson()).toList(); | |||||
} | |||||
data['module_key'] = this.moduleKey; | |||||
data['module_type'] = this.moduleType; | |||||
data['name'] = this.name; | |||||
data['top_left_radius'] = this.topLeftRadius; | |||||
data['top_margin'] = this.topMargin; | |||||
data['top_right_radius'] = this.topRightRadius; | |||||
data['bg_color'] = this.bg_color; | |||||
return data; | |||||
} | |||||
} | |||||
class CashBtn extends SkipModel{ | |||||
String btnText; | |||||
String btnTextColor; | |||||
String image; | |||||
String requiredLogin; | |||||
String requiredTaobaoAuth; | |||||
String skipIdentifier; | |||||
CashBtn( | |||||
{this.btnText, | |||||
this.btnTextColor, | |||||
this.image, | |||||
this.requiredLogin, | |||||
this.requiredTaobaoAuth, | |||||
this.skipIdentifier}); | |||||
CashBtn.fromJson(Map<String, dynamic> json) { | |||||
btnText = json['btn_text']; | btnText = json['btn_text']; | ||||
btnTextColor = json['btn_text_color']; | btnTextColor = json['btn_text_color']; | ||||
btnImg = json['btn_img']; | image = json['image']; | ||||
requiredLogin = json['required_login']; | requiredLogin = json['required_login']; | ||||
requiredTaobaoAuth = json['required_taobao_auth']; | requiredTaobaoAuth = json['required_taobao_auth']; | ||||
skipIdentifier = json['skip_identifier']; | skipIdentifier = json['skip_identifier']; | ||||
gridViewBgColor = json['grid_view_bg_color']; | |||||
gridViewNameColor = json['grid_view_name_color']; | |||||
gridViewValueColor = json['grid_view_value_color']; | |||||
if (json['grid_view'] != null) { | |||||
gridView = new List<MineProfileDataModel>(); | |||||
json['grid_view'].forEach((v) { | |||||
gridView.add(new MineProfileDataModel.fromJson(v)); | |||||
}); | |||||
} | |||||
} | } | ||||
Map<String, dynamic> toJson() { | Map<String, dynamic> toJson() { | ||||
final Map<String, dynamic> data = super.toJson(); | final Map<String, dynamic> data = new Map<String, dynamic>(); | ||||
data['accumulated_earnings_name_color'] = this.accumulatedEarningsNameColor; | |||||
data['accumulated_earnings_color'] = this.accumulatedEarningsColor; | |||||
data['accumulated_earnings_bg_img'] = this.accumulatedEarningsBgImg; | |||||
data['btn_text'] = this.btnText; | data['btn_text'] = this.btnText; | ||||
data['btn_text_color'] = this.btnTextColor; | data['btn_text_color'] = this.btnTextColor; | ||||
data['btn_img'] = this.btnImg; | data['image'] = this.image; | ||||
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['grid_view_bg_color'] = this.gridViewBgColor; | |||||
data['grid_view_name_color'] = this.gridViewNameColor; | |||||
data['grid_view_value_color'] = this.gridViewValueColor; | |||||
if (this.gridView != null) { | |||||
data['grid_view'] = this.gridView.map((v) => v.toJson()).toList(); | |||||
} | |||||
return data; | return data; | ||||
} | } | ||||
} | } | ||||
class ListStyle extends SkipModel{ | |||||
String isShow; | |||||
String name; | |||||
String numColor; | |||||
String requiredLogin; | |||||
String requiredTaobaoAuth; | |||||
String skipIdentifier; | |||||
String textColor; | |||||
String type; | |||||
ListStyle( | |||||
{this.isShow, | |||||
this.name, | |||||
this.numColor, | |||||
this.requiredLogin, | |||||
this.requiredTaobaoAuth, | |||||
this.skipIdentifier, | |||||
this.textColor, | |||||
this.type}); | |||||
ListStyle.fromJson(Map<String, dynamic> json) { | |||||
isShow = json['is_show']; | |||||
name = json['name']; | |||||
numColor = json['num_color']; | |||||
requiredLogin = json['required_login']; | |||||
requiredTaobaoAuth = json['required_taobao_auth']; | |||||
skipIdentifier = json['skip_identifier']; | |||||
textColor = json['text_color']; | |||||
type = json['type']; | |||||
} | |||||
Map<String, dynamic> toJson() { | |||||
final Map<String, dynamic> data = new Map<String, dynamic>(); | |||||
data['is_show'] = this.isShow; | |||||
data['name'] = this.name; | |||||
data['num_color'] = this.numColor; | |||||
data['required_login'] = this.requiredLogin; | |||||
data['required_taobao_auth'] = this.requiredTaobaoAuth; | |||||
data['skip_identifier'] = this.skipIdentifier; | |||||
data['text_color'] = this.textColor; | |||||
data['type'] = this.type; | |||||
return data; | |||||
} | |||||
} |
@@ -1,4 +1,5 @@ | |||||
import 'dart:async'; | import 'dart:async'; | ||||
import 'dart:convert'; | |||||
import 'package:zhiying_base_widget/widgets/mine/mine_header/model/mine_profile_model.dart'; | import 'package:zhiying_base_widget/widgets/mine/mine_header/model/mine_profile_model.dart'; | ||||
import 'package:zhiying_comm/util/base_bloc.dart'; | import 'package:zhiying_comm/util/base_bloc.dart'; | ||||
@@ -21,6 +22,8 @@ class MineHeaderBloc extends BlocBase { | |||||
void loadData() { | void loadData() { | ||||
NetUtil.request('/api/v1/user/profile', | NetUtil.request('/api/v1/user/profile', | ||||
method: NetMethod.GET, onCache: (data) {}, onSuccess: (data) { | method: NetMethod.GET, onCache: (data) {}, onSuccess: (data) { | ||||
Logger.log("我的数据:"+ json.encode(data)); | |||||
_profile = MineProfileModel.fromJson(Map<String, dynamic>.from(data)); | _profile = MineProfileModel.fromJson(Map<String, dynamic>.from(data)); | ||||
_profileController.add(_profile); | _profileController.add(_profile); | ||||
}, onError: (err) { | }, onError: (err) { | ||||
@@ -41,128 +41,119 @@ class _MineHeaderContainerState extends State<MineHeaderContainer> { | |||||
@override | @override | ||||
Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
var width=MediaQuery.of(context).size.width; | var width = MediaQuery.of(context).size.width; | ||||
return StreamBuilder<MineProfileModel>( | return StreamBuilder<MineProfileModel>( | ||||
stream: _bloc.outData, | stream: _bloc.outData, | ||||
builder: (BuildContext context, AsyncSnapshot snapshot) { | builder: (BuildContext context, AsyncSnapshot snapshot) { | ||||
MineProfileModel profile = snapshot.data; | MineProfileModel profile = snapshot.data; | ||||
return profile == null | return profile == null | ||||
? MineHeaderSkeleton() | ? MineHeaderSkeleton() | ||||
: Row( | : Container( | ||||
children: <Widget>[ | child: Row( | ||||
GestureDetector( | children: <Widget>[ | ||||
child: Container( | GestureDetector( | ||||
margin: EdgeInsets.only( | child: Container( | ||||
left: 20, top: 20, bottom: 20, right: 12), | margin: EdgeInsets.only(left: 20, top: 20, bottom: 20, right: 12), | ||||
width: 56, | width: 56, | ||||
height: 56, | height: 56, | ||||
decoration: BoxDecoration( | decoration: BoxDecoration(color: Color(0xfff3f3f3), borderRadius: BorderRadius.circular(28)), | ||||
color: Color(0xfff3f3f3), | child: ClipRRect( | ||||
borderRadius: BorderRadius.circular(28)), | borderRadius: BorderRadius.circular(28), | ||||
child: ClipRRect( | child: CachedNetworkImage( | ||||
borderRadius: BorderRadius.circular(28), | imageUrl: profile?.avatar ?? '', | ||||
child: CachedNetworkImage( | fit: BoxFit.cover, | ||||
imageUrl: profile?.avatar ?? '', | ), | ||||
fit: BoxFit.cover, | |||||
), | ), | ||||
), | ), | ||||
onTap: () async { | |||||
await RouterUtil.route(SkipModel.fromJson(widget.json), widget.json, context); | |||||
_bloc.loadData(); | |||||
}, | |||||
), | ), | ||||
onTap: () async { | Expanded( | ||||
await RouterUtil.route(SkipModel.fromJson(widget.json), | child: Container( | ||||
widget.json, context); | margin: EdgeInsets.only(right: 12), | ||||
_bloc.loadData(); | child: Column( | ||||
}, | mainAxisAlignment: MainAxisAlignment.start, | ||||
), | crossAxisAlignment: CrossAxisAlignment.start, | ||||
Expanded( | children: <Widget>[ | ||||
child: Container( | Row( | ||||
margin: EdgeInsets.only(right: 12), | children: <Widget>[ | ||||
child: Column( | Container( | ||||
mainAxisAlignment: MainAxisAlignment.start, | constraints: BoxConstraints(maxWidth: width - 108 - 80), | ||||
crossAxisAlignment: CrossAxisAlignment.start, | child: Text( | ||||
children: <Widget>[ | profile?.username ?? '', | ||||
Row( | maxLines: 1, | ||||
children: <Widget>[ | overflow: TextOverflow.ellipsis, | ||||
Container( | style: TextStyle( | ||||
constraints: BoxConstraints(maxWidth: width-108-80), | fontSize: 17, color: HexColor.fromHex(widget.staticModel.userNameColor)), | ||||
child: Text( | ), | ||||
profile?.username ?? '', | |||||
maxLines: 1, | |||||
overflow: TextOverflow.ellipsis, | |||||
style: TextStyle( | |||||
fontSize: 17, | |||||
color: HexColor.fromHex( | |||||
widget.staticModel.userNameColor)), | |||||
), | ), | ||||
), | Container( | ||||
Container( | height: 18, | ||||
height: 18, | margin: EdgeInsets.only(left: 6), | ||||
margin: EdgeInsets.only(left: 6), | padding: EdgeInsets.only(left: 6, right: 6), | ||||
padding: EdgeInsets.only(left: 6, right: 6), | decoration: BoxDecoration( | ||||
decoration: BoxDecoration( | color: HexColor.fromHex(widget.staticModel.bgColor), | ||||
color: HexColor.fromHex( | borderRadius: BorderRadius.circular(9)), | ||||
widget.staticModel.lvBgColor), | child: Row( | ||||
borderRadius: BorderRadius.circular(9)), | children: <Widget>[ | ||||
Container( | |||||
width: 12, | |||||
height: 12, | |||||
margin: EdgeInsets.only(right: 2), | |||||
child: CachedNetworkImage( | |||||
imageUrl: profile?.userLvIcon ?? '', | |||||
fit: BoxFit.contain, | |||||
), | |||||
), | |||||
Text( | |||||
profile?.userLvName ?? '', | |||||
style: TextStyle( | |||||
fontSize: 10, color: HexColor.fromHex(widget.staticModel.lvNameColor)), | |||||
) | |||||
], | |||||
), | |||||
), | |||||
], | |||||
), | |||||
GestureDetector( | |||||
child: Container( | |||||
margin: EdgeInsets.only(top: 8), | |||||
child: Row( | child: Row( | ||||
children: <Widget>[ | children: <Widget>[ | ||||
Text( | |||||
'邀请码:${profile.inviteCode}', | |||||
maxLines: 1, | |||||
style: TextStyle( | |||||
fontSize: 13, | |||||
color: HexColor.fromHex(widget.staticModel.userNameColor), | |||||
fontFamily: 'Din', | |||||
package: 'zhiying_comm', | |||||
), | |||||
), | |||||
Container( | Container( | ||||
width: 12, | width: 12, | ||||
height: 12, | height: 12, | ||||
margin: EdgeInsets.only(right: 2), | margin: EdgeInsets.only(left: 2), | ||||
child: CachedNetworkImage( | child: CachedNetworkImage( | ||||
imageUrl: profile?.userLvIcon?? '', | imageUrl: widget.staticModel.coypeIcon, | ||||
fit: BoxFit.contain, | fit: BoxFit.contain, | ||||
), | ), | ||||
), | ), | ||||
Text( | |||||
profile?.userLvName?? '', | |||||
style: TextStyle( | |||||
fontSize: 10, | |||||
color: HexColor.fromHex( | |||||
widget.staticModel.lvNameColor)), | |||||
) | |||||
], | ], | ||||
), | ), | ||||
), | ), | ||||
], | onTap: () { | ||||
), | Fluttertoast.showToast(msg: '复制成功'); | ||||
GestureDetector( | Clipboard.setData(ClipboardData(text: profile.inviteCode)); | ||||
child: Container( | }, | ||||
margin: EdgeInsets.only(top: 8), | |||||
child: Row( | |||||
children: <Widget>[ | |||||
Text( | |||||
'邀请码:${profile.inviteCode}', | |||||
maxLines: 1, | |||||
style: TextStyle( | |||||
fontSize: 13, | |||||
color: HexColor.fromHex( | |||||
widget.staticModel.userNameColor), | |||||
fontFamily: 'Din', | |||||
package: 'zhiying_comm', | |||||
), | |||||
), | |||||
Container( | |||||
width: 12, | |||||
height: 12, | |||||
margin: EdgeInsets.only(left: 2), | |||||
child: CachedNetworkImage( | |||||
imageUrl: widget.staticModel.coypeIcon, | |||||
fit: BoxFit.contain, | |||||
), | |||||
), | |||||
], | |||||
), | |||||
), | ), | ||||
onTap: () { | ], | ||||
Fluttertoast.showToast(msg: '复制成功'); | ), | ||||
Clipboard.setData( | )) | ||||
ClipboardData(text: profile.inviteCode)); | ], | ||||
}, | ), | ||||
), | |||||
], | |||||
), | |||||
)) | |||||
], | |||||
); | ); | ||||
}); | }); | ||||
} | } | ||||
@@ -35,7 +35,7 @@ class _MineStaticContainerState extends State<MineStaticContainer> { | |||||
child: ClipRRect( | child: ClipRRect( | ||||
borderRadius: BorderRadius.circular(28), | borderRadius: BorderRadius.circular(28), | ||||
child: CachedNetworkImage( | child: CachedNetworkImage( | ||||
imageUrl: widget.staticModel.nonLoginAvatar, | imageUrl: widget.staticModel.nonLginAvatar, | ||||
fit: BoxFit.cover)), | fit: BoxFit.cover)), | ||||
), | ), | ||||
onTap: () { | onTap: () { | ||||
@@ -54,7 +54,7 @@ class _MineStaticContainerState extends State<MineStaticContainer> { | |||||
widget.staticModel.loginName, | widget.staticModel.loginName, | ||||
style: TextStyle( | style: TextStyle( | ||||
color: HexColor.fromHex( | color: HexColor.fromHex( | ||||
widget.staticModel?.loginColor ?? '#ffffff'), | widget.staticModel?.userNameColor ?? '#ffffff'), | ||||
fontSize: 17), | fontSize: 17), | ||||
), | ), | ||||
), | ), | ||||
@@ -65,7 +65,7 @@ class _MineStaticContainerState extends State<MineStaticContainer> { | |||||
widget.staticModel.loginNameHelpText, | widget.staticModel.loginNameHelpText, | ||||
style: TextStyle( | style: TextStyle( | ||||
color: HexColor.fromHex( | color: HexColor.fromHex( | ||||
widget.staticModel?.loginColor ?? '#ffffff'), | widget.staticModel?.userNameColor ?? '#ffffff'), | ||||
fontSize: 13), | fontSize: 13), | ||||
)), | )), | ||||
], | ], | ||||
@@ -1,64 +1,128 @@ | |||||
class MineHeaderModel { | class MineHeaderModel { | ||||
String lvBgColor; | String assistColor; | ||||
String lvNameColor; | String bgColor; | ||||
String nonLoginAvatar; | String bgImage; | ||||
String userNameColor; | String bottomLeftRadius; | ||||
String invitedCodeText; | String bottomRightRadius; | ||||
String coypeIcon; | |||||
String desc; | |||||
String invitedCodeColor; | String invitedCodeColor; | ||||
String loginColor; | String isLeftRightMargin; | ||||
String isShow; | |||||
String isTopMargin; | |||||
String leftRightMargin; | |||||
String loginName; | String loginName; | ||||
String loginNameHelpText; | String loginNameHelpText; | ||||
String coypeIcon; | String lvBgImage; | ||||
String requiredLogin; | String lvNameColor; | ||||
String requiredTaobaoAuth; | String moduleKey; | ||||
String moduleType; | |||||
String name; | |||||
String nonLginAvatar; | |||||
int requiredLogin; | |||||
int requiredTaobaoAuth; | |||||
String skipIdentifier; | String skipIdentifier; | ||||
String themeColor; | |||||
String themeType; | |||||
String topLeftRadius; | |||||
String topMargin; | |||||
String topRightRadius; | |||||
String userNameColor; | |||||
MineHeaderModel( | MineHeaderModel( | ||||
{this.lvBgColor, | {this.assistColor, | ||||
this.lvNameColor, | this.bgColor, | ||||
this.nonLoginAvatar, | this.bgImage, | ||||
this.userNameColor, | this.bottomLeftRadius, | ||||
this.invitedCodeText, | this.bottomRightRadius, | ||||
this.coypeIcon, | |||||
this.desc, | |||||
this.invitedCodeColor, | this.invitedCodeColor, | ||||
this.loginColor, | this.isLeftRightMargin, | ||||
this.isShow, | |||||
this.isTopMargin, | |||||
this.leftRightMargin, | |||||
this.loginName, | this.loginName, | ||||
this.loginNameHelpText, | this.loginNameHelpText, | ||||
this.coypeIcon, | this.lvBgImage, | ||||
this.lvNameColor, | |||||
this.moduleKey, | |||||
this.moduleType, | |||||
this.name, | |||||
this.nonLginAvatar, | |||||
this.requiredLogin, | this.requiredLogin, | ||||
this.requiredTaobaoAuth, | this.requiredTaobaoAuth, | ||||
this.skipIdentifier}); | this.skipIdentifier, | ||||
this.themeColor, | |||||
this.themeType, | |||||
this.topLeftRadius, | |||||
this.topMargin, | |||||
this.topRightRadius, | |||||
this.userNameColor}); | |||||
MineHeaderModel.fromJson(Map<String, dynamic> json) { | MineHeaderModel.fromJson(Map<String, dynamic> json) { | ||||
lvBgColor = json['lv_bg_color']; | assistColor = json['assist_color']; | ||||
lvNameColor = json['lv_name_color']; | bgColor = json['bg_color']; | ||||
nonLoginAvatar = json['non_login_avatar']; | bgImage = json['bg_image']; | ||||
userNameColor = json['user_name_color']; | bottomLeftRadius = json['bottom_left_radius']; | ||||
invitedCodeText = json['invited_code_text']; | bottomRightRadius = json['bottom_right_radius']; | ||||
coypeIcon = json['coype_icon']; | |||||
desc = json['desc']; | |||||
invitedCodeColor = json['invited_code_color']; | invitedCodeColor = json['invited_code_color']; | ||||
loginColor = json['login_color']; | isLeftRightMargin = json['is_left_right_margin']; | ||||
isShow = json['is_show']; | |||||
isTopMargin = json['is_top_margin']; | |||||
leftRightMargin = json['left_right_margin']; | |||||
loginName = json['login_name']; | loginName = json['login_name']; | ||||
loginNameHelpText = json['login_name_help_text']; | loginNameHelpText = json['login_name_help_text']; | ||||
coypeIcon = json['coype_icon']; | lvBgImage = json['lv_bg_image']; | ||||
lvNameColor = json['lv_name_color']; | |||||
moduleKey = json['module_key']; | |||||
moduleType = json['module_type']; | |||||
name = json['name']; | |||||
nonLginAvatar = json['non_lgin_avatar']; | |||||
requiredLogin = json['required_login']; | requiredLogin = json['required_login']; | ||||
requiredTaobaoAuth = json['required_taobao_auth']; | requiredTaobaoAuth = json['required_taobao_auth']; | ||||
skipIdentifier = json['skip_identifier']; | skipIdentifier = json['skip_identifier']; | ||||
themeColor = json['theme_color']; | |||||
themeType = json['theme_type']; | |||||
topLeftRadius = json['top_left_radius']; | |||||
topMargin = json['top_margin']; | |||||
topRightRadius = json['top_right_radius']; | |||||
userNameColor = json['user_name_color']; | |||||
} | } | ||||
Map<String, dynamic> toJson() { | Map<String, dynamic> toJson() { | ||||
final Map<String, dynamic> data = new Map<String, dynamic>(); | final Map<String, dynamic> data = new Map<String, dynamic>(); | ||||
data['lv_bg_color'] = this.lvBgColor; | data['assist_color'] = this.assistColor; | ||||
data['lv_name_color'] = this.lvNameColor; | data['bg_color'] = this.bgColor; | ||||
data['non_login_avatar'] = this.nonLoginAvatar; | data['bg_image'] = this.bgImage; | ||||
data['user_name_color'] = this.userNameColor; | data['bottom_left_radius'] = this.bottomLeftRadius; | ||||
data['invited_code_text'] = this.invitedCodeText; | data['bottom_right_radius'] = this.bottomRightRadius; | ||||
data['coype_icon'] = this.coypeIcon; | |||||
data['desc'] = this.desc; | |||||
data['invited_code_color'] = this.invitedCodeColor; | data['invited_code_color'] = this.invitedCodeColor; | ||||
data['login_color'] = this.loginColor; | data['is_left_right_margin'] = this.isLeftRightMargin; | ||||
data['is_show'] = this.isShow; | |||||
data['is_top_margin'] = this.isTopMargin; | |||||
data['left_right_margin'] = this.leftRightMargin; | |||||
data['login_name'] = this.loginName; | data['login_name'] = this.loginName; | ||||
data['login_name_help_text'] = this.loginNameHelpText; | data['login_name_help_text'] = this.loginNameHelpText; | ||||
data['coype_icon'] = this.coypeIcon; | data['lv_bg_image'] = this.lvBgImage; | ||||
data['lv_name_color'] = this.lvNameColor; | |||||
data['module_key'] = this.moduleKey; | |||||
data['module_type'] = this.moduleType; | |||||
data['name'] = this.name; | |||||
data['non_lgin_avatar'] = this.nonLginAvatar; | |||||
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['theme_color'] = this.themeColor; | |||||
data['theme_type'] = this.themeType; | |||||
data['top_left_radius'] = this.topLeftRadius; | |||||
data['top_margin'] = this.topMargin; | |||||
data['top_right_radius'] = this.topRightRadius; | |||||
data['user_name_color'] = this.userNameColor; | |||||
return data; | return data; | ||||
} | } | ||||
} | } | ||||
@@ -22,8 +22,8 @@ class MineNavDelegate extends SliverPersistentHeaderDelegate { | |||||
} else { | } else { | ||||
_color = Colors.amber; | _color = Colors.amber; | ||||
} | } | ||||
if (json.containsKey('app_bar_icons')) { | if (json.containsKey('list_style')) { | ||||
List icons = json['app_bar_icons']; | List icons = json['list_style']; | ||||
_icons = icons.map((icon) { | _icons = icons.map((icon) { | ||||
SkipModel model = SkipModel.fromJson(Map<String, dynamic>.from(icon)); | SkipModel model = SkipModel.fromJson(Map<String, dynamic>.from(icon)); | ||||
return MineNavIcon(icon['icon'], model); | return MineNavIcon(icon['icon'], model); | ||||
@@ -17,7 +17,6 @@ import 'package:zhiying_comm/zhiying_comm.dart'; | |||||
import 'package:provider/provider.dart'; | import 'package:provider/provider.dart'; | ||||
import 'model/search_tab_model.dart'; | import 'model/search_tab_model.dart'; | ||||
class SearchTabWidget extends StatefulWidget { | class SearchTabWidget extends StatefulWidget { | ||||
final Map<String, dynamic> data; | final Map<String, dynamic> data; | ||||
SearchTabModel model; | SearchTabModel model; | ||||
@@ -39,41 +38,49 @@ class _SearchTabWidgetState extends State<SearchTabWidget> { | |||||
String _type = GlobalConfig.PROVIDER_TB; | String _type = GlobalConfig.PROVIDER_TB; | ||||
/// 联想列表的item点击事件 | /// 联想列表的item点击事件 | ||||
_onThinkItemClick(SearchThinkModel model){ | _onThinkItemClick(SearchThinkModel model) { | ||||
model.type = _type; | model.type = _type; | ||||
RouterUtil.hideKeyboard(context); | RouterUtil.hideKeyboard(context); | ||||
Provider.of<SearchTagNotifier>(context, listen: false).addTag(model?.keywords); | Provider.of<SearchTagNotifier>(context, listen: false).addTag(model?.keywords); | ||||
BlocProvider.of<SearchThinkBloc>(context).add(SearchThinkShowBaseViewEvent()); | BlocProvider.of<SearchThinkBloc>(context).add(SearchThinkShowBaseViewEvent()); | ||||
Navigator.push(context, CupertinoPageRoute( | Navigator.push( | ||||
builder: (_)=> SearchResultPage(model.toJson()..['tag'] = 'search_page') | context, CupertinoPageRoute(builder: (_) => SearchResultPage(model.toJson()..['tag'] = 'search_page'))); | ||||
)); | |||||
} | } | ||||
@override | @override | ||||
void initState() { | void initState() { | ||||
_tabController = TabController(length: widget?.model?.search_icon_list?.length ?? 0, vsync: ScrollableState()) | |||||
_tabController = TabController(length: widget?.model?.search_icon_list?.length ?? 0, vsync: ScrollableState())..addListener((){ | ..addListener(() { | ||||
// String type = ''; | // String type = ''; | ||||
// try{ | // try{ | ||||
// type = widget.model.search_icon_list[_tabController.index].type; | // type = widget.model.search_icon_list[_tabController.index].type; | ||||
// }catch(_){} | // }catch(_){} | ||||
// if(!EmptyUtil.isEmpty(type)) { | // if(!EmptyUtil.isEmpty(type)) { | ||||
// BlocProvider.of<SearchThinkBloc>(context).add(SearchThinkChangeTypeEvent(type)); | // BlocProvider.of<SearchThinkBloc>(context).add(SearchThinkChangeTypeEvent(type)); | ||||
// } | // } | ||||
if(!_tabController.indexIsChanging){ | if (!_tabController.indexIsChanging) { | ||||
Logger.log('_tabController.indexIsChanging = ${_tabController?.index}'); | Logger.log('_tabController.indexIsChanging = ${_tabController?.index}'); | ||||
try{ | try { | ||||
_type = widget.model.search_icon_list[_tabController.index].type; | _type = widget.model.search_icon_list[_tabController.index].type; | ||||
Provider.of<SearchTagNotifier>(context, listen: false).setType(_type); | Provider.of<SearchTagNotifier>(context, listen: false).setType(_type); | ||||
}catch(e, s){ | } catch (e, s) { | ||||
Logger.error(e,s); | Logger.error(e, s); | ||||
} | |||||
} | } | ||||
} | }); | ||||
WidgetsBinding.instance.addPostFrameCallback((_) => setTabSelect()); | |||||
}); | |||||
super.initState(); | super.initState(); | ||||
} | } | ||||
setTabSelect() { | |||||
for (int i = 0; i < widget.model.search_icon_list.length; i++) { | |||||
print("tab选择的类型" + widget.model.search_icon_list[i].type); | |||||
} | |||||
// setState(() { | |||||
// _tabController.animateTo(2); | |||||
// }); | |||||
} | |||||
@override | @override | ||||
void dispose() { | void dispose() { | ||||
_tabController?.dispose(); | _tabController?.dispose(); | ||||
@@ -103,8 +110,8 @@ class _SearchTabWidgetState extends State<SearchTabWidget> { | |||||
TabBar( | TabBar( | ||||
controller: _tabController, | controller: _tabController, | ||||
isScrollable: true, | isScrollable: true, | ||||
labelStyle: TextStyle( fontSize: 14, fontWeight: FontWeight.bold), | labelStyle: TextStyle(fontSize: 14, fontWeight: FontWeight.bold), | ||||
unselectedLabelColor: HexColor.fromHex( model?.nameColor ?? '#999999'), | unselectedLabelColor: HexColor.fromHex(model?.nameColor ?? '#999999'), | ||||
labelColor: HexColor.fromHex(model?.nameSelectColor ?? '#FF4242'), | labelColor: HexColor.fromHex(model?.nameSelectColor ?? '#FF4242'), | ||||
// indicatorSize: TabBarIndicatorSize.label, | // indicatorSize: TabBarIndicatorSize.label, | ||||
indicator: MaterialIndicator( | indicator: MaterialIndicator( | ||||
@@ -118,12 +125,14 @@ class _SearchTabWidgetState extends State<SearchTabWidget> { | |||||
), | ), | ||||
tabs: model.search_icon_list.map((item) { | tabs: model.search_icon_list.map((item) { | ||||
return MyTab( | return MyTab( | ||||
icon: CachedNetworkImage(imageUrl: item?.with_icon_color ?? '', width: 14,), | icon: CachedNetworkImage( | ||||
imageUrl: item?.with_icon_color ?? '', | |||||
width: 14, | |||||
), | |||||
text: item.name, | text: item.name, | ||||
); | ); | ||||
}).toList(), | }).toList(), | ||||
), | ), | ||||
Expanded( | Expanded( | ||||
child: _getItemWidget(model), | child: _getItemWidget(model), | ||||
), | ), | ||||
@@ -133,29 +142,26 @@ class _SearchTabWidgetState extends State<SearchTabWidget> { | |||||
} | } | ||||
/// 根据输入框,是否显示联想列表还是其它 | /// 根据输入框,是否显示联想列表还是其它 | ||||
Widget _getItemWidget(SearchTabModel model){ | Widget _getItemWidget(SearchTabModel model) { | ||||
return Stack( | return Stack( | ||||
children: <Widget>[ | children: <Widget>[ | ||||
_getTabBarView(model), | _getTabBarView(model), | ||||
BlocConsumer<SearchThinkBloc, SearchThinkState>( | BlocConsumer<SearchThinkBloc, SearchThinkState>( | ||||
listener: (context, state){}, | listener: (context, state) {}, | ||||
buildWhen: (prev, current){ | buildWhen: (prev, current) { | ||||
if(current is SearchThinkErrorState){ | if (current is SearchThinkErrorState) { | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
}, | }, | ||||
builder: (context, state){ | builder: (context, state) { | ||||
// return Visibility( | // return Visibility( | ||||
// replacement: _getTabBarView(model), | // replacement: _getTabBarView(model), | ||||
// | // | ||||
// child: _getThinkListWidget(), | // child: _getThinkListWidget(), | ||||
// ); | // ); | ||||
if(state is SearchThinkLoadedState){ | if (state is SearchThinkLoadedState) { | ||||
return _getThinkListWidget(state.model); | return _getThinkListWidget(state.model); | ||||
} | } | ||||
return Container(); | return Container(); | ||||
@@ -166,10 +172,10 @@ class _SearchTabWidgetState extends State<SearchTabWidget> { | |||||
} | } | ||||
/// tabBarView | /// tabBarView | ||||
Widget _getTabBarView(SearchTabModel model){ | Widget _getTabBarView(SearchTabModel model) { | ||||
return TabBarView( | return TabBarView( | ||||
controller: _tabController, | controller: _tabController, | ||||
children: model.search_icon_list.map((item){ | children: model.search_icon_list.map((item) { | ||||
// TODO 这里需要和后台沟通改成页面的唯一标示 | // TODO 这里需要和后台沟通改成页面的唯一标示 | ||||
// return PageFactory.create('search_item_page', item.toJson()); | // return PageFactory.create('search_item_page', item.toJson()); | ||||
return SearchItemPage(item.toJson()); | return SearchItemPage(item.toJson()); | ||||
@@ -177,31 +183,31 @@ class _SearchTabWidgetState extends State<SearchTabWidget> { | |||||
); | ); | ||||
} | } | ||||
/// 联想列表 | /// 联想列表 | ||||
Widget _getThinkListWidget(List<SearchThinkModel> model){ | Widget _getThinkListWidget(List<SearchThinkModel> model) { | ||||
return Container( | return Container( | ||||
color: Colors.white, | color: Colors.white, | ||||
height: double.infinity, | height: double.infinity, | ||||
child: ListView.builder(itemBuilder: (context, index){ | child: ListView.builder( | ||||
SearchThinkModel item = model[index]; | itemBuilder: (context, index) { | ||||
return GestureDetector( | SearchThinkModel item = model[index]; | ||||
onTap: ()=> _onThinkItemClick(item), | return GestureDetector( | ||||
child: Container( | onTap: () => _onThinkItemClick(item), | ||||
decoration: BoxDecoration( | child: Container( | ||||
border: Border(bottom: BorderSide(width: 0.5, color: HexColor.fromHex('#EEEEEE'))) | decoration: | ||||
BoxDecoration(border: Border(bottom: BorderSide(width: 0.5, color: HexColor.fromHex('#EEEEEE')))), | |||||
padding: const EdgeInsets.only(top: 13, bottom: 13), | |||||
child: Text( | |||||
'${item?.keywords}', | |||||
style: TextStyle(color: HexColor.fromHex('#333333'), fontSize: 14), | |||||
), | |||||
), | ), | ||||
padding: const EdgeInsets.only(top: 13, bottom: 13), | ); | ||||
child: Text('${item?.keywords}', style: TextStyle( color: HexColor.fromHex('#333333'), fontSize: 14),), | }, | ||||
), | |||||
); | |||||
}, | |||||
itemCount: model?.length ?? 0, | itemCount: model?.length ?? 0, | ||||
padding: const EdgeInsets.only(left: 12.5, right: 12.5), | padding: const EdgeInsets.only(left: 12.5, right: 12.5), | ||||
shrinkWrap: true, | shrinkWrap: true, | ||||
), | ), | ||||
); | ); | ||||
} | } | ||||
} | } |