-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #242 from yakforward-ou/widgetweaver
[yak_flutter] add EdgePositioned
- Loading branch information
Showing
5 changed files
with
121 additions
and
2 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
### 3.0.1 | ||
- add `EdgePositioned` | ||
|
||
### 3.0.0 | ||
- rework due to yak_result v3 | ||
|
||
|
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export 'preferred_size_themed.dart'; | ||
export 'edge_positioned.dart'; |
115 changes: 115 additions & 0 deletions
115
packages/yak_flutter/lib/src/widgets/edge_positioned.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,115 @@ | ||
import 'package:flutter/widgets.dart'; | ||
|
||
/// a positioned widget that "starts" from one of the edges of the screen | ||
/// inspired by `https://gist.github.com/aoatmon/ee4a35747b6826b73aa02aee34963f10` | ||
abstract class EdgePositioned extends Positioned { | ||
final EdgeInsets padding; | ||
final double dimension; | ||
const EdgePositioned({ | ||
required super.child, | ||
required this.dimension, | ||
required this.padding, | ||
super.key, | ||
}); | ||
|
||
const factory EdgePositioned.top({ | ||
required Widget child, | ||
double dimension, | ||
EdgeInsets padding, | ||
Key key, | ||
}) = _EdgePositioneTop; | ||
|
||
const factory EdgePositioned.bottom({ | ||
required Widget child, | ||
double dimension, | ||
EdgeInsets padding, | ||
Key key, | ||
}) = _EdgePositioneBottom; | ||
|
||
const factory EdgePositioned.left({ | ||
required Widget child, | ||
double dimension, | ||
EdgeInsets padding, | ||
Key key, | ||
}) = _EdgePositioneLeft; | ||
|
||
const factory EdgePositioned.right({ | ||
required Widget child, | ||
double dimension, | ||
EdgeInsets padding, | ||
Key key, | ||
}) = _EdgePositioneRight; | ||
} | ||
|
||
class _EdgePositioneBottom extends EdgePositioned { | ||
const _EdgePositioneBottom({ | ||
required super.child, | ||
super.dimension = 0, | ||
super.padding = EdgeInsets.zero, | ||
super.key, | ||
}); | ||
|
||
@override | ||
double get left => padding.left; | ||
@override | ||
double get right => padding.right; | ||
@override | ||
double get bottom => padding.bottom; | ||
@override | ||
double get height => dimension - padding.vertical; | ||
} | ||
|
||
class _EdgePositioneTop extends EdgePositioned { | ||
const _EdgePositioneTop({ | ||
required super.child, | ||
super.dimension = 0, | ||
super.padding = EdgeInsets.zero, | ||
super.key, | ||
}); | ||
|
||
@override | ||
double get left => padding.left; | ||
@override | ||
double get right => padding.right; | ||
@override | ||
double get top => padding.top; | ||
@override | ||
double get height => dimension - padding.vertical; | ||
} | ||
|
||
class _EdgePositioneLeft extends EdgePositioned { | ||
const _EdgePositioneLeft({ | ||
required super.child, | ||
super.dimension = 0, | ||
super.padding = EdgeInsets.zero, | ||
super.key, | ||
}); | ||
|
||
@override | ||
double get left => padding.left; | ||
@override | ||
double get top => padding.top; | ||
@override | ||
double get bottom => padding.bottom; | ||
@override | ||
double get width => dimension - padding.horizontal; | ||
} | ||
|
||
class _EdgePositioneRight extends EdgePositioned { | ||
const _EdgePositioneRight({ | ||
required super.child, | ||
super.dimension = 0, | ||
super.padding = EdgeInsets.zero, | ||
super.key, | ||
}); | ||
|
||
@override | ||
double get right => padding.right; | ||
@override | ||
double get top => padding.top; | ||
@override | ||
double get bottom => padding.bottom; | ||
@override | ||
double get width => dimension - padding.horizontal; | ||
} |
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