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, ), ), );