feat: add onsubmit for textfield

This commit is contained in:
dscyrescotti
2024-07-15 22:15:39 +07:00
parent 2e64ebc570
commit e45eba52fe

View File

@@ -71,12 +71,12 @@ struct Toolbar: View {
.clipShape(.rect(cornerRadius: 8)) .clipShape(.rect(cornerRadius: 8))
.contentShape(.rect(cornerRadius: 8)) .contentShape(.rect(cornerRadius: 8))
} }
.disabled(title.isEmpty)
#if os(iOS) #if os(iOS)
.hoverEffect(.lift) .hoverEffect(.lift)
#else #else
.buttonStyle(.plain) .buttonStyle(.plain)
#endif #endif
.disabled(textFieldState)
.transition(.move(edge: .top).combined(with: .blurReplace)) .transition(.move(edge: .top).combined(with: .blurReplace))
} }
@@ -102,6 +102,9 @@ struct Toolbar: View {
} }
} }
.transition(.move(edge: .top).combined(with: .blurReplace)) .transition(.move(edge: .top).combined(with: .blurReplace))
.onSubmit(of: .text) {
textFieldState = false
}
} }
private var historyControl: some View { private var historyControl: some View {
@@ -135,7 +138,6 @@ struct Toolbar: View {
} }
.background(.regularMaterial) .background(.regularMaterial)
.clipShape(.rect(cornerRadius: 8)) .clipShape(.rect(cornerRadius: 8))
.disabled(textFieldState)
.transition(.move(edge: .top).combined(with: .blurReplace)) .transition(.move(edge: .top).combined(with: .blurReplace))
} }