Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TNT-210] 수업 완료 시 토스트 메시지 추가 #84

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "icn_check_mark_green.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public extension View {
/// - `isPresented`: 토스트의 표시 여부를 제어하는 Binding.
/// - `message`: 토스트에 표시할 메시지.
/// - `leftView`: 토스트 좌측에 추가할 아이콘이나 뷰.
func tToast<LeftView: View>(
func tToast(
isPresented: Binding<Bool>,
message: String,
leftViewType: TToastView.LeftViewType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public extension ImageResource {
static let icnRadioButtonSelected: ImageResource = DesignSystemAsset.icnRadioButtonSelected.imageResource
static let icnCheckMarkEmpty: ImageResource = DesignSystemAsset.icnCheckMarkEmpty.imageResource
static let icnCheckMarkFilled: ImageResource = DesignSystemAsset.icnCheckMarkFilled.imageResource
static let icnCheckMarkGreen: ImageResource = DesignSystemAsset.icnCheckMarkGreen.imageResource
static let icnCheckButtonUnselected: ImageResource = DesignSystemAsset.icnCheckButtonUnselected.imageResource
static let icnCheckButtonSelected: ImageResource = DesignSystemAsset.icnCheckButtonSelected.imageResource
static let icnStarEmpty: ImageResource = DesignSystemAsset.icnStarEmpty.imageResource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public struct TrainerHomeFeature {
var isHideUntilSelected: Bool
/// 트레이니 연결 여부
var isConnected: Bool
/// 수업완료
var sessionTMessage: Bool

// MARK: UI related state
/// 캘린더 표시 페이지
Expand All @@ -62,7 +64,8 @@ public struct TrainerHomeFeature {
isConnected: Bool = false,
view_currentPage: Date = .now,
tappedsessionInfo: GetDateSessionListEntity? = nil,
view_isPopUpPresented: Bool = false
view_isPopUpPresented: Bool = false,
sessionTMessage: Bool = false
) {
self.selectedDate = selectedDate
self.events = events
Expand All @@ -74,6 +77,7 @@ public struct TrainerHomeFeature {
self.view_currentPage = view_currentPage
self.tappedsessionInfo = tappedsessionInfo
self.view_isPopUpPresented = view_isPopUpPresented
self.sessionTMessage = sessionTMessage
}
}

Expand All @@ -93,7 +97,7 @@ public struct TrainerHomeFeature {
/// 우측 상단 알림 페이지 보기 버튼 탭
case tapAlarmPageButton
/// 수업 완료 버튼 탭
case tapSessionCompleted(id: String)
case tapSessionCompleted(id: Int)
/// 수업 추가 버튼 탭
case tapAddSessionButton
/// 연결 권장 팝업 - 다음에 버튼 탭
Expand All @@ -112,6 +116,10 @@ public struct TrainerHomeFeature {
case calendarDateTap
/// 탭한 일자 api 형태에 맞춰 변환하기(yyyy-mm-dd)
case settingSessionList(sessions: GetDateSessionListEntity)
/// 수업 기록 남기기 탭
case tapRecordSessionButton
/// ToastMessage
case sessionToastMessage
}
}

Expand All @@ -132,13 +140,28 @@ public struct TrainerHomeFeature {
case .binding:
return .none

case .tapRecordSessionButton:
print("수업 기록 화면으로 이동")
return .none

/// 수업 완료 후 토스트 메시지
case .sessionToastMessage:
state.sessionTMessage = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앗 해당 부분은 NotificationCenter.default.post(toast:) 로 보내시기만 하면 앱 전역에 깔린 오버레이에 토스트가 표시됩니다!
화면에 안붙이셔도 표시할 수 있어요!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아하 넵넵~!

return .none

case .tapAlarmPageButton:
return .send(.setNavigating(.alarmPage))

/// 수업 완료 버튼 탭
case .tapSessionCompleted(let id):
// TODO: 네비게이션 연결 시 추가
print("tapSessionCompleted otLessionID \(id)")
return .none
return .run { send in
do {
_ = try await trainerRepoUseCase.putCompleteLesson(lessonId: id)
await send(.view(.sessionToastMessage))
} catch {
print("error of put session complete \(error.localizedDescription)")
}
}

case .tapAddSessionButton:
return .send(.setNavigating(.addPTSessionPage))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public struct TrainerHomeView: View {
.onAppear {
send(.onAppear)
}
.tToast(
isPresented: $store.sessionTMessage,
message: "",
leftViewType: .image(.icnCheckMarkGreen)
)
}

// MARK: - Sections
Expand Down Expand Up @@ -117,7 +122,7 @@ public struct TrainerHomeView: View {
if let record = store.tappedsessionInfo, !record.lessons.isEmpty {
ForEach(record.lessons, id: \.id) { record in
SessionCellView(session: record) {
send(.tapSessionCompleted(id: record.ptLessonId))
send(.tapSessionCompleted(id: Int(record.ptLessonId)!))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

엇 강제 언래핑보다는 ?? 0 과 같이 처리해주시면 좋을 것 같아요!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} onTap: {
// TODO: - 트레이너 기록 추가
}
Expand Down