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
|
||||
@Query(sort: \World.createdAt, order: .reverse)
|
||||
private var worlds: [World]
|
||||
let columns = [GridItem(.flexible()), GridItem(.flexible())]
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 24){
|
||||
WorldListHeaderView(worlds: worlds)
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 24){
|
||||
WorldListHeaderView(worlds: worlds)
|
||||
|
||||
if worlds.isEmpty {
|
||||
EmptyWorldView()
|
||||
}else{
|
||||
ScrollView {
|
||||
List {
|
||||
if worlds.isEmpty {
|
||||
EmptyWorldView()
|
||||
}else{
|
||||
LazyVGrid(columns: columns){
|
||||
ForEach(worlds) {world in
|
||||
NavigationLink(world.name){
|
||||
NavigationLink{
|
||||
WorldOverviewView()
|
||||
} label: {
|
||||
WorldCardView(world: world)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(maxHeight: .infinity, alignment: .topLeading)
|
||||
}
|
||||
.frame(maxHeight: .infinity, alignment: .topLeading)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user