From f239fb39bb051e8069c20e04926cae3b1f1dfa9b Mon Sep 17 00:00:00 2001 From: NikhilVadoliya Date: Thu, 27 Jan 2022 17:47:59 +0530 Subject: [PATCH] fearture_request#18 : done - Provide customer app support --- lib/src/app_bar.dart | 13 ++++--------- lib/src/helper/slider_app_bar.dart | 12 ++++++++++-- lib/src/slider.dart | 18 ++++++++++-------- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/lib/src/app_bar.dart b/lib/src/app_bar.dart index 868c623..ac73600 100644 --- a/lib/src/app_bar.dart +++ b/lib/src/app_bar.dart @@ -4,10 +4,8 @@ import 'package:flutter_slider_drawer/src/helper/slider_app_bar.dart'; import 'package:flutter_slider_drawer/src/slider_direction.dart'; class SAppBar extends StatelessWidget { - final Widget? drawerIcon; final Color splashColor; - final Color drawerIconColor; - final double drawerIconSize; + final AnimationController animationController; final VoidCallback onTap; final SlideDirection slideDirection; @@ -16,10 +14,7 @@ class SAppBar extends StatelessWidget { const SAppBar( {Key? key, - this.drawerIcon, this.splashColor = Colors.black, - this.drawerIconColor = Colors.black87, - this.drawerIconSize = 27, required this.animationController, required this.onTap, required this.slideDirection, @@ -40,13 +35,13 @@ class SAppBar extends StatelessWidget { List appBar() { List list = [ - drawerIcon ?? + sliderAppBar.drawerIcon ?? IconButton( splashColor: splashColor, icon: AnimatedIcon( icon: AnimatedIcons.menu_close, - color: drawerIconColor, - size: drawerIconSize, + color: sliderAppBar.drawerIconColor, + size: sliderAppBar.drawerIconSize, progress: animationController), onPressed: () => onTap()), Expanded( diff --git a/lib/src/helper/slider_app_bar.dart b/lib/src/helper/slider_app_bar.dart index 46cadf1..f6739c5 100644 --- a/lib/src/helper/slider_app_bar.dart +++ b/lib/src/helper/slider_app_bar.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -class SliderAppBar { +class SliderAppBar extends StatelessWidget { /// [double] you can change appBar height by this parameter [appBarHeight] /// final double appBarHeight; @@ -40,7 +40,10 @@ class SliderAppBar { const SliderAppBar({ this.appBarHeight = 70, - this.title = const Text('AppBar'), + this.title = const Text( + 'AppBar', + style: TextStyle(fontWeight: FontWeight.w500, fontSize: 20), + ), this.isTitleCenter = true, this.appBarColor = Colors.white, this.appBarPadding = const EdgeInsets.only(top: 24), @@ -49,4 +52,9 @@ class SliderAppBar { this.drawerIcon, this.drawerIconSize = 27, }); + + @override + Widget build(BuildContext context) { + return Offstage(); + } } diff --git a/lib/src/slider.dart b/lib/src/slider.dart index 5e09969..0fd17d3 100644 --- a/lib/src/slider.dart +++ b/lib/src/slider.dart @@ -62,7 +62,7 @@ class SliderDrawer extends StatefulWidget { ///[appBar] if you set [null] then it will not display app bar /// - final SliderAppBar? appBar; + final Widget? appBar; /// The primary color of the button when the drawer button is in the down (pressed) state. /// The splash is represented as a circular overlay that appears above the @@ -153,6 +153,10 @@ class SliderDrawerState extends State @override Widget build(BuildContext context) { + Color appBarColor = Colors.white; + if (widget.appBar is SliderAppBar) { + appBarColor = (widget.appBar as SliderAppBar).appBarColor; + } return LayoutBuilder(builder: (context, constrain) { return Container( child: Stack(children: [ @@ -193,20 +197,19 @@ class SliderDrawerState extends State child: Container( width: double.infinity, height: double.infinity, - color: widget.appBar?.appBarColor ?? Colors.transparent, + color: appBarColor, child: Column( children: [ - if (widget.appBar != null) + if (widget.appBar != null && widget.appBar is SliderAppBar) SAppBar( slideDirection: widget.slideDirection, onTap: () => toggle(), animationController: _animationDrawerController!, - drawerIcon: widget.appBar!.drawerIcon, - drawerIconColor: widget.appBar!.drawerIconColor, - drawerIconSize: widget.appBar!.drawerIconSize, splashColor: widget.splashColor, - sliderAppBar: widget.appBar!, + sliderAppBar: widget.appBar as SliderAppBar, ), + if (widget.appBar != null && widget.appBar is! SliderAppBar) + widget.appBar!, Expanded(child: widget.child), ], ), @@ -296,7 +299,6 @@ class SliderDrawerState extends State move(double percent) { _percent = percent; _animationDrawerController!.value = percent; - //_animationDrawerController!.notifyListeners(); } openOrClose() {