@@ -37,6 +37,7 @@ struct OnlineMangaView: View {
37
37
let lastReadChapterAvailable : Bool
38
38
let areChaptersFetched : Bool
39
39
let firstChapterOptions : [ ChapterDetails ] ?
40
+ let userReadsManga : Bool
40
41
41
42
init ( state: OnlineMangaFeature . State ) {
42
43
manga = state. manga
@@ -50,6 +51,7 @@ struct OnlineMangaView: View {
50
51
lastReadChapterAvailable = state. lastReadChapterID. hasValue && state. pagesState. hasValue
51
52
areChaptersFetched = state. pagesState. hasValue
52
53
firstChapterOptions = state. firstChapterOptions
54
+ userReadsManga = state. isUserOnReadingView
53
55
}
54
56
}
55
57
@@ -125,61 +127,54 @@ extension OnlineMangaView {
125
127
. font ( . title3)
126
128
. padding ( . bottom, 10 )
127
129
128
- if let firstChapterOptions = viewStore. firstChapterOptions {
129
- VStack ( alignment: . leading, spacing: 12 ) {
130
- ForEach ( firstChapterOptions) { chapter in
131
- VStack ( alignment: . leading) {
132
- HStack ( alignment: . bottom) {
133
- Text ( chapter. chapterName)
134
-
135
- Spacer ( )
136
-
137
- if chapter. attributes. externalURL != nil {
138
- Image ( " ExternalLinkIcon " )
139
- . resizable ( )
140
- . frame ( width: 20 , height: 20 )
141
- }
142
- }
130
+ ForEach ( viewStore. firstChapterOptions ?? [ ] ) { chapter in
131
+ LazyVStack ( alignment: . leading) {
132
+ HStack ( alignment: . bottom) {
133
+ Text ( chapter. chapterName)
134
+
135
+ Spacer ( )
136
+
137
+ if chapter. attributes. externalURL != nil {
138
+ Image ( " ExternalLinkIcon " )
139
+ . resizable ( )
140
+ . frame ( width: 20 , height: 20 )
141
+ }
142
+ }
143
+
144
+ if let scanlationGroup = chapter. scanlationGroup {
145
+ HStack {
146
+ Text ( scanlationGroup. name)
147
+ . fontWeight ( . bold)
148
+ . lineLimit ( 1 )
149
+ . font ( . caption)
150
+ . foregroundColor ( . theme. secondaryText)
143
151
144
- if let scanlationGroup = chapter. scanlationGroup {
145
- HStack {
146
- Text ( scanlationGroup. name)
147
- . fontWeight ( . bold)
148
- . lineLimit ( 1 )
149
- . font ( . caption)
150
- . foregroundColor ( . theme. secondaryText)
151
-
152
- if scanlationGroup. attributes. isOfficial {
153
- Image ( systemName: " person.badge.shield.checkmark " )
154
- . resizable ( )
155
- . scaledToFit ( )
156
- . foregroundColor ( . green)
157
- . frame ( height: 15 )
158
- }
159
- }
152
+ if scanlationGroup. attributes. isOfficial {
153
+ Image ( systemName: " person.badge.shield.checkmark " )
154
+ . resizable ( )
155
+ . scaledToFit ( )
156
+ . foregroundColor ( . green)
157
+ . frame ( height: 15 )
160
158
}
161
-
162
- Divider ( )
163
- }
164
- . onTapGesture {
165
- showFirstChaptersPopup = false
166
- viewStore. send ( . userTappedOnFirstChapterOption( chapter) )
167
159
}
168
160
}
169
- . frame ( maxWidth: . infinity, alignment: . leading)
161
+
162
+ Divider ( )
163
+ }
164
+ . onTapGesture {
165
+ showFirstChaptersPopup = false
166
+ viewStore. send ( . userTappedOnFirstChapterOption( chapter) )
170
167
}
171
- } else {
172
- ProgressView ( )
173
168
}
169
+ . frame ( maxWidth: . infinity, alignment: . leading)
174
170
}
175
- . animation ( . linear, value: viewStore. firstChapterOptions? . count)
176
- . padding ( 25 )
177
- . background ( Color . theme. background. cornerRadius ( 20 ) )
178
- . frame ( maxWidth: . infinity)
179
- . padding ( . horizontal, 40 )
180
171
}
172
+ . padding ( 25 )
173
+ . background ( Color . theme. background. cornerRadius ( 20 ) )
174
+ . frame ( maxWidth: . infinity)
175
+ . padding ( . horizontal, 40 )
181
176
}
182
-
177
+
183
178
private var footer : some View {
184
179
HStack ( spacing: 0 ) {
185
180
Text ( " All information on this page provided by " )
@@ -574,10 +569,8 @@ extension OnlineMangaView {
574
569
}
575
570
}
576
571
. padding ( . horizontal, 5 )
577
- . onChange ( of: viewStore. firstChapterOptions) { newValue in
578
- if newValue. hasValue && newValue!. count > 1 {
579
- showFirstChaptersPopup = true
580
- }
572
+ . onChange ( of: viewStore. firstChapterOptions. hasValue) { _ in
573
+ showFirstChaptersPopup = !viewStore. userReadsManga
581
574
}
582
575
}
583
576
}
0 commit comments