-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c702c1a
commit 7d70713
Showing
6 changed files
with
45 additions
and
151 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
packages/superdeck/lib/components/atoms/sized_transition.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import 'dart:math' as math; | ||
|
||
import 'package:flutter/widgets.dart'; | ||
|
||
class SizedTransition extends StatelessWidget { | ||
const SizedTransition({ | ||
super.key, | ||
required this.sizeFactor, | ||
this.child, | ||
this.direction = Axis.horizontal, | ||
}); | ||
|
||
final double sizeFactor; | ||
final Axis direction; | ||
|
||
final Widget? child; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
AlignmentDirectional alignment; | ||
if (direction == Axis.horizontal) { | ||
alignment = const AlignmentDirectional(0.0, -1.0); | ||
} else { | ||
alignment = const AlignmentDirectional(-1.0, 0.0); | ||
} | ||
return ClipRect( | ||
child: Align( | ||
alignment: alignment, | ||
heightFactor: | ||
direction == Axis.vertical ? math.max(sizeFactor, 0.0) : 1.0, | ||
widthFactor: | ||
direction == Axis.horizontal ? math.max(sizeFactor, 0.0) : 1.0, | ||
child: child, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters