remove index prompt
This commit is contained in:
parent
23b6664c04
commit
466ff8e387
@ -50,11 +50,6 @@ final class IndexModel {
|
||||
let dramas: [DramaItem]
|
||||
}
|
||||
|
||||
enum LoadMoreResult {
|
||||
case success
|
||||
case error(String)
|
||||
}
|
||||
|
||||
var dramas: [DramaItem]
|
||||
var selectedDate: String
|
||||
|
||||
@ -79,7 +74,7 @@ final class IndexModel {
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func loadMoreUpdateDramas(userId: String, mode: API.LoadMode) async -> LoadMoreResult {
|
||||
func loadMoreUpdateDramas(userId: String, mode: API.LoadMode) async {
|
||||
// 按照id来判断不一定正确,需要借助其他值
|
||||
let dramaIds = self.getDramaIds(self.updateDramaGroups)
|
||||
print("current ids: \(dramaIds)")
|
||||
@ -98,13 +93,7 @@ final class IndexModel {
|
||||
print("--------- after ------------")
|
||||
displayDramaGroups(self.updateDramaGroups)
|
||||
print("--------- ------------")
|
||||
|
||||
return .success
|
||||
} else {
|
||||
return .error("没有更多数据")
|
||||
}
|
||||
} else {
|
||||
return .error("加载失败")
|
||||
}
|
||||
}
|
||||
case .next:
|
||||
@ -119,17 +108,10 @@ final class IndexModel {
|
||||
print("----------after-----------")
|
||||
displayDramaGroups(self.updateDramaGroups)
|
||||
print("---------------------")
|
||||
|
||||
return .success
|
||||
} else {
|
||||
return .error("没有更多数据")
|
||||
}
|
||||
} else {
|
||||
return .error("加载失败")
|
||||
}
|
||||
}
|
||||
}
|
||||
return .success
|
||||
}
|
||||
}
|
||||
|
||||
// 指定日期,并更新日期下对应的数据
|
||||
@ -294,7 +276,7 @@ extension IndexView {
|
||||
@State private var showDateNavPopover: Bool = false
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .center) {
|
||||
VStack {
|
||||
|
||||
HStack(alignment: .center) {
|
||||
Color.clear
|
||||
@ -305,8 +287,9 @@ extension IndexView {
|
||||
}
|
||||
}
|
||||
.frame(height: 50)
|
||||
.background(Color(hex: "#F2F2F2"), ignoresSafeAreaEdges: .bottom)
|
||||
.background(Color(hex: "#F2F2F2"), ignoresSafeAreaEdges: .top)
|
||||
|
||||
VStack(alignment: .center) {
|
||||
HStack(alignment: .center) {
|
||||
Spacer()
|
||||
Text("番剧补完计划")
|
||||
@ -343,16 +326,7 @@ extension IndexView {
|
||||
if screenBounds.height - frame.minY > 50 && contextFrame.minY > 0 && !isMoreLoading {
|
||||
Task {
|
||||
self.isMoreLoading = true
|
||||
let result = await self.indexModel.loadMoreUpdateDramas(userId: self.userId, mode: .next)
|
||||
switch result {
|
||||
case .success:
|
||||
()
|
||||
case .error(let message):
|
||||
DispatchQueue.main.async {
|
||||
self.showPrompt = true
|
||||
self.promptMessage = message
|
||||
}
|
||||
}
|
||||
await self.indexModel.loadMoreUpdateDramas(userId: self.userId, mode: .next)
|
||||
self.isMoreLoading = false
|
||||
}
|
||||
}
|
||||
@ -378,21 +352,13 @@ extension IndexView {
|
||||
|
||||
// 上拉刷新功能
|
||||
self.isPrevLoading = true
|
||||
let result = await self.indexModel.loadMoreUpdateDramas(userId: self.userId, mode: .prev)
|
||||
switch result {
|
||||
case .success:
|
||||
()
|
||||
case .error(let message):
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
||||
self.showPrompt = true
|
||||
self.promptMessage = message
|
||||
}
|
||||
}
|
||||
await self.indexModel.loadMoreUpdateDramas(userId: self.userId, mode: .prev)
|
||||
self.isPrevLoading = false
|
||||
}
|
||||
|
||||
}
|
||||
.frame(width: 370)
|
||||
}
|
||||
.ignoresSafeArea(edges: .bottom)
|
||||
.alert(isPresented: $showPrompt) {
|
||||
Alert(title: Text("提示"), message: Text(self.promptMessage), dismissButton: .default(Text("OK")))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user