4
4
// available in the top-level LICENSE file of the project.
5
5
//
6
6
7
- import SwiftUI
8
7
import R2Shared
9
8
import ReadiumOPDS
9
+ import SwiftUI
10
10
11
11
struct CatalogFeed : View {
12
-
13
12
var catalog : Catalog
14
13
@State private var parseData : ParseData ?
15
-
14
+
16
15
let catalogFeed : ( Catalog ) -> CatalogFeed
17
16
let publicationDetail : ( Publication ) -> PublicationDetail
18
-
17
+
19
18
var body : some View {
20
-
21
19
ScrollView {
22
20
VStack ( alignment: . leading) {
23
21
if let feed = parseData? . feed {
@@ -30,14 +28,14 @@ struct CatalogFeed: View {
30
28
}
31
29
Divider ( ) . frame ( height: 50 )
32
30
}
33
-
34
- // TODO This probably needs its own file
31
+
32
+ // TODO: This probably needs its own file
35
33
if !feed. publications. isEmpty {
36
34
let columns : [ GridItem ] = [ GridItem ( . adaptive( minimum: 150 + 8 ) ) ]
37
35
LazyVGrid ( columns: columns) {
38
36
ForEach ( feed. publications) { publication in
39
37
let authors = publication. metadata. authors
40
- . map { $0 . name }
38
+ . map ( \ . name)
41
39
. joined ( separator: " , " )
42
40
NavigationLink ( destination: publicationDetail ( publication) ) {
43
41
BookCover (
@@ -52,7 +50,7 @@ struct CatalogFeed: View {
52
50
}
53
51
Divider ( ) . frame ( height: 50 )
54
52
}
55
-
53
+
56
54
if !feed. groups. isEmpty {
57
55
ForEach ( feed. groups as [ R2Shared . Group ] ) { group in
58
56
CatalogGroup ( group: group, publicationDetail: publicationDetail, catalogFeed: catalogFeed)
@@ -74,31 +72,29 @@ struct CatalogFeed: View {
74
72
}
75
73
76
74
extension CatalogFeed {
77
-
78
75
func parseFeed( ) async {
79
76
if let url = URL ( string: catalog. url) {
80
- OPDSParser . parseURL ( url: url) { data, error in
77
+ OPDSParser . parseURL ( url: url) { data, _ in
81
78
self . parseData = data
82
79
}
83
80
}
84
81
}
85
82
}
86
83
87
- // FIXME this causes a Swift compiler error segmentation fault 11
84
+ // FIXME: this causes a Swift compiler error segmentation fault 11
88
85
89
- //struct CatalogDetail_Previews: PreviewProvider {
86
+ // struct CatalogDetail_Previews: PreviewProvider {
90
87
// static var previews: some View {
91
88
// let catalog = Catalog(title: "Test", url: "https://www.test.com")
92
89
// let catalogDetail: (Catalog) -> CatalogDetail = { CatalogDetail(CatalogDetailViewModel(catalog: catalog)) }
93
90
// CatalogDetail(viewModel: CatalogDetailViewModel(catalog: catalog), catalogDetail: catalogDetail)
94
91
// }
95
- //}
92
+ // }
96
93
97
94
struct CatalogDetail_Previews : PreviewProvider {
98
95
static var previews : some View {
99
96
let catalog = Catalog ( title: " Test " , url: " https://www.test.com " )
100
97
CatalogFeed ( catalog: catalog, catalogFeed: { _ in fatalError ( ) } ,
101
- publicationDetail: { _ in fatalError ( ) }
102
- )
98
+ publicationDetail: { _ in fatalError ( ) } )
103
99
}
104
100
}
0 commit comments