From 23e9551f510a8e7885000433fc8cf1d8994887ce Mon Sep 17 00:00:00 2001 From: laiiihz Date: Fri, 7 May 2021 10:48:30 +0800 Subject: [PATCH] update goods page --- lib/constants/api.dart | 2 +- lib/constants/app_theme.dart | 3 + lib/ui/market/_market_data.dart | 24 ++++-- lib/ui/market/category/category_page.dart | 9 ++- lib/ui/market/goods/goods_card.dart | 92 +++++++++++++++++++++++ lib/ui/market/goods/goods_list_view.dart | 86 +++++++++++++++++++++ lib/widget/bee_scaffold.dart | 11 ++- macos/Podfile.lock | 12 +++ pubspec.lock | 14 ++++ pubspec.yaml | 1 + 10 files changed, 244 insertions(+), 10 deletions(-) create mode 100644 lib/ui/market/goods/goods_card.dart create mode 100644 lib/ui/market/goods/goods_list_view.dart diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 05b4e2d7..df5bd990 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -1,6 +1,6 @@ class API { ///HOST - static const String host = 'http://test.akuhotel.com:8804'; + static const String host = 'http://test.kaidalai.cn'; ///接口基础地址 static const String baseURL = '$host/IntelligentCommunity/app'; diff --git a/lib/constants/app_theme.dart b/lib/constants/app_theme.dart index 313af275..3f39232a 100644 --- a/lib/constants/app_theme.dart +++ b/lib/constants/app_theme.dart @@ -34,6 +34,9 @@ class AppTheme { elevation: 0, centerTitle: true, brightness: Brightness.light, + iconTheme: IconThemeData( + color: Color(0xFF333333), + ), textTheme: TextTheme( headline6: TextStyle( color: Color(0xFF333333), diff --git a/lib/ui/market/_market_data.dart b/lib/ui/market/_market_data.dart index 1805052e..52604cf1 100644 --- a/lib/ui/market/_market_data.dart +++ b/lib/ui/market/_market_data.dart @@ -1,10 +1,12 @@ +import 'package:aku_community/ui/market/goods/goods_card.dart'; +import 'package:aku_community/ui/market/goods/goods_list_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:get/get.dart'; import 'package:aku_community/utils/headers.dart'; -import 'package:aku_community/widget/bee_scaffold.dart'; +import 'package:waterfall_flow/waterfall_flow.dart'; @Deprecated('NO NEED THIS CLASS IN FUTURE') class MarketData { @@ -57,9 +59,7 @@ class MockableMarketWidget extends StatelessWidget { ), onPressed: () { Get.to( - () => BeeScaffold( - title: data.name, - ), + () => GoodsListView(), ); }, ); @@ -80,7 +80,21 @@ class _MockableMarketListState extends State { return EasyRefresh( header: MaterialHeader(completeDuration: Duration(milliseconds: 300)), onRefresh: () async {}, - child: ListView(), + child: WaterfallFlow( + padding: EdgeInsets.all(32.w), + gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + mainAxisSpacing: 20.w, + crossAxisSpacing: 20.w, + ), + children: [ + GoodsCard(), + GoodsCard(), + GoodsCard(), + GoodsCard(), + GoodsCard(), + ], + ), ); } } diff --git a/lib/ui/market/category/category_page.dart b/lib/ui/market/category/category_page.dart index 6e98ee2e..9983c5da 100644 --- a/lib/ui/market/category/category_page.dart +++ b/lib/ui/market/category/category_page.dart @@ -1,4 +1,5 @@ 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'; @@ -15,7 +16,13 @@ class _CategoryPageState extends State { @override Widget build(BuildContext context) { return BeeScaffold( - title: '', + title: '分类', + actions: [ + IconButton( + icon: Icon(CupertinoIcons.search), + onPressed: () {}, + ), + ], bgColor: Colors.white, appBarBottom: PreferredSize( child: Divider(height: 1), diff --git a/lib/ui/market/goods/goods_card.dart b/lib/ui/market/goods/goods_card.dart new file mode 100644 index 00000000..b6f022b5 --- /dev/null +++ b/lib/ui/market/goods/goods_card.dart @@ -0,0 +1,92 @@ +import 'package:aku_community/base/base_style.dart'; +import 'package:flutter/material.dart'; +import 'package:aku_community/utils/headers.dart'; + +class GoodsCard extends StatelessWidget { + const GoodsCard({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return MaterialButton( + color: Colors.white, + elevation: 0, + padding: EdgeInsets.zero, + onPressed: () {}, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AspectRatio( + aspectRatio: 1, + child: Stack( + children: [ + Image.asset( + R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + fit: BoxFit.cover, + ), + Positioned( + left: 0, + right: 0, + bottom: 0, + child: Container( + height: 38.w, + color: Colors.black54, + alignment: Alignment.centerLeft, + padding: EdgeInsets.symmetric(horizontal: 12.w), + child: Text( + '分别是紫色烦恼则妇女色泽封闭周四鹅u部分紫色部分', + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: Colors.white, + fontSize: 18.sp, + ), + ), + ), + ), + ], + ), + ), + Padding( + padding: EdgeInsets.symmetric( + horizontal: 12.w, + vertical: 20.w, + ), + child: Text( + '袁隆平水稻大米精选 56kg唇齿流香 无常有机稻花 无常有机稻花', + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 24.sp, + ), + ), + ), + Padding( + padding: EdgeInsets.symmetric( + horizontal: 12.w, + ), + child: RichText( + text: TextSpan( + children: [ + TextSpan( + text: '¥123.45 ', + style: TextStyle( + color: Colors.red, + fontSize: 28.sp, + ), + ), + TextSpan( + text: '123已付款', + style: TextStyle( + color: ktextSubColor, + fontSize: 20.sp, + ), + ), + ], + ), + ), + ), + 16.hb, + ], + ), + ); + } +} diff --git a/lib/ui/market/goods/goods_list_view.dart b/lib/ui/market/goods/goods_list_view.dart new file mode 100644 index 00000000..cd7c342d --- /dev/null +++ b/lib/ui/market/goods/goods_list_view.dart @@ -0,0 +1,86 @@ +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'; + +class GoodsListView extends StatefulWidget { + GoodsListView({Key? key}) : super(key: key); + + @override + _GoodsListViewState createState() => _GoodsListViewState(); +} + +class _GoodsListViewState extends State { + @override + Widget build(BuildContext context) { + return BeeScaffold( + title: 'TEST', + actions: [ + IconButton( + icon: Icon(CupertinoIcons.search), + onPressed: () {}, + ) + ], + appBarBottom: PreferredSize( + child: SizedBox( + height: 220.w, + child: ListView( + padding: EdgeInsets.symmetric(horizontal: 18.w), + scrollDirection: Axis.horizontal, + children: [ + GoodsSubTypeButton(), + ], + ), + ), + preferredSize: Size.fromHeight(220.w), + ), + body: WaterfallFlow( + padding: EdgeInsets.all(32.w), + gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + mainAxisSpacing: 20.w, + crossAxisSpacing: 20.w, + ), + children: [ + GoodsCard(), + GoodsCard(), + GoodsCard(), + GoodsCard(), + GoodsCard(), + ], + ), + ); + } +} + +class GoodsSubTypeButton extends StatelessWidget { + const GoodsSubTypeButton({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return MaterialButton( + minWidth: 136.w, + padding: EdgeInsets.zero, + onPressed: () {}, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + width: 100.w, + height: 100.w, + ), + 20.hb, + Text( + '健康运动', + style: TextStyle( + fontSize: 24.sp, + ), + ), + ], + ), + ); + } +} diff --git a/lib/widget/bee_scaffold.dart b/lib/widget/bee_scaffold.dart index c65dad38..1df5daba 100644 --- a/lib/widget/bee_scaffold.dart +++ b/lib/widget/bee_scaffold.dart @@ -1,8 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:velocity_x/velocity_x.dart'; - import 'package:aku_community/constants/app_theme.dart'; import 'package:aku_community/widget/bee_back_button.dart'; @@ -51,13 +49,20 @@ class BeeScaffold extends StatelessWidget { }) : this.bodyColor = Colors.white, super(key: key); + Widget? get _titleWidget { + if (title == null) return null; + if (title is String) return Text(title!); + if (title is Widget) return title as Widget; + return null; + } + @override Widget build(BuildContext context) { Widget? appBar; if (title != null) appBar = AppBar( backgroundColor: bgColor, - title: title!.text.make(), + title: _titleWidget, leading: leading ?? BeeBackButton(), actions: actions, bottom: appBarBottom, diff --git a/macos/Podfile.lock b/macos/Podfile.lock index 11022e25..93516674 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -1,4 +1,6 @@ PODS: + - device_info_plus_macos (0.0.1): + - FlutterMacOS - Firebase/CoreOnly (7.11.0): - FirebaseCore (= 7.11.0) - Firebase/Crashlytics (7.11.0): @@ -50,6 +52,8 @@ PODS: - nanopb/encode (2.30908.0) - package_info (0.0.1): - FlutterMacOS + - package_info_plus_macos (0.0.1): + - FlutterMacOS - path_provider_macos (0.0.1): - FlutterMacOS - PromisesObjC (1.2.12) @@ -59,10 +63,12 @@ PODS: - FlutterMacOS DEPENDENCIES: + - device_info_plus_macos (from `Flutter/ephemeral/.symlinks/plugins/device_info_plus_macos/macos`) - firebase_core (from `Flutter/ephemeral/.symlinks/plugins/firebase_core/macos`) - firebase_crashlytics (from `Flutter/ephemeral/.symlinks/plugins/firebase_crashlytics/macos`) - FlutterMacOS (from `Flutter/ephemeral`) - package_info (from `Flutter/ephemeral/.symlinks/plugins/package_info/macos`) + - package_info_plus_macos (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus_macos/macos`) - path_provider_macos (from `Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos`) - shared_preferences_macos (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_macos/macos`) - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) @@ -80,6 +86,8 @@ SPEC REPOS: - PromisesObjC EXTERNAL SOURCES: + device_info_plus_macos: + :path: Flutter/ephemeral/.symlinks/plugins/device_info_plus_macos/macos firebase_core: :path: Flutter/ephemeral/.symlinks/plugins/firebase_core/macos firebase_crashlytics: @@ -88,6 +96,8 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral package_info: :path: Flutter/ephemeral/.symlinks/plugins/package_info/macos + package_info_plus_macos: + :path: Flutter/ephemeral/.symlinks/plugins/package_info_plus_macos/macos path_provider_macos: :path: Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos shared_preferences_macos: @@ -96,6 +106,7 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos SPEC CHECKSUMS: + device_info_plus_macos: 1ad388a1ef433505c4038e7dd9605aadd1e2e9c7 Firebase: c121feb35e4126c0b355e3313fa9b487d47319fd firebase_core: 9e45a9c5ba9dbcb8973b3a68e6ff43ecf2dcf206 firebase_crashlytics: 4ab08e6b22a4f6ec909cc1f0a046eac2d1b2925c @@ -108,6 +119,7 @@ SPEC CHECKSUMS: GoogleUtilities: 284cddc7fffc14ae1907efb6f78ab95c1fccaedc nanopb: a0ba3315591a9ae0a16a309ee504766e90db0c96 package_info: 6eba2fd8d3371dda2d85c8db6fe97488f24b74b2 + package_info_plus_macos: f010621b07802a241d96d01876d6705f15e77c1c path_provider_macos: a0a3fd666cb7cd0448e936fb4abad4052961002b PromisesObjC: 3113f7f76903778cf4a0586bd1ab89329a0b7b97 shared_preferences_macos: 480ce071d0666e37cef23fe6c702293a3d21799e diff --git a/pubspec.lock b/pubspec.lock index adbff0d0..e3bbbfb4 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -302,6 +302,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "4.0.0" + extended_list_library: + dependency: transitive + description: + name: extended_list_library + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.0" fake_async: dependency: transitive description: @@ -1124,6 +1131,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.0.0" + waterfall_flow: + dependency: "direct main" + description: + name: waterfall_flow + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.1" web_socket_channel: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index c33f45f9..55203378 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -66,6 +66,7 @@ dependencies: share: ^2.0.1 collection: ^1.15.0 json_annotation: ^4.0.1 + waterfall_flow: ^3.0.1 dev_dependencies: flutter_test: