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 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 {
|
||||
var themeIdiom: UIUserInterfaceIdiom {
|
||||
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
|
||||
|
|
|
@ -58,8 +58,9 @@ extension OrganizerView {
|
|||
private var mainView: some View {
|
||||
List {
|
||||
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 {
|
||||
profilesView
|
||||
} header: {
|
||||
|
|
|
@ -78,7 +78,7 @@ extension OrganizerView {
|
|||
return
|
||||
}
|
||||
isFirstLaunch = false
|
||||
if !isiPadPortrait, let activeProfileId = profileManager.activeProfileId {
|
||||
if !themeIsiPadPortrait, let activeProfileId = profileManager.activeProfileId {
|
||||
profileManager.currentProfileId = activeProfileId
|
||||
}
|
||||
}
|
||||
|
@ -103,10 +103,5 @@ extension OrganizerView {
|
|||
private func persist() {
|
||||
profileManager.persist()
|
||||
}
|
||||
|
||||
private var isiPadPortrait: Bool {
|
||||
let device: UIDevice = .current
|
||||
return device.userInterfaceIdiom == .pad && device.orientation.isPortrait
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue