summaryrefslogtreecommitdiff
path: root/JuickNext/Helpers
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2024-05-15 11:52:54 +0300
committerGravatar Vitaly Takmazov2024-05-15 11:58:06 +0300
commit7fe780a549f71bb95e4df0a52a1e701c5f8169dd (patch)
treeb6eabaac982bd77ba4b4db761a8bda8c71ad0b07 /JuickNext/Helpers
parent2088d0196956a9321f1dc2afaf82125bd1775a90 (diff)
Fix both layouts
Diffstat (limited to 'JuickNext/Helpers')
-rw-r--r--JuickNext/Helpers/View+ScreenTitle.swift39
1 files changed, 39 insertions, 0 deletions
diff --git a/JuickNext/Helpers/View+ScreenTitle.swift b/JuickNext/Helpers/View+ScreenTitle.swift
new file mode 100644
index 0000000..192b3bc
--- /dev/null
+++ b/JuickNext/Helpers/View+ScreenTitle.swift
@@ -0,0 +1,39 @@
+//
+// View+ScreenTitle.swift
+// JuickNext
+//
+// Created by Vitaly Takmazov on 15.05.2024.
+// Copyright © 2024 com.juick. All rights reserved.
+//
+
+import Foundation
+import SwiftUI
+
+public struct ScreenTitleModifier: ViewModifier {
+
+ let screenTitle: String
+
+ init(title: String) {
+ self.screenTitle = title
+ }
+
+
+ public func body(content: Content) -> some View {
+ if #available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *) {
+ content.navigationTitle(self.screenTitle)
+ } else {
+#if os(iOS)
+ content.navigationBarTitle(self.screenTitle)
+#else
+ content
+#endif
+ }
+ }
+}
+
+extension View {
+ @ViewBuilder
+ func screenTitle(title: String) -> some View {
+ modifier(ScreenTitleModifier(title: title))
+ }
+}