Skip to content

Commit

Permalink
Merge pull request #13 from SplashByte/dev
Browse files Browse the repository at this point in the history
version 0.3.0-beta.2
  • Loading branch information
maeddin authored Mar 21, 2022
2 parents 1b07cb3 + d2e88d6 commit 9b1d5de
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.0-beta.2 (2022-03-20)

- Minor fix

## 0.3.0-beta.1 (2022-03-20)

- BREAKING: Most constructors of `AnimatedToggleSwitch` have a standard and a more customizable parameter for each of their builders now
Expand Down
35 changes: 18 additions & 17 deletions lib/src/widgets/animated_toggle_switch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class AnimatedToggleSwitch<T> extends StatelessWidget {

/// Provides an [AnimatedToggleSwitch] with the standard size animation of the icons.
///
/// Exactly one builder of [iconBuilder] and [customIconBuilder] must be provided.
/// Maximum one builder of [iconBuilder] and [customIconBuilder] must be provided.
AnimatedToggleSwitch.size({
Key? key,
required this.value,
Expand Down Expand Up @@ -210,7 +210,7 @@ class AnimatedToggleSwitch<T> extends StatelessWidget {
/// All size values ([indicatorWidth], [iconSize], [selectedIconSize]) are relative to the specified height.
/// (So an [indicatorWidth] of 1.0 means equality of [height] - 2*[borderWidth] and [indicatorWidth])
///
/// Exactly one builder of [iconBuilder] and [customIconBuilder] must be provided.
/// Maximum one builder of [iconBuilder] and [customIconBuilder] must be provided.
AnimatedToggleSwitch.sizeByHeight({
Key? key,
this.height = 50.0,
Expand Down Expand Up @@ -260,10 +260,10 @@ class AnimatedToggleSwitch<T> extends StatelessWidget {
SizeIconBuilder<T>? customIconBuilder,
Size iconSize,
Size selectedIconSize) {
assert((iconBuilder == null) ^ (customIconBuilder == null));
if (customIconBuilder == null)
customIconBuilder = (c, l, g) => iconBuilder!(l.value, l.iconSize);
return iconBuilder == null
assert(iconBuilder == null || customIconBuilder == null);
if (customIconBuilder == null && iconBuilder != null)
customIconBuilder = (c, l, g) => iconBuilder(l.value, l.iconSize);
return customIconBuilder == null
? null
: (context, local, global) => customIconBuilder!(
context,
Expand Down Expand Up @@ -327,7 +327,7 @@ class AnimatedToggleSwitch<T> extends StatelessWidget {
/// All size values ([indicatorWidth], [indicatorSize], [selectedIconSize]) are relative to the specified height.
/// (So an [indicatorWidth] of 1.0 means equality of [height] - 2*[borderWidth] and [indicatorWidth])
///
/// Exactly one builder of [iconBuilder] and [customIconBuilder] must be provided.
/// Maximum one builder of [iconBuilder] and [customIconBuilder] must be provided.
AnimatedToggleSwitch.rollingByHeight({
Key? key,
this.height = 50.0,
Expand Down Expand Up @@ -380,7 +380,7 @@ class AnimatedToggleSwitch<T> extends StatelessWidget {

/// Defining a rolling animation using the [foregroundIndicatorIconBuilder] of [AnimatedToggleSwitch].
///
/// Exactly one builder of [iconBuilder] and [customIconBuilder] must be provided.
/// Maximum one builder of [iconBuilder] and [customIconBuilder] must be provided.
AnimatedToggleSwitch.rolling({
Key? key,
required this.value,
Expand Down Expand Up @@ -430,10 +430,11 @@ class AnimatedToggleSwitch<T> extends StatelessWidget {
SimpleRollingIconBuilder<T>? iconBuilder,
RollingIconBuilder<T>? customIconBuilder,
Size iconSize) {
assert((iconBuilder == null) ^ (customIconBuilder == null));
if (customIconBuilder == null)
customIconBuilder = (c, l, g) => iconBuilder!(l.value, l.iconSize);
assert(iconBuilder == null || customIconBuilder == null);
if (customIconBuilder == null && iconBuilder != null)
customIconBuilder = (c, l, g) => iconBuilder(l.value, l.iconSize);
return (context, global) {
if (customIconBuilder == null) return SizedBox();
double distance = global.dif + global.indicatorSize.width;
double angleDistance = distance / iconSize.longestSide * 2;
final pos = global.position;
Expand All @@ -445,7 +446,7 @@ class AnimatedToggleSwitch<T> extends StatelessWidget {
angle: transitionValue * angleDistance,
child: Opacity(
opacity: 1 - transitionValue,
child: customIconBuilder!(
child: customIconBuilder(
context,
RollingProperties(
iconSize: iconSize,
Expand Down Expand Up @@ -480,10 +481,10 @@ class AnimatedToggleSwitch<T> extends StatelessWidget {
RollingIconBuilder<T>? customIconBuilder,
Size iconSize,
Size selectedIconSize) {
assert((iconBuilder == null) ^ (customIconBuilder == null));
if (customIconBuilder == null)
customIconBuilder = (c, l, g) => iconBuilder!(l.value, l.iconSize);
return iconBuilder == null
assert(iconBuilder == null || customIconBuilder == null);
if (customIconBuilder == null && iconBuilder != null)
customIconBuilder = (c, l, g) => iconBuilder(l.value, l.iconSize);
return customIconBuilder == null
? null
: (t, local, global) => customIconBuilder!(
t,
Expand All @@ -495,7 +496,7 @@ class AnimatedToggleSwitch<T> extends StatelessWidget {

/// Defining an rolling animation using the [foregroundIndicatorIconBuilder] of [AnimatedToggleSwitch].
///
/// Exactly one builder of [iconBuilder] and [customIconBuilder] must be provided.
/// Maximum one builder of [iconBuilder] and [customIconBuilder] must be provided.
/// Maximum one builder of [textBuilder] and [customTextBuilder] must be provided.
AnimatedToggleSwitch.dual({
Key? key,
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: animated_toggle_switch
description: Simple and animated toggle switch for multiple choices. It's a good alternative if you don't want to use something like a dropdown menu.
version: 0.3.0-beta.1
version: 0.3.0-beta.2
repository: https://github.com/SplashByte/animated_toggle_switch

environment:
Expand Down

0 comments on commit 9b1d5de

Please sign in to comment.