replace List by LazyVGrid
This commit is contained in:
1 parent
1311f3127e
commit
844c4d7587
2 files changed
+31
-9
No files matched your search
@@ -0,0 +1,19 @@
|
|||||||
|
//
|
||||||
|
// WorldCardView.swift
|
||||||
|
// WorldBuilder
|
||||||
|
//
|
||||||
|
// Created by Giovanni Josserand on 03/09/2026.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct WorldCardView : View {
|
||||||
|
var world : World
|
||||||
|
|
||||||
|
var body : some View {
|
||||||
|
VStack {
|
||||||
|
Text(world.name)
|
||||||
|
}
|
||||||
|
.background(.red)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,25 +12,28 @@ struct WorldListView: View {
|
|||||||
@Environment(\.modelContext) private var context
|
@Environment(\.modelContext) private var context
|
||||||
@Query(sort: \World.createdAt, order: .reverse)
|
@Query(sort: \World.createdAt, order: .reverse)
|
||||||
private var worlds: [World]
|
private var worlds: [World]
|
||||||
|
let columns = [GridItem(.flexible()), GridItem(.flexible())]
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(alignment: .leading, spacing: 24){
|
ScrollView {
|
||||||
WorldListHeaderView(worlds: worlds)
|
VStack(alignment: .leading, spacing: 24){
|
||||||
|
WorldListHeaderView(worlds: worlds)
|
||||||
|
|
||||||
if worlds.isEmpty {
|
if worlds.isEmpty {
|
||||||
EmptyWorldView()
|
EmptyWorldView()
|
||||||
}else{
|
}else{
|
||||||
ScrollView {
|
LazyVGrid(columns: columns){
|
||||||
List {
|
|
||||||
ForEach(worlds) {world in
|
ForEach(worlds) {world in
|
||||||
NavigationLink(world.name){
|
NavigationLink{
|
||||||
WorldOverviewView()
|
WorldOverviewView()
|
||||||
|
} label: {
|
||||||
|
WorldCardView(world: world)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.frame(maxHeight: .infinity, alignment: .topLeading)
|
||||||
}
|
}
|
||||||
.frame(maxHeight: .infinity, alignment: .topLeading)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user