fix view
This commit is contained in:
parent
98265c72d6
commit
8517c5afc3
@ -113,6 +113,7 @@ struct IndexMainView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
||||||
if let fixedDramaGroup = indexModel.fixedDramaGroup {
|
if let fixedDramaGroup = indexModel.fixedDramaGroup {
|
||||||
Text(fixedDramaGroup.group_name)
|
Text(fixedDramaGroup.group_name)
|
||||||
.font(.system(size: 18))
|
.font(.system(size: 18))
|
||||||
|
|||||||
@ -87,17 +87,17 @@ final class IndexModel {
|
|||||||
var scrollIDPublisher = PassthroughSubject<(String, Int), Never>()
|
var scrollIDPublisher = PassthroughSubject<(String, Int), Never>()
|
||||||
|
|
||||||
@ObservationIgnored
|
@ObservationIgnored
|
||||||
private var bag = Set<AnyCancellable>()
|
private var cancel: AnyCancellable?
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
self.selectedDate = ""
|
self.selectedDate = ""
|
||||||
|
|
||||||
self.scrollIDPublisher
|
self.cancel = self.scrollIDPublisher
|
||||||
.sink { userId, scrollID in
|
.sink { userId, scrollID in
|
||||||
|
|
||||||
self.dramaGroupElements.forEach { element in
|
self.dramaGroupElements.forEach { element in
|
||||||
switch element {
|
switch element {
|
||||||
case .label(let groupId, let groupName):
|
case .label(_, _):
|
||||||
()
|
()
|
||||||
case .item(let groupId, let item):
|
case .item(let groupId, let item):
|
||||||
if item.id == scrollID {
|
if item.id == scrollID {
|
||||||
@ -108,16 +108,8 @@ final class IndexModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let ids = self.dramaGroupElements.suffix(6).compactMap { element -> Int? in
|
|
||||||
switch element {
|
|
||||||
case .label(_, _):
|
|
||||||
return nil
|
|
||||||
case .item(groupId: _, item: let item):
|
|
||||||
return item.id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 判断更新周期
|
// 判断更新周期
|
||||||
|
let ids = self.getDramaIds(self.updateDramaGroups).suffix(6)
|
||||||
let timeDistance = self.updateInterval.distance(to: Date())
|
let timeDistance = self.updateInterval.distance(to: Date())
|
||||||
// 滑动停止的时候,检测是否到达了底部
|
// 滑动停止的时候,检测是否到达了底部
|
||||||
if timeDistance > 1.0 && ids.contains(scrollID) {
|
if timeDistance > 1.0 && ids.contains(scrollID) {
|
||||||
@ -127,7 +119,6 @@ final class IndexModel {
|
|||||||
self.updateInterval = Date()
|
self.updateInterval = Date()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.store(in: &bag)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadData(userId: String) async {
|
func loadData(userId: String) async {
|
||||||
|
|||||||
@ -62,26 +62,8 @@ extension ListView {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack(alignment: .center) {
|
HStack(alignment: .center) {
|
||||||
|
FlexImage(urlString: episode.thumb, width: 90, height: 60, placeholder: "ph_img_medium")
|
||||||
AsyncImage(url: URL(string: episode.thumb)) { phase in
|
.frame(width: 90, height: 60)
|
||||||
switch phase {
|
|
||||||
case .empty:
|
|
||||||
ProgressView()
|
|
||||||
case .success(let image):
|
|
||||||
image
|
|
||||||
.resizable()
|
|
||||||
.aspectRatio(contentMode: .fill)
|
|
||||||
.frame(width: 90, height: 60)
|
|
||||||
.clipped()
|
|
||||||
default:
|
|
||||||
Image("ph_img_medium")
|
|
||||||
.resizable()
|
|
||||||
.aspectRatio(contentMode: .fill)
|
|
||||||
.clipped()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
.frame(width: 90, height: 60)
|
|
||||||
|
|
||||||
VStack(alignment: .leading, spacing: 20) {
|
VStack(alignment: .leading, spacing: 20) {
|
||||||
Text(episode.num_name)
|
Text(episode.num_name)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user