添加drawer

null_safety
小赖 4 years ago
parent a37be431e1
commit acbc775c06

@ -1,5 +1,6 @@
import 'package:ansu_ui/ansu_ui.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class ExampleScaffold extends StatefulWidget {
ExampleScaffold({Key key}) : super(key: key);
@ -26,12 +27,29 @@ class _ExampleScaffoldState extends State<ExampleScaffold>
@override
Widget build(BuildContext context) {
return ASScaffold(
title: '标题',
title: '标题 SCaffold',
appBarBottom: ASTabBar(
items: tabs,
isScrollable: true,
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 'scaffold/as_scaffold.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
export 'package:flutter_screenutil/flutter_screenutil.dart';

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