-
Notifications
You must be signed in to change notification settings - Fork 14
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
Showing
6 changed files
with
62 additions
and
20 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
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,21 @@ | ||
import SwiftUI | ||
|
||
extension View { | ||
/// Le but de cet helper est de simplifier l'utilisation du geometry reader | ||
/// - Parameter onChange: what to do on size update | ||
func readSize(onChange: @escaping (CGSize) -> Void) -> some View { | ||
background( | ||
GeometryReader { geometryProxy in | ||
Color.clear | ||
.preference(key: ReadSizePreferenceKey.self, value: geometryProxy.size) | ||
} | ||
) | ||
.onPreferenceChange(ReadSizePreferenceKey.self, perform: onChange) | ||
} | ||
} | ||
|
||
struct ReadSizePreferenceKey: PreferenceKey { | ||
static var defaultValue: CGSize = .zero | ||
|
||
static func reduce(value _: inout CGSize, nextValue _: () -> CGSize) {} | ||
} |
6 changes: 6 additions & 0 deletions
6
Showcase/ShowcaseSnapshotTests/__Snapshots__/NonRegressionTests/testButtonAlignement.1.txt
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,6 @@ | ||
<_TtGC7SwiftUI14_UIHostingViewGVS_15ModifiedContentGVS_6HStackGVS_9TupleViewTGS1_GS1_GS1_V14VitaminSwiftUI13VitaminButtonVS_16_FixedSizeLayout_GVS_19_BackgroundModifierGVS_14GeometryReaderGS1_VS_5ColorGVS_26_PreferenceWritingModifierV21ShowcaseSnapshotTests21ReadSizePreferenceKey_____GVS_25_PreferenceActionModifierS12___GS1_GS1_GS1_S5_S6__GS7_GS8_GS1_S9_GS10_S12______GS13_S12______VS_14_PaddingLayout__; frame = (0 0; 390 844); autoresize = W+H; gestureRecognizers = <NSArray>; backgroundColor = <UIDynamicSystemColor; name = systemBackgroundColor>; layer = <CALayer>> | ||
| <_TtC7SwiftUIP33_A34643117F00277B93DEBAB70EC0697122_UIShapeHitTestingView; frame = (67 406; 188 52); anchorPoint = (0, 0); autoresizesSubviews = NO; backgroundColor = UIExtendedSRGBColorSpace 0.905882 0.952941 0.976471 1; layer = <CALayer>> | ||
| <SwiftUI._UIGraphicsView; frame = (87 422; 20 20); anchorPoint = (0, 0); autoresizesSubviews = NO; layer = <SwiftUI.ImageLayer>> | ||
| <_TtCOCV7SwiftUI11DisplayList11ViewUpdater8Platform13CGDrawingView; frame = (117 422.667; 118 19); anchorPoint = (0, 0); opaque = NO; autoresizesSubviews = NO; layer = <_TtCOCV7SwiftUI11DisplayList11ViewUpdater8PlatformP33_65A81BD07F0108B0485D2E15DE104A7514CGDrawingLayer>> | ||
| <_TtC7SwiftUIP33_A34643117F00277B93DEBAB70EC0697122_UIShapeHitTestingView; frame = (263 406; 60 52); anchorPoint = (0, 0); autoresizesSubviews = NO; backgroundColor = UIExtendedSRGBColorSpace 0.905882 0.952941 0.976471 1; layer = <CALayer>> | ||
| <SwiftUI._UIGraphicsView; frame = (283 422; 20 20); anchorPoint = (0, 0); autoresizesSubviews = NO; layer = <SwiftUI.ImageLayer>> |
Binary file added
BIN
+20.8 KB
...owcaseSnapshotTests/__Snapshots__/NonRegressionTests/testButtonAlignement.2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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