diff --git a/README.md b/README.md index 4c41d32..578869e 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ dependencies: - Provide shadow of Main screen with customization of shadow colors,blurRadius and spreadRadius - Provide RTL(RightToLeft),LTR(LeftToRight) and TTB(TopToBottom) slider open selection - Provide Custom Appbar support and you can also use plugin appBar with use of `SliderAppBar` widget + - If you are using CupertinoApp then pass `isCupertino: true` # Code @@ -64,6 +65,8 @@ dependencies:

+ + # Slider open | SliderOpen.LEFT_TO_RIGHT | SliderOpen.RIGHT_TO_LEFT | SliderOpen.TOP_TO_BOTTOM | diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml new file mode 100644 index 0000000..61b6c4d --- /dev/null +++ b/example/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/example/lib/helper/colours.dart b/example/lib/helper/colours.dart new file mode 100644 index 0000000..3f97530 --- /dev/null +++ b/example/lib/helper/colours.dart @@ -0,0 +1,9 @@ +import 'dart:ui'; + +class Colours { + Colours._(); + + static Color blue() => const Color(0xff5e6ceb); + + static Color blueDark() => const Color(0xff4D5DFB); +} diff --git a/example/pubspec.lock b/example/pubspec.lock index 17d1a62..7a806b9 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.9.0" boolean_selector: dependency: transitive description: @@ -21,80 +21,94 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" + version: "1.2.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" cupertino_icons: dependency: "direct main" description: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "1.0.5" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" flutter_slider_drawer: dependency: "direct main" description: path: ".." relative: true source: path - version: "1.2.1" + version: "2.1.1" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10" + version: "0.12.12" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.8.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.2" sky_engine: dependency: transitive description: flutter @@ -106,7 +120,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -127,34 +141,27 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" + version: "0.4.12" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.2" sdks: - dart: ">=2.12.0 <3.0.0" + dart: ">=2.17.6 <3.0.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 83f5a82..03ee617 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -2,7 +2,7 @@ name: example description: A new Flutter project. # The following line prevents the package from being accidentally published to -# pub.dev using `pub publish`. This is preferred for private packages. +# pub.dev using `flutter pub publish`. This is preferred for private packages. publish_to: 'none' # Remove this line if you wish to publish to pub.dev # The following defines the version and build number for your application. @@ -18,29 +18,40 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=2.12.0 <3.0.0' - + sdk: ">=2.17.6 <3.0.0" + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. dependencies: flutter: sdk: flutter - # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^0.1.3 + cupertino_icons: ^1.0.2 flutter_slider_drawer: path: ../ - dev_dependencies: flutter_test: sdk: flutter + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^2.0.0 + # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec -# The following section is specific to Flutter. +# The following section is specific to Flutter packages. flutter: # The following line ensures that the Material Icons font is @@ -49,12 +60,12 @@ flutter: uses-material-design: true # To add assets to your application, add an assets section, like this: - assets: - - assets/images/user_profile.jpg -# - images/a_dot_ham.jpeg + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware. + # https://flutter.dev/assets-and-images/#resolution-aware # For details regarding adding assets from package dependencies, see # https://flutter.dev/assets-and-images/#from-packages diff --git a/lib/src/app_bar.dart b/lib/src/app_bar.dart index 5ec614e..5064abc 100644 --- a/lib/src/app_bar.dart +++ b/lib/src/app_bar.dart @@ -1,7 +1,6 @@ +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_slider_drawer/flutter_slider_drawer.dart'; -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 Color splashColor; @@ -11,14 +10,16 @@ class SAppBar extends StatelessWidget { final SlideDirection slideDirection; final SliderAppBar sliderAppBar; + final bool isCupertino; const SAppBar( {Key? key, - this.splashColor = Colors.black, + this.splashColor = const Color(0xff000000), required this.animationController, required this.onTap, required this.slideDirection, - required this.sliderAppBar}) + required this.sliderAppBar, + this.isCupertino = false}) : super(key: key); @override @@ -36,26 +37,27 @@ class SAppBar extends StatelessWidget { List appBar() { List list = [ - sliderAppBar.drawerIcon ?? - IconButton( - splashColor: splashColor, - icon: AnimatedIcon( - icon: AnimatedIcons.menu_close, - color: sliderAppBar.drawerIconColor, - size: sliderAppBar.drawerIconSize, - progress: animationController), - onPressed: () => onTap()), - Expanded( - child: sliderAppBar.isTitleCenter - ? Center( - child: sliderAppBar.title, + if (sliderAppBar.drawerIcon == null) + isCupertino + ? AnimatedCupertinoIcon( + progress: animationController, + onTap: () => onTap(), ) - : sliderAppBar.title, - ), - sliderAppBar.trailing ?? - SizedBox( - width: 35, - ) + : IconButton( + splashColor: splashColor, + icon: AnimatedIcon( + icon: AnimatedIcons.menu_close, + color: sliderAppBar.drawerIconColor, + size: sliderAppBar.drawerIconSize, + progress: animationController), + onPressed: () => onTap()) + else + sliderAppBar.drawerIcon!, + Expanded( + child: sliderAppBar.isTitleCenter + ? Center(child: sliderAppBar.title) + : sliderAppBar.title), + sliderAppBar.trailing ?? SizedBox(width: 35) ]; if (slideDirection == SlideDirection.RIGHT_TO_LEFT) { @@ -64,3 +66,44 @@ class SAppBar extends StatelessWidget { return list; } } + +class AnimatedCupertinoIcon extends StatefulWidget { + final Animation progress; + final VoidCallback onTap; + + const AnimatedCupertinoIcon( + {Key? key, required this.progress, required this.onTap}) + : super(key: key); + + @override + State createState() => _AnimatedCupertinoIconState(); +} + +class _AnimatedCupertinoIconState extends State { + bool isCompleted = false; + + @override + void initState() { + widget.progress.addListener(() { + isCompleted = widget.progress.isCompleted; + setState(() {}); + }); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: widget.onTap, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Icon( + isCompleted + ? CupertinoIcons.clear_thick + : CupertinoIcons.line_horizontal_3, + color: Colors.grey, + size: 25.0), + ), + ); + } +} diff --git a/lib/src/helper/slider_app_bar.dart b/lib/src/helper/slider_app_bar.dart index f6739c5..745bcf5 100644 --- a/lib/src/helper/slider_app_bar.dart +++ b/lib/src/helper/slider_app_bar.dart @@ -1,4 +1,4 @@ -import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; class SliderAppBar extends StatelessWidget { /// [double] you can change appBar height by this parameter [appBarHeight] @@ -38,17 +38,17 @@ class SliderAppBar extends StatelessWidget { /// final double drawerIconSize; + + const SliderAppBar({ this.appBarHeight = 70, - this.title = const Text( - 'AppBar', - style: TextStyle(fontWeight: FontWeight.w500, fontSize: 20), - ), + this.title = const Text('AppBar', + style: TextStyle(fontWeight: FontWeight.w500, fontSize: 20)), this.isTitleCenter = true, - this.appBarColor = Colors.white, + this.appBarColor = const Color(0xffffffff), this.appBarPadding = const EdgeInsets.only(top: 24), this.trailing, - this.drawerIconColor = Colors.black, + this.drawerIconColor = const Color(0xff2c2b2b), this.drawerIcon, this.drawerIconSize = 27, }); diff --git a/lib/src/helper/slider_shadow.dart b/lib/src/helper/slider_shadow.dart index c926a6d..62a1e4a 100644 --- a/lib/src/helper/slider_shadow.dart +++ b/lib/src/helper/slider_shadow.dart @@ -1,6 +1,4 @@ -import 'dart:ui'; - -import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; class SliderShadow { final Color shadowColor; @@ -14,7 +12,7 @@ class SliderShadow { final double shadowSpreadRadius; SliderShadow( - {this.shadowColor = Colors.grey, + {this.shadowColor = const Color(0xFF9E9E9E), this.shadowBlurRadius = 25.0, this.shadowSpreadRadius = 5.0}); } diff --git a/lib/src/slider.dart b/lib/src/slider.dart index a98e8f1..b5da19e 100644 --- a/lib/src/slider.dart +++ b/lib/src/slider.dart @@ -1,10 +1,9 @@ -import 'package:flutter/animation.dart'; -import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_slider_drawer/src/app_bar.dart'; import 'package:flutter_slider_drawer/src/helper/slider_app_bar.dart'; import 'package:flutter_slider_drawer/src/helper/slider_shadow.dart'; -import 'package:flutter_slider_drawer/src/slider_bar.dart'; import 'package:flutter_slider_drawer/src/helper/utils.dart'; +import 'package:flutter_slider_drawer/src/slider_bar.dart'; import 'package:flutter_slider_drawer/src/slider_direction.dart'; /// SliderDrawer which have two [child] and [slider] parameter @@ -88,6 +87,10 @@ class SliderDrawer extends StatefulWidget { /// final SlideDirection slideDirection; + ///[bool] if you use CupertinoApp then it will true otherwise it will false + /// + final bool isCupertino; + const SliderDrawer( {Key? key, required this.slider, @@ -95,11 +98,12 @@ class SliderDrawer extends StatefulWidget { this.isDraggable = true, this.animationDuration = 400, this.sliderOpenSize = 265, - this.splashColor = Colors.transparent, + this.splashColor = const Color(0xffffff), this.sliderCloseSize = 0, this.slideDirection = SlideDirection.LEFT_TO_RIGHT, this.sliderShadow, - this.appBar = const SliderAppBar()}) + this.appBar = const SliderAppBar(), + this.isCupertino = false}) : super(key: key); @override @@ -134,6 +138,7 @@ class SliderDrawerState extends State /// Close slider void closeSlider() => _animationDrawerController!.reverse(); + Color _appBarColor = Color(0xffffffff); @override void initState() { @@ -149,14 +154,13 @@ class SliderDrawerState extends State parent: _animationDrawerController!, curve: Curves.decelerate, reverseCurve: Curves.decelerate)); + if (widget.appBar is SliderAppBar) { + _appBarColor = (widget.appBar as SliderAppBar).appBarColor; + } } @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: [ @@ -197,11 +201,12 @@ class SliderDrawerState extends State child: Container( width: double.infinity, height: double.infinity, - color: appBarColor, + color: _appBarColor, child: Column( children: [ if (widget.appBar != null && widget.appBar is SliderAppBar) SAppBar( + isCupertino: widget.isCupertino, slideDirection: widget.slideDirection, onTap: () => toggle(), animationController: _animationDrawerController!,