diff --git a/lib/ui/market/collection/collection_list_card.dart b/lib/ui/market/collection/collection_list_card.dart index 350324b5..4a012a29 100644 --- a/lib/ui/market/collection/collection_list_card.dart +++ b/lib/ui/market/collection/collection_list_card.dart @@ -1,3 +1,4 @@ +import 'package:aku_new_community/ui/market/widget/goods_%20tag_widget.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; @@ -67,8 +68,7 @@ class CollectionListCard extends StatelessWidget { ), ), 5.hb, - // _getIcon(2), - //_getIcon(model.kind??0), + GoodsTagWidget(type: model.kind??0), Spacer(), 20.hb, RichText( @@ -188,48 +188,4 @@ class CollectionListCard extends StatelessWidget { return count + '折'; } - Widget _getIcon(int type) { - if (type == 1) { - return Container( - width: 86.w, - height: 26.w, - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(4.w), - ), - gradient: LinearGradient( - begin: FractionalOffset.centerLeft, - end: FractionalOffset.centerRight, - colors: [Color(0xFFEC5329), Color(0xFFF58123)], - ), - ), - child: Text( - '京东自营', - style: TextStyle(fontSize: 18.sp, color: kForeGroundColor), - ), - ); - } else if (type == 2) { - return Container( - alignment: Alignment.center, - width: 86.w, - height: 30.w, - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(4.w), - ), - gradient: LinearGradient( - begin: FractionalOffset.centerLeft, - end: FractionalOffset.centerRight, - colors: [Color(0xFFF59B1C), Color(0xFFF5AF16)], - ), - ), - child: Text( - '京东POP', - style: TextStyle(fontSize: 18.sp, color: kForeGroundColor), - ), - ); - } else - return SizedBox(); - } } diff --git a/lib/ui/market/market_enums.dart b/lib/ui/market/market_enums.dart new file mode 100644 index 00000000..9ff91f8f --- /dev/null +++ b/lib/ui/market/market_enums.dart @@ -0,0 +1,12 @@ +enum GoodTag { + jdSelfSupport(1, '京东自营'), + jdPop(2, '京东POP'); + + final typeNum; + final typeStr; + + static GoodTag getValue(int value) => + GoodTag.values.firstWhere((element) => element.typeNum == value); + + const GoodTag(this.typeNum, this.typeStr); +} diff --git a/lib/ui/market/market_home_goods_card.dart b/lib/ui/market/market_home_goods_card.dart index 207e3b3d..d69913de 100644 --- a/lib/ui/market/market_home_goods_card.dart +++ b/lib/ui/market/market_home_goods_card.dart @@ -1,3 +1,4 @@ +import 'package:aku_new_community/ui/market/widget/goods_%20tag_widget.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -83,15 +84,15 @@ class MarketHomeGoodsCard extends StatelessWidget { style: TextStyle(fontSize: 28.sp, color: ktextPrimary), ), ), - // Padding( - // padding: EdgeInsets.only( - // left: 16.w, - // right: 16.w, - // top: 10.w, - // ), - // child: Container( - // child: _getIcon(1), - // )), + Padding( + padding: EdgeInsets.only( + left: 16.w, + right: 16.w, + top: 10.w, + ), + child: Container( + child: GoodsTagWidget(type: item.kind??0), + )), 10.hb, Padding( padding: EdgeInsets.symmetric( @@ -187,48 +188,4 @@ class MarketHomeGoodsCard extends StatelessWidget { return count + '折'; } - Widget _getIcon(int type) { - if (type == 1) { - return Container( - width: 86.w, - height: 26.w, - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(4.w), - ), - gradient: LinearGradient( - begin: FractionalOffset.centerLeft, - end: FractionalOffset.centerRight, - colors: [Color(0xFFEC5329), Color(0xFFF58123)], - ), - ), - child: Text( - '京东自营', - style: TextStyle(fontSize: 18.sp, color: kForeGroundColor), - ), - ); - } else if (type == 2) { - return Container( - alignment: Alignment.center, - width: 86.w, - height: 30.w, - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(4.w), - ), - gradient: LinearGradient( - begin: FractionalOffset.centerLeft, - end: FractionalOffset.centerRight, - colors: [Color(0xFFF59B1C), Color(0xFFF5AF16)], - ), - ), - child: Text( - '京东POP', - style: TextStyle(fontSize: 18.sp, color: kForeGroundColor), - ), - ); - } else - return SizedBox(); - } } diff --git a/lib/ui/market/search/good_detail_page.dart b/lib/ui/market/search/good_detail_page.dart index 536ee89f..68641705 100644 --- a/lib/ui/market/search/good_detail_page.dart +++ b/lib/ui/market/search/good_detail_page.dart @@ -1,5 +1,6 @@ import 'dart:async'; +import 'package:aku_new_community/ui/market/widget/goods_%20tag_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -348,7 +349,7 @@ class _GoodDetailPageState extends State { overflow: TextOverflow.ellipsis, ), ), - // _getIcon(_goodDetail!.kind), + GoodsTagWidget(type: _goodDetail!.kind), Spacer(), Row( crossAxisAlignment: CrossAxisAlignment.center, @@ -558,52 +559,6 @@ class _GoodDetailPageState extends State { return url.substring(2); } - Widget _getIcon(int type) { - if (type == 1) { - return Container( - margin: EdgeInsets.only(left: 15.w), - width: 86.w, - height: 26.w, - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(4.w), - ), - gradient: LinearGradient( - begin: FractionalOffset.centerLeft, - end: FractionalOffset.centerRight, - colors: [Color(0xFFEC5329), Color(0xFFF58123)], - ), - ), - child: Text( - '京东自营', - style: TextStyle(fontSize: 18.sp, color: kForeGroundColor), - ), - ); - } else if (type == 2) { - return Container( - alignment: Alignment.center, - width: 86.w, - height: 30.w, - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(4.w), - ), - gradient: LinearGradient( - begin: FractionalOffset.centerLeft, - end: FractionalOffset.centerRight, - colors: [Color(0xFFF59B1C), Color(0xFFF5AF16)], - ), - ), - child: Text( - '京东POP', - style: TextStyle(fontSize: 18.sp, color: kForeGroundColor), - ), - ); - } else - return SizedBox(); - } - _bottomButton() { return Container( width: double.infinity, diff --git a/lib/ui/market/search/goods_list_card.dart b/lib/ui/market/search/goods_list_card.dart index 090865f2..55957a27 100644 --- a/lib/ui/market/search/goods_list_card.dart +++ b/lib/ui/market/search/goods_list_card.dart @@ -1,3 +1,4 @@ +import 'package:aku_new_community/ui/market/widget/goods_%20tag_widget.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; @@ -76,8 +77,7 @@ class GoodsListCardState extends State { ), ), 5.hb, - // _getIcon(2), - //_getIcon(model.kind??0), + GoodsTagWidget(type: widget.model.kind??0), Spacer(), 20.hb, RichText( @@ -195,48 +195,4 @@ class GoodsListCardState extends State { return count + '折'; } - Widget _getIcon(int type) { - if (type == 1) { - return Container( - width: 86.w, - height: 26.w, - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(4.w), - ), - gradient: LinearGradient( - begin: FractionalOffset.centerLeft, - end: FractionalOffset.centerRight, - colors: [Color(0xFFEC5329), Color(0xFFF58123)], - ), - ), - child: Text( - '京东自营', - style: TextStyle(fontSize: 18.sp, color: kForeGroundColor), - ), - ); - } else if (type == 2) { - return Container( - alignment: Alignment.center, - width: 86.w, - height: 30.w, - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(4.w), - ), - gradient: LinearGradient( - begin: FractionalOffset.centerLeft, - end: FractionalOffset.centerRight, - colors: [Color(0xFFF59B1C), Color(0xFFF5AF16)], - ), - ), - child: Text( - '京东POP', - style: TextStyle(fontSize: 18.sp, color: kForeGroundColor), - ), - ); - } else - return SizedBox(); - } } diff --git a/lib/ui/market/search_goods_card.dart b/lib/ui/market/search_goods_card.dart index e84c5703..1fc6c0aa 100644 --- a/lib/ui/market/search_goods_card.dart +++ b/lib/ui/market/search_goods_card.dart @@ -1,3 +1,4 @@ +import 'package:aku_new_community/ui/market/widget/goods_%20tag_widget.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; @@ -91,15 +92,15 @@ class _SearchGoodsCardState extends State { style: TextStyle(fontSize: 28.sp, color: ktextPrimary), ), ), - // Padding( - // padding: EdgeInsets.only( - // left: 16.w, - // right: 16.w, - // top: 10.w, - // ), - // child: Container( - // child: _getIcon(widget.item.kind ?? 0), - // )), + Padding( + padding: EdgeInsets.only( + left: 16.w, + right: 16.w, + top: 10.w, + ), + child: Container( + child: GoodsTagWidget(type: widget.item.kind ?? 0), + )), 10.hb, Padding( padding: EdgeInsets.symmetric( diff --git a/lib/ui/market/widget/goods_ tag_widget.dart b/lib/ui/market/widget/goods_ tag_widget.dart new file mode 100644 index 00000000..0a14d0a8 --- /dev/null +++ b/lib/ui/market/widget/goods_ tag_widget.dart @@ -0,0 +1,60 @@ +import 'package:aku_new_community/utils/headers.dart'; +import 'package:flutter/cupertino.dart'; + +import '../../../base/base_style.dart'; + +class GoodsTagWidget extends StatelessWidget { + final int type; + const GoodsTagWidget({Key? key, required this.type}) : super(key: key); + + @override + Widget build(BuildContext context) { + return _getIcon(type); + } + + Widget _getIcon(int type) { + if (type == 1) { + return Container( + width: 86.w, + height: 26.w, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(4.w), + ), + gradient: LinearGradient( + begin: FractionalOffset.centerLeft, + end: FractionalOffset.centerRight, + colors: [Color(0xFFEC5329), Color(0xFFF58123)], + ), + ), + child: Text( + '京东自营', + style: TextStyle(fontSize: 18.sp, color: kForeGroundColor), + ), + ); + } else if (type == 2) { + return Container( + alignment: Alignment.center, + width: 86.w, + height: 30.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(4.w), + ), + gradient: LinearGradient( + begin: FractionalOffset.centerLeft, + end: FractionalOffset.centerRight, + colors: [Color(0xFFF59B1C), Color(0xFFF5AF16)], + ), + ), + child: Text( + '京东POP', + style: TextStyle(fontSize: 18.sp, color: kForeGroundColor), + ), + ); + } else + return SizedBox(); + } + +}