-
Notifications
You must be signed in to change notification settings - Fork 7
feat: waved (shader-based) flags #454
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
24 commits
Select commit
Hold shift + click to select a range
f09cf7f
chore(deps): update kotlin jvm target and gradle wrapper version
tsinis 64f198e
feat: enable impeller and update sdk version for world_flags package
tsinis f6f95c8
feat(ui)!: add clipped triangle painter and update flag properties
tsinis 08b761a
feat(shader): add waved flag shader implementation
tsinis 46eaf26
feat(ui): add shader options and delegate for flag rendering
tsinis b085416
feat: integrate flag shader delegate and remove shader options
tsinis 4ecef84
feat(shader): add shader support to iso and country flag widgets
tsinis 8492e82
feat(model): remove enabled option from waved flag shader
tsinis 7a3a9c3
feat(model): remove shader delegate from basic flag implementation
tsinis 7ea91eb
feat(shader): add waved flag shader delegate and update typedefs
tsinis 259407f
refactor(ui): optimize shader painting and improve caching mechanism
tsinis a9b5c11
docs(ui): doc dispose method and improve documentation for painters
tsinis ff85805
fix(data)!: update alternate and disambiguate symbols for ars
tsinis 0f2d825
refactor(shader): update shader references and improve resource manag…
tsinis f1b9571
feat(ui): add flag shader surface widget with customizable options
tsinis d6be045
refactor(shader): refactor waved flag shader with unrolled fbm functi…
tsinis 62c2443
test(shader): add comprehensive tests for flag shader options and del…
tsinis dcf6df8
test(golden): add waved flag golden tests
tsinis f2f687a
test(ui): improve null safety and formatting in shader classes, fix c…
tsinis b747a46
style(test): improve formatting in waved flag shader delegate tests
tsinis 0aa32de
chore(test): update golden test files for `world_flags` package
tsinis e4d9abb
fix(test): update alternate symbols in fiat currency to match spec
tsinis d21f812
style: improve formatting and clean up imports in various files
tsinis c242866
refactor: simplify wave direction equaluty in shader options and tests
tsinis 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
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
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
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
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
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 |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ publish_to: none | |
| resolution: workspace | ||
|
|
||
| environment: | ||
| sdk: ^3.9.2 | ||
| sdk: ^3.10.4 | ||
|
|
||
| dependencies: | ||
| flutter: | ||
|
|
||
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
8 changes: 8 additions & 0 deletions
8
packages/world_flags/lib/src/helpers/extensions/aspect_ratio_extension.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,8 @@ | ||
| import "package:flutter/foundation.dart" show internal; | ||
|
|
||
| @internal | ||
| extension AspectRatioExtension<T extends double> on T? { | ||
| /// Calculated aspect ratio. | ||
| double? aspectRatio(double? width) => | ||
| width == null || this == null ? null : width / (this ?? 1); | ||
tsinis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
4 changes: 2 additions & 2 deletions
4
packages/world_flags/lib/src/helpers/extensions/decorated_flag_interface_extension.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 |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| import "../../interfaces/decorated_flag_interface.dart"; | ||
| import "aspect_ratio_extension.dart"; | ||
tsinis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /// An extension on [DecoratedFlagInterface] that provides a method to calculate | ||
| /// the aspect ratio of the flag based on its width and height. | ||
| extension DecoratedFlagInterfaceExtension on DecoratedFlagInterface { | ||
| /// The calculated aspect ratio of the flag based on its width and height. | ||
| double? get calculatedAspectRatio => | ||
| width == null || height == null ? null : (width ?? 1) / (height ?? 1); | ||
| double? get calculatedAspectRatio => height.aspectRatio(width); | ||
| } | ||
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
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
39 changes: 39 additions & 0 deletions
39
packages/world_flags/lib/src/ui/effects/flag_shader_delegate.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,39 @@ | ||
| import "dart:ui" show Canvas, Image, Size; | ||
|
|
||
| import "package:flutter/foundation.dart" show Listenable; | ||
|
|
||
| /// A delegate that knows how to post-process flag content with a shader. | ||
| /// | ||
| /// Implementations can decide whether to apply a shader or bail out and let the | ||
| /// fallback painter run. | ||
| abstract class FlagShaderDelegate implements Listenable { | ||
| /// Creates a new instance of [FlagShaderDelegate]. | ||
| const FlagShaderDelegate( // coverage:ignore-line | ||
| { | ||
| this.contentScale = 1, // Dart 3.8 formatting. | ||
| this.shouldClipContent = false, | ||
| }); | ||
|
|
||
| /// Whether the painter should clip to the flag bounds before invoking the | ||
| /// shader. | ||
| /// | ||
| /// Defaults to `false`, allowing shader effects to extend beyond the | ||
| /// rectangle. | ||
| final bool shouldClipContent; | ||
|
|
||
| /// Uniform scale factor to apply to the painted flag before handing it to the | ||
| /// shader. | ||
| /// | ||
| /// Values below `1.0` shrink the base content to leave visual headroom for | ||
| /// shader-driven overflow. Defaults to `1.0` (no scaling). | ||
| final double contentScale; | ||
|
|
||
| /// Attempts to paint [image] with a shader. | ||
| /// | ||
| /// Returns `true` when the shader path was taken. If `false` is returned, the | ||
| /// caller should paint the content normally. | ||
| bool paintWithShader(Canvas destination, Size size, {required Image image}); | ||
|
|
||
| /// Releases any resources allocated by the delegate. | ||
| void dispose(); | ||
| } |
Oops, something went wrong.
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.