fix issues with Area Inset and Tool Bar

This commit is contained in:
Giovanni committed 2026-09-03 19:12:56 +02:00
1 parent 2e4dfa48cd
commit 85259446b1
3 files changed
+14 -3

No files matched your search

@@ -9,7 +9,7 @@ import SwiftUI
import SwiftData
struct WorldListAreaInsetModifier : ViewModifier {
let isSelecting : Bool
@Binding var isSelecting : Bool
@Binding var selectedWorlds : Set<World.ID>
let worlds : [World]
@@ -36,9 +36,16 @@ struct WorldListAreaInsetModifier : ViewModifier {
Spacer()
Button(role: .destructive){
let shouldExitSelection = worldsToAction.count == worlds.count
for world in worldsToAction {
context.delete(world)
}
selectedWorlds.removeAll()
if shouldExitSelection {
isSelecting = false
}
}label : {
Label("Supprimer", systemImage: "trash")
}
@@ -10,10 +10,12 @@ import SwiftUI
struct WorldListToolbarModifier : ViewModifier {
@Binding var isSelecting : Bool
@Binding var selectedWorlds : Set<World.ID>
let worldsIsEmpty : Bool
func body(content: Content) -> some View {
content
.toolbar{
if !worldsIsEmpty {
ToolbarItem(placement: .topBarLeading) {
if isSelecting {
Button("Annuler") {
@@ -26,6 +28,7 @@ struct WorldListToolbarModifier : ViewModifier {
}
}
}
}
ToolbarItem(placement: .topBarTrailing) {
if !isSelecting {
@@ -69,7 +69,7 @@ struct WorldListView: View {
.frame(maxHeight: .infinity, alignment: .topLeading)
.modifier(
WorldListAreaInsetModifier(
isSelecting: isSelecting,
isSelecting: $isSelecting,
selectedWorlds: $selectedWorlds,
worlds: worlds
)
@@ -78,7 +78,8 @@ struct WorldListView: View {
.modifier(
WorldListToolbarModifier(
isSelecting: $isSelecting,
selectedWorlds: $selectedWorlds
selectedWorlds: $selectedWorlds,
worldsIsEmpty: worlds.isEmpty
)
)
}