-
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.
- Loading branch information
Showing
4 changed files
with
61 additions
and
56 deletions.
There are no files selected for viewing
Binary file modified
BIN
+5.85 KB
(100%)
...odeproj/project.xcworkspace/xcuserdata/plarson.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// BibleClient.swift | ||
// TCA-Bible | ||
// | ||
// Created by Peter Larson on 7/18/23. | ||
// | ||
|
||
import Foundation | ||
import BibleCore | ||
import ComposableArchitecture | ||
|
||
public struct BibleClient { | ||
public var translations: @Sendable () async throws -> [Translation] | ||
public var translation: @Sendable (TranslationID) async throws -> Translation | ||
public var genres: @Sendable () async throws -> [Genre] | ||
public var genre: @Sendable (GenreID) async throws -> Genre | ||
public var books: @Sendable () async throws -> [Book] | ||
public var book: @Sendable (BookID) async throws -> Book | ||
public var chapters: @Sendable (BookID) async throws -> [Chapter] | ||
public var verses: @Sendable (BookID, ChapterID) async throws -> [Verse] | ||
public var verse: @Sendable (BookID, ChapterID, VerseID) async throws -> Verse | ||
} | ||
|
||
extension DependencyValues { | ||
public var bible: BibleClient { | ||
get { | ||
self[BibleClient.self] | ||
} | ||
|
||
set { | ||
self[BibleClient.self] = newValue | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import BibleCore | ||
import Foundation | ||
import ComposableArchitecture | ||
|
||
enum BibleClientError: Error { | ||
case unknown | ||
} | ||
|
||
extension BibleClient { | ||
public static var testValue: BibleClient = Self( | ||
translations: { [.mock] }, | ||
translation: { _ in .mock }, | ||
genres: { [.mock] }, | ||
genre: { _ in .mock }, | ||
books: { [.genesis, .exodus, .leviticus] }, | ||
book: { id in | ||
guard let book = IdentifiedArray(uniqueElements: [Book].mock)[id: id] else { | ||
throw BibleClientError.unknown | ||
} | ||
|
||
return book | ||
}, | ||
chapters: { _ in [.mock] }, | ||
verses: { _, _ in [.mock] }, | ||
verse: { _, _, _ in .mock } | ||
) | ||
} |