Skip to content

Commit

Permalink
renames onSlide to slide & fixes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
maeddin committed Jul 5, 2022
1 parent 15ad149 commit b6a3c77
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 38 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
2 changes: 2 additions & 0 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
</dict>
</plist>
23 changes: 13 additions & 10 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class _MyHomePageState extends State<MyHomePage> {
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
Expand All @@ -63,7 +63,7 @@ class _MyHomePageState extends State<MyHomePage> {
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
Expand All @@ -82,7 +82,7 @@ class _MyHomePageState extends State<MyHomePage> {
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
Expand All @@ -100,7 +100,7 @@ class _MyHomePageState extends State<MyHomePage> {
toggleColor: Colors.amber,
iconAlignment: Alignment.centerRight,
loadingIcon: SizedBox(
width: 50,
width: 55,
child: Center(
child: SizedBox(
width: 24.0,
Expand All @@ -109,10 +109,10 @@ class _MyHomePageState extends State<MyHomePage> {
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
Expand All @@ -127,7 +127,7 @@ class _MyHomePageState extends State<MyHomePage> {
controller: _controller,
height: 60.0,
toggleWidth: 60.0,
toggleMargin: const EdgeInsets.all(12.0),
toggleMargin: EdgeInsets.zero,
backgroundColor: Colors.green,
foregroundChild: DecoratedBox(
decoration: BoxDecoration(
Expand All @@ -136,6 +136,7 @@ class _MyHomePageState extends State<MyHomePage> {
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),
Expand All @@ -152,14 +153,16 @@ class _MyHomePageState extends State<MyHomePage> {
),
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!,
Expand All @@ -182,7 +185,7 @@ class _MyHomePageState extends State<MyHomePage> {
await Future.delayed(const Duration(seconds: 1));
controller.reset(); //resets the slider
},
)
),
],
),
),
Expand Down
25 changes: 9 additions & 16 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.4.0"
version: "0.6.0"
async:
dependency: transitive
description:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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"
23 changes: 12 additions & 11 deletions lib/src/action_slider_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -457,6 +457,7 @@ class _ActionSliderState extends State<ActionSlider>
void dispose() {
_slideAnimationController.dispose();
_loadingAnimationController.dispose();
_controller.removeListener(_onModeChange);
_localController?.dispose();
super.dispose();
}
Expand Down Expand Up @@ -487,11 +488,13 @@ class _ActionSliderState extends State<ActionSlider>
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) {
Expand Down Expand Up @@ -525,10 +528,8 @@ class _ActionSliderState extends State<ActionSlider>

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;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit b6a3c77

Please sign in to comment.