Skip to content

Commit

Permalink
♻️ (UIExplorer): Instantiate gameplays with @StateObject
Browse files Browse the repository at this point in the history
Using @StateObject instead of @ObservedObject initiate gameplay when we start the activity instead of before
  • Loading branch information
HPezz committed Sep 22, 2023
1 parent 5da7045 commit 436e1ae
Show file tree
Hide file tree
Showing 18 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import GameEngineKit
import SwiftUI

struct DanceFreezeActivity: View {
let gameplay = DanceFreezeGameplay()
@StateObject private var gameplay = DanceFreezeGameplay()

var body: some View {
DanceFreezeView(gameplay: gameplay)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private var steps: [StandardStepModel] = [
]

struct ListenThenTouchToSelectFourChoicesActivity: View {

Check failure on line 61 in Apps/LekaActivityUIExplorer/Sources/NewUI/Activities/ListenThenTouchToSelect/ListenThenTouchToSelecFourChoicesActivity.swift

View workflow job for this annotation

GitHub Actions / lint

Type name 'ListenThenTouchToSelectFourChoicesActivity' should be between 4 and 40 characters long (type_name)
@ObservedObject private var stepManager = StepManager(steps: steps)
@StateObject private var stepManager = StepManager(steps: steps)

var body: some View {
stepManager.interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private var steps: [StandardStepModel] = [
]

struct ListenThenTouchToSelectOneChoiceActivity: View {
@ObservedObject private var stepManager = StepManager(steps: steps)
@StateObject private var stepManager = StepManager(steps: steps)

var body: some View {
stepManager.interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private var steps: [StandardStepModel] = [
]

struct ListenThenTouchToSelectSixChoicesActivity: View {

Check failure on line 71 in Apps/LekaActivityUIExplorer/Sources/NewUI/Activities/ListenThenTouchToSelect/ListenThenTouchToSelectSixChoicesActivity.swift

View workflow job for this annotation

GitHub Actions / lint

Type name 'ListenThenTouchToSelectSixChoicesActivity' should be between 4 and 40 characters long (type_name)
@ObservedObject private var stepManager = StepManager(steps: steps)
@StateObject private var stepManager = StepManager(steps: steps)

var body: some View {
stepManager.interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private var steps: [StandardStepModel] = [
]

struct ListenThenTouchToSelectThreeChoicesActivity: View {

Check failure on line 56 in Apps/LekaActivityUIExplorer/Sources/NewUI/Activities/ListenThenTouchToSelect/ListenThenTouchToSelectThreeChoicesActivity.swift

View workflow job for this annotation

GitHub Actions / lint

Type name 'ListenThenTouchToSelectThreeChoicesActivity' should be between 4 and 40 characters long (type_name)
@ObservedObject private var stepManager = StepManager(steps: steps)
@StateObject private var stepManager = StepManager(steps: steps)

var body: some View {
stepManager.interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private var steps: [StandardStepModel] = [
]

struct ListenThenTouchToSelectThreeChoicesInlineActivity: View {

Check failure on line 56 in Apps/LekaActivityUIExplorer/Sources/NewUI/Activities/ListenThenTouchToSelect/ListenThenTouchToSelectThreeChoicesInlineActivity.swift

View workflow job for this annotation

GitHub Actions / lint

Type name 'ListenThenTouchToSelectThreeChoicesInlineActivity' should be between 4 and 40 characters long (type_name)
@ObservedObject private var stepManager = StepManager(steps: steps)
@StateObject private var stepManager = StepManager(steps: steps)

var body: some View {
stepManager.interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private var steps: [StandardStepModel] = [
]

struct ListenThenTouchToSelectTwoChoicesActivity: View {

Check failure on line 51 in Apps/LekaActivityUIExplorer/Sources/NewUI/Activities/ListenThenTouchToSelect/ListenThenTouchToSelectTwoChoicesActivity.swift

View workflow job for this annotation

GitHub Actions / lint

Type name 'ListenThenTouchToSelectTwoChoicesActivity' should be between 4 and 40 characters long (type_name)
@ObservedObject private var stepManager = StepManager(steps: steps)
@StateObject private var stepManager = StepManager(steps: steps)

var body: some View {
stepManager.interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import GameEngineKit
import SwiftUI

struct MelodyActivity: View {
let gameplay = MelodyGameplay(song: kListOfMelodySongsAvailable[0])
@StateObject private var gameplay = MelodyGameplay(song: kListOfMelodySongsAvailable[0])

var body: some View {
MelodyView(gameplay: gameplay)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private var steps: [StandardStepModel] = [
]

struct TouchToSelectFiveChoicesActivity: View {
@ObservedObject private var stepManager = StepManager(steps: steps)
@StateObject private var stepManager = StepManager(steps: steps)

var body: some View {
stepManager.interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private var steps: [StandardStepModel] = [
]

struct TouchToSelectFourChoicesActivity: View {
@ObservedObject private var stepManager = StepManager(steps: steps)
@StateObject private var stepManager = StepManager(steps: steps)

var body: some View {
stepManager.interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private var steps: [StandardStepModel] = [
]

struct TouchToSelectFourChoicesInlineActivity: View {
@ObservedObject private var stepManager = StepManager(steps: steps)
@StateObject private var stepManager = StepManager(steps: steps)

var body: some View {
stepManager.interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private var steps: [StandardStepModel] = [
]

struct TouchToSelectOneChoiceActivity: View {
@ObservedObject private var stepManager = StepManager(steps: steps)
@StateObject private var stepManager = StepManager(steps: steps)

var body: some View {
stepManager.interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private var steps: [StandardStepModel] = [
]

struct TouchToSelectSixChoicesActivity: View {
@ObservedObject private var stepManager = StepManager(steps: steps)
@StateObject private var stepManager = StepManager(steps: steps)

var body: some View {
stepManager.interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private var steps: [StandardStepModel] = [
]

struct TouchToSelectThreeChoicesActivity: View {
@ObservedObject private var stepManager = StepManager(steps: steps)
@StateObject private var stepManager = StepManager(steps: steps)

var body: some View {
stepManager.interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private var steps: [StandardStepModel] = [
]

struct TouchToSelectThreeChoicesInlineActivity: View {
@ObservedObject private var stepManager = StepManager(steps: steps)
@StateObject private var stepManager = StepManager(steps: steps)

var body: some View {
stepManager.interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private var steps: [StandardStepModel] = [
]

struct TouchToSelectTwoChoicesActivity: View {
@ObservedObject private var stepManager = StepManager(steps: steps)
@StateObject private var stepManager = StepManager(steps: steps)

var body: some View {
stepManager.interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import Combine
import SwiftUI

public class DanceFreezeGameplay {
public class DanceFreezeGameplay: ObservableObject {
var audioPlayer: AudioPlayer
@Published public var progress: CGFloat = 0.0
@Published public var state: GameplayState = .idle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import AudioKit
import Combine
import SwiftUI

public class MelodyGameplay {
public class MelodyGameplay: ObservableObject {
@Published public var progress: CGFloat = 0.0
@Published public var state: GameplayState = .idle

Expand Down

0 comments on commit 436e1ae

Please sign in to comment.