From 74623d38fe1882cd14112a6051098f45a9611d05 Mon Sep 17 00:00:00 2001 From: fmk Date: Tue, 12 Oct 2021 15:21:19 +0800 Subject: [PATCH] safety --- lib/store/store_view/product_sku.dart | 121 +++++++-------------- lib/store/store_view/store_order_list.dart | 10 +- 2 files changed, 49 insertions(+), 82 deletions(-) diff --git a/lib/store/store_view/product_sku.dart b/lib/store/store_view/product_sku.dart index 516d6287..be084206 100644 --- a/lib/store/store_view/product_sku.dart +++ b/lib/store/store_view/product_sku.dart @@ -2,15 +2,16 @@ import 'package:flutter/material.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:huixiang/retrofit/data/miNiDetail.dart'; import 'package:huixiang/store/store_view/store_order_list.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/round_button.dart'; class ProductSku extends StatefulWidget { - final ProductListBean productListBean; + final MiNiDetail miNiDetail; - ProductSku(this.productListBean); + ProductSku(this.miNiDetail); @override State createState() { @@ -19,13 +20,6 @@ class ProductSku extends StatefulWidget { } class _ProductSku extends State { - List temperatureStoreList = [ - testModel("正常冰"), - testModel("少冰"), - testModel("多冰"), - testModel("去冰") - ]; - List sweetnessStoreList = [testModel("正常糖"), testModel("5分糖")]; int isChoice = 0; int tempClickIndex = 0; @@ -33,11 +27,7 @@ class _ProductSku extends State { Widget build(BuildContext context) { return Container( alignment: Alignment.topCenter, - padding: EdgeInsets.only( - top: 16, - left: 16, - right: 16, - ), + padding: EdgeInsets.only(top: 16, left: 16, right: 16), width: double.infinity, decoration: BoxDecoration( color: Color(0xFFFAFAFA), @@ -55,21 +45,19 @@ class _ProductSku extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ MImage( - widget.productListBean.imgPath, + widget.miNiDetail.imgs[0], width: 70, height: 70, fit: BoxFit.cover, errorSrc: "assets/image/default_1.png", fadeSrc: "assets/image/default_1.png", ), - SizedBox( - width: 10, - ), + SizedBox(width: 10), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - widget.productListBean.productName, + widget.miNiDetail.productName, style: TextStyle( color: Colors.black, fontSize: 16.sp, @@ -98,7 +86,7 @@ class _ProductSku extends State { ), ), Text( - widget.productListBean.applyPrice, + widget.miNiDetail.price, style: TextStyle( color: Color(0xFFFF7A1A), fontSize: 14.sp, @@ -125,57 +113,33 @@ class _ProductSku extends State { SizedBox( height: 23, ), - Text( - "温度", - style: TextStyle( - color: Colors.black, - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, - ), - ), - SizedBox( - height: 15, - ), - sweetnessStore( - () { - setState(() { - for (var i = 0; i < temperatureStoreList.length; i++) { - if (tempClickIndex == i) - temperatureStoreList[i].isSelected = true; - else - temperatureStoreList[i].isSelected = false; - } - }); - }, - temperatureStoreList, - ), - SizedBox( - height: 24, - ), - Text( - "甜度", - style: TextStyle( - color: Colors.black, - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, - ), - ), - SizedBox( - height: 15, - ), - sweetnessStore( - () { - setState(() { - for (var i = 0; i < sweetnessStoreList.length; i++) { - if (tempClickIndex == i) - sweetnessStoreList[i].isSelected = true; - else - sweetnessStoreList[i].isSelected = false; - } - }); + Expanded( + child: ListView.builder( + itemCount: widget.miNiDetail.attrList.length, + scrollDirection: Axis.vertical, + physics: BouncingScrollPhysics(), + itemBuilder: (context, position) { + return attrItem( + () { + setState(() { + for (var i = 0; + i < + widget.miNiDetail.attrList[position].attrValueList + .length; + i++) { + if (tempClickIndex == i) + widget.miNiDetail.attrList[position].attrValueList[i] + .isSelected = true; + else + widget.miNiDetail.attrList[position].attrValueList[i] + .isSelected = false; + } + }); + }, + widget.miNiDetail.attrList[position], + ); }, - sweetnessStoreList, - ), + )), SizedBox( height: 24, ), @@ -183,15 +147,14 @@ class _ProductSku extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Expanded( - child: Text( - "数量", - style: TextStyle( - color: Colors.black, - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, - ), + child: Text( + "数量", + style: TextStyle( + color: Colors.black, + fontSize: 14.sp, + fontWeight: MyFontWeight.regular, ), - ), + )), InkWell( onTap: () {}, child: Image.asset( @@ -203,7 +166,7 @@ class _ProductSku extends State { Padding( padding: EdgeInsets.only(left: 8, right: 8), child: Text( - widget.productListBean.buyNum.toString(), + "1", style: TextStyle( color: Colors.black, fontSize: 14.sp, diff --git a/lib/store/store_view/store_order_list.dart b/lib/store/store_view/store_order_list.dart index def2b8f3..519f06cf 100644 --- a/lib/store/store_view/store_order_list.dart +++ b/lib/store/store_view/store_order_list.dart @@ -368,8 +368,12 @@ class _StoreOrderListPage extends State { context: context, backgroundColor: Colors.transparent, builder: (context) { - return StatefulBuilder(builder: (context1, state) { - return ProductSku(productListBean); - + return StatefulBuilder(builder: (context1, state) + { + return ProductSku(miNiDetail); + }); + } + ); + } }