Ver código fonte

修复商品详情,自购省显示错误bug

tags/0.0.1
Weller 4 anos atrás
pai
commit
31782bcb94
2 arquivos alterados com 163 adições e 109 exclusões
  1. +81
    -44
      lib/widgets/goods_details/footer/goods_details_footer_widget.dart
  2. +82
    -65
      lib/widgets/goods_details/footer/model/goods_details_footer_model.dart

+ 81
- 44
lib/widgets/goods_details/footer/goods_details_footer_widget.dart Ver arquivo

@@ -30,7 +30,8 @@ class GoodsDetailsFooterWidget extends StatelessWidget {
visible: !EmptyUtil.isEmpty(model),
replacement: GoodsDetailsFooterSkeleton(),
child: BlocProvider<GoodsDetailsFooterBloc>(
create: (_) => GoodsDetailsFooterBloc(repository: GoodsDetailsFooterRepository()),
create: (_) =>
GoodsDetailsFooterBloc(repository: GoodsDetailsFooterRepository()),
//..add(GoodsDetailsFooterInitEvent(model: model)),
child: GooddsDetailsFooterContainer(
model,
@@ -47,16 +48,18 @@ class GooddsDetailsFooterContainer extends StatefulWidget {
const GooddsDetailsFooterContainer(this.model, {Key key}) : super(key: key);

@override
_GooddsDetailsFooterContainerState createState() => _GooddsDetailsFooterContainerState();
_GooddsDetailsFooterContainerState createState() =>
_GooddsDetailsFooterContainerState();
}

class _GooddsDetailsFooterContainerState extends State<GooddsDetailsFooterContainer> {
class _GooddsDetailsFooterContainerState
extends State<GooddsDetailsFooterContainer> {
UserInfoModel _user;

@override
void initState() {
BlocProvider.of<GoodsDetailsFooterBloc>(context).add(GoodsDetailsFooterInitEvent(model: widget?.model));
BlocProvider.of<GoodsDetailsFooterBloc>(context)
.add(GoodsDetailsFooterInitEvent(model: widget?.model));
super.initState();
}

@@ -64,7 +67,9 @@ class _GooddsDetailsFooterContainerState extends State<GooddsDetailsFooterContai
void _openHome() {
Navigator.pushAndRemoveUntil(
context,
CupertinoPageRoute(builder: (BuildContext context) => PageFactory.create('homePage', null)),
CupertinoPageRoute(
builder: (BuildContext context) =>
PageFactory.create('homePage', null)),
(Route<dynamic> route) => false,
);
}
@@ -100,7 +105,8 @@ class _GooddsDetailsFooterContainerState extends State<GooddsDetailsFooterContai
return;
}
}
Navigator.of(context).push(CupertinoPageRoute(builder: (context) => GoodsSharePage(widget.model)));
Navigator.of(context).push(CupertinoPageRoute(
builder: (context) => GoodsSharePage(widget.model)));
}
}

@@ -170,7 +176,8 @@ class _GooddsDetailsFooterContainerState extends State<GooddsDetailsFooterContai
return SafeArea(
child: Container(
width: double.infinity,
padding: EdgeInsets.only(bottom: (height > 10 ? 0 : 8), top: 8, left: 21, right: 12.5),
padding: EdgeInsets.only(
bottom: (height > 10 ? 0 : 8), top: 8, left: 21, right: 12.5),
decoration: BoxDecoration(
// boxShadow: [
// BoxShadow(color: Colors.grey[300], offset: Offset(0.0, 0.0), blurRadius: 5.0, spreadRadius: 2.0),
@@ -209,12 +216,18 @@ class _GooddsDetailsFooterContainerState extends State<GooddsDetailsFooterContai
onTap: () => _openHome(),
child: Padding(
padding: const EdgeInsets.only(right: 35),
child: _getCustomWidget(model?.home ?? '首页', model?.home_color ?? '999999', model?.home_icon ?? ''),
child: _getCustomWidget(model?.home ?? '首页',
model?.home_color ?? '999999', model?.home_icon ?? ''),
)),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => _collectOnClick(),
child: Padding(padding: const EdgeInsets.only(right: 0), child: _getCustomWidget(model?.collect ?? '收藏', model?.collect_color ?? '999999', model?.collect_icon ?? '')))
child: Padding(
padding: const EdgeInsets.only(right: 0),
child: _getCustomWidget(
model?.collect ?? '收藏',
model?.collect_color ?? '999999',
model?.collect_icon ?? '')))
],
);
}
@@ -241,30 +254,40 @@ class _GooddsDetailsFooterContainerState extends State<GooddsDetailsFooterContai
width: 110,
// padding: const EdgeInsets.only(left: 30, right: 30, top: 5, bottom: 5),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [HexColor.fromHex(model?.share_earn_bg1_color ?? '#FFCA66'), HexColor.fromHex(model?.share_earn_bg2_color ?? '#FFD961')],
begin: Alignment.centerLeft,
end: Alignment.centerRight),
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(25), topLeft: Radius.circular(25))),
gradient: LinearGradient(colors: [
HexColor.fromHex(model?.share_earn_bg1_color ?? '#FFCA66'),
HexColor.fromHex(model?.share_earn_bg2_color ?? '#FFD961')
], begin: Alignment.centerLeft, end: Alignment.centerRight),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(25), topLeft: Radius.circular(25))),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
RichText(
text: TextSpan(text: '¥ ', style: TextStyle(fontSize: 12, color: HexColor.fromHex(model?.share_earn_val_color ?? 'FFFFFF')), children: [
TextSpan(
text: model?.share_value ?? '0.0',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: HexColor.fromHex(model?.share_earn_color ?? '#FFFFFF'),
fontFamily: 'Din',
package: 'zhiying_base_widget')),
]),
text: TextSpan(
text: '¥ ',
style: TextStyle(
fontSize: 12,
color: HexColor.fromHex(
model?.share_earn_val_color ?? 'FFFFFF')),
children: [
TextSpan(
text: model?.share_value ?? '0.0',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: HexColor.fromHex(
model?.share_earn_color ?? '#FFFFFF'),
fontFamily: 'Din',
package: 'zhiying_base_widget')),
]),
),
Text(
model?.share_earn ?? '分享赚',
style: TextStyle(color: HexColor.fromHex(model?.share_earn_color ?? '#FFFFFF'), fontSize: 12),
style: TextStyle(
color: HexColor.fromHex(model?.share_earn_color ?? '#FFFFFF'),
fontSize: 12),
),
],
),
@@ -283,29 +306,42 @@ class _GooddsDetailsFooterContainerState extends State<GooddsDetailsFooterContai
height: 44,
width: 110,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [HexColor.fromHex(model?.save_earn_bg1_color ?? '#FF6969'), HexColor.fromHex(model?.save_earn_bg2_color ?? '#FF4646')],
begin: Alignment.centerLeft,
end: Alignment.centerRight),
borderRadius: BorderRadius.only(bottomRight: Radius.circular(25), topRight: Radius.circular(25))),
gradient: LinearGradient(colors: [
HexColor.fromHex(model?.save_earn_bg1_color ?? '#FF6969'),
HexColor.fromHex(model?.save_earn_bg2_color ?? '#FF4646')
], begin: Alignment.centerLeft, end: Alignment.centerRight),
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(25),
topRight: Radius.circular(25))),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
RichText(
text: TextSpan(text: '¥ ', style: TextStyle(fontSize: 12, color: HexColor.fromHex(model?.save_earn_val_color ?? 'FFFFFF')), children: [
TextSpan(
text: model?.slef_buy_value ?? '0.0',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: HexColor.fromHex(model?.save_earn_val_color ?? '#FFFFFF'),
fontFamily: 'Din',
package: 'zhiying_base_widget',
)),
]),
text: TextSpan(
text: '¥ ',
style: TextStyle(
fontSize: 12,
color: HexColor.fromHex(
model?.save_earn_val_color ?? 'FFFFFF')),
children: [
TextSpan(
text: model?.self_buy_value ?? '0.0',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: HexColor.fromHex(
model?.save_earn_val_color ?? '#FFFFFF'),
fontFamily: 'Din',
package: 'zhiying_base_widget',
)),
]),
),
Text(model?.save_earn ?? '自购省', style: TextStyle(color: HexColor.fromHex(model?.save_earn_color ?? '#FFFFFF'), fontSize: 12))
Text(model?.save_earn ?? '自购省',
style: TextStyle(
color:
HexColor.fromHex(model?.save_earn_color ?? '#FFFFFF'),
fontSize: 12))
],
),
),
@@ -328,7 +364,8 @@ class _GooddsDetailsFooterContainerState extends State<GooddsDetailsFooterContai
const SizedBox(height: 5),

