forked from pointfreeco/isowords
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cube preview selection (pointfreeco#51)
* Animate selection on cube preview. * wip * wip * wip * wip * wip * wip * clean up * wip * wip * clean up * extracted out haptics core * clean up * wip * wip * wip * clean up * fix tests * clean up * fix scoring * undo * wip * fix things discussed * fix trailer * fix tests
- Loading branch information
Showing
26 changed files
with
787 additions
and
867 deletions.
There are no files selected for viewing
158 changes: 56 additions & 102 deletions
158
App/Previews/CubePreviewPreview/CubePreviewPreviewApp.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,117 +1,71 @@ | ||
import ClientModels | ||
import CubeCore | ||
import CubePreview | ||
import PuzzleGen | ||
import SharedModels | ||
import Styleguide | ||
import SwiftUI | ||
|
||
@testable import CubePreview | ||
|
||
@main | ||
struct CubePreviewPreviewApp: App { | ||
@State var wordPreviewIsPresented = false | ||
@State var gamePreviewIsPresented = false | ||
|
||
init() { | ||
Styleguide.registerFonts() | ||
} | ||
|
||
var body: some Scene { | ||
WindowGroup { | ||
NavigationView { | ||
Form { | ||
Button("Word Preview") { self.wordPreviewIsPresented = true } | ||
.sheet(isPresented: self.$wordPreviewIsPresented) { | ||
CubePreviewView( | ||
store: .init( | ||
initialState: .init( | ||
preview: .words( | ||
.init( | ||
words: [word] | ||
) | ||
) | ||
CubePreviewView( | ||
store: .init( | ||
initialState: .init( | ||
cubes: .mock, | ||
isHapticsEnabled: true, | ||
isOnLowPowerMode: false, | ||
moveIndex: 0, | ||
moves: [ | ||
.init( | ||
playedAt: .mock, | ||
playerIndex: nil, | ||
reactions: nil, | ||
score: 2_000, | ||
type: .playedWord([ | ||
.init( | ||
index: .init(x: .two, y: .two, z: .two), | ||
side: .top | ||
), | ||
reducer: cubePreviewReducer, | ||
environment: CubePreviewEnvironment() | ||
) | ||
) | ||
} | ||
|
||
Button("Game Preview") { self.gamePreviewIsPresented = true } | ||
.sheet(isPresented: self.$gamePreviewIsPresented) { | ||
CubePreviewView( | ||
store: .init( | ||
initialState: .init( | ||
preview: .game( | ||
.init( | ||
cubes: .init(cubes: randomCubes(for: isowordsLetter).run()), | ||
moves: word.moves | ||
) | ||
) | ||
.init( | ||
index: .init(x: .two, y: .two, z: .one), | ||
side: .top | ||
), | ||
reducer: cubePreviewReducer, | ||
environment: CubePreviewEnvironment() | ||
) | ||
.init( | ||
index: .init(x: .two, y: .two, z: .zero), | ||
side: .top | ||
), | ||
.init( | ||
index: .init(x: .two, y: .two, z: .zero), | ||
side: .right | ||
), | ||
.init( | ||
index: .init(x: .two, y: .two, z: .one), | ||
side: .right | ||
), | ||
.init( | ||
index: .init(x: .two, y: .two, z: .two), | ||
side: .right | ||
), | ||
]) | ||
) | ||
} | ||
} | ||
.navigationTitle(Text("Cube Preview")) | ||
} | ||
], | ||
settings: .init() | ||
), | ||
reducer: cubePreviewReducer, | ||
environment: CubePreviewEnvironment( | ||
audioPlayer: .noop, | ||
feedbackGenerator: .live, | ||
lowPowerMode: .live, | ||
mainQueue: DispatchQueue.main.eraseToAnyScheduler() | ||
) | ||
) | ||
) | ||
} | ||
} | ||
} | ||
|
||
let word = PreviewType.Word( | ||
cubes: .init(cubes: randomCubes(for: isowordsLetter).run()), | ||
moveIndex: 5, | ||
moves: [ | ||
.init( | ||
playedAt: Date(), | ||
playerIndex: nil, | ||
reactions: nil, | ||
score: 0, | ||
type: .removedCube(.init(x: .two, y: .two, z: .two)) | ||
), | ||
.init( | ||
playedAt: Date(), | ||
playerIndex: nil, | ||
reactions: nil, | ||
score: 0, | ||
type: .removedCube(.init(x: .two, y: .one, z: .two)) | ||
), | ||
.init( | ||
playedAt: Date(), | ||
playerIndex: nil, | ||
reactions: nil, | ||
score: 0, | ||
type: .removedCube(.init(x: .one, y: .two, z: .two)) | ||
), | ||
.init( | ||
playedAt: Date(), | ||
playerIndex: nil, | ||
reactions: nil, | ||
score: 0, | ||
type: .removedCube(.init(x: .two, y: .two, z: .one)) | ||
), | ||
.init( | ||
playedAt: Date(), | ||
playerIndex: nil, | ||
reactions: nil, | ||
score: 100, | ||
type: .playedWord([ | ||
.init(index: .init(x: .one, y: .zero, z: .two), side: .left), | ||
.init(index: .init(x: .zero, y: .zero, z: .two), side: .left), | ||
.init(index: .init(x: .one, y: .one, z: .two), side: .left), | ||
.init(index: .init(x: .one, y: .two, z: .two), side: .left), | ||
.init(index: .init(x: .zero, y: .two, z: .two), side: .left), | ||
]) | ||
), | ||
.init( | ||
playedAt: Date(), | ||
playerIndex: nil, | ||
reactions: nil, | ||
score: 100, | ||
type: .playedWord([ | ||
.init(index: .init(x: .two, y: .zero, z: .two), side: .left), | ||
.init(index: .init(x: .two, y: .zero, z: .two), side: .top), | ||
.init(index: .init(x: .two, y: .one, z: .one), side: .left), | ||
.init(index: .init(x: .one, y: .two, z: .one), side: .left), | ||
.init(index: .init(x: .zero, y: .two, z: .one), side: .top), | ||
]) | ||
), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.