gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-ios] 56/204: innerHeight


From: gnunet
Subject: [taler-taler-ios] 56/204: innerHeight
Date: Thu, 05 Dec 2024 23:50:24 +0100

This is an automated email from the git hooks/post-receive script.

marc-stibane pushed a commit to branch master
in repository taler-ios.

commit 0e5a0788e715b1d94f89858795911098c7dbea5a
Author: Marc Stibane <marc@taler.net>
AuthorDate: Sat Oct 12 22:45:50 2024 +0200

    innerHeight
---
 .../Views/HelperViews/View+fixedInnerHeight.swift  | 61 ++++++++++++++++++----
 1 file changed, 52 insertions(+), 9 deletions(-)

diff --git a/TalerWallet1/Views/HelperViews/View+fixedInnerHeight.swift 
b/TalerWallet1/Views/HelperViews/View+fixedInnerHeight.swift
index 36a010d..27d213d 100644
--- a/TalerWallet1/Views/HelperViews/View+fixedInnerHeight.swift
+++ b/TalerWallet1/Views/HelperViews/View+fixedInnerHeight.swift
@@ -20,26 +20,69 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
THE
  * SOFTWARE.
  */
+/**
+ * @author Marc Stibane
+ */
 import SwiftUI
-import UIKit
 
-struct InnerHeightPreferenceKey: PreferenceKey {
-    static var defaultValue: CGFloat = .zero
+fileprivate struct InnerHeightKey: PreferenceKey {
+    static var defaultValue: CGFloat { 10 }
     static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
         value = nextValue()
     }
 }
 
+fileprivate struct InnerWidthKey: PreferenceKey {
+    static var defaultValue: CGFloat { 10 }
+    static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
+        value = nextValue()
+    }
+}
+
+fileprivate struct InnerSizeKey: PreferenceKey {
+    static var defaultValue: CGSize { CGSize(width: 10, height: 10) }
+    static func reduce(value: inout CGSize, nextValue: () -> CGSize) {
+        value = nextValue()
+    }
+}
+
 extension View {
     func innerHeight(_ height: Binding<CGFloat>) -> some View {
         overlay {      // background doesn't work for sheets
-                GeometryReader { proxy in
-                    Color.clear.preference(key: InnerHeightPreferenceKey.self, 
value: proxy.size.height)
-                }
+            GeometryReader { proxy in
+                Color.clear
+                    .preference(key: InnerHeightKey.self, value: 
proxy.size.height)
+            }
+        }
+        .onPreferenceChange(InnerHeightKey.self) { newValue in
+ print("❗️InnerHeight \(newValue)❗️")
+            height.wrappedValue = newValue
+        }
+    }
+
+    func innerWidth(_ width: Binding<CGFloat>) -> some View {
+        overlay {      // background doesn't work for sheets
+            GeometryReader { proxy in
+                Color.clear
+                    .preference(key: InnerWidthKey.self, value: 
proxy.size.width)
             }
-            .onPreferenceChange(InnerHeightPreferenceKey.self) { newHeight in
-//                print("InnerHeightPreferenceKey \(newHeight)")
-            height.wrappedValue = newHeight
+        }
+        .onPreferenceChange(InnerWidthKey.self) { newValue in
+  print("❗️InnerWidth \(newValue)❗️")
+            width.wrappedValue = newValue
+        }
+    }
+
+    func innerSize(_ size: Binding<CGSize>) -> some View {
+        overlay {      // background doesn't work for sheets
+            GeometryReader { proxy in
+                Color.clear
+                    .preference(key: InnerSizeKey.self, value: proxy.size)
             }
+        }
+        .onPreferenceChange(InnerSizeKey.self) { newValue in
+  print("❗️InnerSize \(newValue)❗️")
+            size.wrappedValue = newValue
+        }
     }
 }

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]