From e45eba52fe718a25ebb927cfc4fb214203a31125 Mon Sep 17 00:00:00 2001 From: dscyrescotti Date: Mon, 15 Jul 2024 22:15:39 +0700 Subject: [PATCH] feat: add onsubmit for textfield --- Memola/Features/Memo/Toolbar/Toolbar.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Memola/Features/Memo/Toolbar/Toolbar.swift b/Memola/Features/Memo/Toolbar/Toolbar.swift index 64d214d..89e98ce 100644 --- a/Memola/Features/Memo/Toolbar/Toolbar.swift +++ b/Memola/Features/Memo/Toolbar/Toolbar.swift @@ -71,12 +71,12 @@ struct Toolbar: View { .clipShape(.rect(cornerRadius: 8)) .contentShape(.rect(cornerRadius: 8)) } + .disabled(title.isEmpty) #if os(iOS) .hoverEffect(.lift) #else .buttonStyle(.plain) #endif - .disabled(textFieldState) .transition(.move(edge: .top).combined(with: .blurReplace)) } @@ -102,6 +102,9 @@ struct Toolbar: View { } } .transition(.move(edge: .top).combined(with: .blurReplace)) + .onSubmit(of: .text) { + textFieldState = false + } } private var historyControl: some View { @@ -135,7 +138,6 @@ struct Toolbar: View { } .background(.regularMaterial) .clipShape(.rect(cornerRadius: 8)) - .disabled(textFieldState) .transition(.move(edge: .top).combined(with: .blurReplace)) }