-
-
Notifications
You must be signed in to change notification settings - Fork 104
feat: add stacSliverPadding widget, parser,example and documentation #421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
064026a
feat: Add SliverPadding widget and its parser with documentation
akhil-ge0rge 434bd4c
feat: Add SliverPaddingParser to StacService
akhil-ge0rge ab00df4
fix: Update SliverPadding documentation and examples for accuracy
akhil-ge0rge 41767e2
fix: Correct SliverPadding widget description and update JSON example…
akhil-ge0rge 390c7a9
fix: Update subtitle for SliverPadding widget in home_screen.json
akhil-ge0rge 59c4804
fix: Simplify padding structure in SliverPadding JSON examples and do…
akhil-ge0rge 98c118e
fix: Enable explicit JSON serialization for StacSliverPadding
akhil-ge0rge c495d04
Merge branch 'dev' into feat-sliver-padding
akhil-ge0rge 9f6359e
fix: remove explicitToJson from StacSliverPadding JSON serialization
akhil-ge0rge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,43 @@ | ||
| --- | ||
| title: "SliverPadding" | ||
| description: "Documentation for SliverPadding" | ||
| --- | ||
|
|
||
| The Stac SliverPadding allows you to inset a sliver widget by a given padding using JSON. It is typically used inside a `CustomScrollView`. | ||
| To know more about the sliver padding widget in Flutter, refer to | ||
| the [official documentation](https://api.flutter.dev/flutter/widgets/SliverPadding-class.html). | ||
|
|
||
| ## Properties | ||
|
|
||
| | Property | Type | Description | | ||
| |----------|------------------------|--------------------------------------------------| | ||
| | padding | `Map<String, dynamic>` | The amount of space by which to inset the child. | | ||
| | sliver | `Map<String, dynamic>` | The sliver widget inside the padding. | | ||
|
|
||
| ## Example JSON | ||
|
|
||
| ```json | ||
| { | ||
| "type": "sliverPadding", | ||
| "padding": 16.0, | ||
| "sliver": { | ||
| "type": "sliverToBoxAdapter", | ||
| "child": { | ||
| "type": "container", | ||
| "height": 150, | ||
| "color": "#4CAF50", | ||
| "child": { | ||
| "type": "center", | ||
| "child": { | ||
| "type": "text", | ||
| "data": "I am a Box inside a SliverPadding!", | ||
| "style": { | ||
| "color": "#FFFFFF", | ||
| "fontWeight": "bold" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ``` |
This file contains hidden or 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
31 changes: 31 additions & 0 deletions
31
examples/stac_gallery/assets/json/sliver_padding_example.json
This file contains hidden or 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,31 @@ | ||
| { | ||
| "type": "scaffold", | ||
| "body": { | ||
| "type": "customScrollView", | ||
| "slivers": [ | ||
| { | ||
| "type": "sliverPadding", | ||
| "padding": 16.0, | ||
| "sliver": { | ||
| "type": "sliverToBoxAdapter", | ||
| "child": { | ||
| "type": "container", | ||
| "height": 150, | ||
| "color": "#4CAF50", | ||
| "child": { | ||
| "type": "center", | ||
| "child": { | ||
| "type": "text", | ||
| "data": "I am a Box inside a SliverPadding!", | ||
| "style": { | ||
| "color": "#FFFFFF", | ||
| "fontWeight": "bold" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } |
This file contains hidden or 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
25 changes: 25 additions & 0 deletions
25
packages/stac/lib/src/parsers/widgets/stac_sliver_padding/stac_sliver_padding_parser.dart
This file contains hidden or 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,25 @@ | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:stac/src/parsers/core/stac_widget_parser.dart'; | ||
|
|
||
| import 'package:stac/src/parsers/foundation/geometry/stac_edge_insets_parser.dart'; | ||
| import 'package:stac_core/stac_core.dart'; | ||
| import 'package:stac_framework/stac_framework.dart'; | ||
|
|
||
| class StacSliverPaddingParser extends StacParser<StacSliverPadding> { | ||
| const StacSliverPaddingParser(); | ||
|
|
||
| @override | ||
| String get type => WidgetType.sliverPadding.name; | ||
|
|
||
| @override | ||
| StacSliverPadding getModel(Map<String, dynamic> json) => | ||
| StacSliverPadding.fromJson(json); | ||
|
|
||
| @override | ||
| Widget parse(BuildContext context, StacSliverPadding model) { | ||
| return SliverPadding( | ||
| padding: model.padding.parse, | ||
| sliver: model.sliver.parse(context), | ||
| ); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
73 changes: 73 additions & 0 deletions
73
packages/stac_core/lib/widgets/sliver_padding/stac_sliver_padding.dart
This file contains hidden or 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,73 @@ | ||
| import 'package:json_annotation/json_annotation.dart'; | ||
| import 'package:stac_core/core/stac_widget.dart'; | ||
| import 'package:stac_core/foundation/foundation.dart'; | ||
| part 'stac_sliver_padding.g.dart'; | ||
|
|
||
| /// A Stac model representing Flutter's [SliverPadding] widget. | ||
| /// | ||
| /// Insets its sliver child by the given padding. | ||
| /// | ||
| /// {@tool snippet} | ||
| /// Dart Example: | ||
| /// ```dart | ||
| /// const StacSliverPadding( | ||
| /// padding: StacEdgeInsets.all(16), | ||
| /// sliver: StacSliverToBoxAdapter(...), | ||
| /// ) | ||
| /// ``` | ||
| /// {@end-tool} | ||
| /// | ||
| /// {@tool snippet} | ||
| /// JSON Example: | ||
| /// ```json | ||
| /// { | ||
| /// "type": "sliverPadding", | ||
| /// "padding": 16.0, | ||
| /// "sliver": { | ||
| /// "type": "sliverToBoxAdapter", | ||
| /// "child": { | ||
| /// "type": "container", | ||
| /// "height": 150, | ||
| /// "color": "#4CAF50", | ||
| /// "child": { | ||
| /// "type": "center", | ||
| /// "child": { | ||
| /// "type": "text", | ||
| /// "data": "I am a Box inside a SliverPadding!", | ||
| /// "style": { | ||
| /// "color": "#FFFFFF", | ||
| /// "fontWeight": "bold" | ||
| /// } | ||
| /// } | ||
| /// } | ||
| /// } | ||
| /// } | ||
| /// } | ||
| /// ``` | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| /// {@end-tool} | ||
| /// | ||
| /// See also: | ||
| /// * Flutter's [SliverPadding documentation](https://api.flutter.dev/flutter/widgets/SliverPadding-class.html) | ||
| @JsonSerializable() | ||
| class StacSliverPadding extends StacWidget { | ||
| /// Creates a [StacSliverPadding]. | ||
| const StacSliverPadding({required this.sliver, required this.padding}); | ||
|
|
||
| /// The amount of space by which to inset the child sliver. | ||
| final StacEdgeInsets padding; | ||
|
|
||
| /// The sliver to apply padding to. | ||
| final StacWidget sliver; | ||
|
|
||
| /// Widget type identifier. | ||
| @override | ||
| String get type => WidgetType.sliverPadding.name; | ||
|
|
||
| /// Creates a [StacSliverPadding] from a JSON map. | ||
| factory StacSliverPadding.fromJson(Map<String, dynamic> json) => | ||
| _$StacSliverPaddingFromJson(json); | ||
|
|
||
| /// Converts this [StacSliverPadding] instance to JSON. | ||
| @override | ||
| Map<String, dynamic> toJson() => _$StacSliverPaddingToJson(this); | ||
| } | ||
20 changes: 20 additions & 0 deletions
20
packages/stac_core/lib/widgets/sliver_padding/stac_sliver_padding.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.