-
Notifications
You must be signed in to change notification settings - Fork 155
SUI refactoring facets screen #501
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
mickael-menu
merged 18 commits into
readium:develop
from
FuzzzzyBoy:SUI-refactoring-facets-screen
Nov 19, 2024
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ffb321b
add feed preview
FuzzzzyBoy aa7be26
add OPDSFacetView
FuzzzzyBoy 7f4f462
add navigation bar
FuzzzzyBoy bbec8b3
add dismiss button
FuzzzzyBoy c42acc6
refactoring
FuzzzzyBoy 24a284d
add OPDSFacetLInkView
FuzzzzyBoy 16da49e
add facetsList
FuzzzzyBoy d611b36
add tap handler
FuzzzzyBoy fc6e1de
setup for debug
FuzzzzyBoy ac8d6b9
use OPDSFacetsView
FuzzzzyBoy 76cd665
remove unused
FuzzzzyBoy d95aac9
create view controller without factory
FuzzzzyBoy b27685e
remove unused
FuzzzzyBoy 6232c51
use @Observable
FuzzzzyBoy e9d280a
restore
FuzzzzyBoy 1dbc8a2
swiftlink fixes
FuzzzzyBoy 32a69de
Merge branch 'develop' into SUI-refactoring-facets-screen
mickael-menu 4ea891c
Various changes
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
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
// | ||
// Copyright 2024 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 | ||
import ReadiumOPDS | ||
import ReadiumShared | ||
|
||
extension Feed { | ||
static var preview: Feed { | ||
try! OPDS2Parser.parse( | ||
jsonData: .preview, | ||
url: URL(string: "http://opds-spec.org/opds.json")!, | ||
response: URLResponse() | ||
).feed! | ||
} | ||
} | ||
|
||
private extension Data { | ||
static var preview: Data { | ||
let jsonString = """ | ||
{ | ||
"@context": "http://opds-spec.org/opds.json", | ||
"metadata": { | ||
"title": "Example Library", | ||
"modified": "2024-11-05T12:00:00Z", | ||
"numberOfItems": 5000, | ||
"itemsPerPage": 30 | ||
}, | ||
"links": [ | ||
{ | ||
"rel": "self", | ||
"href": "/opds", | ||
"type": "application/opds+json" | ||
} | ||
], | ||
"facets": [ | ||
{ | ||
"metadata": { | ||
"title": "Genre" | ||
}, | ||
"links": [ | ||
{ | ||
"rel": "http://opds-spec.org/facet", | ||
"href": "/opds/books/new?genre=fiction", | ||
"title": "Fiction", | ||
"type": "application/opds+json", | ||
"properties": { | ||
"numberOfItems": 1250 | ||
} | ||
}, | ||
{ | ||
"rel": "http://opds-spec.org/facet", | ||
"href": "/opds/books/new?genre=mystery", | ||
"title": "Mystery & Detective", | ||
"type": "application/opds+json", | ||
"properties": { | ||
"numberOfItems": 850 | ||
} | ||
}, | ||
{ | ||
"rel": "http://opds-spec.org/facet", | ||
"href": "/opds/books/new?genre=scifi", | ||
"title": "Science Fiction", | ||
"type": "application/opds+json", | ||
"properties": { | ||
"numberOfItems": 725 | ||
} | ||
}, | ||
{ | ||
"rel": "http://opds-spec.org/facet", | ||
"href": "/opds/books/new?genre=non-fiction", | ||
"title": "Non-Fiction", | ||
"type": "application/opds+json", | ||
"properties": { | ||
"numberOfItems": 2175 | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"metadata": { | ||
"title": "Language" | ||
}, | ||
"links": [ | ||
{ | ||
"rel": "http://opds-spec.org/facet", | ||
"href": "/opds/books/new?language=en", | ||
"title": "English", | ||
"type": "application/opds+json", | ||
"properties": { | ||
"numberOfItems": 3000 | ||
} | ||
}, | ||
{ | ||
"rel": "http://opds-spec.org/facet", | ||
"href": "/opds/books/new?language=es", | ||
"title": "Spanish", | ||
"type": "application/opds+json", | ||
"properties": { | ||
"numberOfItems": 1000 | ||
} | ||
}, | ||
{ | ||
"rel": "http://opds-spec.org/facet", | ||
"href": "/opds/books/new?language=ru", | ||
"title": "Russian", | ||
"type": "application/opds+json", | ||
"properties": { | ||
"numberOfItems": 800 | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"metadata": { | ||
"title": "Availability" | ||
}, | ||
"links": [ | ||
{ | ||
"rel": "http://opds-spec.org/facet", | ||
"href": "/opds/books/new?availability=free", | ||
"title": "Free", | ||
"type": "application/opds+json", | ||
"properties": { | ||
"numberOfItems": 1500 | ||
} | ||
}, | ||
{ | ||
"rel": "http://opds-spec.org/facet", | ||
"href": "/opds/books/new?availability=subscription", | ||
"title": "Subscription", | ||
"type": "application/opds+json", | ||
"properties": { | ||
"numberOfItems": 2500 | ||
} | ||
}, | ||
{ | ||
"rel": "http://opds-spec.org/facet", | ||
"href": "/opds/books/new?availability=buy", | ||
"title": "Purchase Required", | ||
"type": "application/opds+json", | ||
"properties": { | ||
"numberOfItems": 1000 | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"metadata": { | ||
"title": "Reading Age" | ||
}, | ||
"links": [ | ||
{ | ||
"rel": "http://opds-spec.org/facet", | ||
"href": "/opds/books/new?age=children", | ||
"title": "Children (0-11)", | ||
"type": "application/opds+json", | ||
"properties": { | ||
"numberOfItems": 800 | ||
} | ||
}, | ||
{ | ||
"rel": "http://opds-spec.org/facet", | ||
"href": "/opds/books/new?age=teen", | ||
"title": "Teen (12-18)", | ||
"type": "application/opds+json", | ||
"properties": { | ||
"numberOfItems": 1200 | ||
} | ||
}, | ||
{ | ||
"rel": "http://opds-spec.org/facet", | ||
"href": "/opds/books/new?age=adult", | ||
"title": "Adult (18+)", | ||
"type": "application/opds+json", | ||
"properties": { | ||
"numberOfItems": 3000 | ||
} | ||
} | ||
] | ||
} | ||
], | ||
"publications": [ | ||
{ | ||
"metadata": { | ||
"title": "Sample Book", | ||
"identifier": "urn:uuid:6409a00b-7bf2-405e-826c-3fdff0fd0734", | ||
"modified": "2024-11-05T12:00:00Z", | ||
"language": ["en"], | ||
"published": "2024", | ||
"author": [ | ||
{ | ||
"name": "Sample Author" | ||
} | ||
], | ||
"subject": [ | ||
{ | ||
"name": "Fiction", | ||
"code": "fiction" | ||
} | ||
] | ||
}, | ||
"links": [ | ||
{ | ||
"rel": "http://opds-spec.org/acquisition", | ||
"href": "/books/sample.epub", | ||
"type": "application/epub+zip" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
""" | ||
guard let data = jsonString.data(using: .utf8) else { | ||
return Data() | ||
} | ||
return data | ||
} | ||
} |
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,39 @@ | ||
// | ||
// Copyright 2024 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 ReadiumShared | ||
import SwiftUI | ||
|
||
struct OPDSFacetLink: View { | ||
let link: ReadiumShared.Link | ||
|
||
var body: some View { | ||
HStack { | ||
if let title = link.title { | ||
Text(title) | ||
.foregroundStyle(Color.primary) | ||
} | ||
|
||
Spacer() | ||
|
||
if let count = link.properties.numberOfItems { | ||
Text("\(count)") | ||
.foregroundStyle(Color.secondary) | ||
.font(.subheadline) | ||
} | ||
|
||
Image(systemName: "chevron.right") | ||
} | ||
.font(.body) | ||
} | ||
} | ||
|
||
#Preview { | ||
OPDSFacetLink( | ||
link: Feed.preview.facets[0].links[0] | ||
) | ||
.padding() | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mickael-menu Perhaps we should move these mocks to the swift-toolkit package?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to keep them here as it's out of scope for the toolkit itself.