update drawer

update example
update docs
null_safety
小赖 4 years ago
parent ca7a004c1b
commit df8a05c694

@ -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<ExampleDrawer> {
@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();
},
);
},
),
),
);
}
}

@ -26,14 +26,16 @@ class _ExampleScaffoldState extends State<ExampleScaffold>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ASScaffold( return ASScaffold(
title: '标题 Scaffold', title: '框架 Scaffold',
appBarBottom: ASTabBar( appBarBottom: ASTabBar(
items: tabs, items: tabs,
isScrollable: true, isScrollable: true,
controller: _tabController, controller: _tabController,
), ),
endDrawer: ASDrawer( endDrawer: ASDrawer(
child: Text('DRAWER'), children: [
Text('DRAWER'),
],
), ),
body: ListView( body: ListView(
children: [ children: [

@ -32,7 +32,7 @@ class _ExampleTabBarState extends State<ExampleTabBar>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ASScaffold( return ASScaffold(
title: 'TabBar', title: '选项卡 TabBar',
appBarBottom: PreferredSize( appBarBottom: PreferredSize(
child: Column( child: Column(
children: [ children: [

@ -1,5 +1,6 @@
import 'package:ansu_ui/ansu_ui.dart'; import 'package:ansu_ui/ansu_ui.dart';
import 'package:example/example_bottom_button.dart'; import 'package:example/example_bottom_button.dart';
import 'package:example/example_drawer.dart';
import 'package:example/example_tag.dart'; import 'package:example/example_tag.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
@ -66,9 +67,9 @@ class _MyHomePageState extends State<MyHomePage> {
ASButton.info( ASButton.info(
title: '按钮 Button', onPressed: () => Get.to(ExampleButton())), title: '按钮 Button', onPressed: () => Get.to(ExampleButton())),
ASButton.info( ASButton.info(
title: 'Scaffold', onPressed: () => Get.to(ExampleScaffold())), title: '框架 Scaffold', onPressed: () => Get.to(ExampleScaffold())),
ASButton.info( ASButton.info(
title: 'Tabbar', onPressed: () => Get.to(ExampleTabBar())), title: '选项卡 Tabbar', onPressed: () => Get.to(ExampleTabBar())),
ASButton.info( ASButton.info(
title: '数量选择器NumericButton', title: '数量选择器NumericButton',
onPressed: () => Get.to(ExampleNumericButton())), onPressed: () => Get.to(ExampleNumericButton())),
@ -78,7 +79,14 @@ class _MyHomePageState extends State<MyHomePage> {
title: '底部按钮 BottomButton', title: '底部按钮 BottomButton',
onPressed: () => Get.to(ExampleBottomButton()), 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()),
),
], ],
), ),
); );

@ -4,9 +4,54 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
/// ///
class ASDrawer extends StatefulWidget { class ASDrawer extends StatefulWidget {
///List Children
///
///ListView
final List<Widget> 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; 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 @override
_ASDrawerState createState() => _ASDrawerState(); _ASDrawerState createState() => _ASDrawerState();
@ -17,16 +62,28 @@ class _ASDrawerState extends State<ASDrawer> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Align( return Align(
alignment: Alignment.bottomRight, alignment: Alignment.bottomRight,
child: ClipRRect(
borderRadius: BorderRadius.only(topLeft: Radius.circular(34.w)),
child: SizedBox( child: SizedBox(
height: screenHeight - statusBarHeight, height: screenHeight - statusBarHeight,
width: screenWidth - 44.w, width: screenWidth - 44.w,
child: Material( child: Material(
shape: RoundedRectangleBorder( child: widget.child ??
borderRadius: BorderRadius.only( Stack(
topLeft: Radius.circular(34.w), 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,
), ),
), ),
); );

Loading…
Cancel
Save