Skip to content

Commit

Permalink
fix: reduce switch active scale (#780)
Browse files Browse the repository at this point in the history
Fix scale computing so it looks like before #777
  • Loading branch information
Jupi007 authored Sep 20, 2023
1 parent 2994c72 commit 1b70816
Show file tree
Hide file tree
Showing 13 changed files with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/src/widgets/yaru_togglable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const _kTogglableSizeAnimationDuration = Duration(milliseconds: 100);
const _kIndicatorAnimationDuration = Duration(milliseconds: 200);
const _kIndicatorRadius = 20.0;
// Used to resize the canvas on active state. Must be an even number.
const _kTogglableActiveResizeFactor = .1;
const _kTogglableActiveResizeFactor = 2;

/// A generic class to create a togglable widget
///
Expand Down Expand Up @@ -427,7 +427,14 @@ abstract class YaruTogglablePainter extends ChangeNotifier
@override
void paint(Canvas canvas, Size size) {
final origin = (Offset.zero & size).center;
final scale = 1 - _kTogglableActiveResizeFactor * sizePosition.value;

final activeScaleX =
1 - (size.width - _kTogglableActiveResizeFactor) / size.width;
final activeScaleY =
1 - (size.height - _kTogglableActiveResizeFactor) / size.height;
final activeScale =
activeScaleX > activeScaleY ? activeScaleX : activeScaleY;
final scale = 1 - activeScale * sizePosition.value;

canvas.save();
canvas.translate(origin.dx, origin.dy);
Expand Down
Binary file modified test/widgets/goldens/yaru_switch-checked-pressed-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/widgets/goldens/yaru_switch-checked-pressed-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/widgets/goldens/yaru_switch-unckecked-pressed-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/widgets/goldens/yaru_switch-unckecked-pressed-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/widgets/goldens/yaru_switch_button-off-pressed-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/widgets/goldens/yaru_switch_button-off-pressed-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/widgets/goldens/yaru_switch_button-on-pressed-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/widgets/goldens/yaru_switch_button-on-pressed-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/widgets/goldens/yaru_switch_list_tile-off-pressed-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/widgets/goldens/yaru_switch_list_tile-off-pressed-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/widgets/goldens/yaru_switch_list_tile-on-pressed-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/widgets/goldens/yaru_switch_list_tile-on-pressed-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1b70816

Please sign in to comment.