Skip to content

Commit

Permalink
removes animateThemeChanges
Browse files Browse the repository at this point in the history
  • Loading branch information
maeddin committed Oct 8, 2023
1 parent 10b0229 commit c360f2f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 30 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- adds `indicatorGradient` to `ToggleStyle` ([#44](https://github.com/splashbyte/animated_toggle_switch/issues/44))
- fixes problems with `backgroundGradient` and `backgroundColor` ([#46](https://github.com/splashbyte/animated_toggle_switch/issues/46))
- adds `AnimationType.none`
- adds `animateThemeChanges` to `AnimatedToggleSwitch`
- introduces `CustomToggleStyle` for disabling the animation of single style properties

## 0.8.0 (2023-09-02)

Expand Down
13 changes: 13 additions & 0 deletions lib/src/style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,19 @@ class ToggleStyle extends BaseToggleStyle {
this.boxShadow,
}) : super._();

Check warning on line 251 in lib/src/style.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/style.dart#L251

Added line #L251 was not covered by tests

const ToggleStyle._({
required this.indicatorColor,
required this.indicatorGradient,
required this.backgroundColor,
required this.backgroundGradient,
required this.borderColor,
required this.borderRadius,
required this.indicatorBorderRadius,
required this.indicatorBorder,
required this.indicatorBoxShadow,
required this.boxShadow,
}) : super._();

@override
ToggleStyleProperty<Color>? get _backgroundColor =>
ToggleStyleProperty.nullable(backgroundColor);
Expand Down
34 changes: 5 additions & 29 deletions lib/src/widgets/animated_toggle_switch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,6 @@ class AnimatedToggleSwitch<T extends Object?>
/// For deactivating this animation please set [inactiveOpacity] to [1.0].
final Duration inactiveOpacityDuration;

/// Indicates whether external changes to the [Theme] will be animated.
///
/// This is useful if the theme is already animated externally.
final bool animateThemeChanges;

/// Constructor of AnimatedToggleSwitch with all possible settings.
///
/// Consider using [CustomAnimatedToggleSwitch] for maximum customizability.
Expand Down Expand Up @@ -330,7 +325,6 @@ class AnimatedToggleSwitch<T extends Object?>
this.inactiveOpacity = 0.6,
this.inactiveOpacityCurve = Curves.easeInOut,
this.inactiveOpacityDuration = const Duration(milliseconds: 350),
this.animateThemeChanges = true,
}) : _iconArrangement = IconArrangement.row,
super(
values: values,
Expand Down Expand Up @@ -393,7 +387,6 @@ class AnimatedToggleSwitch<T extends Object?>
this.inactiveOpacity = 0.6,
this.inactiveOpacityCurve = Curves.easeInOut,
this.inactiveOpacityDuration = const Duration(milliseconds: 350),
this.animateThemeChanges = true,
}) : spacing = spacing * (height - 2 * borderWidth),
indicatorSize = indicatorSize * (height - 2 * borderWidth),
_iconArrangement = IconArrangement.row,
Expand Down Expand Up @@ -458,7 +451,6 @@ class AnimatedToggleSwitch<T extends Object?>
this.inactiveOpacity = 0.6,
this.inactiveOpacityCurve = Curves.easeInOut,
this.inactiveOpacityDuration = const Duration(milliseconds: 350),
this.animateThemeChanges = true,
}) : animatedIconBuilder = _iconSizeBuilder<T>(
iconBuilder, customIconBuilder, iconList, selectedIconScale),
_iconArrangement = IconArrangement.row,
Expand Down Expand Up @@ -526,7 +518,6 @@ class AnimatedToggleSwitch<T extends Object?>
this.inactiveOpacity = 0.6,
this.inactiveOpacityCurve = Curves.easeInOut,
this.inactiveOpacityDuration = const Duration(milliseconds: 350),
this.animateThemeChanges = true,
}) : indicatorSize = indicatorSize * (height - 2 * borderWidth),
spacing = spacing * (height - 2 * borderWidth),
animatedIconBuilder = _iconSizeBuilder<T>(
Expand Down Expand Up @@ -622,7 +613,6 @@ class AnimatedToggleSwitch<T extends Object?>
this.inactiveOpacityCurve = Curves.easeInOut,
this.inactiveOpacityDuration = const Duration(milliseconds: 350),
double indicatorIconScale = 1.0,
this.animateThemeChanges = true,
}) : iconAnimationCurve = Curves.linear,
iconAnimationDuration = Duration.zero,
selectedIconOpacity = iconOpacity,
Expand Down Expand Up @@ -704,7 +694,6 @@ class AnimatedToggleSwitch<T extends Object?>
this.inactiveOpacityCurve = Curves.easeInOut,
this.inactiveOpacityDuration = const Duration(milliseconds: 350),
double indicatorIconScale = 1.0,
this.animateThemeChanges = true,
}) : iconAnimationCurve = Curves.linear,
spacing = spacing * (height - 2 * borderWidth),
iconAnimationDuration = Duration.zero,
Expand Down Expand Up @@ -901,7 +890,6 @@ class AnimatedToggleSwitch<T extends Object?>
this.inactiveOpacity = 0.6,
this.inactiveOpacityCurve = Curves.easeInOut,
this.inactiveOpacityDuration = const Duration(milliseconds: 350),
this.animateThemeChanges = true,
}) : assert(clipAnimation || opacityAnimation),
iconOpacity = 1.0,
selectedIconOpacity = 1.0,
Expand Down Expand Up @@ -1036,25 +1024,13 @@ class AnimatedToggleSwitch<T extends Object?>
ThemeData theme = Theme.of(context);
BorderRadiusGeometry defaultBorderRadius =
BorderRadius.circular(height / 2);
final style = CustomToggleStyle._(
indicatorColor: ToggleStyleProperty(
theme.colorScheme.secondary,
animationEnabled: animateThemeChanges,
),
final style = ToggleStyle._(
indicatorColor: theme.colorScheme.secondary,
indicatorGradient: null,
backgroundColor: ToggleStyleProperty(
theme.colorScheme.surface,
animationEnabled: animateThemeChanges,
),
backgroundColor: theme.colorScheme.surface,
backgroundGradient: null,
borderColor: ToggleStyleProperty(
theme.colorScheme.secondary,
animationEnabled: animateThemeChanges,
),
borderRadius: ToggleStyleProperty(
defaultBorderRadius,
animationEnabled: animateThemeChanges,
),
borderColor: theme.colorScheme.secondary,
borderRadius: defaultBorderRadius,
indicatorBorderRadius: null,
indicatorBorder: null,
indicatorBoxShadow: null,
Expand Down

0 comments on commit c360f2f

Please sign in to comment.