From 171c1e1dd4bccc2b658cb2445d9c8e4506a8643b Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sun, 1 May 2022 19:27:13 +0200 Subject: [PATCH] Omit wrapping Section on Mac --- Passepartout/App/Views/OrganizerView.swift | 27 ++++++++++++------- .../Managers/ProfileManager.swift | 4 +++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Passepartout/App/Views/OrganizerView.swift b/Passepartout/App/Views/OrganizerView.swift index 2d5f4de1..133659e4 100644 --- a/Passepartout/App/Views/OrganizerView.swift +++ b/Passepartout/App/Views/OrganizerView.swift @@ -125,7 +125,7 @@ struct OrganizerView: View { return ZStack { hiddenSceneView mainView - if profileManager.headers.isEmpty { + if !profileManager.hasProfiles { emptyView } }.toolbar { @@ -171,18 +171,27 @@ struct OrganizerView: View { private var mainView: some View { List { - let headers = sortedHeaders - if !headers.isEmpty { - // FIXME: iPad multitasking, navigation binding does not clear on pop without Section - Section { - ForEach(sortedHeaders, content: profileRow(forHeader:)) - .onDelete(perform: removeProfiles) - } header: { - Text(L10n.Global.Strings.profiles) + if profileManager.hasProfiles { + switch themeIdiom { + case .mac: + profilesView + + default: + // FIXME: iPad multitasking, navigation binding does not clear on pop without Section + Section { + profilesView + } header: { + Text(L10n.Global.Strings.profiles) + } } } }.themeAnimation(on: profileManager.headers) } + + private var profilesView: some View { + ForEach(sortedHeaders, content: profileRow(forHeader:)) + .onDelete(perform: removeProfiles) + } private var emptyView: some View { VStack { diff --git a/PassepartoutCore/Sources/PassepartoutProfiles/Managers/ProfileManager.swift b/PassepartoutCore/Sources/PassepartoutProfiles/Managers/ProfileManager.swift index 954dee1c..c7c5c0fe 100644 --- a/PassepartoutCore/Sources/PassepartoutProfiles/Managers/ProfileManager.swift +++ b/PassepartoutCore/Sources/PassepartoutProfiles/Managers/ProfileManager.swift @@ -109,6 +109,10 @@ extension ProfileManager { availableHeaders } + public var hasProfiles: Bool { + !availableHeaders.isEmpty + } + public var hasActiveProfile: Bool { activeHeader != nil }