Skip to content

Commit

Permalink
🔀️ Merge branch 'hugo/feature/Trigger-correct-reinforcer-on-activity'
Browse files Browse the repository at this point in the history
  • Loading branch information
ladislas committed Apr 10, 2024
2 parents 30220b0 + a9ef1fd commit b9b4fdb
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Apps/LekaApp/Sources/Navigation/Navigation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import SwiftUI

// MARK: - FullScreenCoverContent

enum FullScreenCoverContent: Identifiable {
enum FullScreenCoverContent: Hashable, Identifiable {
case welcomeView
case activityView
case activityView(carereceiver: Carereceiver? = nil)

// MARK: Internal

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct CategoryActivitiesView: View {
self.navigation.sheetContent = .carereceiverPicker(activity: activity)
} else {
self.navigation.currentActivity = activity
self.navigation.fullScreenCoverContent = .activityView
self.navigation.fullScreenCoverContent = .activityView(carereceiver: nil)
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct CategoryCurriculumsView: View {
self.navigation.sheetContent = .carereceiverPicker(activity: activity)
} else {
self.navigation.currentActivity = activity
self.navigation.fullScreenCoverContent = .activityView
self.navigation.fullScreenCoverContent = .activityView(carereceiver: nil)
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct CategoryRemotesView: View {
self.navigation.sheetContent = .carereceiverPicker(activity: activity)
} else {
self.navigation.currentActivity = activity
self.navigation.fullScreenCoverContent = .activityView
self.navigation.fullScreenCoverContent = .activityView(carereceiver: nil)
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct AllActivitiesView: View {
ScrollView(showsIndicators: true) {
ActivityGridView(activities: self.activities, onStartActivity: { activity in
self.navigation.currentActivity = activity
self.navigation.fullScreenCoverContent = .activityView
self.navigation.fullScreenCoverContent = .activityView(carereceiver: nil)
})
}
.navigationTitle("All Activities")
Expand Down
8 changes: 4 additions & 4 deletions Apps/LekaApp/Sources/Views/MainView/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ struct MainView: View {
switch content {
case .welcomeView:
WelcomeView()
case .activityView:
ActivityView(activity: self.navigation.currentActivity!)
case let .activityView(carereceiver):
ActivityView(activity: self.navigation.currentActivity!, reinforcer: carereceiver?.reinforcer ?? .rainbow)
}
}
}
Expand Down Expand Up @@ -173,10 +173,10 @@ struct MainView: View {
}, onSelected: { carereceiver in
self.carereceiverManager.setCurrentCarereceiver(to: carereceiver)
self.navigation.currentActivity = activity
self.navigation.fullScreenCoverContent = .activityView
self.navigation.fullScreenCoverContent = .activityView(carereceiver: carereceiver)
}, onSkip: {
self.navigation.currentActivity = activity
self.navigation.fullScreenCoverContent = .activityView
self.navigation.fullScreenCoverContent = .activityView(carereceiver: nil)
})
.navigationBarTitleDisplayMode(.inline)
}
Expand Down
1 change: 1 addition & 0 deletions Modules/ContentKit/Sources/Activity/Activity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import Foundation
import LocalizationKit
import RobotKit
import UIKit
import Yams

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import SwiftUI
public struct ActivityView: View {
// MARK: Lifecycle

public init(activity: Activity) {
public init(activity: Activity, reinforcer: Robot.Reinforcer = .rainbow) {
self._viewModel = StateObject(wrappedValue: ActivityViewViewModel(activity: activity))
self.reinforcer = reinforcer
}

// MARK: Public
Expand Down Expand Up @@ -179,6 +180,7 @@ public struct ActivityView: View {
@State private var isInfoSheetPresented: Bool = false

private let robot = Robot.shared
private let reinforcer: Robot.Reinforcer

@ViewBuilder
private var endOfActivityScoreView: some View {
Expand All @@ -196,8 +198,7 @@ public struct ActivityView: View {
speed: 0.2
)
.onAppear {
// TODO(@ladislas/@hugo): Use reinforcer children choice
self.robot.run(.fire)
self.robot.run(self.reinforcer)
}
.transition(
.asymmetric(
Expand Down

0 comments on commit b9b4fdb

Please sign in to comment.