-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Calculate container size and close sheet if offset > height / 2
- Loading branch information
1 parent
f3d1554
commit 2d95831
Showing
3 changed files
with
42 additions
and
1 deletion.
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
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,32 @@ | ||
// | ||
// Utils.swift | ||
// ChatlaxSheet | ||
// | ||
// Created by Арам on 26.02.2023. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct SizeCalculator: ViewModifier { | ||
|
||
@Binding var size: CGSize | ||
|
||
func body(content: Content) -> some View { | ||
content | ||
.background( | ||
GeometryReader { proxy in | ||
Color.clear | ||
.onAppear { | ||
size = proxy.size | ||
} | ||
} | ||
) | ||
} | ||
|
||
} | ||
|
||
extension View { | ||
func saveSize(in size: Binding<CGSize>) -> some View { | ||
modifier(SizeCalculator(size: size)) | ||
} | ||
} |