Fix visual of EmptyWorld.swift

This commit is contained in:
Giovanni committed 2026-09-03 00:17:56 +02:00
1 parent 38a202109d
commit a53bb8870b
5 files changed
+103 -17

No files matched your search

@@ -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)
}
}
+1 -4
View File
@@ -9,9 +9,6 @@ import SwiftUI
struct HomeView : View { struct HomeView : View {
var body: some View { var body: some View {
NavigationLink("Créer un monde"){ CreateWorldButtonView()
CreateWorldView()
}
.buttonStyle(.glass)
} }
} }
@@ -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)
}
}
@@ -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)
}
}
@@ -10,26 +10,26 @@ import SwiftData
struct WorldListView: View { struct WorldListView: View {
@Environment(\.modelContext) private var context @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 { var body: some View {
Group { VStack{
WorldListHeaderView(worlds: worlds)
if worlds.isEmpty { if worlds.isEmpty {
Text("Aucun monde") EmptyWorldView()
NavigationLink("Créer un monde"){
CreateWorldView()
}
.buttonStyle(.glass)
}else{ }else{
List { ScrollView {
ForEach(worlds) {world in List {
Text(world.name) ForEach(worlds) {world in
Text(world.overview) NavigationLink(world.name){
WorldOverviewView()
}
}
} }
} }
} }
} }
.navigationTitle("Mes mondes")
.navigationBarTitleDisplayMode(.inline)
} }
} }