Skip to content

Commit

Permalink
Fixes compile issue with AutoCapitalization on Xcode 14.2 and below
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerrod Putman committed May 17, 2023
1 parent cbf0a6d commit bfdb0d3
Showing 1 changed file with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,7 @@ public extension Backport where Wrapped: View {
func textInputAutocapitalization(_ autocapitalization: Backport<Any>.TextInputAutocapitalization?) -> some View {
Group {
if #available(iOS 16, *) {
var type: SwiftUI.TextInputAutocapitalization {
switch autocapitalization {
case .none:
return .sentences
case .some(let wrapped):
switch wrapped {
case .never: return .never
case .words: return .words
case .sentences: return .sentences
case .characters: return .characters
default: return .sentences
}
}
}
wrapped.textInputAutocapitalization(type)
wrapped.textInputAutocapitalization(textInputAutocapitalizationType(autocapitalization))
} else {
wrapped.modifier(
AutoCapitalizationModifier(
Expand All @@ -51,6 +37,22 @@ public extension Backport where Wrapped: View {
}
.environment(\.textInputAutocapitalization, autocapitalization)
}

@available(iOS 16.0, *)
private func textInputAutocapitalizationType(_ autocapitalization: Backport<Any>.TextInputAutocapitalization?) -> SwiftUI.TextInputAutocapitalization {
switch autocapitalization {
case .none:
return .sentences
case .some(let wrapped):
switch wrapped {
case .never: return .never
case .words: return .words
case .sentences: return .sentences
case .characters: return .characters
default: return .sentences
}
}
}
}

@available(iOS, deprecated: 15)
Expand Down

0 comments on commit bfdb0d3

Please sign in to comment.