From a53bb8870b94bf6d89cf262222248909af0d66b8 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Thu, 3 Sep 2026 00:17:56 +0200 Subject: [PATCH] Fix visual of EmptyWorld.swift --- .../Components/CreateWorldButtonView.swift | 23 +++++++++++ WorldBuilder/Views/Home/HomeView.swift | 5 +-- .../WorldList/Components/EmptyWorldView.swift | 39 +++++++++++++++++++ .../Components/WorldListHeaderView.swift | 27 +++++++++++++ .../Views/WorldList/WorldListView.swift | 26 ++++++------- 5 files changed, 103 insertions(+), 17 deletions(-) create mode 100644 WorldBuilder/Components/CreateWorldButtonView.swift create mode 100644 WorldBuilder/Views/WorldList/Components/EmptyWorldView.swift create mode 100644 WorldBuilder/Views/WorldList/Components/WorldListHeaderView.swift diff --git a/WorldBuilder/Components/CreateWorldButtonView.swift b/WorldBuilder/Components/CreateWorldButtonView.swift new file mode 100644 index 0000000..1a67e40 --- /dev/null +++ b/WorldBuilder/Components/CreateWorldButtonView.swift @@ -0,0 +1,23 @@ +// +// CreateWorldButton.swift +// WorldBuilder +// +// Created by Giovanni Josserand on 02/09/2026. +// + +import SwiftUI + +struct CreateWorldButtonView : View { + var body: some View { + NavigationLink{ + CreateWorldView() + } label : { + Label("Créer un monde", systemImage: "plus") + .font(.headline) + .padding(.vertical, 14) + .frame(maxWidth: .infinity) + } + .frame(maxWidth: 300) + .buttonStyle(.glassProminent) + } +} diff --git a/WorldBuilder/Views/Home/HomeView.swift b/WorldBuilder/Views/Home/HomeView.swift index 656ac7d..21a486e 100644 --- a/WorldBuilder/Views/Home/HomeView.swift +++ b/WorldBuilder/Views/Home/HomeView.swift @@ -9,9 +9,6 @@ import SwiftUI struct HomeView : View { var body: some View { - NavigationLink("Créer un monde"){ - CreateWorldView() - } - .buttonStyle(.glass) + CreateWorldButtonView() } } diff --git a/WorldBuilder/Views/WorldList/Components/EmptyWorldView.swift b/WorldBuilder/Views/WorldList/Components/EmptyWorldView.swift new file mode 100644 index 0000000..39cae46 --- /dev/null +++ b/WorldBuilder/Views/WorldList/Components/EmptyWorldView.swift @@ -0,0 +1,39 @@ +// +// EmptyWorldView.swift +// WorldBuilder +// +// Created by Giovanni Josserand on 02/09/2026. +// + +import SwiftUI + +struct EmptyWorldView : View { + var body : some View { + VStack(spacing: 20) { + ZStack { + Circle() + .fill(.indigo.opacity(0.12)) + .frame(width: 100, height: 100) + + Image(systemName: "globe.europe.africa") + .font(.system(size: 42)) + .foregroundStyle(.indigo) + } + + VStack { + Text("Ton univers commence ici.") + .font(.title3.bold()) + Text("Crée ton premier monde et commence à construire ton univers.") + .font(.subheadline) + .foregroundStyle(.secondary) + .multilineTextAlignment(.center) + } + .frame(maxWidth: 300) + + + CreateWorldButtonView() + } + .frame(maxWidth: .infinity, maxHeight: .infinity) + } +} + diff --git a/WorldBuilder/Views/WorldList/Components/WorldListHeaderView.swift b/WorldBuilder/Views/WorldList/Components/WorldListHeaderView.swift new file mode 100644 index 0000000..0af27e7 --- /dev/null +++ b/WorldBuilder/Views/WorldList/Components/WorldListHeaderView.swift @@ -0,0 +1,27 @@ +// +// WorldListHeader.swift +// WorldBuilder +// +// Created by Giovanni Josserand on 02/09/2026. +// + +import SwiftUI + +struct WorldListHeaderView : View { + var worlds : [World] + + var body : some View { + VStack (alignment: .leading, spacing: 6){ + Text("Mes mondes").font(.largeTitle.bold()) + Text( + worlds.isEmpty + ? "Créer ton premier monde pour commencer ton aventure." + : "\(worlds.count) monde\(worlds.count > 1 ? "s" : "")" + ) + .font(.subheadline) + .foregroundStyle(.secondary) + + } + .padding(.vertical, 50) + } +} diff --git a/WorldBuilder/Views/WorldList/WorldListView.swift b/WorldBuilder/Views/WorldList/WorldListView.swift index 61b4731..7064d4b 100644 --- a/WorldBuilder/Views/WorldList/WorldListView.swift +++ b/WorldBuilder/Views/WorldList/WorldListView.swift @@ -10,26 +10,26 @@ import SwiftData struct WorldListView: View { @Environment(\.modelContext) private var context - @Query(sort: \World.createdAt, order: .reverse) private var worlds: [World] + @Query(sort: \World.createdAt, order: .reverse) + private var worlds: [World] var body: some View { - Group { + VStack{ + WorldListHeaderView(worlds: worlds) + if worlds.isEmpty { - Text("Aucun monde") - NavigationLink("Créer un monde"){ - CreateWorldView() - } - .buttonStyle(.glass) + EmptyWorldView() }else{ - List { - ForEach(worlds) {world in - Text(world.name) - Text(world.overview) + ScrollView { + List { + ForEach(worlds) {world in + NavigationLink(world.name){ + WorldOverviewView() + } + } } } } } - .navigationTitle("Mes mondes") - .navigationBarTitleDisplayMode(.inline) } }