Skip to content

Commit

Permalink
Classroom, Exercise, Lesson, Grade init
Browse files Browse the repository at this point in the history
  • Loading branch information
p-larson committed Sep 8, 2023
1 parent d10384e commit d9e22f1
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>Bible.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
Expand Down
1 change: 1 addition & 0 deletions BibleCore/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ let package = Package(
dependencies: [
"BibleCore",
"BibleClient",
"DirectoryCore",
"UserDefaultsClient",
.product(name: "WrappingHStack", package: "WrappingHStack"),
.product(name: "ComposableArchitecture", package: "swift-composable-architecture")
Expand Down
16 changes: 10 additions & 6 deletions BibleCore/Sources/Classroom/Classroom.swift
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
import ComposableArchitecture
import DirectoryCore
import Foundation
import UserDefaultsClient

struct Classroom: Reducer {

struct State: Equatable, Codable {
var lessons: IdentifiedArrayOf<Lesson.State> = []
var selected: Lesson.State.ID? = nil
var directory: Directory.State? = nil
}

enum Action: Equatable {
case task
case lesson(Lesson.Action)
case select(id: UUID)
case openDirectory
}

@Dependency(\.defaults) var defaults: UserDefaultsClient


var body: some ReducerOf<Self> {
Reduce { state, action in
switch action {
case .task
return .run {
defaults.get
}
case .task:
return .none
case .openDirectory:



return .none
case .select(id: let id):
state.selected = id
return .none
Expand Down
4 changes: 3 additions & 1 deletion BibleCore/Sources/Classroom/ClassroomView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ struct ClassroomView: View {
let store: StoreOf<Classroom>

var body: some View {
EmptyView()
WithViewStore(store, observe: { $0 }) { viewStore in

}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,7 @@ import ComposableArchitecture
import BibleCore
import BibleClient

/*
Types of learning modes

FITB, fill in the blank
- In the beginning




*/

struct FillInTheBlank: Reducer {
struct BuildByLetter: Reducer {
enum Difficulty: Equatable, Codable {
case easy, medium, hard
}
Expand Down Expand Up @@ -43,7 +32,6 @@ struct FillInTheBlank: Reducer {
Reduce { state, action in
switch action {
case .task:

state.wordBank = withRandomNumberGenerator {
state.correctAnswer.shuffled(using: &$0)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ComposableArchitecture
import BibleCore
import BibleClient

public struct Piecemeal: Reducer {
public struct BuildByWord: Reducer {
public init() {}

public struct State: Equatable, Codable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import SwiftUI

import WrappingHStack

public struct PiecemealView: View {
public let store: StoreOf<Piecemeal>
public struct BuildByWordView: View {
public let store: StoreOf<BuildByWord>

public init(store: StoreOf<Piecemeal>) {
public init(store: StoreOf<BuildByWord>) {
self.store = store
}

Expand Down Expand Up @@ -70,13 +70,13 @@ public struct PiecemealView: View {
}
}

struct PiecemealView_Previews: PreviewProvider {
struct BuildByWordView_Previews: PreviewProvider {
static var previews: some View {
PiecemealView(
BuildByWordView(
store: Store(
initialState: Piecemeal.State(),
initialState: BuildByWord.State(),
reducer: {
Piecemeal()
BuildByWord()
.dependency(\.bible, .testValue)
}
)
Expand Down
23 changes: 23 additions & 0 deletions BibleCore/Sources/Classroom/Lesson/Excercise/Exercise.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import BibleCore
import ComposableArchitecture

struct Exercise: Reducer {
enum State: Equatable, Codable {
case buildByWord(BuildByWord.State)
case buildByLetter(BuildByLetter.State)
}

enum Action: Equatable {
case buildByWord(BuildByWord.Action)
case buildByLetter(BuildByLetter.Action)
}

var body: some ReducerOf<Self> {
Scope(state: /State.buildByWord, action: /Action.buildByWord) {
BuildByWord()
}
Scope(state: /State.buildByLetter, action: /Action.buildByLetter) {
BuildByLetter()
}
}
}
21 changes: 0 additions & 21 deletions BibleCore/Sources/Classroom/Lesson/Exercise.swift

This file was deleted.

24 changes: 24 additions & 0 deletions BibleCore/Sources/Classroom/Lesson/Grade.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import ComposableArchitecture

struct Grade: Reducer {
enum State: Equatable, Codable {
case disabled
case ready
case failed(String)
case partial(String)
case correct
}

enum Action: Equatable {
case submit
}

var body: some ReducerOf<Self> {
Reduce { state, action in
switch action {
case .submit:
return .none
}
}
}
}
20 changes: 19 additions & 1 deletion BibleCore/Sources/Classroom/Lesson/Lesson.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,33 @@ import Foundation
struct Lesson: Reducer {
struct State: Identifiable, Equatable, Codable {
var verses: [Verse]
var exercise: Exercise.State?
var exercise: Exercise.State? = nil
var grade: Grade.State = .disabled
var id: UUID

public init(
verses: [Verse],
exercise: Exercise.State? = nil,
grade: Grade.State,
id: UUID
) {
self.verses = verses
self.exercise = exercise
self.grade = grade
self.id = id
}
}

enum Action: Equatable {
case prepare
case excercise(Exercise.Action)
case grade(Grade.Action)
}

var body: some ReducerOf<Self> {
Scope(state: \.grade, action: /Action.grade) {
Grade()
}
Reduce { state, action in
switch action {
default:
Expand Down

0 comments on commit d9e22f1

Please sign in to comment.