Skip to content

Commit 549ca87

Browse files
Added Tab initializers with Symbol paramenets
1 parent cbc14ba commit 549ca87

1 file changed

Lines changed: 113 additions & 0 deletions

File tree

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import SwiftUI
2+
3+
@available(macOS 15.0, *)
4+
@available(iOS 18.0, *)
5+
public extension Tab {
6+
/// Creates a tab that the tab view presents when the tab view's selection
7+
/// matches the tab's value using a system symbol for the tab's tab item image,
8+
/// with a string label.
9+
///
10+
/// - Parameters:
11+
/// - title: The label for the tab's tab item.
12+
/// - symbol: The system symbol for the tab's tab item.
13+
/// - value: The `selection` value which selects this tab.
14+
/// - content: The view content of the tab.
15+
init<S>(_ title: S, symbol: SFSymbol, value: Value, @ViewBuilder content: () -> Content) where Label == DefaultTabLabel, S : StringProtocol, Value: Hashable, Content: View {
16+
self = Tab(title, systemImage: symbol.name, value: value, content: content)
17+
}
18+
19+
/// Creates a tab that the tab view presents when the tab view's selection
20+
/// matches the tab's value using a system symbol for the tab's tab item image,
21+
/// with a string label.
22+
///
23+
/// - Parameters:
24+
/// - title: The label for the tab's tab item.
25+
/// - systemImage: The system symbol for the tab's tab item.
26+
/// - value: The `selection` value which selects this tab.
27+
/// - role: The role defining the semantic purpose of the tab.
28+
/// - content: The view content of the tab.
29+
init<S>(_ title: S, symbol: SFSymbol, value: Value, role: TabRole?, @ViewBuilder content: () -> Content) where Label == DefaultTabLabel, S : StringProtocol, Value: Hashable, Content: View {
30+
self = Tab(title, systemImage: symbol.name, value: value, role: role, content: content)
31+
}
32+
33+
/// Creates a tab that the tab view presents when the tab view's selection
34+
/// matches the tab's value using a system symbol for the tab's tab item image,
35+
/// with a string label.
36+
///
37+
/// - Parameters:
38+
/// - title: The label for the tab's tab item.
39+
/// - systemImage: The system symbol for the tab's tab item.
40+
/// - value: The `selection` value which selects this tab.
41+
/// - content: The view content of the tab.
42+
init<S, T>(_ title: S, symbol: SFSymbol, value: T, @ViewBuilder content: () -> Content) where Value == T?, Label == DefaultTabLabel, S : StringProtocol, T : Hashable, T: Hashable, Content: View {
43+
self = Tab(title, systemImage: symbol.name, value: value, content: content)
44+
}
45+
46+
/// Creates a tab that the tab view presents when the tab view's selection
47+
/// matches the tab's value using a system symbol for the tab's tab item image,
48+
/// with a string label.
49+
///
50+
/// - Parameters:
51+
/// - title: The label for the tab's tab item.
52+
/// - systemImage: The system symbol for the tab's tab item.
53+
/// - value: The `selection` value which selects this tab.
54+
/// - role: The role defining the semantic purpose of the tab.
55+
/// - content: The view content of the tab.
56+
init<S, T>(_ title: S, symbol: SFSymbol, value: T, role: TabRole?, @ViewBuilder content: () -> Content) where Value == T?, Label == DefaultTabLabel, S : StringProtocol, T : Hashable, Content: View {
57+
self = Tab(title, systemImage: symbol.name, value: value, role: role, content: content)
58+
}
59+
60+
/// Creates a tab that the tab view presents when the tab view's selection
61+
/// matches the tab's value using a system symbol for the tab's tab item image,
62+
/// with a localized string key label.
63+
///
64+
/// - Parameters:
65+
/// - titleKey: The localized string key label for the tab's tab item.
66+
/// - symbol: The system symbol for the tab's tab item.
67+
/// - value: The `selection` value which selects this tab.
68+
/// - content: The view content of the tab.
69+
init(_ titleKey: LocalizedStringKey, symbol: SFSymbol, value: Value, @ViewBuilder content: () -> Content) where Label == DefaultTabLabel, Value: Hashable, Content: View {
70+
self = Tab(titleKey, systemImage: symbol.name, value: value, content: content)
71+
}
72+
73+
/// Creates a tab that the tab view presents when the tab view's selection
74+
/// matches the tab's value using a system symbol for the tab's tab item image,
75+
/// with a localized string key label.
76+
///
77+
/// - Parameters:
78+
/// - titleKey: The localized string key label for the tab's tab item.
79+
/// - symbol: The system symbol for the tab's tab item.
80+
/// - value: The `selection` value which selects this tab.
81+
/// - role: The role defining the semantic purpose of the tab.
82+
/// - content: The view content of the tab.
83+
init(_ titleKey: LocalizedStringKey, symbol: SFSymbol, value: Value, role: TabRole?, @ViewBuilder content: () -> Content) where Label == DefaultTabLabel, Value: Hashable, Content: View {
84+
self = Tab(titleKey, systemImage: symbol.name, value: value, role: role, content: content)
85+
}
86+
87+
/// Creates a tab that the tab view presents when the tab view's selection
88+
/// matches the tab's value using a system symbol for the tab's tab item image,
89+
/// with a localized string key label.
90+
///
91+
/// - Parameters:
92+
/// - titleKey: The localized string key label for the tab's tab item.
93+
/// - symbol: The system symbol for the tab's tab item.
94+
/// - value: The `selection` value which selects this tab.
95+
/// - content: The view content of the tab.
96+
init<T>(_ titleKey: LocalizedStringKey, symbol: SFSymbol, value: T, @ViewBuilder content: () -> Content) where Value == T?, Label == DefaultTabLabel, T : Hashable, Content: View {
97+
self = Tab(titleKey, systemImage: symbol.name, value: value, content: content)
98+
}
99+
100+
/// Creates a tab that the tab view presents when the tab view's selection
101+
/// matches the tab's value using a system symbol for the tab's tab item image,
102+
/// with a localized string key label.
103+
///
104+
/// - Parameters:
105+
/// - titleKey: The localized string key label for the tab's tab item.
106+
/// - systemImage: The system symbol for the tab's tab item.
107+
/// - value: The `selection` value which selects this tab.
108+
/// - role: The role defining the semantic purpose of the tab.
109+
/// - content: The view content of the tab.
110+
init<T>(_ titleKey: LocalizedStringKey, symbol: SFSymbol, value: T, role: TabRole?, @ViewBuilder content: () -> Content) where Value == T?, Label == DefaultTabLabel, T : Hashable, Content: View {
111+
self = Tab(titleKey, systemImage: symbol.name, value: value, role: role, content: content)
112+
}
113+
}

0 commit comments

Comments
 (0)