From c23e186969988d860d3043759f2f6d01de9b8eef Mon Sep 17 00:00:00 2001 From: laiiihz Date: Sat, 8 May 2021 10:25:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=95=86=E5=93=81=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ui/market/market_page.dart | 8 ++ lib/ui/market/search/search_goods_page.dart | 146 ++++++++++++++++++++ lib/widget/bee_scaffold.dart | 2 +- 3 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 lib/ui/market/search/search_goods_page.dart diff --git a/lib/ui/market/market_page.dart b/lib/ui/market/market_page.dart index 4f158f9f..ca21b32f 100644 --- a/lib/ui/market/market_page.dart +++ b/lib/ui/market/market_page.dart @@ -1,3 +1,5 @@ +import 'package:aku_community/ui/market/search/search_goods_page.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -30,6 +32,12 @@ class _MarketPageState extends State super.build(context); final mediaWidth = MediaQuery.of(context).size.width; return BeeScaffold( + leading: IconButton( + icon: Icon(CupertinoIcons.search), + onPressed: () { + Get.to(() => SearchGoodsPage()); + }, + ), title: '商城', actions: [ MaterialButton( diff --git a/lib/ui/market/search/search_goods_page.dart b/lib/ui/market/search/search_goods_page.dart new file mode 100644 index 00000000..03c321d5 --- /dev/null +++ b/lib/ui/market/search/search_goods_page.dart @@ -0,0 +1,146 @@ +import 'package:aku_community/base/base_style.dart'; +import 'package:aku_community/ui/market/goods/goods_card.dart'; +import 'package:aku_community/widget/bee_scaffold.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:aku_community/utils/headers.dart'; +import 'package:waterfall_flow/waterfall_flow.dart'; + +enum OrderType { + NORMAL, + SALES, + PRICE_HIGH, + PRICE_LOW, +} + +class SearchGoodsPage extends StatefulWidget { + SearchGoodsPage({Key? key}) : super(key: key); + + @override + SearchGoodsPageState createState() => SearchGoodsPageState(); +} + +class SearchGoodsPageState extends State { + TextEditingController _editingController = TextEditingController(); + OrderType _orderType = OrderType.NORMAL; + IconData priceIcon = CupertinoIcons.chevron_up_chevron_down; + @override + Widget build(BuildContext context) { + final normalTypeButton = MaterialButton( + onPressed: () { + _orderType = OrderType.NORMAL; + priceIcon = CupertinoIcons.chevron_up_chevron_down; + setState(() {}); + }, + child: Text( + '综合', + style: TextStyle( + color: + _orderType == OrderType.NORMAL ? kDarkPrimaryColor : ktextPrimary, + ), + ), + height: 80.w, + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + ); + final salesTypeButton = MaterialButton( + onPressed: () { + _orderType = OrderType.SALES; + priceIcon = CupertinoIcons.chevron_up_chevron_down; + setState(() {}); + }, + child: Text( + '销量', + style: TextStyle( + color: + _orderType == OrderType.SALES ? kDarkPrimaryColor : ktextPrimary, + ), + ), + height: 80.w, + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + ); + + final priceButton = MaterialButton( + onPressed: () { + switch (_orderType) { + case OrderType.NORMAL: + case OrderType.SALES: + _orderType = OrderType.PRICE_HIGH; + priceIcon = CupertinoIcons.chevron_up; + break; + case OrderType.PRICE_HIGH: + _orderType = OrderType.PRICE_LOW; + priceIcon = CupertinoIcons.chevron_down; + break; + case OrderType.PRICE_LOW: + _orderType = OrderType.PRICE_HIGH; + priceIcon = CupertinoIcons.chevron_up; + break; + } + setState(() {}); + }, + child: Row( + children: [ + Text( + '价格', + style: TextStyle( + color: _orderType == OrderType.PRICE_HIGH || + _orderType == OrderType.PRICE_LOW + ? kDarkPrimaryColor + : ktextPrimary, + ), + ), + Icon( + priceIcon, + size: 32.w, + color: _orderType == OrderType.PRICE_HIGH || + _orderType == OrderType.PRICE_LOW + ? kDarkPrimaryColor + : ktextPrimary, + ), + ], + ), + height: 80.w, + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + ); + return BeeScaffold( + title: Padding( + padding: EdgeInsets.symmetric(vertical: 12.w), + child: TextField( + controller: _editingController, + decoration: InputDecoration( + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(40), + ), + filled: true, + fillColor: Color(0xFFF3F3F3), + isDense: true, + prefixIcon: Icon(CupertinoIcons.search), + ), + ), + ), + //TODO 列表排序 + // appBarBottom: PreferredSize( + // child: Row( + // children: [ + // normalTypeButton, + // salesTypeButton, + // priceButton, + // ], + // ), + // preferredSize: Size.fromHeight(80.w), + // ), + body: WaterfallFlow.builder( + padding: EdgeInsets.all(32.w), + gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + mainAxisSpacing: 20.w, + crossAxisSpacing: 20.w, + ), + itemBuilder: (context, index) { + return GoodsCard(); + }, + itemCount: 10, + ), + ); + } +} diff --git a/lib/widget/bee_scaffold.dart b/lib/widget/bee_scaffold.dart index 1df5daba..b4ce21be 100644 --- a/lib/widget/bee_scaffold.dart +++ b/lib/widget/bee_scaffold.dart @@ -5,7 +5,7 @@ import 'package:aku_community/constants/app_theme.dart'; import 'package:aku_community/widget/bee_back_button.dart'; class BeeScaffold extends StatelessWidget { - final String? title; + final dynamic? title; final Widget? body; /// appbar background color