comparison GeoQuiz/ProfileModalView.swift @ 20:e281791e0494

finish implementation
author Dennis C. M. <dennis@denniscm.com>
date Sun, 23 Oct 2022 11:48:39 +0100
parents f140bb277c96
children b145c408f791
comparison
equal deleted inserted replaced
19:f140bb277c96 20:e281791e0494
9 9
10 struct ProfileModalView: View { 10 struct ProfileModalView: View {
11 @ObservedObject var userController: UserController 11 @ObservedObject var userController: UserController
12 @ObservedObject var storeKitController: StoreKitController 12 @ObservedObject var storeKitController: StoreKitController
13 13
14 @State var showingEditModalView = false 14 @State private var showingEditModalView = false
15 15
16 @FetchRequest(sortDescriptors: [ 16 @FetchRequest(sortDescriptors: [
17 SortDescriptor(\.date, order: .reverse), 17 SortDescriptor(\.date, order: .reverse),
18 ]) var playedGames: FetchedResults<PlayedGame> 18 ]) var playedGames: FetchedResults<PlayedGame>
19 19
29 storeKitController: storeKitController, 29 storeKitController: storeKitController,
30 isShowing: $showingEditModalView 30 isShowing: $showingEditModalView
31 ) 31 )
32 32
33 VStack(spacing: 20) { 33 VStack(spacing: 20) {
34 ForEach(playedGames.prefix(8)) { playedGame in 34 HStack {
35 RecentGame(game: playedGame) 35 Text("Latest games")
36 .foregroundColor(.secondary)
37
38 Spacer()
39
40 NavigationLink {
41 PlayedGamesList(playedGames: playedGames)
42 } label: {
43 Text("Show all")
44 }
45 .disabled(playedGames.isEmpty)
46 }
47
48 if playedGames.isEmpty {
49 Spacer()
50 LatestGamesPlaceholder()
51 } else {
52 ForEach(playedGames.prefix(8)) { playedGame in
53 RecentGame(game: playedGame)
54 .padding()
55 .background(Color(.secondarySystemGroupedBackground))
56 .cornerRadius(20)
57 }
36 } 58 }
37 } 59 }
38 } 60 }
39 .padding() 61 .padding()
40 } 62 }
63 .frame(maxWidth: .infinity)
41 .navigationTitle("Profile") 64 .navigationTitle("Profile")
42 .navigationBarTitleDisplayMode(.inline) 65 .navigationBarTitleDisplayMode(.inline)
43 .background(Color(.systemGroupedBackground)) 66 .background(Color(.systemGroupedBackground))
44 .toolbar { 67 .toolbar {
45 ToolbarItem(placement: .cancellationAction) { 68 ToolbarItem(placement: .cancellationAction) {