fix issues with Area Inset and Tool Bar
This commit is contained in:
1 parent
2e4dfa48cd
commit
85259446b1
3 files changed
+14
-3
No files matched your search
@@ -9,7 +9,7 @@ import SwiftUI
|
|||||||
import SwiftData
|
import SwiftData
|
||||||
|
|
||||||
struct WorldListAreaInsetModifier : ViewModifier {
|
struct WorldListAreaInsetModifier : ViewModifier {
|
||||||
let isSelecting : Bool
|
@Binding var isSelecting : Bool
|
||||||
@Binding var selectedWorlds : Set<World.ID>
|
@Binding var selectedWorlds : Set<World.ID>
|
||||||
let worlds : [World]
|
let worlds : [World]
|
||||||
|
|
||||||
@@ -36,9 +36,16 @@ struct WorldListAreaInsetModifier : ViewModifier {
|
|||||||
Spacer()
|
Spacer()
|
||||||
|
|
||||||
Button(role: .destructive){
|
Button(role: .destructive){
|
||||||
|
let shouldExitSelection = worldsToAction.count == worlds.count
|
||||||
|
|
||||||
for world in worldsToAction {
|
for world in worldsToAction {
|
||||||
context.delete(world)
|
context.delete(world)
|
||||||
}
|
}
|
||||||
|
selectedWorlds.removeAll()
|
||||||
|
|
||||||
|
if shouldExitSelection {
|
||||||
|
isSelecting = false
|
||||||
|
}
|
||||||
}label : {
|
}label : {
|
||||||
Label("Supprimer", systemImage: "trash")
|
Label("Supprimer", systemImage: "trash")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,12 @@ import SwiftUI
|
|||||||
struct WorldListToolbarModifier : ViewModifier {
|
struct WorldListToolbarModifier : ViewModifier {
|
||||||
@Binding var isSelecting : Bool
|
@Binding var isSelecting : Bool
|
||||||
@Binding var selectedWorlds : Set<World.ID>
|
@Binding var selectedWorlds : Set<World.ID>
|
||||||
|
let worldsIsEmpty : Bool
|
||||||
|
|
||||||
func body(content: Content) -> some View {
|
func body(content: Content) -> some View {
|
||||||
content
|
content
|
||||||
.toolbar{
|
.toolbar{
|
||||||
|
if !worldsIsEmpty {
|
||||||
ToolbarItem(placement: .topBarLeading) {
|
ToolbarItem(placement: .topBarLeading) {
|
||||||
if isSelecting {
|
if isSelecting {
|
||||||
Button("Annuler") {
|
Button("Annuler") {
|
||||||
@@ -26,6 +28,7 @@ struct WorldListToolbarModifier : ViewModifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ToolbarItem(placement: .topBarTrailing) {
|
ToolbarItem(placement: .topBarTrailing) {
|
||||||
if !isSelecting {
|
if !isSelecting {
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ struct WorldListView: View {
|
|||||||
.frame(maxHeight: .infinity, alignment: .topLeading)
|
.frame(maxHeight: .infinity, alignment: .topLeading)
|
||||||
.modifier(
|
.modifier(
|
||||||
WorldListAreaInsetModifier(
|
WorldListAreaInsetModifier(
|
||||||
isSelecting: isSelecting,
|
isSelecting: $isSelecting,
|
||||||
selectedWorlds: $selectedWorlds,
|
selectedWorlds: $selectedWorlds,
|
||||||
worlds: worlds
|
worlds: worlds
|
||||||
)
|
)
|
||||||
@@ -78,7 +78,8 @@ struct WorldListView: View {
|
|||||||
.modifier(
|
.modifier(
|
||||||
WorldListToolbarModifier(
|
WorldListToolbarModifier(
|
||||||
isSelecting: $isSelecting,
|
isSelecting: $isSelecting,
|
||||||
selectedWorlds: $selectedWorlds
|
selectedWorlds: $selectedWorlds,
|
||||||
|
worldsIsEmpty: worlds.isEmpty
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user