Skip to content

Commit

Permalink
[Feat/#43] Alert 추가 챌린지 완료
Browse files Browse the repository at this point in the history
  • Loading branch information
kim-seonwoo committed May 30, 2024
1 parent 8d15eb2 commit b1bde50
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ final class PointViewModel: ObservableObject {
guard let data = result.data else { return }
}
}
// 앱 잠금해제시에 사용될 포인트를 조회하는 api입니다.

func patchEarnPoint(day: Int) {
let date = pointList[day].challengeDate
Expand All @@ -27,6 +28,7 @@ final class PointViewModel: ObservableObject {
guard let data = result.data else { return }
}
}
// 하루하루 챌린지를 성공하고, 포인트를 받는 버튼을 눌렀을 때, 포인트를 받는 API

func getPointList() {
Providers.pointProvider.request(target: .getPointList,
Expand All @@ -37,6 +39,7 @@ final class PointViewModel: ObservableObject {
self.pointList = data.challengePointStatuses
}
}
// 챌린지 보상 수령 여부를 리스트로 조회하는 api입니다.

func patchPointUse(day: Int) {
let date = pointList[day].challengeDate
Expand All @@ -46,6 +49,7 @@ final class PointViewModel: ObservableObject {
guard let data = result.data else { return }
}
}
// 포인트를 사용해 이용시간 잠금을 해제할 때 사용하는 api

func getCurrentPoint(date: String) {
let request = PointRequestDTO(challengeDate: date)
Expand All @@ -54,5 +58,5 @@ final class PointViewModel: ObservableObject {
guard let data = result.data else { return }
}
}

// 현재 유저 포인트 불러오기
}
13 changes: 8 additions & 5 deletions HMH_iOS/HMH_iOS/Presentation/Challenge/Views/PointView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ extension PointView {

private var listView: some View {
ForEach(1...viewModel.challengeDay, id: \.self) { day in
HStack{
VStack(alignment: .leading){
HStack {
VStack(alignment: .leading) {
Text("\(day)" + StringLiteral.Challenge.pointTitle)
.font(.text4_semibold_16)
.foregroundStyle(.whiteText)
.foregroundColor(.whiteText)
.padding(.bottom, 2)
Text("\(viewModel.challengeDay)" + StringLiteral.Challenge.pointSubTitle)
.font(.detail4_medium_12)
.foregroundStyle(.gray2)
.foregroundColor(.gray2)
}
Spacer()
EarnPointButton(day: Int)
EarnPointButton(day: day, viewModel: viewModel)
}
.frame(height: 80)
}
Expand All @@ -62,6 +62,9 @@ extension PointView {
}

struct EarnPointButton: View {
let day: Int
@ObservedObject var viewModel: PointViewModel

var body: some View {
Button(action: {
viewModel.patchPointUse(day: day)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class OnboardingViewModel: ObservableObject {
@Published
var isCompleted: Bool

@Published
var isCompletePresented: Bool = false

@Published
var selectedGoalTime: String

Expand Down Expand Up @@ -78,9 +81,7 @@ class OnboardingViewModel: ObservableObject {
case 3:
self.goalTime = convertToTotalMilliseconds(hour: selectedGoalTime, minute: "0")
if isChallengeMode {
print("isChallengeMode")
postCreateChallengeData()
addOnboardingState()
isCompletePresented = true
} else {
addOnboardingState()
}
Expand All @@ -102,6 +103,11 @@ class OnboardingViewModel: ObservableObject {
}
}

func alertAction() {
postCreateChallengeData()
addOnboardingState()
}

func addOnboardingState() {
onboardingState += 1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,31 @@ struct OnboardingContentView: View {
self.presentationMode.wrappedValue.dismiss()
}
}
.customAlert(
isPresented: $onboardingViewModel.isCompletePresented,
customAlert: {
CustomAlertView(
alertType: .challengeCreationComplete,
confirmBtn: CustomAlertButtonView(
buttonType: .Confirm,
alertType: .challengeCreationComplete,
isPresented: $onboardingViewModel.isCompletePresented,
action: {
onboardingViewModel.alertAction()
}
),
cancelBtn: CustomAlertButtonView(
buttonType: .Cancel,
alertType: .challengeCreationComplete,
isPresented: $onboardingViewModel.isCompletePresented,
action: {
onboardingViewModel.alertAction()
}
)
)
}
)

}
}

Expand Down

0 comments on commit b1bde50

Please sign in to comment.