Omit wrapping Section on Mac

This commit is contained in:
Davide De Rosa 2022-05-01 19:27:13 +02:00
parent cfc0d4f572
commit 171c1e1dd4
2 changed files with 22 additions and 9 deletions

View File

@ -125,7 +125,7 @@ struct OrganizerView: View {
return ZStack { return ZStack {
hiddenSceneView hiddenSceneView
mainView mainView
if profileManager.headers.isEmpty { if !profileManager.hasProfiles {
emptyView emptyView
} }
}.toolbar { }.toolbar {
@ -171,18 +171,27 @@ struct OrganizerView: View {
private var mainView: some View { private var mainView: some View {
List { List {
let headers = sortedHeaders if profileManager.hasProfiles {
if !headers.isEmpty { switch themeIdiom {
// FIXME: iPad multitasking, navigation binding does not clear on pop without Section case .mac:
Section { profilesView
ForEach(sortedHeaders, content: profileRow(forHeader:))
.onDelete(perform: removeProfiles) default:
} header: { // FIXME: iPad multitasking, navigation binding does not clear on pop without Section
Text(L10n.Global.Strings.profiles) Section {
profilesView
} header: {
Text(L10n.Global.Strings.profiles)
}
} }
} }
}.themeAnimation(on: profileManager.headers) }.themeAnimation(on: profileManager.headers)
} }
private var profilesView: some View {
ForEach(sortedHeaders, content: profileRow(forHeader:))
.onDelete(perform: removeProfiles)
}
private var emptyView: some View { private var emptyView: some View {
VStack { VStack {

View File

@ -109,6 +109,10 @@ extension ProfileManager {
availableHeaders availableHeaders
} }
public var hasProfiles: Bool {
!availableHeaders.isEmpty
}
public var hasActiveProfile: Bool { public var hasActiveProfile: Bool {
activeHeader != nil activeHeader != nil
} }