Skip to content

Commit

Permalink
ProblemOfDaySolvedModalViewController show share streak
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-magda committed Nov 8, 2023
1 parent adab561 commit cf20b45
Show file tree
Hide file tree
Showing 7 changed files with 218 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ class StepDelegate<TFragment>(
is StepCompletionFeature.Action.ViewAction.ShowShareStreakModal -> {
// TODO: ALTAPPS-1028 Show share streak modal
}
is StepCompletionFeature.Action.ViewAction.ShowShareStreakSystemModal -> {
// TODO: ALTAPPS-1028 Show system share streak modal (after "Share your streak" button clicked)
// on the problem of day solved modal
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ enum Strings {
enum ProblemOfDaySolvedModal {
static let title = sharedStrings.step_quiz_problem_of_day_solved_modal_title.localized()
static let text = sharedStrings.step_quiz_problem_of_day_solved_modal_text.localized()

static let shareStreakButton =
sharedStrings.step_quiz_problem_of_day_solved_modal_share_streak_button_text.localized()
}

enum TopicCompletedModal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,6 @@ final class StepViewModel: FeatureViewModel<StepFeatureState, StepFeatureMessage
}
}

// MARK: Problem of day solved

func doGoBackProblemOfDaySolvedAction() {
onNewMessage(
StepFeatureMessageStepCompletionMessage(
message: StepCompletionFeatureMessageProblemOfDaySolvedModalGoBackClicked()
)
)
}

// MARK: Daily notifications request

func handleSendDailyStudyRemindersPermissionRequestResult(isGranted: Bool) {
Expand Down Expand Up @@ -122,22 +112,6 @@ final class StepViewModel: FeatureViewModel<StepFeatureState, StepFeatureMessage
func logViewedEvent() {
onNewMessage(StepFeatureMessageViewedEventMessage())
}

func logDailyStepCompletedModalShownEvent() {
onNewMessage(
StepFeatureMessageStepCompletionMessage(
message: StepCompletionFeatureMessageDailyStepCompletedModalShownEventMessage()
)
)
}

func logDailyStepCompletedModalHiddenEvent() {
onNewMessage(
StepFeatureMessageStepCompletionMessage(
message: StepCompletionFeatureMessageDailyStepCompletedModalHiddenEventMessage()
)
)
}
}

// MARK: - StepViewModel: StepQuizOutputProtocol -
Expand Down Expand Up @@ -195,3 +169,44 @@ extension StepViewModel: TopicCompletedModalViewControllerDelegate {
)
}
}

// MARK: - StepViewModel: ProblemOfDaySolvedModalViewControllerDelegate -

extension StepViewModel: ProblemOfDaySolvedModalViewControllerDelegate {
func problemOfDaySolvedModalViewControllerDidAppear(_ viewController: ProblemOfDaySolvedModalViewController) {
onNewMessage(
StepFeatureMessageStepCompletionMessage(
message: StepCompletionFeatureMessageDailyStepCompletedModalShownEventMessage()
)
)
}

func problemOfDaySolvedModalViewControllerDidDisappear(_ viewController: ProblemOfDaySolvedModalViewController) {
onNewMessage(
StepFeatureMessageStepCompletionMessage(
message: StepCompletionFeatureMessageDailyStepCompletedModalHiddenEventMessage()
)
)
}

func problemOfDaySolvedModalViewControllerDidTapGoBackButton(
_ viewController: ProblemOfDaySolvedModalViewController
) {
onNewMessage(
StepFeatureMessageStepCompletionMessage(
message: StepCompletionFeatureMessageProblemOfDaySolvedModalGoBackClicked()
)
)
}

func problemOfDaySolvedModalViewControllerDidTapShareStreakButton(
_ viewController: ProblemOfDaySolvedModalViewController,
streak: Int
) {
onNewMessage(
StepFeatureMessageStepCompletionMessage(
message: StepCompletionFeatureMessageProblemOfDaySolvedModalShareStreakClicked(streak: Int32(streak))
)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,15 @@ struct StepView: View {
case .requestDailyStudyRemindersPermission:
presentSendDailyStudyRemindersPermissionAlert()
case .showProblemOfDaySolvedModal(let showProblemOfDaySolvedModalViewAction):
presentDailyStepCompletedModal(earnedGemsText: showProblemOfDaySolvedModalViewAction.earnedGemsText)
presentDailyStepCompletedModal(
earnedGemsText: showProblemOfDaySolvedModalViewAction.earnedGemsText,
streakText: showProblemOfDaySolvedModalViewAction.streakText,
streak: showProblemOfDaySolvedModalViewAction.streak?.intValue
)
case .showShareStreakModal:
#warning("TODO: ALTAPPS-1027 Show share streak modal")
case .showShareStreakSystemModal:
#warning("TODO: ALTAPPS-1027 Show system share streak modal")
}
}

Expand Down Expand Up @@ -145,20 +151,18 @@ extension StepView {
panModalPresenter.presentPanModal(modal)
}

private func presentDailyStepCompletedModal(earnedGemsText: String) {
viewModel.logDailyStepCompletedModalShownEvent()

let panModal = ProblemOfDaySolvedModalViewController(
private func presentDailyStepCompletedModal(
earnedGemsText: String,
streakText: String?,
streak: Int?
) {
let modal = ProblemOfDaySolvedModalViewController(
earnedGemsText: earnedGemsText,
onGoBackButtonTap: { [weak viewModel] in
viewModel?.doGoBackProblemOfDaySolvedAction()
}
streakText: streakText,
streak: streak,
delegate: viewModel
)
panModal.onDisappear = { [weak viewModel] in
viewModel?.logDailyStepCompletedModalHiddenEvent()
}

panModalPresenter.presentPanModal(panModal)
panModalPresenter.presentPanModal(modal)
}
}

Expand Down
Loading

0 comments on commit cf20b45

Please sign in to comment.