From ca7a004c1b70189301cd040a6d2cb46fdad74e22 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Wed, 25 Nov 2020 09:22:09 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=8C=89=E9=92=AE=E6=B7=BB=E5=8A=A0splash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/lib/example_button.dart | 14 ++++----- lib/buttons/as_button.dart | 51 ++++++++++++++++++++------------- lib/styles/as_colors.dart | 3 ++ 3 files changed, 41 insertions(+), 27 deletions(-) diff --git a/example/lib/example_button.dart b/example/lib/example_button.dart index 1687eb2..8db99bf 100644 --- a/example/lib/example_button.dart +++ b/example/lib/example_button.dart @@ -16,20 +16,20 @@ class _ExampleButtonState extends State { title: 'Button', body: ListView( children: [ - ASButton.delete( - title: '删除订单', + ASButton.danger( + title: '危险按钮', onPressed: () {}, ), ASButton.info( - title: '删除订单', + title: '提示按钮', onPressed: () {}, ), ASButton.warn( - title: '删除订单', + title: '警告按钮', onPressed: () {}, ), - ASButton.opration( - title: '删除订单', + ASButton.operation( + title: '操作按钮', onPressed: () {}, ), SizedBox(height: 12.w), @@ -51,7 +51,7 @@ class _ExampleButtonState extends State { title: '支付', onPressed: () {}, ), - ASButton.delete( + ASButton.danger( title: '删除', onPressed: () {}, ), diff --git a/lib/buttons/as_button.dart b/lib/buttons/as_button.dart index 3c0d252..1aeba66 100644 --- a/lib/buttons/as_button.dart +++ b/lib/buttons/as_button.dart @@ -1,3 +1,4 @@ +import 'package:ansu_ui/styles/as_colors.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -40,6 +41,8 @@ class ASButton extends StatefulWidget { ///不可点击时文字颜色 final Color disableTextColor; + + final Color splashColor; ASButton({ Key key, this.bgcolor, @@ -54,22 +57,24 @@ class ASButton extends StatefulWidget { this.width, this.disableColor, this.disableTextColor, + this.splashColor, }) : super(key: key); - ASButton.warn( - {Key key, - this.textStyle, - this.padding, - this.radius, - this.bgcolor, - this.onPressed, - @required this.title, - this.width, - this.disableColor, - this.disableTextColor}) - : outline = true, - outlineColor = Color(0xFFE50112), - textColor = Color(0xFFE50112), + ASButton.danger({ + Key key, + this.textStyle, + this.padding, + this.radius, + this.bgcolor, + this.onPressed, + @required this.title, + this.width, + this.disableColor, + this.disableTextColor, + }) : outline = true, + outlineColor = kDangerColor, + textColor = kDangerColor, + splashColor = kDangerColor.withOpacity(0.2), super(key: key); ASButton.info( @@ -82,13 +87,14 @@ class ASButton extends StatefulWidget { this.onPressed, this.width, this.disableColor, - this.disableTextColor}) + this.disableTextColor, + this.splashColor}) : outline = true, outlineColor = Color(0x73000000), textColor = Color(0xD9000000), super(key: key); - ASButton.delete( + ASButton.warn( {Key key, this.radius, this.outlineColor, @@ -98,12 +104,13 @@ class ASButton extends StatefulWidget { this.onPressed, this.width, this.disableColor, - this.disableTextColor}) + this.disableTextColor, + this.splashColor}) : bgcolor = Color(0xFFFFB600), textColor = Color(0xD9FFFFFF), outline = false, super(key: key); - ASButton.opration( + ASButton.operation( {Key key, this.radius, this.outlineColor, @@ -113,7 +120,8 @@ class ASButton extends StatefulWidget { this.onPressed, this.width, this.disableColor, - this.disableTextColor}) + this.disableTextColor, + this.splashColor}) : bgcolor = Color(0xFFF2F2F2), textColor = Color(0xD9000000), outline = false, @@ -124,6 +132,7 @@ class ASButton extends StatefulWidget { this.onPressed, this.outlineColor, this.width, + this.splashColor, }) : bgcolor = Color(0xFFFFBD32), textColor = Color(0xFF0000000), textStyle = TextStyle(fontSize: 14.sp, fontWeight: FontWeight.bold), @@ -158,7 +167,9 @@ class _ASButtonState extends State { ? BorderSide(color: widget.outlineColor, width: 0.5.w) : BorderSide.none, borderRadius: BorderRadius.circular(widget.radius ?? 15.5.w)), - color: widget.bgcolor ?? Color(0xFFFFFFFF), + color: widget.bgcolor ?? kForegroundColor, + splashColor: widget.splashColor, + highlightColor: widget.splashColor, elevation: 0, focusElevation: 0, highlightElevation: 0, diff --git a/lib/styles/as_colors.dart b/lib/styles/as_colors.dart index a287086..2b7c412 100644 --- a/lib/styles/as_colors.dart +++ b/lib/styles/as_colors.dart @@ -17,3 +17,6 @@ const Color kForegroundColor = Color(0xFFFFFFFF); ///背景色 const Color kBackgroundColor = Color(0xFFF6F6F6); + +///危险色 +const Color kDangerColor = Color(0xFFE50112); From df8a05c694323c3bb1642b968bce64ce185b0067 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Wed, 25 Nov 2020 09:47:43 +0800 Subject: [PATCH 2/4] update drawer update example update docs --- example/lib/example_drawer.dart | 39 ++++++++++++++++ example/lib/example_scaffold.dart | 6 ++- example/lib/example_tab_bar.dart | 2 +- example/lib/main.dart | 14 ++++-- lib/drawer/as_drawer.dart | 77 +++++++++++++++++++++++++++---- 5 files changed, 122 insertions(+), 16 deletions(-) create mode 100644 example/lib/example_drawer.dart diff --git a/example/lib/example_drawer.dart b/example/lib/example_drawer.dart new file mode 100644 index 0000000..517ad8d --- /dev/null +++ b/example/lib/example_drawer.dart @@ -0,0 +1,39 @@ +import 'package:ansu_ui/ansu_ui.dart'; +import 'package:flutter/material.dart'; + +class ExampleDrawer extends StatefulWidget { + ExampleDrawer({Key key}) : super(key: key); + + @override + _ExampleDrawerState createState() => _ExampleDrawerState(); +} + +class _ExampleDrawerState extends State { + @override + Widget build(BuildContext context) { + return ASScaffold( + title: 'Drawer', + endDrawer: ASDrawer( + children: [ + Text('title'), + ], + bottom: ASLongButton.solid( + title: '确定', + onPressed: () {}, + ), + ), + body: Center( + child: Builder( + builder: (context) { + return ASLongButton.solid( + title: 'DRAWER', + onPressed: () { + Scaffold.of(context).openEndDrawer(); + }, + ); + }, + ), + ), + ); + } +} diff --git a/example/lib/example_scaffold.dart b/example/lib/example_scaffold.dart index 9554bb9..70d1fca 100644 --- a/example/lib/example_scaffold.dart +++ b/example/lib/example_scaffold.dart @@ -26,14 +26,16 @@ class _ExampleScaffoldState extends State @override Widget build(BuildContext context) { return ASScaffold( - title: '标题 Scaffold', + title: '框架 Scaffold', appBarBottom: ASTabBar( items: tabs, isScrollable: true, controller: _tabController, ), endDrawer: ASDrawer( - child: Text('DRAWER'), + children: [ + Text('DRAWER'), + ], ), body: ListView( children: [ diff --git a/example/lib/example_tab_bar.dart b/example/lib/example_tab_bar.dart index 6df6cab..18aabd6 100644 --- a/example/lib/example_tab_bar.dart +++ b/example/lib/example_tab_bar.dart @@ -32,7 +32,7 @@ class _ExampleTabBarState extends State @override Widget build(BuildContext context) { return ASScaffold( - title: 'TabBar', + title: '选项卡 TabBar', appBarBottom: PreferredSize( child: Column( children: [ diff --git a/example/lib/main.dart b/example/lib/main.dart index e2b209f..2f64b85 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,5 +1,6 @@ import 'package:ansu_ui/ansu_ui.dart'; import 'package:example/example_bottom_button.dart'; +import 'package:example/example_drawer.dart'; import 'package:example/example_tag.dart'; import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; @@ -66,9 +67,9 @@ class _MyHomePageState extends State { ASButton.info( title: '按钮 Button', onPressed: () => Get.to(ExampleButton())), ASButton.info( - title: 'Scaffold', onPressed: () => Get.to(ExampleScaffold())), + title: '框架 Scaffold', onPressed: () => Get.to(ExampleScaffold())), ASButton.info( - title: 'Tabbar', onPressed: () => Get.to(ExampleTabBar())), + title: '选项卡 Tabbar', onPressed: () => Get.to(ExampleTabBar())), ASButton.info( title: '数量选择器NumericButton', onPressed: () => Get.to(ExampleNumericButton())), @@ -78,7 +79,14 @@ class _MyHomePageState extends State { title: '底部按钮 BottomButton', onPressed: () => Get.to(ExampleBottomButton()), ), - ASButton.info(title: '标签 TAG',onPressed: () => Get.to(ExampleTag()),), + ASButton.info( + title: '标签 TAG', + onPressed: () => Get.to(ExampleTag()), + ), + ASButton.info( + title: '抽屉 DRAWER', + onPressed: () => Get.to(ExampleDrawer()), + ), ], ), ); diff --git a/lib/drawer/as_drawer.dart b/lib/drawer/as_drawer.dart index cdb0f1b..740df5d 100644 --- a/lib/drawer/as_drawer.dart +++ b/lib/drawer/as_drawer.dart @@ -4,9 +4,54 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; ///安速抽屉 class ASDrawer extends StatefulWidget { + ///子组件List Children + /// + ///内部为ListView实现 + final List children; + + ///Padding + /// + ///默认Padding `EdgeInsets.fromLTRB(26.w, 24.w, 26.w, 90.w)` + final EdgeInsets padding; + + ///底部操作空间 + /// + ///默认 + ///```dart + ///bottom: 45.w, + ///left: 26.w, + ///right: 26.w, + ///``` + final Widget bottom; + ///子组件 + /// + ///使用该选项,`bottom`、`padding`、`children`将失效 final Widget child; - ASDrawer({Key key, @required this.child}) : super(key: key); + + ///默认抽屉 + /// + ///默认Padding `EdgeInsets.fromLTRB(26.w, 24.w, 26.w, 90.w)` + ASDrawer({ + Key key, + this.children, + this.bottom, + this.child, + }) : this.padding = EdgeInsets.fromLTRB(26.w, 24.w, 26.w, 90.w), + assert(child != null || children != null, + 'child or children cant be null'), + super(key: key); + + ///自定义Padding + ASDrawer.padding({ + Key key, + this.padding = EdgeInsets.zero, + this.children, + this.child, + this.bottom, + }) : assert(child != null || children != null, + 'child or children cant be null'), + super(key: key); @override _ASDrawerState createState() => _ASDrawerState(); @@ -17,16 +62,28 @@ class _ASDrawerState extends State { Widget build(BuildContext context) { return Align( alignment: Alignment.bottomRight, - child: SizedBox( - height: screenHeight - statusBarHeight, - width: screenWidth - 44.w, - child: Material( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(34.w), - ), + child: ClipRRect( + borderRadius: BorderRadius.only(topLeft: Radius.circular(34.w)), + child: SizedBox( + height: screenHeight - statusBarHeight, + width: screenWidth - 44.w, + child: Material( + child: widget.child ?? + Stack( + children: [ + ListView( + padding: widget.padding, + children: widget.children, + ), + Positioned( + child: widget.bottom ?? SizedBox(), + bottom: 45.w, + left: 26.w, + right: 26.w, + ), + ], + ), ), - child: widget.child, ), ), ); From 2b8b67dfeb2852e711c8e91694dc92db2ba49d01 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Wed, 25 Nov 2020 09:53:16 +0800 Subject: [PATCH 3/4] add get support --- README.md | 3 ++- example/lib/main.dart | 6 ++++++ lib/buttons/as_back_button.dart | 3 ++- lib/scaffold/as_scaffold.dart | 4 ++-- pubspec.lock | 9 ++++++++- pubspec.yaml | 1 + 6 files changed, 21 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e34d124..803865a 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ # ansu_ui 安速物流移动组件 -## dep +## dep 依赖 ![flutter_screenutil](https://img.shields.io/badge/flutter__screenutil-3.2.0-brightgreen) +![get](https://img.shields.io/badge/get-3.17.1-brightgreen) ## Getting Started diff --git a/example/lib/main.dart b/example/lib/main.dart index 2f64b85..d077444 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -55,6 +55,12 @@ class _MyHomePageState extends State { @override Widget build(BuildContext context) { return ASScaffold( + leading: navigator.canPop() + ? IconButton( + icon: Icon(Icons.backpack, color: Colors.black), + onPressed: () {}, + ) + : SizedBox(), title: '安速组件', body: ListView( padding: EdgeInsets.all(16.w), diff --git a/lib/buttons/as_back_button.dart b/lib/buttons/as_back_button.dart index 91208c7..388f2a1 100644 --- a/lib/buttons/as_back_button.dart +++ b/lib/buttons/as_back_button.dart @@ -1,6 +1,7 @@ import 'package:ansu_ui/ansu_ui.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:get/get.dart'; ///安速返回按钮 /// @@ -17,7 +18,7 @@ class ASBackButton extends StatelessWidget { @override Widget build(BuildContext context) { - return Navigator.canPop(context) + return navigator.canPop() ? IconButton( icon: Icon( CupertinoIcons.chevron_back, diff --git a/lib/scaffold/as_scaffold.dart b/lib/scaffold/as_scaffold.dart index 2bca3e9..d39f659 100644 --- a/lib/scaffold/as_scaffold.dart +++ b/lib/scaffold/as_scaffold.dart @@ -27,7 +27,7 @@ class ASScaffold extends StatefulWidget { final PreferredSizeWidget appBarBottom; /// `EndDrawer` endDrawer - /// + /// /// 右方向的抽屉 final Widget endDrawer; ASScaffold({ @@ -54,7 +54,7 @@ class _ASScaffoldState extends State { appBar: AppBar( backgroundColor: kForegroundColor, elevation: 0, - leading: ASBackButton(), + leading: widget.leading ?? ASBackButton(), centerTitle: true, title: DefaultTextStyle( style: TextStyle( diff --git a/pubspec.lock b/pubspec.lock index 708b7b9..3d511dc 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -67,6 +67,13 @@ packages: description: flutter source: sdk version: "0.0.0" + get: + dependency: "direct main" + description: + name: get + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.17.1" matcher: dependency: transitive description: @@ -150,5 +157,5 @@ packages: source: hosted version: "2.1.0-nullsafety.3" sdks: - dart: ">=2.10.0-110 <2.11.0" + dart: ">=2.10.0 <2.11.0" flutter: ">=1.17.0" diff --git a/pubspec.yaml b/pubspec.yaml index aa9dcf8..abe0607 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,6 +11,7 @@ dependencies: flutter: sdk: flutter flutter_screenutil: ^3.2.0 + get: ^3.17.1 dev_dependencies: flutter_test: From fbe602c85f817b645d608ee59c5b0bcc9306e0e6 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Wed, 25 Nov 2020 10:01:52 +0800 Subject: [PATCH 4/4] update color --- example/lib/example_style_color.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/example/lib/example_style_color.dart b/example/lib/example_style_color.dart index 5edc661..059ca73 100644 --- a/example/lib/example_style_color.dart +++ b/example/lib/example_style_color.dart @@ -15,6 +15,14 @@ class _ExampleStyleColorState extends State { children: [ Text(object.name), Text(object.codeName), + Text( + object.color.toString(), + style: TextStyle( + color: object.color, + backgroundColor: + object.color.value > 0xFFAAAAAA ? Colors.black : Colors.white, + ), + ), Card( color: object.color, child: SizedBox(height: 50.w, width: double.infinity),