-
Notifications
You must be signed in to change notification settings - Fork 29
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 #120 from MohamedAbd0/add_aspect_ratio
Feat : Adding AspectRatio, FittedBox, LimitedBox Widgets
- Loading branch information
Showing
27 changed files
with
1,359 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
examples/mirai_gallery/assets/json/aspect_ratio_example.json
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,39 @@ | ||
{ | ||
"type": "scaffold", | ||
"appBar": { | ||
"type": "appBar", | ||
"title": { | ||
"type": "text", | ||
"data": "AspectRatio" | ||
} | ||
}, | ||
"body": { | ||
"type": "padding", | ||
"padding": { | ||
"top": 12, | ||
"left": 12, | ||
"right": 12 | ||
}, | ||
"child": { | ||
"type": "column", | ||
"mainAxisAlignment": "start", | ||
"crossAxisAlignment": "start", | ||
"children": [ | ||
{ | ||
"type": "sizedBox", | ||
"height": 12 | ||
}, | ||
{ | ||
"type": "aspectRatio", | ||
"aspectRatio": 1.33, | ||
"child": { | ||
"type": "container", | ||
"color": "#FF5733", | ||
"width": 100, | ||
"height": 100 | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
examples/mirai_gallery/assets/json/fitted_box_example.json
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,42 @@ | ||
{ | ||
"type": "scaffold", | ||
"appBar": { | ||
"type": "appBar", | ||
"title": { | ||
"type": "text", | ||
"data": "FittedBox" | ||
} | ||
}, | ||
"body": { | ||
"type": "padding", | ||
"padding": { | ||
"top": 12, | ||
"left": 12, | ||
"right": 12 | ||
}, | ||
"child": { | ||
"type": "column", | ||
"mainAxisAlignment": "start", | ||
"crossAxisAlignment": "start", | ||
"children": [ | ||
{ | ||
"type": "sizedBox", | ||
"height": 12 | ||
}, | ||
{ | ||
"type": "fittedBox", | ||
"fit": "contain", | ||
"alignment": "center", | ||
"child": { | ||
"type": "text", | ||
"data": "Hello, World!", | ||
"style": { | ||
"fontSize": 20, | ||
"color": "#000000" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
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
40 changes: 40 additions & 0 deletions
40
examples/mirai_gallery/assets/json/limited_box_example.json
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,40 @@ | ||
{ | ||
"type": "scaffold", | ||
"appBar": { | ||
"type": "appBar", | ||
"title": { | ||
"type": "text", | ||
"data": "LimitedBox" | ||
} | ||
}, | ||
"body": { | ||
"type": "listView", | ||
"shrinkWrap": true, | ||
"children": [ | ||
{ | ||
"type": "sizedBox", | ||
"height": 25 | ||
}, | ||
|
||
{ | ||
"type": "limitedBox", | ||
"child": { | ||
"type": "container", | ||
"height": 100, | ||
"color": "#FF0000", | ||
"child": { | ||
"type": "text", | ||
"data": "Hello, World! from Limited Box", | ||
"style": { | ||
"fontSize": 16, | ||
"color": "#000000" | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
||
|
||
] | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
packages/mirai/lib/src/parsers/mirai_aspect_ratio/mirai_aspect_ratio.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,16 @@ | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
export 'package:mirai/src/parsers/mirai_aspect_ratio/mirai_aspect_ratio_parser.dart'; | ||
|
||
part 'mirai_aspect_ratio.freezed.dart'; | ||
part 'mirai_aspect_ratio.g.dart'; | ||
|
||
@freezed | ||
class MiraiAspectRatio with _$MiraiAspectRatio { | ||
const factory MiraiAspectRatio({ | ||
@Default(1) double aspectRatio, | ||
Map<String, dynamic>? child, | ||
}) = _MiraiAspectRatio; | ||
|
||
factory MiraiAspectRatio.fromJson(Map<String, dynamic> json) => | ||
_$MiraiAspectRatioFromJson(json); | ||
} |
Oops, something went wrong.