Move device checks to Theme
Drop unused code along the way.
This commit is contained in:
parent
d558edf665
commit
eaaa1fe260
|
@ -26,20 +26,31 @@
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
import PassepartoutCore
|
import PassepartoutCore
|
||||||
|
|
||||||
extension Color {
|
|
||||||
init(red: Double, green: Double, blue: Double, brightness: Double) {
|
|
||||||
self.init(
|
|
||||||
red: red * brightness,
|
|
||||||
green: green * brightness,
|
|
||||||
blue: blue * brightness
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extension View {
|
extension View {
|
||||||
var themeIdiom: UIUserInterfaceIdiom {
|
var themeIdiom: UIUserInterfaceIdiom {
|
||||||
UIDevice.current.userInterfaceIdiom
|
UIDevice.current.userInterfaceIdiom
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var themeIsiPad: Bool {
|
||||||
|
#if targetEnvironment(macCatalyst)
|
||||||
|
false
|
||||||
|
#else
|
||||||
|
UIDevice.current.userInterfaceIdiom == .pad
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
var themeIsiPadPortrait: Bool {
|
||||||
|
#if targetEnvironment(macCatalyst)
|
||||||
|
false
|
||||||
|
#else
|
||||||
|
let device: UIDevice = .current
|
||||||
|
return device.userInterfaceIdiom == .pad && device.orientation.isPortrait
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
var themeIsMultitasking: Bool {
|
||||||
|
UIDevice.current.isMultitaskingSupported
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Global
|
// MARK: Global
|
||||||
|
|
|
@ -58,8 +58,9 @@ extension OrganizerView {
|
||||||
private var mainView: some View {
|
private var mainView: some View {
|
||||||
List {
|
List {
|
||||||
if profileManager.hasProfiles {
|
if profileManager.hasProfiles {
|
||||||
if #available(iOS 15, *), themeIdiom == .pad {
|
|
||||||
// FIXME: iPad multitasking, navigation binding does not clear on pop without Section
|
// FIXME: iPad multitasking, navigation binding does not clear on pop without Section
|
||||||
|
if themeIsiPad && themeIsMultitasking {
|
||||||
Section {
|
Section {
|
||||||
profilesView
|
profilesView
|
||||||
} header: {
|
} header: {
|
||||||
|
|
|
@ -78,7 +78,7 @@ extension OrganizerView {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
isFirstLaunch = false
|
isFirstLaunch = false
|
||||||
if !isiPadPortrait, let activeProfileId = profileManager.activeProfileId {
|
if !themeIsiPadPortrait, let activeProfileId = profileManager.activeProfileId {
|
||||||
profileManager.currentProfileId = activeProfileId
|
profileManager.currentProfileId = activeProfileId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,10 +103,5 @@ extension OrganizerView {
|
||||||
private func persist() {
|
private func persist() {
|
||||||
profileManager.persist()
|
profileManager.persist()
|
||||||
}
|
}
|
||||||
|
|
||||||
private var isiPadPortrait: Bool {
|
|
||||||
let device: UIDevice = .current
|
|
||||||
return device.userInterfaceIdiom == .pad && device.orientation.isPortrait
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue