Make UnmaskSecureField respond to dynamic type (#1424)

* Make UnmaskSecureField respond to dynamic type

* use environment font

---------

Co-authored-by: Ethan Pippin <ethanpippin2343@gmail.com>
This commit is contained in:
Sam 2025-02-15 14:05:51 -08:00 committed by GitHub
parent 0235793bc6
commit 6ee2b71cab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 3 deletions

View File

@ -10,7 +10,7 @@ import SwiftUI
extension Font { extension Font {
var uiFont: UIFont { var uiFont: UIFont? {
switch self { switch self {
#if os(iOS) #if os(iOS)
case .largeTitle: case .largeTitle:
@ -37,7 +37,7 @@ extension Font {
case .body: case .body:
return UIFont.preferredFont(forTextStyle: .body) return UIFont.preferredFont(forTextStyle: .body)
default: default:
return UIFont.preferredFont(forTextStyle: .body) return nil
} }
} }
} }

View File

@ -32,6 +32,8 @@ struct UnmaskSecureField: UIViewRepresentable {
func makeUIView(context: Context) -> UITextField { func makeUIView(context: Context) -> UITextField {
let textField = UITextField() let textField = UITextField()
textField.font = context.environment.font?.uiFont ?? UIFont.preferredFont(forTextStyle: .body)
textField.adjustsFontForContentSizeCategory = true
textField.isSecureTextEntry = true textField.isSecureTextEntry = true
textField.keyboardType = .asciiCapable textField.keyboardType = .asciiCapable
textField.placeholder = title textField.placeholder = title

View File

@ -66,7 +66,7 @@ extension SeriesEpisodeSelector {
v.frame( v.frame(
height: "A\nA\nA".height( height: "A\nA\nA".height(
withConstrainedWidth: 10, withConstrainedWidth: 10,
font: Font.caption.uiFont font: Font.caption.uiFont ?? UIFont.preferredFont(forTextStyle: .body)
) )
) )
} }