replace List by LazyVGrid

This commit is contained in:
Giovanni committed 2026-09-03 01:03:05 +02:00
1 parent 1311f3127e
commit 844c4d7587
2 files changed
+26 -4

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,20 +12,22 @@ struct WorldListView: View {
@Environment(\.modelContext) private var context
@Query(sort: \World.createdAt, order: .reverse)
private var worlds: [World]
let columns = [GridItem(.flexible()), GridItem(.flexible())]
var body: some View {
ScrollView {
VStack(alignment: .leading, spacing: 24){
WorldListHeaderView(worlds: worlds)
if worlds.isEmpty {
EmptyWorldView()
}else{
ScrollView {
List {
LazyVGrid(columns: columns){
ForEach(worlds) {world in
NavigationLink(world.name){
NavigationLink{
WorldOverviewView()
}
} label: {
WorldCardView(world: world)
}
}
}
@@ -34,3 +36,4 @@ struct WorldListView: View {
.frame(maxHeight: .infinity, alignment: .topLeading)
}
}
}