Dismiss the iPhone keyboard on pages with no text field
This commit is contained in:
@@ -28,6 +28,18 @@ private enum PhoneRoute: Hashable {
|
|||||||
case task
|
case task
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private struct PhonePage: Equatable {
|
||||||
|
var tab: PhoneTab
|
||||||
|
var depth: Int
|
||||||
|
var task: String?
|
||||||
|
var taskTab: TaskTab?
|
||||||
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
private func taskTab(_ store: Store) -> TaskTab {
|
||||||
|
store.sheet.flatMap { $0.owner == .lead ? nil : $0.tab } ?? store.primaryTab
|
||||||
|
}
|
||||||
|
|
||||||
private enum MoreRoute: Hashable {
|
private enum MoreRoute: Hashable {
|
||||||
case notes, workflows, status, settings
|
case notes, workflows, status, settings
|
||||||
}
|
}
|
||||||
@@ -122,6 +134,9 @@ struct PhoneView: View {
|
|||||||
.onChange(of: tab == .tasks && !path.isEmpty, initial: true) { _, shown in
|
.onChange(of: tab == .tasks && !path.isEmpty, initial: true) { _, shown in
|
||||||
store.paneFocus.setShown(shown)
|
store.paneFocus.setShown(shown)
|
||||||
}
|
}
|
||||||
|
.onChange(of: page) {
|
||||||
|
dismissKeyboard()
|
||||||
|
}
|
||||||
.fullScreenCover(isPresented: Binding(get: { zoomed != nil }, set: { shown in
|
.fullScreenCover(isPresented: Binding(get: { zoomed != nil }, set: { shown in
|
||||||
if !shown {
|
if !shown {
|
||||||
store.sheet = nil
|
store.sheet = nil
|
||||||
@@ -160,6 +175,13 @@ struct PhoneView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var page: PhonePage {
|
||||||
|
if tab != .tasks || path.isEmpty {
|
||||||
|
return PhonePage(tab: tab, depth: path.count)
|
||||||
|
}
|
||||||
|
return PhonePage(tab: tab, depth: path.count, task: store.selectedTaskId, taskTab: taskTab(store))
|
||||||
|
}
|
||||||
|
|
||||||
private var zoomed: SheetView? {
|
private var zoomed: SheetView? {
|
||||||
switch store.sheet?.view {
|
switch store.sheet?.view {
|
||||||
case .image, .diagram: store.sheet?.view
|
case .image, .diagram: store.sheet?.view
|
||||||
@@ -291,7 +313,7 @@ private struct PhoneTask: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
let selected = store.selectedTaskId.flatMap { store.findTask($0) }
|
let selected = store.selectedTaskId.flatMap { store.findTask($0) }
|
||||||
let accent = selected.map { taskPalette[$0.color] } ?? Palette.accent
|
let accent = selected.map { taskPalette[$0.color] } ?? Palette.accent
|
||||||
let tab = store.sheet.flatMap { $0.owner == .lead ? nil : $0.tab } ?? store.primaryTab
|
let tab = taskTab(store)
|
||||||
VStack(spacing: 0) {
|
VStack(spacing: 0) {
|
||||||
TaskBar()
|
TaskBar()
|
||||||
.overlay(alignment: .leading) {
|
.overlay(alignment: .leading) {
|
||||||
@@ -322,6 +344,11 @@ private struct PhoneTask: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
private func dismissKeyboard() {
|
||||||
|
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
|
||||||
|
}
|
||||||
|
|
||||||
private struct MoreScreen: View {
|
private struct MoreScreen: View {
|
||||||
@ViewState private var route = MoreRoute.notes
|
@ViewState private var route = MoreRoute.notes
|
||||||
|
|
||||||
@@ -331,6 +358,7 @@ private struct MoreScreen: View {
|
|||||||
ForEach([MoreRoute.notes, .workflows, .status, .settings], id: \.self) { r in
|
ForEach([MoreRoute.notes, .workflows, .status, .settings], id: \.self) { r in
|
||||||
PaneTabButton(label: moreTitles[r]!, active: route == r) {
|
PaneTabButton(label: moreTitles[r]!, active: route == r) {
|
||||||
route = r
|
route = r
|
||||||
|
dismissKeyboard()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Spacer(minLength: 0)
|
Spacer(minLength: 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user