Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classroom, Exercise, Lesson, Grade init #12

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 5 additions & 3 deletions Bible/BibleApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ final public class AppDelegate: NSObject, UIApplicationDelegate {
)
) {
AppReducer()
._printChanges()
}

public func application(
Expand All @@ -32,16 +33,17 @@ final public class AppDelegate: NSObject, UIApplicationDelegate {

@main
struct BibleApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate


var body: some Scene {
WindowGroup {
#if os(macOS)
DesktopReaderView(store: Store(initialState: DesktopReader.State.init()) {
DesktopReader()
})
#elseif os(iOS)
ReaderView(store: Store(initialState: Reader.State.init()) {
Reader()
})
AppView(store: delegate.store)
#else
fatalError("Unsupported OS")
#endif
Expand Down
9 changes: 8 additions & 1 deletion BibleCore/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ let package = Package(
.library(name: "DirectoryCore", targets: ["DirectoryCore"]),
.library(name: "UserDefaultsClient", targets: ["UserDefaultsClient"]),
.library(name: "AppFeature", targets: ["AppFeature"]),
.library(name: "Classroom", targets: ["Classroom"])
.library(name: "Classroom", targets: ["Classroom"]),
.library(name: "BibleComponents", targets: ["BibleComponents"])
],
dependencies: [
.package(
Expand All @@ -30,6 +31,9 @@ let package = Package(
)
],
targets: [
.target(
name: "BibleComponents"
),
.target(
name: "ReaderCore",
dependencies: [
Expand Down Expand Up @@ -113,14 +117,17 @@ let package = Package(
name: "AppFeature",
dependencies: [
"ReaderCore",
"Classroom",
.product(name: "ComposableArchitecture", package: "swift-composable-architecture")
]
),
.target(
name: "Classroom",
dependencies: [
"BibleCore",
"BibleComponents",
"BibleClient",
"DirectoryCore",
"UserDefaultsClient",
.product(name: "WrappingHStack", package: "WrappingHStack"),
.product(name: "ComposableArchitecture", package: "swift-composable-architecture")
Expand Down
11 changes: 7 additions & 4 deletions BibleCore/Sources/AppFeature/App.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ComposableArchitecture
import ReaderCore
import Classroom

public struct AppReducer: Reducer {

Expand All @@ -8,15 +9,17 @@ public struct AppReducer: Reducer {


public enum State: Equatable {
case reader(Reader.State = .init())
case empty
case classroom(Classroom.State = .init())
}

public enum Action: Equatable {
case reader(Reader.Action)
case classroom(Classroom.Action)
}

public var body: some ReducerOf<Self> {
Scope(state: /State.classroom, action: /Action.classroom) {
Classroom()
}
Reduce { state, action in .none }
}
}
Expand Down Expand Up @@ -66,7 +69,7 @@ public struct AppReducer: Reducer {
case .tabSelected(let tab):

if tab == .read {
state.path.append(.empty)
state.path.append(.classroom())
}

return .none
Expand Down
19 changes: 9 additions & 10 deletions BibleCore/Sources/AppFeature/AppView.swift
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import ComposableArchitecture
import Classroom
import ReaderCore
import SwiftUI

struct AppView: View {
public struct AppView: View {
let store: StoreOf<AppReducer>

@ObservedObject var viewStore: ViewStoreOf<AppReducer>

init(store: StoreOf<AppReducer>) {
public init(store: StoreOf<AppReducer>) {
self.store = store
self.viewStore = ViewStore(store, observe: { $0 })
}

var body: some View {
public var body: some View {
NavigationStackStore(
store.scope(state: \.path, action: AppReducer.Action.path)
) {
Expand All @@ -33,15 +34,13 @@ struct AppView: View {
}
} destination: { initialState in
switch initialState {
case .empty:
Text("hello")
.navigationBarBackButtonHidden(true)
case .reader:
case .classroom:
CaseLet(
/AppReducer.Path.State.reader,
action: AppReducer.Path.Action.reader,
then: ReaderView.init(store:)
/AppReducer.Path.State.classroom,
action: AppReducer.Path.Action.classroom,
then: ClassroomView.init(store:)
)
.navigationBarBackButtonHidden(true)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import SwiftUI

public struct CorrectButtonStyle: ButtonStyle {

public func makeBody(configuration: Configuration) -> some View {
configuration.label
.kerning(0.5)
.textCase(.uppercase)
.offset(y: configuration.isPressed ? 0 : -4)
.font(.system(size: 14))
.fontWeight(.bold)
.foregroundColor(.white)
.frame(height: 50)
.frame(maxWidth: .infinity)
.background {
RoundedRectangle(cornerRadius: 16, style: .continuous)
.fill(
Color.correctGreen.shadow(
ShadowStyle.inner(
color: .darkGreen,
radius: 0,
x: 0,
y: configuration.isPressed ? 0 : -4
)
)
)
}
}
}

public extension ButtonStyle where Self == CorrectButtonStyle {
static var correct: CorrectButtonStyle { CorrectButtonStyle() }
}

struct BibleButton_Previews: PreviewProvider {
static var previews: some View {
Button("Correct") {

}
.buttonStyle(.correct)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import SwiftUI

public struct DisabledButtonStyle: ButtonStyle {
public func makeBody(configuration: Configuration) -> some View {
configuration.label
.kerning(0.5)
.textCase(.uppercase)
.font(.system(size: 14))
.fontWeight(.bold)
.foregroundColor(.softBlack)
.frame(height: 50)
.frame(maxWidth: .infinity)
.background {
RoundedRectangle(cornerRadius: 16, style: .continuous)
.fill(
Color.softGray
)
}
.disabled(true)
}
}

public extension ButtonStyle where Self == DisabledButtonStyle {
static var disabled: DisabledButtonStyle { DisabledButtonStyle() }
}

public struct DisabledButtonStylePreviews: PreviewProvider {
public static var previews: some View {
Button("disabled") {

}
.buttonStyle(.disabled)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// SwiftUIView.swift
//
//
// Created by Peter Larson on 9/12/23.
//

import SwiftUI

public struct OptionButtonStyle: ButtonStyle {
public func makeBody(configuration: Configuration) -> some View {
configuration.label
.font(.system(size: 14))
.fontWeight(.bold)
.foregroundColor(.softBlack)
.padding()
.overlay {
RoundedRectangle(cornerRadius: 16, style: .continuous)
.stroke(lineWidth: 2.5)
.foregroundColor(.softGray)
}
.background {
RoundedRectangle(cornerRadius: 16, style: .continuous)
.fill(
Color.white.shadow(
ShadowStyle.inner(
color: .softGray,
radius: 0,
x: 0,
y: -4
)
)
)
}
}
}

public extension ButtonStyle where Self == OptionButtonStyle {
static var option: OptionButtonStyle { OptionButtonStyle() }
}

struct OptionButtonStyle_Previews: PreviewProvider {
static var previews: some View {
Button("Word") {

}
.buttonStyle(.option)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import SwiftUI

public struct UnselecedButtonStyle: ButtonStyle {
public func makeBody(configuration: Configuration) -> some View {
configuration.label
.textCase(.uppercase)
.offset(y: configuration.isPressed ? 0 : -4)
.font(.system(size: 14))
.fontWeight(.bold)
.foregroundColor(.softBlack)
.frame(height: 50)
.frame(maxWidth: .infinity)
.overlay {
RoundedRectangle(cornerRadius: 16, style: .continuous)
.stroke(lineWidth: 2.5)
.foregroundColor(.softGray)
}
.background {
RoundedRectangle(cornerRadius: 16, style: .continuous)
.fill(
Color.white.shadow(
ShadowStyle.inner(
color: .softGray,
radius: 0,
x: 0,
y: configuration.isPressed ? 0 : -4
)
)
)
}
}
}

public extension ButtonStyle where Self == UnselecedButtonStyle {
static var unselected: UnselecedButtonStyle { UnselecedButtonStyle() }
}


22 changes: 22 additions & 0 deletions BibleCore/Sources/BibleComponents/Color+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import SwiftUI

public extension Color {
init(hex: UInt, alpha: Double = 1) {
self.init(
.sRGB,
red: Double((hex >> 16) & 0xff) / 255,
green: Double((hex >> 08) & 0xff) / 255,
blue: Double((hex >> 00) & 0xff) / 255,
opacity: alpha
)
}
}

public extension Color {
static var softGray: Self { .init(hex: 0xE5E5E5) }
static var darkGray: Self { .init(hex: 0xAFAFAF) }
static var softBlack: Self { .init(hex: 0x3C3C3C) }
static var softGreen: Self { .init(hex: 0xD7FFB8) }
static var correctGreen: Self { .init(hex: 0x58CC02) }
static var darkGreen: Self { .init(hex: 0x58A700) }
}
36 changes: 36 additions & 0 deletions BibleCore/Sources/BibleComponents/ProgressBar.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import SwiftUI

public struct ProgressBar: View {

private let progress: Double

public init(progress: Double) {
self.progress = progress
}

public var body: some View {
ZStack {
RoundedRectangle(cornerRadius: 16)
.fill(Color.softGray)
GeometryReader { proxy in
RoundedRectangle(cornerRadius: 16)
.fill(Color.correctGreen)
.frame(width: (proxy.size.width - 32) * progress + 32)
// RoundedRectangle(cornerRadius: 16)
// .fill(Color.white.opacity(1/10))
// .frame(width: (proxy.size.width - 32) * progress + 16)
// .frame(height: 8)
// .offset(x: 8, y: 2)
}
}
.frame(minWidth: 48)
.frame(height: 16)
}
}

struct ProgressBar_Previews: PreviewProvider {
static var previews: some View {
ProgressBar(progress: 1.0)
.padding()
}
}
4 changes: 4 additions & 0 deletions BibleCore/Sources/BibleCore/Book.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ public extension Book {
static var leviticus: Self {
.init(id: 3, name: "Leviticus", testament: "ot")
}

static var john: Self {
.init(id: 43, name: "John", testament: "nt")
}
}

public extension Array where Element == Book {
Expand Down
Loading