Skip to content

Commit

Permalink
Filter used time indices by other items
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdejong1 committed Sep 25, 2024
1 parent 0973998 commit 745e643
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,11 @@ extension BasalProfileEditor {
self.calcTotal()
}
}

func availableTimeIndices(forItemIndex: Int) -> [Int]
{
let usedIndicesByOtherItems = items.filter { $0 != items[forItemIndex] }.map(\.timeIndex)
return (0 ..< timeValues.count).filter { !usedIndicesByOtherItems.contains($0) }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ extension BasalProfileEditor {
.clipped()

Picker(selection: $state.items[index].timeIndex, label: EmptyView()) {
ForEach(0 ..< state.timeValues.count, id: \.self) { i in
ForEach(state.availableTimeIndices(forItemIndex: index), id: \.self) { i in
Text(
self.dateFormatter
.string(from: Date(
Expand Down

0 comments on commit 745e643

Please sign in to comment.