Skip to content

Commit

Permalink
Fixes an issue that data source cannot be focused on iOS 15 & 16.
Browse files Browse the repository at this point in the history
  • Loading branch information
mntone committed Jan 31, 2024
1 parent d31ab83 commit 44fb39b
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/App/Views/Settings/Data/DataSettingsPane.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,27 @@ import SwiftUI

#if os(iOS)
import SwiftUIIntrospect

fileprivate extension View {
var isiOS17: Bool {
if #available(iOS 17.0, *) {
true
} else {
false
}
}
}
#endif

struct DataSettingsPane: View {
@StateObject
private var viewModel = DataSettingsViewModel()

#if os(iOS)
@Environment(\.horizontalLayoutMargin)
private var horizontalLayoutMargin
#endif

#if !os(watchOS)
@FocusState
private var isActive: Bool
Expand Down Expand Up @@ -75,9 +90,8 @@ struct DataSettingsPane: View {
} header: {
Text("Data Source")
} footer: {
if isEditMode {
Text("If there is a problem with the reference data, Prof. Monster may crash.")
}
Text("If there is a problem with the reference data, Prof. Monster may crash.")
.opacity(isEditMode ? 1.0 : 0.0) // DO NOT USE `if`. It no longer works on iOS 15 & 16.
}

if !isEditMode {
Expand All @@ -103,6 +117,9 @@ struct DataSettingsPane: View {
isActive = false
#endif
}
#if os(iOS)
.padding(.trailing, isiOS17 ? 0.0 : horizontalLayoutMargin)
#endif
.disabled(!viewModel.enableSaveButton)
}
}
Expand Down Expand Up @@ -133,7 +150,7 @@ struct DataSettingsPane: View {
.animation(.default, value: isActive)
#endif
#if os(iOS)
.closeButtonDisabled(isEditMode)
.closeButtonDisabled(isActive)
#endif
.interactiveDismissDisabled(isEditMode)
#if !os(macOS)
Expand Down

0 comments on commit 44fb39b

Please sign in to comment.