Closed longseespace closed 12 months ago
I've just released SettingsKit 0.2.1 which implements exactly your suggestion.
@longseespace, note that since 0.2.0, the following code does not build anymore:
SettingsTab(.init("Models" as String, systemSymbol: .cpu), id: "model") {
SettingsSubtab(.init("Static Item 1" as String, systemSymbol: .cpu), id: "model-static-1") {
StaticItem1()
}
}
Instead, use:
SettingsTab(.new(title: "Models", icon: .cpu), id: "model") {
SettingsSubtab(.new(title: "Static Item 1", icon: .cpu), id: "model-static-1") {
StaticItem1()
}
}
The reason for that change is that SettingsKit now supports a sidebar layout additionally to the tab bar layout.
Problem Statement
The current implementation of
. standardActions {}
usesindex
instead ofid
for theremove
action. This is quite problematic when the order of the list changes, or when there is a mix of static items and dynamic items.Let me explain. Given this code:
When removing an item, I always have to check if the index >= 2 (dynamic) or static. When I add new static item to the settings sub-tabs, it's prone to error.
Suggestion
Maybe support both index and id in the callback parameters? Something like this
IMO,
id
should be the source of truth, notindex
.