Skip to content

Commit

Permalink
[Feat] 트레이니 Home, Mypage - AppStroage-isConnected UI 로직 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
FpRaArNkK committed Feb 12, 2025
1 parent 55812a1 commit eb92309
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public struct TraineeHomeFeature {
// MARK: Data related state
/// 3일 동안 보지 않기 시작 날짜
@Shared(.appStorage(AppStorage.hideHomePopupUntil)) var hidePopupUntil: Date?
/// 트레이너 연결 여부
@Shared(.appStorage(AppStorage.isConnected)) var isConnected: Bool = false
/// 선택된 날짜
var selectedDate: Date
/// 캘린더 이벤트
Expand All @@ -29,8 +31,6 @@ public struct TraineeHomeFeature {
var records: [RecordListItemEntity]
/// 3일 동안 보지 않기 선택되었는지 여부
var isHideUntilSelected: Bool
/// 트레이너 연결 여부
var isConnected: Bool

// MARK: UI related state
/// 캘린더 표시 페이지
Expand All @@ -55,7 +55,6 @@ public struct TraineeHomeFeature {
sessionInfo: WorkoutListItemEntity? = nil,
records: [RecordListItemEntity] = [],
isHideUntilSelected: Bool = false,
isConnected: Bool = false,
view_currentPage: Date = .now,
view_isBottomSheetPresented: Bool = false,
view_isPopUpPresented: Bool = false
Expand All @@ -65,7 +64,6 @@ public struct TraineeHomeFeature {
self.sessionInfo = sessionInfo
self.records = records
self.isHideUntilSelected = isHideUntilSelected
self.isConnected = isConnected
self.view_currentPage = view_currentPage
self.view_isBottomSheetPresented = view_isBottomSheetPresented
self.view_isPopUpPresented = view_isPopUpPresented
Expand Down Expand Up @@ -172,11 +170,9 @@ public struct TraineeHomeFeature {
return .send(.setNavigating(.traineeInvitationCodeInput))

case .onAppear:
if let hideUntil = state.hidePopupUntil, hideUntil > Date() {
state.view_isPopUpPresented = false
} else {
state.view_isPopUpPresented = true
}
let hideUntil = state.hidePopupUntil ?? Date()
let hidePopUp = state.isConnected || hideUntil > Date()
state.view_isPopUpPresented = !hidePopUp
return .none
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public struct TraineeMyPageFeature {
// MARK: Data related state
/// 3일 동안 보지 않기 시작 날짜
@Shared(.appStorage(AppStorage.hideHomePopupUntil)) var hidePopupUntil: Date?
/// 트레이너 연결 여부
@Shared(.appStorage(AppStorage.isConnected)) var isConnected: Bool = false
/// 사용자 이름
var userName: String
/// 사용자 이미지 URL
Expand Down Expand Up @@ -240,6 +242,7 @@ public struct TraineeMyPageFeature {
}

case .setMyPageInfo(let myPageInfo):
state.$isConnected.withLock { $0 = myPageInfo.isConnected }
state.userName = myPageInfo.name
state.userImageUrl = myPageInfo.profileImageUrl
return .none
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public struct TraineeMyPageView: View {
@ViewBuilder
private func TopItemSection() -> some View {
VStack(spacing: 12) {
if !store.view_isTrainerConnected {
if !store.isConnected {
ProfileItemView(title: "트레이너 연결하기", tapAction: { send(.tapConnectTrainerButton) })
.padding(.vertical, 4)
.background(Color.common0)
Expand Down

0 comments on commit eb92309

Please sign in to comment.