Preselect profile on NavigationLink appearance
More accurate than ForEach and maybe the only right place.
This commit is contained in:
parent
5d85699ce4
commit
b1882dcf80
|
@ -79,7 +79,6 @@ extension OrganizerView {
|
||||||
Section {
|
Section {
|
||||||
ForEach(headers.sorted(), content: navigationLink(forHeader:))
|
ForEach(headers.sorted(), content: navigationLink(forHeader:))
|
||||||
.onDelete(perform: removeProfiles)
|
.onDelete(perform: removeProfiles)
|
||||||
.onAppear(perform: selectActiveProfile)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,6 +100,8 @@ extension OrganizerView {
|
||||||
} else {
|
} else {
|
||||||
ProfileHeaderRow(header: header)
|
ProfileHeaderRow(header: header)
|
||||||
}
|
}
|
||||||
|
}.onAppear {
|
||||||
|
preselectActiveProfile(header.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,7 +134,7 @@ extension OrganizerView.ProfilesList {
|
||||||
}
|
}
|
||||||
|
|
||||||
extension OrganizerView.ProfilesList {
|
extension OrganizerView.ProfilesList {
|
||||||
private func selectActiveProfile() {
|
private func preselectActiveProfile(_ id: UUID) {
|
||||||
guard isFirstLaunch else {
|
guard isFirstLaunch else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -146,9 +147,9 @@ extension OrganizerView.ProfilesList {
|
||||||
//
|
//
|
||||||
if alertType == nil,
|
if alertType == nil,
|
||||||
themeIdiom != .pad,
|
themeIdiom != .pad,
|
||||||
let activeProfileId = profileManager.activeHeader?.id {
|
id == profileManager.activeHeader?.id {
|
||||||
|
|
||||||
selectedProfileId = activeProfileId
|
selectedProfileId = id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue