@@ -223,13 +223,14 @@ public struct SettingsTab: Identifiable, View {
223
223
/// The standard set of actions with an add button, a remove button and optionally an options button.
224
224
/// - Parameters:
225
225
/// - add: The action that is called when the add button is pressed.
226
- /// - remove: The action that is called when the remove button is pressed, giving the the selected subtab's index.
226
+ /// - remove: The action that is called when the remove button is pressed,
227
+ /// giving the the selected subtab's id and index.
227
228
/// - options: The action that is called when the options button is pressed.
228
229
/// If it is nil, there is no options button.
229
230
/// - Returns: The new tab with the actions.
230
231
public func standardActions(
231
232
add: @escaping ( ) -> Void ,
232
- remove: @escaping ( Int ? ) -> Void ,
233
+ remove: @escaping ( String ? , Int ? ) -> Void ,
233
234
options: ( ( ) -> Void ) ? = nil
234
235
) -> Self {
235
236
actions {
@@ -243,7 +244,8 @@ public struct SettingsTab: Identifiable, View {
243
244
. init( localized: " Remove " , comment: " SettingsTab (Label of the standard \" Remove \" action) " ) ,
244
245
systemSymbol: . minus
245
246
) {
246
- remove ( content. firstIndex { $0. id == SettingsModel . shared. selectedSubtabs [ id] } )
247
+ let index = content. firstIndex { $0. id == SettingsModel . shared. selectedSubtabs [ id] }
248
+ remove ( content [ safe: index] ? . id, index)
247
249
}
248
250
}
249
251
. spacer ( )
@@ -265,13 +267,14 @@ public struct SettingsTab: Identifiable, View {
265
267
/// The standard set of actions with an add menu, a remove button and optionally an options button.
266
268
/// - Parameters:
267
269
/// - add: The menu that is opened when the add button is pressed.
268
- /// - remove: The action that is called when the remove button is pressed, giving the the selected subtab's index.
270
+ /// - remove: The action that is called when the remove button is pressed,
271
+ /// giving the the selected subtab's id and index.
269
272
/// - options: The action that is called when the options button is pressed.
270
273
/// If it is nil, there is no options button.
271
274
/// - Returns: The new tab with the actions.
272
275
public func standardActions< ContentView> (
273
276
@ViewBuilder add: @escaping ( ) -> ContentView ,
274
- remove: @escaping ( Int ? ) -> Void ,
277
+ remove: @escaping ( String ? , Int ? ) -> Void ,
275
278
options: ( ( ) -> Void ) ? = nil
276
279
) -> Self where ContentView: View {
277
280
actions {
@@ -282,14 +285,13 @@ public struct SettingsTab: Identifiable, View {
282
285
comment: " SettingsTab (Label of the standard \" Add \" action) "
283
286
) ,
284
287
systemSymbol: . plus
285
- ) {
286
- add ( )
287
- }
288
+ ) { add ( ) }
288
289
ToolbarAction (
289
290
. init( localized: " Remove " , comment: " SettingsTab (Label of the standard \" Remove \" action) " ) ,
290
291
systemSymbol: . minus
291
292
) {
292
- remove ( content. firstIndex { $0. id == SettingsModel . shared. selectedSubtabs [ id] } )
293
+ let index = content. firstIndex { $0. id == SettingsModel . shared. selectedSubtabs [ id] }
294
+ remove ( content [ safe: index] ? . id, index)
293
295
}
294
296
}
295
297
. spacer ( )
0 commit comments