Skip to content

Commit 4c3b667

Browse files
authored
Add missing HorizontalAlignment, VerticalAlignment, and ToolbarItemPlacement cases (#1292)
* Add missing alignment cases * Add missing `ToolbarItemPlacement` cases * Add watchOS version checks
1 parent e9799a2 commit 4c3b667

File tree

2 files changed

+50
-5
lines changed

2 files changed

+50
-5
lines changed

Sources/LiveViewNative/Utils/Alignment.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ extension Alignment: Decodable, AttributeDecodable {
7575
/// - `leading`
7676
/// - `center`
7777
/// - `trailing`
78+
/// - `listRowSeparatorLeading`
79+
/// - `listRowSeparatorTrailing`
7880
extension HorizontalAlignment: Decodable, AttributeDecodable {
7981
public init(from decoder: Decoder) throws {
8082
let container = try decoder.singleValueContainer()
@@ -94,6 +96,12 @@ extension HorizontalAlignment: Decodable, AttributeDecodable {
9496
self = .leading
9597
case "trailing":
9698
self = .trailing
99+
#if os(iOS) || os(macOS)
100+
case "listRowSeparatorLeading":
101+
self = .listRowSeparatorLeading
102+
case "listRowSeparatorTrailing":
103+
self = .listRowSeparatorTrailing
104+
#endif
97105
default:
98106
return nil
99107
}
@@ -112,6 +120,8 @@ extension HorizontalAlignment: Decodable, AttributeDecodable {
112120
/// - `top`
113121
/// - `center`
114122
/// - `bottom`
123+
/// - `firstTextBaseline`
124+
/// - `lastTextBaseline`
115125
extension VerticalAlignment: Decodable, AttributeDecodable {
116126
public init(from decoder: Decoder) throws {
117127
let container = try decoder.singleValueContainer()
@@ -131,6 +141,10 @@ extension VerticalAlignment: Decodable, AttributeDecodable {
131141
self = .top
132142
case "bottom":
133143
self = .bottom
144+
case "firstTextBaseline":
145+
self = .firstTextBaseline
146+
case "lastTextBaseline":
147+
self = .lastTextBaseline
134148
default:
135149
return nil
136150
}

Sources/LiveViewNative/Views/Toolbars/ToolbarItem.swift

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,25 +158,26 @@ enum ToolbarItemPlacement: String, AttributeDecodable {
158158
case principal
159159
@_documentation(visibility: public)
160160
case navigation
161-
/// `primary-action`
162161
@_documentation(visibility: public)
163162
case primaryAction
164-
/// `secondary-action`
165163
@_documentation(visibility: public)
166164
case secondaryAction
167165
@_documentation(visibility: public)
168166
case status
169-
/// `confirmation-action`
170167
@_documentation(visibility: public)
171168
case confirmationAction
172-
/// `cancellation-action`
173169
@_documentation(visibility: public)
174170
case cancellationAction
175-
/// `destructive-action`
176171
@_documentation(visibility: public)
177172
case destructiveAction
178173
@_documentation(visibility: public)
179174
case keyboard
175+
@_documentation(visibility: public)
176+
case topBarLeading
177+
@_documentation(visibility: public)
178+
case topBarTrailing
179+
@_documentation(visibility: public)
180+
case bottomBar
180181

181182
var placement: SwiftUI.ToolbarItemPlacement {
182183
switch self {
@@ -215,6 +216,36 @@ enum ToolbarItemPlacement: String, AttributeDecodable {
215216
#else
216217
return .keyboard
217218
#endif
219+
case .topBarLeading:
220+
#if os(macOS)
221+
return .automatic
222+
#else
223+
if #available(watchOS 10, *) {
224+
return .topBarLeading
225+
} else {
226+
return .automatic
227+
}
228+
#endif
229+
case .topBarTrailing:
230+
#if os(macOS)
231+
return .automatic
232+
#else
233+
if #available(watchOS 10, *) {
234+
return .topBarTrailing
235+
} else {
236+
return .automatic
237+
}
238+
#endif
239+
case .bottomBar:
240+
#if os(macOS) || os(tvOS)
241+
return .automatic
242+
#else
243+
if #available(watchOS 10, *) {
244+
return .bottomBar
245+
} else {
246+
return .automatic
247+
}
248+
#endif
218249
}
219250
}
220251
}

0 commit comments

Comments
 (0)