Add stepper and scroll dismiss keyboard in settings

This commit is contained in:
Arkadiusz Fal 2022-12-21 00:14:38 +01:00
parent 79df3c6e8b
commit 5b482323a0

View File

@ -45,6 +45,10 @@ struct PlayerControlsSettings: View {
List { List {
sections sections
} }
#if !os(tvOS)
.backport
.scrollDismissesKeyboard()
#endif
#endif #endif
} }
#if os(tvOS) #if os(tvOS)
@ -208,15 +212,64 @@ struct PlayerControlsSettings: View {
Text(name) Text(name)
.frame(minWidth: 140, alignment: .leading) .frame(minWidth: 140, alignment: .leading)
Spacer() Spacer()
TextField("Duration", text: value)
.frame(maxWidth: 100, alignment: .trailing) HStack {
.multilineTextAlignment(.trailing) #if !os(tvOS)
Button {
var intValue = Int(value.wrappedValue) ?? 10
intValue += 5
if intValue <= 0 {
intValue = 5
}
value.wrappedValue = String(intValue)
} label: {
Label("Plus", systemImage: "plus")
.imageScale(.large)
.padding(7)
.labelStyle(.iconOnly)
.frame(minHeight: 35)
.foregroundColor(.primary)
.contentShape(Rectangle())
}
.background(RoundedRectangle(cornerRadius: 4).stroke(lineWidth: 1))
#endif
.labelsHidden() #if os(tvOS)
#if !os(macOS) let textFieldWidth = 100.00
.keyboardType(.numberPad) #else
#endif let textFieldWidth = 30.00
#endif
TextField("Duration", text: value)
.frame(width: textFieldWidth, alignment: .trailing)
.multilineTextAlignment(.center)
.labelsHidden()
#if !os(macOS)
.keyboardType(.numberPad)
#endif
#if !os(tvOS)
Button {
var intValue = Int(value.wrappedValue) ?? 10
intValue -= 5
if intValue <= 0 {
intValue = 5
}
value.wrappedValue = String(intValue)
} label: {
Label("Minus", systemImage: "minus")
.imageScale(.large)
.padding(7)
.labelStyle(.iconOnly)
.frame(minHeight: 35)
.foregroundColor(.primary)
.contentShape(Rectangle())
}
.background(RoundedRectangle(cornerRadius: 4).stroke(lineWidth: 1))
.buttonStyle(.plain)
#endif
}
} }
} }