@@ -13,39 +13,37 @@ import Domain
1313import DesignSystem
1414
1515/// 트레이니의 메인 홈 뷰입니다
16+ @ViewAction ( for: TraineeHomeFeature . self)
1617public struct TraineeHomeView : View {
1718
18- // MARK: 임시 State
19- @State var ispresented : Bool = false
20- @State var selectedDate : Date = Date ( )
21- @State var currentPage : Date = Date ( )
22- @State var events : [ Date : Int ] = [ : ]
23- @State var todaysSessionInfo : WorkoutListItemEntity ? = . init( currentCount: 8 , startDate: . now, endDate: . now, trainerProfileImageUrl: nil , trainerName: " 김민수 " , hasRecord: true )
24- @State var records : [ RecordListItemEntity ] = [
25- . init( type: . meal( type: . lunch) , date: . now, title: " 자고싶다 " , hasFeedBack: true , imageUrl: nil ) ,
26- . init( type: . meal( type: . dinner) , date: . now, title: " 자고싶다 " , hasFeedBack: false , imageUrl: " https://images.genius.com/8e0b15e4847f8e59db7dfda22b4db4ec.1000x1000x1.png " ) ,
27- . init( type: . meal( type: . morning) , date: . now, title: " 자고싶다 " , hasFeedBack: true , imageUrl: nil )
28- ]
29- @State var toggleMode : Bool = true
19+ @Bindable public var store : StoreOf < TraineeHomeFeature >
3020
31-
32- public init ( ) { }
21+ public init ( store: StoreOf < TraineeHomeFeature > ) {
22+ self . store = store
23+ }
3324
3425 public var body : some View {
3526 ScrollView {
3627 VStack ( spacing: 0 ) {
3728 CalendarSection ( )
29+ . background ( Color . common0)
3830
3931 RecordListSection ( )
32+ . frame ( maxWidth: . infinity)
4033 . background ( Color . neutral100)
41-
34+
4235 Spacer ( )
4336 }
4437 }
38+ . background (
39+ VStack {
40+ Color . common0
41+ Color . neutral100
42+ }
43+ )
4544 . overlay ( alignment: . bottomTrailing) {
4645 Button ( action: {
47- // TODO: STORE
48- ispresented = true
46+ send ( . tapAddRecordButton)
4947 } , label: {
5048 Image ( . icnPlus)
5149 . renderingMode ( . template)
@@ -60,16 +58,10 @@ public struct TraineeHomeView: View {
6058 . padding ( . trailing, 12 )
6159 }
6260 . navigationBarBackButtonHidden ( )
63- . sheet ( isPresented: $ispresented ) {
61+ . sheet ( isPresented: $store . view_isBottomSheetPresented ) {
6462 TraineeRecordStartView ( itemContents: [
65- ( " 🏋🏻♀️ " , " 개인 운동 " , {
66- // TODO: Store 연결
67- print ( " pop " )
68- } ) ,
69- ( " 🥗 " , " 식단 " , {
70- // TODO: Store 연결
71- print ( " pop " )
72- } )
63+ ( " 🏋🏻♀️ " , " 개인 운동 " , { send ( . tapAddWorkoutRecordButton) } ) ,
64+ ( " 🥗 " , " 식단 " , { send ( . tapAddMealRecordButton) } )
7365 ] )
7466 . autoSizingBottomSheet ( )
7567 }
@@ -80,13 +72,11 @@ public struct TraineeHomeView: View {
8072 private func CalendarSection( ) -> some View {
8173 VStack ( spacing: 16 ) {
8274 TCalendarHeader (
83- currentPage: $currentPage ,
75+ currentPage: $store . view_currentPage ,
8476 formatter: { TDateFormatUtility . formatter ( for: . yyyy년_MM월) . string ( from: $0) } ,
8577 rightView: {
8678 Button ( action: {
87- // TODO: Store 연결
88- print ( " pop " )
89- toggleMode. toggle ( )
79+ send ( . tapAlarmPageButton)
9080 } , label: {
9181 Image ( . icnAlarm)
9282 . resizable ( )
@@ -99,23 +89,22 @@ public struct TraineeHomeView: View {
9989 // Calendar + 금일 수업 카드
10090 VStack ( spacing: 12 ) {
10191 TCalendarView (
102- selectedDate: $selectedDate,
103- currentPage: $currentPage ,
104- events: events,
105- isWeekMode: toggleMode
92+ selectedDate: $store . selectedDate,
93+ currentPage: $store . view_currentPage ,
94+ events: store . events,
95+ isWeekMode: true
10696 )
10797 . padding ( . horizontal, 20 )
10898
109- if let todaysSessionInfo {
99+ if let sessionInfo = store . sessionInfo {
110100 TWorkoutCard (
111- chipUIInfo: RecordType . session ( count: todaysSessionInfo . currentCount) . chipInfo,
112- timeText: " \( TDateFormatUtility . formatter ( for : . a_HHmm ) . string ( from : todaysSessionInfo . startDate ) ) ~ \( TDateFormatUtility . formatter ( for : . a_HHmm ) . string ( from : todaysSessionInfo . endDate ) ) " ,
113- title: " \( todaysSessionInfo . trainerName) 트레이너 " ,
114- imgURL: . init( string: todaysSessionInfo . trainerProfileImageUrl ?? " " ) ,
115- hasRecord: todaysSessionInfo . hasRecord,
101+ chipUIInfo: RecordType . session ( count: sessionInfo . currentCount) . chipInfo,
102+ timeText: store . view_sessionCardTimeString ,
103+ title: " \( sessionInfo . trainerName) 트레이너 " ,
104+ imgURL: . init( string: sessionInfo . trainerProfileImageUrl ?? " " ) ,
105+ hasRecord: sessionInfo . hasRecord,
116106 footerTapAction: {
117- // TODO: STORe
118- print ( " 얍ㅂ삐 " )
107+ send ( . tapShowSessionRecordButton( id: sessionInfo. id) )
119108 }
120109 )
121110 . padding ( . horizontal, 20 )
@@ -135,27 +124,36 @@ public struct TraineeHomeView: View {
135124 @ViewBuilder
136125 private func RecordListSection( ) -> some View {
137126 VStack ( alignment: . leading, spacing: 0 ) {
138- Text ( TDateFormatUtility . formatter ( for: . MM월_dd일_EEEE) . string ( from: selectedDate) )
139- . typographyStyle ( . heading3, with: . neutral800)
140- . padding ( 20 )
127+ HStack {
128+ Text ( store. view_recordTitleString)
129+ . typographyStyle ( . heading3, with: . neutral800)
130+ . padding ( 20 )
131+ Spacer ( )
132+ }
141133
142134 VStack ( spacing: 12 ) {
143- ForEach ( records. indices, id: \. self) { index in
144- let item = records [ index]
145- TRecordCard (
146- chipUIInfo: item. type. chipInfo,
147- timeText: TDateFormatUtility . formatter ( for: . a_HHmm) . string ( from: item. date) ,
148- title: " 자고 싶어요 진짜로 ㄴㅇㅁㄹㅁㄴㅇ래ㅣㅑㅕㅗㅁㅈㄷ;ㅐㅓㅑㅗㅁㅈㄷ래ㅑ;ㅗㅓㅁㄷㄹㅈ;ㅐㅗㅕㅑㄷㄹㅁㅈ " ,
149- imgURL: URL ( string: item. imageUrl ?? " " ) ,
150- hasFeedback: item. hasFeedBack,
151- footerTapAction: {
152- // TODO: STORE
153- print ( " pop \( index) " )
154- }
155- )
135+ if !store. records. isEmpty {
136+ ForEach ( store. records, id: \. id) { item in
137+ TRecordCard (
138+ chipUIInfo: item. type. chipInfo,
139+ timeText: TDateFormatUtility . formatter ( for: . a_HHmm) . string ( from: item. date) ,
140+ title: item. title,
141+ imgURL: URL ( string: item. imageUrl ?? " " ) ,
142+ hasFeedback: item. hasFeedBack,
143+ footerTapAction: {
144+ send ( . tapShowRecordFeedbackButton( id: item. id) )
145+ }
146+ )
147+ }
148+ } else {
149+ RecordEmptyView ( )
150+ . padding ( . top, 80 )
151+ . padding ( . bottom, 100 )
156152 }
157153 }
158154 . padding ( . horizontal, 16 )
155+
156+ Spacer ( )
159157 }
160158 }
161159}
@@ -175,7 +173,7 @@ private extension TraineeHomeView {
175173 struct RecordEmptyView : View {
176174 var body : some View {
177175 VStack ( spacing: 4 ) {
178- Text ( " 추가 버튼을 눌러 식사와 운동을 기록해보세요 " )
176+ Text ( " 아직 기록이 없어요 " )
179177 . typographyStyle ( . body2Bold, with: . neutral600)
180178 . frame ( maxWidth: . infinity)
181179
0 commit comments