mirror of
https://github.com/maxgoedjen/secretive.git
synced 2024-11-22 05:27:28 +00:00
Add default selections (fixes #32)
This commit is contained in:
parent
07ceffb789
commit
6584fc4f3d
@ -17,11 +17,11 @@ struct ContentView: View {
|
|||||||
Section(header: Text(store.name)) {
|
Section(header: Text(store.name)) {
|
||||||
if store.secrets.isEmpty {
|
if store.secrets.isEmpty {
|
||||||
if store is AnySecretStoreModifiable {
|
if store is AnySecretStoreModifiable {
|
||||||
NavigationLink(destination: EmptyStoreModifiableView()) {
|
NavigationLink(destination: EmptyStoreModifiableView(), tag: Constants.emptyStoreModifiableTag, selection: self.$active) {
|
||||||
Text("No Secrets")
|
Text("No Secrets")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
NavigationLink(destination: EmptyStoreView()) {
|
NavigationLink(destination: EmptyStoreView(), tag: Constants.emptyStoreTag, selection: self.$active) {
|
||||||
Text("No Secrets")
|
Text("No Secrets")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -42,7 +42,13 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.onAppear {
|
}.onAppear {
|
||||||
self.active = self.storeList.stores.compactMap { $0.secrets.first }.first?.id
|
let fallback: AnyHashable
|
||||||
|
if self.storeList.modifiableStore?.isAvailable ?? false {
|
||||||
|
fallback = Constants.emptyStoreModifiableTag
|
||||||
|
} else {
|
||||||
|
fallback = Constants.emptyStoreTag
|
||||||
|
}
|
||||||
|
self.active = self.storeList.stores.compactMap { $0.secrets.first }.first?.id ?? fallback
|
||||||
}
|
}
|
||||||
.listStyle(SidebarListStyle())
|
.listStyle(SidebarListStyle())
|
||||||
.frame(minWidth: 100, idealWidth: 240)
|
.frame(minWidth: 100, idealWidth: 240)
|
||||||
@ -66,6 +72,15 @@ struct ContentView: View {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension ContentView {
|
||||||
|
|
||||||
|
enum Constants {
|
||||||
|
static let emptyStoreModifiableTag: AnyHashable = "emptyStoreModifiableTag"
|
||||||
|
static let emptyStoreTag: AnyHashable = "emptyStoreModifiableTag"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
struct ContentView_Previews: PreviewProvider {
|
struct ContentView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
Group {
|
Group {
|
||||||
|
Loading…
Reference in New Issue
Block a user