添加drawer

null_safety
小赖 4 years ago
parent a37be431e1
commit acbc775c06

@ -1,5 +1,6 @@
import 'package:ansu_ui/ansu_ui.dart'; import 'package:ansu_ui/ansu_ui.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart';
class ExampleScaffold extends StatefulWidget { class ExampleScaffold extends StatefulWidget {
ExampleScaffold({Key key}) : super(key: key); ExampleScaffold({Key key}) : super(key: key);
@ -26,12 +27,29 @@ class _ExampleScaffoldState extends State<ExampleScaffold>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ASScaffold( return ASScaffold(
title: '标题', title: '标题 SCaffold',
appBarBottom: ASTabBar( appBarBottom: ASTabBar(
items: tabs, items: tabs,
isScrollable: true, isScrollable: true,
controller: _tabController, controller: _tabController,
), ),
endDrawer: ASDrawer(
child: Text('DRAWER'),
),
body: ListView(
children: [
Builder(
builder: (context) {
return TextButton(
onPressed: () {
Scaffold.of(context).openEndDrawer();
},
child: Text('open drawer'),
);
},
)
],
),
); );
} }
} }

@ -3,7 +3,9 @@ library ansu_ui;
export 'buttons/as_button.dart'; export 'buttons/as_button.dart';
export 'scaffold/as_scaffold.dart'; export 'scaffold/as_scaffold.dart';
export 'styles/as_colors.dart'; export 'styles/as_colors.dart';
export 'tabbar/as_tabbar.dart'; export 'bar/as_tabbar.dart';
export 'drawer/as_drawer.dart';
export 'utils/screen_adapter.dart';
//`BOTTOM` is external lib //`BOTTOM` is external lib
export 'package:flutter_screenutil/flutter_screenutil.dart'; export 'package:flutter_screenutil/flutter_screenutil.dart';

@ -1,5 +1,5 @@
import 'package:ansu_ui/styles/as_colors.dart'; import 'package:ansu_ui/styles/as_colors.dart';
import 'package:ansu_ui/tabbar/as_tab_indicator.dart'; import 'package:ansu_ui/bar/as_tab_indicator.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
/// ## Tabbar /// ## Tabbar

@ -0,0 +1,34 @@
import 'package:ansu_ui/utils/screen_adapter.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
///
class ASDrawer extends StatefulWidget {
///
final Widget child;
ASDrawer({Key key, @required this.child}) : super(key: key);
@override
_ASDrawerState createState() => _ASDrawerState();
}
class _ASDrawerState extends State<ASDrawer> {
@override
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: widget.child,
),
),
);
}
}

@ -25,6 +25,11 @@ class ASScaffold extends StatefulWidget {
/// `AppBar` appBarBottom /// `AppBar` appBarBottom
final PreferredSizeWidget appBarBottom; final PreferredSizeWidget appBarBottom;
/// `EndDrawer` endDrawer
///
///
final Widget endDrawer;
ASScaffold({ ASScaffold({
Key key, Key key,
@required this.title, @required this.title,
@ -32,6 +37,7 @@ class ASScaffold extends StatefulWidget {
this.body, this.body,
this.bottomNavigationBar, this.bottomNavigationBar,
this.appBarBottom, this.appBarBottom,
this.endDrawer,
}) : super(key: key); }) : super(key: key);
@override @override
@ -42,6 +48,7 @@ class _ASScaffoldState extends State<ASScaffold> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
endDrawer: widget.endDrawer,
backgroundColor: kBackgroundColor, backgroundColor: kBackgroundColor,
bottomNavigationBar: widget.bottomNavigationBar, bottomNavigationBar: widget.bottomNavigationBar,
appBar: AppBar( appBar: AppBar(

@ -0,0 +1,5 @@
import 'package:ansu_ui/ansu_ui.dart';
double statusBarHeight = ScreenUtil().statusBarHeight;
double screenHeight = ScreenUtil().screenHeight;
double screenWidth = ScreenUtil().screenWidth;
Loading…
Cancel
Save