so I have been trying to create an expandable list to present different types of information.
I have a generic struct as such for all the different instances:
struct Password: Identifiable {
var id = UUID()
var password: String?
var containsSymbols: Bool?
var containsUppercase: Bool?
var entropy: Double?
var possibleCombinations: Double?
var strengthColor: Color?
var content: [Password]?
}
And I instantiate various Password objects as such:
let entropyPassword = Password(entropy: entropy)
let combinationPassword = Password(possibleCombinations: possibleCombinaisons)
let password = Password(password: newPassword, containsSymbols: containsSymbols, containsUppercase: containsUppercase, strengthColor: color, content: [entropyPassword, combinationPassword])
However, in the main ContentView, I do something like this to achieve a nested expandable list.
List(vm.passwords) { password in
HStack {
Text("\(password.password ?? "Default")")
.padding()
.textSelection(.enabled)
Spacer()
Image(systemName: "lock.fill")
.foregroundColor(password.strengthColor)
}
}
However, I keep seeing the word "Default" when clicking on the initial password. Is there a way to click on the initial password to then see the entropy and the possible combinations, preferably in an expandable list?