Skip to content

Commit 1ae3fb7

Browse files
committed
Add watchOS support
1 parent a178307 commit 1ae3fb7

File tree

7 files changed

+20
-9
lines changed

7 files changed

+20
-9
lines changed

Package.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ let package = Package(
88
platforms: [
99
.iOS("16.0"),
1010
.macOS("13.0"),
11+
.watchOS("9.0"),
1112
],
1213
products: [
1314
// Products define the executables and libraries a package produces, and make them visible to other packages.

Sources/LiveViewNative/BuiltinRegistry.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct BuiltinRegistry {
5656
Link(element: element, context: context)
5757
case "divider":
5858
Divider()
59-
#if !os(macOS)
59+
#if os(iOS)
6060
case "edit-button":
6161
EditButton()
6262
#endif

Sources/LiveViewNative/Modifiers/ListRowSeparatorModifier.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ struct ListRowSeparatorModifier: ViewModifier, Decodable, Equatable {
5555
}
5656

5757
func body(content: Content) -> some View {
58+
#if !os(watchOS)
5859
content.listRowSeparator(visibility, edges: edges)
60+
#else
61+
content
62+
#endif
5963
}
6064

6165
private enum CodingKeys: String, CodingKey {

Sources/LiveViewNative/Views/Layout Containers/Collection Containers/List.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private extension SwiftUI.List {
4545
switch element.attributeValue(for: "style") {
4646
case nil, "plain":
4747
self.listStyle(.plain)
48-
#if !os(macOS)
48+
#if os(iOS)
4949
case "grouped":
5050
self.listStyle(.grouped)
5151
case "inset-grouped":

Sources/LiveViewNative/Views/Text Input and Output/SecureField.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ struct SecureField<R: CustomRegistry>: TextFieldProtocol {
2626
.focused($isFocused)
2727
.applyTextFieldStyle(textFieldStyle)
2828
.applyAutocorrectionDisabled(disableAutocorrection)
29-
#if !os(macOS)
29+
#if os(iOS) || os(tvOS)
3030
.textInputAutocapitalization(autocapitalization)
3131
.applyKeyboardType(keyboard)
3232
#endif

Sources/LiveViewNative/Views/Text Input and Output/TextField.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ struct TextField<R: CustomRegistry>: TextFieldProtocol {
2424
.applyAutocorrectionDisabled(disableAutocorrection)
2525
#if !os(macOS)
2626
.textInputAutocapitalization(autocapitalization)
27+
#endif
28+
#if os(iOS) || os(tvOS)
2729
.applyKeyboardType(keyboard)
2830
#endif
2931
.applySubmitLabel(submitLabel)

Sources/LiveViewNative/Views/Text Input and Output/TextFieldProtocol.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ extension TextFieldProtocol {
108108
}
109109
#endif
110110

111-
#if !os(macOS)
111+
#if os(iOS) || os(tvOS)
112112
var keyboard: UIKeyboardType? {
113113
switch element.attributeValue(for: "keyboard") {
114114
case "ascii-capable":
@@ -168,8 +168,12 @@ extension TextFieldProtocol {
168168
enum TextFieldStyle: String {
169169
case automatic
170170
case plain
171+
#if !os(watchOS)
171172
case roundedBorder = "rounded-border"
173+
#endif
174+
#if os(macOS)
172175
case squareBorder = "square-border"
176+
#endif
173177
}
174178

175179
extension View {
@@ -180,14 +184,14 @@ extension View {
180184
self.textFieldStyle(.automatic)
181185
case .plain:
182186
self.textFieldStyle(.plain)
187+
#if !os(watchOS)
183188
case .roundedBorder:
184189
self.textFieldStyle(.roundedBorder)
190+
#endif
191+
#if os(macOS)
185192
case .squareBorder:
186-
#if os(macOS)
187193
self.textFieldStyle(.squareBorder)
188-
#else
189-
self
190-
#endif
194+
#endif
191195
}
192196
}
193197

@@ -200,7 +204,7 @@ extension View {
200204
}
201205
}
202206

203-
#if !os(macOS)
207+
#if os(iOS) || os(tvOS)
204208
@ViewBuilder
205209
func applyKeyboardType(_ keyboardType: UIKeyboardType?) -> some View {
206210
if let keyboardType {

0 commit comments

Comments
 (0)