James Black
04/13/2022, 7:02 PMenum class ClothingTypes(val clothingLabel:String) {
BLAZER("blazer"),
BLOUSE("blouse"),
UNDERSHIRT("undershirt");
companion object {
fun getNumberOfItems() = values().size
}
}
This code isn't going to compile but basically how would I loop over ClothTypes and get each item in the enum? I did this on the Android side already.
ClothingTypes.allCases.forEach { item in
Toggle(isOn: $isPushEnable) {
item.text
}
}
This is basically what I want to do in a loop.
Toggle(isOn: $isPushEnable) {
Text(list.*get*(index: 0)!.clothingLabel)
}
Toggle(isOn: $isPushEnable) {
Text(list.*get*(index: 1)!.clothingLabel)
}val clothingTypeList = ClothingTypes.values().map{it.clothingLabel}
in my shared viewmodel and then exposing that in the iosApp view model (it is basically just a pass-thru) and I can now use clothingTypeList to loop over.