From 844c4d7587f8cbea9d4fff2e6ad9184df8f4d273 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Thu, 3 Sep 2026 01:03:05 +0200 Subject: [PATCH] replace List by LazyVGrid --- WorldBuilder/Components/WorldCardView.swift | 19 +++++++++++++++ .../Views/WorldList/WorldListView.swift | 23 +++++++++++-------- 2 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 WorldBuilder/Components/WorldCardView.swift diff --git a/WorldBuilder/Components/WorldCardView.swift b/WorldBuilder/Components/WorldCardView.swift new file mode 100644 index 0000000..43436e7 --- /dev/null +++ b/WorldBuilder/Components/WorldCardView.swift @@ -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) + } +} diff --git a/WorldBuilder/Views/WorldList/WorldListView.swift b/WorldBuilder/Views/WorldList/WorldListView.swift index 17b8ce8..a413493 100644 --- a/WorldBuilder/Views/WorldList/WorldListView.swift +++ b/WorldBuilder/Views/WorldList/WorldListView.swift @@ -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) - - if worlds.isEmpty { - EmptyWorldView() - }else{ - ScrollView { - List { + ScrollView { + VStack(alignment: .leading, spacing: 24){ + WorldListHeaderView(worlds: worlds) + + 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) } }