/// 图片
Text(text, style: TextStyle(color: HexColor.fromHex(textColor), fontSize: 11))
Text(text,
style: TextStyle(color: HexColor.fromHex(textColor), fontSize: 11))
],
);
}


+ 82
- 65
lib/widgets/goods_details/footer/model/goods_details_footer_model.dart Ver arquivo

@@ -1,69 +1,86 @@

class GoodsDetailsFooterModel {
String collect;
String collect_color;
String collect_icon;
String home;
String home_color;
String home_icon;
String save_earn;
String save_earn_bg1_color;
String save_earn_bg2_color;
String save_earn_color;
String save_earn_val_color;
String share_earn;
String share_earn_bg1_color;
String share_earn_bg2_color;
String share_earn_color;
String share_earn_val_color;
String share_value;
String slef_buy_value;
String collect;
String collect_color;
String collect_icon;
String home;
String home_color;
String home_icon;
String save_earn;
String save_earn_bg1_color;
String save_earn_bg2_color;
String save_earn_color;
String save_earn_val_color;
String share_earn;
String share_earn_bg1_color;
String share_earn_bg2_color;
String share_earn_color;
String share_earn_val_color;
String share_value;
String self_buy_value;

GoodsDetailsFooterModel({this.collect, this.collect_color, this.collect_icon, this.home, this.home_color, this.home_icon, this.save_earn, this.save_earn_bg1_color, this.save_earn_bg2_color, this.save_earn_color, this.save_earn_val_color, this.share_earn, this.share_earn_bg1_color, this.share_earn_bg2_color, this.share_earn_color, this.share_earn_val_color, this.share_value, this.slef_buy_value});
GoodsDetailsFooterModel(
{this.collect,
this.collect_color,
this.collect_icon,
this.home,
this.home_color,
this.home_icon,
this.save_earn,
this.save_earn_bg1_color,
this.save_earn_bg2_color,
this.save_earn_color,
this.save_earn_val_color,
this.share_earn,
this.share_earn_bg1_color,
this.share_earn_bg2_color,
this.share_earn_color,
this.share_earn_val_color,
this.share_value,
this.self_buy_value});

factory GoodsDetailsFooterModel.fromJson(Map<String, dynamic> json) {
return GoodsDetailsFooterModel(
collect: json['collect'],
collect_color: json['collect_color'],
collect_icon: json['collect_icon'],
home: json['home'],
home_color: json['home_color'],
home_icon: json['home_icon'],
save_earn: json['save_earn'],
save_earn_bg1_color: json['save_earn_bg1_color'],
save_earn_bg2_color: json['save_earn_bg2_color'],
save_earn_color: json['save_earn_color'],
save_earn_val_color: json['save_earn_val_color'],
share_earn: json['share_earn'],
share_earn_bg1_color: json['share_earn_bg1_color'],
share_earn_bg2_color: json['share_earn_bg2_color'],
share_earn_color: json['share_earn_color'],
share_earn_val_color: json['share_earn_val_color'],
share_value: json['share_value'],
slef_buy_value: json['slef_buy_value'],
);
}
factory GoodsDetailsFooterModel.fromJson(Map<String, dynamic> json) {
return GoodsDetailsFooterModel(
collect: json['collect'],
collect_color: json['collect_color'],
collect_icon: json['collect_icon'],
home: json['home'],
home_color: json['home_color'],
home_icon: json['home_icon'],
save_earn: json['save_earn'],
save_earn_bg1_color: json['save_earn_bg1_color'],
save_earn_bg2_color: json['save_earn_bg2_color'],
save_earn_color: json['save_earn_color'],
save_earn_val_color: json['save_earn_val_color'],
share_earn: json['share_earn'],
share_earn_bg1_color: json['share_earn_bg1_color'],
share_earn_bg2_color: json['share_earn_bg2_color'],
share_earn_color: json['share_earn_color'],
share_earn_val_color: json['share_earn_val_color'],
share_value: json['share_value'],
self_buy_value: json['self_buy_value'],
);
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['collect'] = this.collect;
data['collect_color'] = this.collect_color;
data['collect_icon'] = this.collect_icon;
data['home'] = this.home;
data['home_color'] = this.home_color;
data['home_icon'] = this.home_icon;
data['save_earn'] = this.save_earn;
data['save_earn_bg1_color'] = this.save_earn_bg1_color;
data['save_earn_bg2_color'] = this.save_earn_bg2_color;
data['save_earn_color'] = this.save_earn_color;
data['save_earn_val_color'] = this.save_earn_val_color;
data['share_earn'] = this.share_earn;
data['share_earn_bg1_color'] = this.share_earn_bg1_color;
data['share_earn_bg2_color'] = this.share_earn_bg2_color;
data['share_earn_color'] = this.share_earn_color;
data['share_earn_val_color'] = this.share_earn_val_color;
data['share_value'] = this.share_value;
data['slef_buy_value'] = this.slef_buy_value;
return data;
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['collect'] = this.collect;
data['collect_color'] = this.collect_color;
data['collect_icon'] = this.collect_icon;
data['home'] = this.home;
data['home_color'] = this.home_color;
data['home_icon'] = this.home_icon;
data['save_earn'] = this.save_earn;
data['save_earn_bg1_color'] = this.save_earn_bg1_color;
data['save_earn_bg2_color'] = this.save_earn_bg2_color;
data['save_earn_color'] = this.save_earn_color;
data['save_earn_val_color'] = this.save_earn_val_color;
data['share_earn'] = this.share_earn;
data['share_earn_bg1_color'] = this.share_earn_bg1_color;
data['share_earn_bg2_color'] = this.share_earn_bg2_color;
data['share_earn_color'] = this.share_earn_color;
data['share_earn_val_color'] = this.share_earn_val_color;
data['share_value'] = this.share_value;
data['self_buy_value'] = this.self_buy_value;
return data;
}
}

Carregando…
Cancelar
Salvar