Fix visual of EmptyWorld.swift
This commit is contained in:
1 parent
38a202109d
commit
a53bb8870b
5 files changed
+101
-15
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)
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,6 @@ import SwiftUI
|
||||
|
||||
struct HomeView : View {
|
||||
var body: some View {
|
||||
NavigationLink("Créer un monde"){
|
||||
CreateWorldView()
|
||||
}
|
||||
.buttonStyle(.glass)
|
||||
CreateWorldButtonView()
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
@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{
|
||||
ScrollView {
|
||||
List {
|
||||
ForEach(worlds) {world in
|
||||
Text(world.name)
|
||||
Text(world.overview)
|
||||
NavigationLink(world.name){
|
||||
WorldOverviewView()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationTitle("Mes mondes")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user