-
Notifications
You must be signed in to change notification settings - Fork 184
Swift UI initial start #56
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
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
d261c54
Initial SwiftUI, tab bar with basic content
stevenzeck 05874e9
Add license info to new files, clean up About tab contents
stevenzeck 7359773
Start book cover and bookshelf
stevenzeck 06703aa
Display books from db
stevenzeck 6df9aa5
Add add icon button to toolbars
stevenzeck 77a749f
Use db for OPDS feeds
stevenzeck 571a211
Switch to using ViewModel
stevenzeck 30de323
Use async/await for database
stevenzeck c248ee9
Add new function to parse OPDS URL async
stevenzeck 49f7581
Show sheet for adding a book
stevenzeck 2ad2236
Sheet for adding OPDS feed, file cleanup
stevenzeck ee4622a
Refactor dependency management with `Container`
mickael-menu 6b184d3
Start making suggested changes
stevenzeck f8750b0
Make suggested changes
stevenzeck ac903cc
Add initial SQL database migration
mickael-menu fdbb68f
Fix file headers
mickael-menu daedf2b
Bump deployment targets
mickael-menu 72636b1
Update Carthage project
mickael-menu 58a9ec7
Fix deployment target
mickael-menu 24caa2f
Revert preloading catalogs with UIKit
mickael-menu d56bc89
Change buttons for sheet, add catalog from URL
stevenzeck 29fb01f
Change button placement on add book sheet
stevenzeck 6d4cd9a
Make suggested changes
stevenzeck 7a5f2ee
Refactor button creation
mickael-menu 5cc16b7
Merge branch 'swiftui' of github.com:readium/swift-toolkit into swiftui
mickael-menu d7cc9f5
Fix database async accesses
mickael-menu 1f01c96
Minor API renames
mickael-menu 45c3651
Refactor usage of `ValueObservation`
mickael-menu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,48 @@ | ||
| // | ||
| // Copyright 2022 Readium Foundation. All rights reserved. | ||
| // Use of this source code is governed by the BSD-style license | ||
| // available in the top-level LICENSE file of the project. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| class Container { | ||
|
|
||
| private let db: Database | ||
|
|
||
| init() throws { | ||
| self.db = try Database( | ||
| file: Paths.library.appendingPathComponent("database.db"), | ||
| migrations: [InitialMigration()] | ||
| ) | ||
| } | ||
|
|
||
| // Bookshelf | ||
|
|
||
| private lazy var bookRepository = BookRepository(db: db) | ||
|
|
||
| func bookshelf() -> Bookshelf { | ||
| Bookshelf(viewModel: BookshelfViewModel(bookRepository: bookRepository)) | ||
| } | ||
|
|
||
| // Catalogs | ||
|
|
||
| private lazy var catalogRepository = CatalogRepository(db: db) | ||
|
|
||
| func catalogs() -> Catalogs { | ||
| Catalogs( | ||
| viewModel: CatalogsViewModel(catalogRepository: catalogRepository), | ||
| catalogDetail: catalogDetail(with:) | ||
| ) | ||
| } | ||
|
|
||
| func catalogDetail(with catalog: Catalog) -> CatalogDetail { | ||
| CatalogDetail(viewModel: CatalogDetailViewModel(catalog: catalog)) | ||
| } | ||
|
|
||
| // About | ||
|
|
||
| func about() -> About { | ||
| About() | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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,52 @@ | ||
| // | ||
| // Copyright 2022 Readium Foundation. All rights reserved. | ||
| // Use of this source code is governed by the BSD-style license | ||
| // available in the top-level LICENSE file of the project. | ||
| // | ||
|
|
||
| import Combine | ||
| import Foundation | ||
| import GRDB | ||
|
|
||
| /// Represents an OPDS catalog. | ||
| struct Catalog: Codable, Hashable, Identifiable { | ||
| struct Id: EntityId { let rawValue: Int64 } | ||
|
|
||
| var id: Id? | ||
| var title: String | ||
| var url: String | ||
| var created: Date | ||
|
|
||
| init(id: Id? = nil, title: String, url: String, created: Date = Date()) { | ||
| self.id = id | ||
| self.title = title | ||
| self.url = url | ||
| self.created = created | ||
| } | ||
| } | ||
|
|
||
| extension Catalog: TableRecord, FetchableRecord, PersistableRecord { | ||
| enum Columns: String, ColumnExpression { | ||
| case id, title, url, created | ||
| } | ||
| } | ||
|
|
||
| final class CatalogRepository { | ||
| private let db: Database | ||
|
|
||
| init(db: Database) { | ||
| self.db = db | ||
| } | ||
|
|
||
| func all() -> AnyPublisher<[Catalog]?, Never> { | ||
| db.observe { | ||
| try Catalog.order(Catalog.Columns.title).fetchAll($0) | ||
| } | ||
| } | ||
|
|
||
| func save(_ catalog: inout Catalog) async throws { | ||
| catalog = try await db.write { [catalog] db in | ||
| try catalog.saved(db) | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.