@@ -9,6 +9,7 @@ import SwiftUI
99
1010struct HomeView : View {
1111
12+ @Environment ( HomeViewModel . self) var vm
1213 @State private var showPortfolio : Bool = false
1314
1415 var body : some View {
@@ -18,6 +19,18 @@ struct HomeView: View {
1819
1920 VStack {
2021 homeHeader
22+
23+ columnTitles
24+
25+ if !showPortfolio {
26+ allCoinsList
27+ . transition ( . move( edge: . leading) )
28+ }
29+ if showPortfolio {
30+ portfolioCoinsList
31+ . transition ( . move( edge: . trailing) )
32+ }
33+
2134 Spacer ( minLength: 0 )
2235 }
2336 }
@@ -29,6 +42,7 @@ struct HomeView: View {
2942 HomeView ( )
3043 . toolbarVisibility ( . hidden)
3144 }
45+ . environment ( dev. homeVM)
3246}
3347
3448extension HomeView {
@@ -56,4 +70,39 @@ extension HomeView {
5670 }
5771 . padding ( . horizontal)
5872 }
73+
74+ private var allCoinsList : some View {
75+ List {
76+ ForEach ( vm. allCoins) { coin in
77+ CoinRowView ( coin: coin, showHoldingsColumn: false )
78+ . listRowInsets ( . init( top: 10 , leading: 0 , bottom: 10 , trailing: 10 ) )
79+ }
80+ }
81+ . listStyle ( . plain)
82+ }
83+
84+ private var portfolioCoinsList : some View {
85+ List {
86+ ForEach ( vm. allCoins) { coin in
87+ CoinRowView ( coin: coin, showHoldingsColumn: true )
88+ . listRowInsets ( . init( top: 10 , leading: 0 , bottom: 10 , trailing: 10 ) )
89+ }
90+ }
91+ . listStyle ( . plain)
92+ }
93+
94+ private var columnTitles : some View {
95+ HStack {
96+ Text ( " Coin " )
97+ Spacer ( )
98+ if showPortfolio {
99+ Text ( " Holdings " )
100+ }
101+ Text ( " Price " )
102+ . frame ( width: UIScreen . main. bounds. width / 3.5 , alignment: . trailing)
103+ }
104+ . font ( . caption)
105+ . foregroundStyle ( Color . theme. secondaryText)
106+ . padding ( . horizontal)
107+ }
59108}
0 commit comments