From b6a3c775fe56f73981452fb3c02cb49c14be1643 Mon Sep 17 00:00:00 2001 From: MaddinMade Date: Tue, 5 Jul 2022 13:53:27 +0200 Subject: [PATCH] renames onSlide to slide & fixes #1 --- CHANGELOG.md | 5 +++++ example/ios/Runner/Info.plist | 2 ++ example/lib/main.dart | 23 +++++++++++++---------- example/pubspec.lock | 25 +++++++++---------------- lib/src/action_slider_widget.dart | 23 ++++++++++++----------- pubspec.yaml | 2 +- 6 files changed, 42 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c62af16..1411ed7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.6.0 [2022-03-22] +- minor fixes +- fixes #1 +- BREAKING: renames `onSlide` to `action` in `ActionSlider.standard` + ## 0.5.0 [2022-03-17] - adds `stateChangeCallback`, `actionThreshold` and `actionThresholdType` - BREAKING: renames `onSlide` to `action` diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index 27491e8..5eeb16f 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -43,5 +43,7 @@ UIViewControllerBasedStatusBarAppearance + CADisableMinimumFrameDurationOnPhone + diff --git a/example/lib/main.dart b/example/lib/main.dart index b9484e4..eae38c0 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -48,7 +48,7 @@ class _MyHomePageState extends State { width: 300.0, actionThresholdType: ThresholdType.release, child: const Text('Slide to confirm'), - onSlide: (controller) async { + action: (controller) async { controller.loading(); //starts loading animation await Future.delayed(const Duration(seconds: 3)); controller.success(); //starts success animation @@ -63,7 +63,7 @@ class _MyHomePageState extends State { child: const Text('Slide to confirm'), backgroundColor: Colors.white, toggleColor: Colors.lightGreenAccent, - onSlide: (controller) async { + action: (controller) async { controller.loading(); //starts loading animation await Future.delayed(const Duration(seconds: 3)); controller.success(); //starts success animation @@ -82,7 +82,7 @@ class _MyHomePageState extends State { reverseSlideAnimationDuration: const Duration(milliseconds: 500), toggleColor: Colors.purpleAccent, icon: const Icon(Icons.add), - onSlide: (controller) async { + action: (controller) async { controller.loading(); //starts loading animation await Future.delayed(const Duration(seconds: 3)); controller.success(); //starts success animation @@ -100,7 +100,7 @@ class _MyHomePageState extends State { toggleColor: Colors.amber, iconAlignment: Alignment.centerRight, loadingIcon: SizedBox( - width: 50, + width: 55, child: Center( child: SizedBox( width: 24.0, @@ -109,10 +109,10 @@ class _MyHomePageState extends State { strokeWidth: 2.0, color: theme.iconTheme.color), ))), successIcon: const SizedBox( - width: 50, child: Center(child: Icon(Icons.check_rounded))), + width: 55, child: Center(child: Icon(Icons.check_rounded))), icon: const SizedBox( - width: 50, child: Center(child: Icon(Icons.refresh_rounded))), - onSlide: (controller) async { + width: 55, child: Center(child: Icon(Icons.refresh_rounded))), + action: (controller) async { controller.loading(); //starts loading animation await Future.delayed(const Duration(seconds: 3)); controller.success(); //starts success animation @@ -127,7 +127,7 @@ class _MyHomePageState extends State { controller: _controller, height: 60.0, toggleWidth: 60.0, - toggleMargin: const EdgeInsets.all(12.0), + toggleMargin: EdgeInsets.zero, backgroundColor: Colors.green, foregroundChild: DecoratedBox( decoration: BoxDecoration( @@ -136,6 +136,7 @@ class _MyHomePageState extends State { child: const Icon(Icons.check_rounded, color: Colors.white)), foregroundBuilder: (context, state, child) => child!, outerBackgroundBuilder: (context, state, child) => Card( + margin: EdgeInsets.zero, color: Color.lerp(Colors.red, Colors.green, state.position), child: Center( child: Text(state.position.toStringAsFixed(2), @@ -152,14 +153,16 @@ class _MyHomePageState extends State { ), const SizedBox(height: 24.0), ActionSlider.custom( + toggleMargin: EdgeInsets.zero, width: 300.0, controller: _controller, + toggleWidth: 60.0, height: 60.0, backgroundColor: Colors.green, foregroundChild: Container( decoration: const BoxDecoration( color: Colors.black, - borderRadius: BorderRadius.all(Radius.circular(27.5)), + borderRadius: BorderRadius.all(Radius.circular(30.0)), ), child: const Icon(Icons.check_rounded, color: Colors.white)), foregroundBuilder: (context, state, child) => child!, @@ -182,7 +185,7 @@ class _MyHomePageState extends State { await Future.delayed(const Duration(seconds: 1)); controller.reset(); //resets the slider }, - ) + ), ], ), ), diff --git a/example/pubspec.lock b/example/pubspec.lock index 4625082..f79e581 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,7 +7,7 @@ packages: path: ".." relative: true source: path - version: "0.4.0" + version: "0.6.0" async: dependency: transitive description: @@ -49,14 +49,14 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" flutter: dependency: "direct main" description: flutter @@ -94,7 +94,7 @@ packages: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "0.1.4" meta: dependency: transitive description: @@ -108,7 +108,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" sky_engine: dependency: transitive description: flutter @@ -120,7 +120,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" stack_trace: dependency: transitive description: @@ -155,21 +155,14 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.8" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" + version: "0.4.9" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" sdks: - dart: ">=2.15.1 <3.0.0" + dart: ">=2.17.0-0 <3.0.0" flutter: ">=1.17.0" diff --git a/lib/src/action_slider_widget.dart b/lib/src/action_slider_widget.dart index d6fa3a4..6c2a511 100644 --- a/lib/src/action_slider_widget.dart +++ b/lib/src/action_slider_widget.dart @@ -219,7 +219,7 @@ class ActionSlider extends StatefulWidget { double height = 65.0, double borderWidth = 5.0, bool rolling = false, - Action? onSlide, + Action? action, TapCallback? onTap = _defaultOnTap, ActionSliderController? controller, double? width, @@ -274,7 +274,7 @@ class ActionSlider extends StatefulWidget { toggleWidth: height - borderWidth * 2, toggleMargin: EdgeInsets.all(borderWidth), backgroundColor: backgroundColor, - action: onSlide, + action: action, onTap: onTap, controller: controller, width: width, @@ -457,6 +457,7 @@ class _ActionSliderState extends State void dispose() { _slideAnimationController.dispose(); _loadingAnimationController.dispose(); + _controller.removeListener(_onModeChange); _localController?.dispose(); super.dispose(); } @@ -487,11 +488,13 @@ class _ActionSliderState extends State void _onModeChange() { if (_controller.value.expanded) { if (_controller.value.jumpPosition > 0.0) { - _changeState( - _state.copyWith(releasePosition: _controller.value.jumpPosition), - null, - setState: false); - _slideAnimationController.forward(); + if (_state.state == SlidingState.released) { + _changeState( + _state.copyWith(releasePosition: _controller.value.jumpPosition), + null, + setState: false); + _slideAnimationController.forward(); + } _controller._setMode(SliderMode.standard, notify: false); } else { if (_loadingAnimationController.isCompleted) { @@ -525,10 +528,8 @@ class _ActionSliderState extends State void _changeState(SliderState state, ActionSliderState? oldActionSliderState, {bool setState = true}) { - if (_state != state) { - _state = state; - if (setState) this.setState(() {}); - } + _state = state; + if (setState) this.setState(() {}); if (widget.stateChangeCallback == null) return; oldActionSliderState ??= _lastActionSliderState; if (oldActionSliderState == null) return; diff --git a/pubspec.yaml b/pubspec.yaml index 5c72f04..e766003 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: action_slider description: A slider to confirm actions and provide feedback on the success of these after subsequent loading. -version: 0.5.0 +version: 0.6.0 repository: https://github.com/SplashByte/action_slider environment: