-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathTabViewProps.swift
More file actions
90 lines (80 loc) · 2.18 KB
/
TabViewProps.swift
File metadata and controls
90 lines (80 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import SwiftUI
internal enum MinimizeBehavior: String {
case automatic
case never
case onScrollUp
case onScrollDown
#if compiler(>=6.2)
@available(iOS 26.0, macOS 26.0, tvOS 26.0, *)
func convert() -> TabBarMinimizeBehavior {
#if os(macOS) || os(tvOS)
return .automatic
#else
switch self {
case .automatic:
return .automatic
case .never:
return .never
case .onScrollUp:
return .onScrollUp
case .onScrollDown:
return .onScrollDown
}
#endif
}
#endif
}
public enum TabBarRole: String {
case search
@available(iOS 18, macOS 15, visionOS 2, tvOS 18, *)
func convert() -> TabRole {
switch self {
case .search:
return .search
}
}
}
struct IdentifiablePlatformView: Identifiable, Equatable {
let id = UUID()
let view: PlatformView
init(_ view: PlatformView) {
self.view = view
}
}
/**
Props that component accepts. SwiftUI view gets re-rendered when ObservableObject changes.
*/
class TabViewProps: ObservableObject {
@Published var children: [IdentifiablePlatformView] = []
@Published var items: [TabInfo] = []
@Published var selectedPage: String?
@Published var icons: [Int: PlatformImage] = [:]
@Published var sidebarAdaptable: Bool?
@Published var labeled: Bool = false
@Published var minimizeBehavior: MinimizeBehavior?
@Published var scrollEdgeAppearance: String?
@Published var barTintColor: PlatformColor?
@Published var activeTintColor: PlatformColor?
@Published var inactiveTintColor: PlatformColor?
@Published var translucent: Bool = true
@Published var disablePageAnimations: Bool = false
@Published var hapticFeedbackEnabled: Bool = false
@Published var layoutDirection: String?
@Published var fontSize: Int?
@Published var fontFamily: String?
@Published var fontWeight: String?
@Published var tabBarHidden: Bool = false
var selectedActiveTintColor: PlatformColor? {
if let selectedPage,
let tabData = items.findByKey(selectedPage),
let activeTintColor = tabData.activeTintColor {
return activeTintColor
}
return activeTintColor
}
var filteredItems: [TabInfo] {
items.filter {
!$0.hidden || $0.key == selectedPage
}
}
}