fix
This commit is contained in:
parent
d8dae2fa3c
commit
605062c7a8
@ -54,7 +54,7 @@ final class DetailModel {
|
||||
self.config = DisplayConfig(name: "前排占位", bgColor: .black, fontColor: .white)
|
||||
case "following":
|
||||
self.status = rawValue
|
||||
self.config = DisplayConfig(name: "追番", bgColor: .black, fontColor: .white)
|
||||
self.config = DisplayConfig(name: "♡ 追番", bgColor: .black, fontColor: .white)
|
||||
case "catching_up":
|
||||
self.status = rawValue
|
||||
self.config = DisplayConfig(name: "补番", bgColor: .black, fontColor: .white)
|
||||
|
||||
@ -78,6 +78,7 @@ final class FavorModel {
|
||||
|
||||
struct FavorView: View {
|
||||
@AppStorage("userId") private var userId: String = Utils.defaultUserId()
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
@State var favorModel = FavorModel()
|
||||
@State var isMoreLoading: Bool = false
|
||||
@ -87,68 +88,63 @@ struct FavorView: View {
|
||||
|
||||
HStack(alignment: .center) {
|
||||
Color.clear
|
||||
.overlay {
|
||||
HStack(alignment: .center) {
|
||||
Text("亚次元")
|
||||
.font(.system(size: 16))
|
||||
.padding([.top, .bottom], 5)
|
||||
Spacer()
|
||||
|
||||
HStack {
|
||||
Text("♡ 12")
|
||||
.font(.system(size: 16))
|
||||
.padding([.top, .bottom], 5)
|
||||
.overlay(alignment: .leading) {
|
||||
Text("< 番剧补完计划")
|
||||
.font(.system(size: 16))
|
||||
.foregroundColor(Color(hex: "#999999"))
|
||||
.padding([.top, .bottom], 5)
|
||||
.padding([.leading], 15)
|
||||
.onTapGesture {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
.padding([.leading, .trailing], 15)
|
||||
}
|
||||
}
|
||||
.frame(height: 50)
|
||||
.background(Color(hex: "#F2F2F2"), ignoresSafeAreaEdges: .top)
|
||||
|
||||
VStack(alignment: .center) {
|
||||
|
||||
ScrollView(.vertical, showsIndicators: false) {
|
||||
HStack(alignment: .center) {
|
||||
Spacer()
|
||||
Text("番剧补完计划")
|
||||
.font(.system(size: 24))
|
||||
.foregroundColor(Color(hex: "#999999"))
|
||||
}
|
||||
|
||||
ForEach(favorModel.dramas, id: \.id) { drama in
|
||||
DramaCellView(dramaItem: drama)
|
||||
}
|
||||
|
||||
Rectangle()
|
||||
.frame(height: 0)
|
||||
.background(GeometryReader {
|
||||
geometry in
|
||||
Color.clear.onChange(of: geometry.frame(in: .global).minY) {_, offset in
|
||||
|
||||
let frame = geometry.frame(in: .global)
|
||||
let screenBounds = UIScreen.main.bounds
|
||||
let contextFrame = geometry.frame(in: .named("indexScrollView"))
|
||||
|
||||
if screenBounds.height - frame.minY > 50 && contextFrame.minY > 0 && !isMoreLoading {
|
||||
Task {
|
||||
self.isMoreLoading = true
|
||||
await self.favorModel.loadMoreFavorDramas(userId: userId)
|
||||
self.isMoreLoading = false
|
||||
if favorModel.dramas.count > 0 {
|
||||
VStack(alignment: .center) {
|
||||
ScrollView(.vertical, showsIndicators: false) {
|
||||
ForEach(favorModel.dramas, id: \.id) { drama in
|
||||
DramaCellView(dramaItem: drama)
|
||||
}
|
||||
|
||||
Rectangle()
|
||||
.frame(height: 0)
|
||||
.background(GeometryReader {
|
||||
geometry in
|
||||
Color.clear.onChange(of: geometry.frame(in: .global).minY) {_, offset in
|
||||
|
||||
let frame = geometry.frame(in: .global)
|
||||
let screenBounds = UIScreen.main.bounds
|
||||
let contextFrame = geometry.frame(in: .named("indexScrollView"))
|
||||
|
||||
if screenBounds.height - frame.minY > 50 && contextFrame.minY > 0 && !isMoreLoading {
|
||||
Task {
|
||||
self.isMoreLoading = true
|
||||
await self.favorModel.loadMoreFavorDramas(userId: userId)
|
||||
self.isMoreLoading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if self.isMoreLoading {
|
||||
ProgressView()
|
||||
})
|
||||
|
||||
if self.isMoreLoading {
|
||||
ProgressView()
|
||||
}
|
||||
}
|
||||
.coordinateSpace(name: "indexScrollView")
|
||||
}
|
||||
.frame(width: 370)
|
||||
} else {
|
||||
VStack {
|
||||
Text("你还没有")
|
||||
Spacer()
|
||||
}
|
||||
.coordinateSpace(name: "indexScrollView")
|
||||
}
|
||||
.frame(width: 370)
|
||||
}
|
||||
.ignoresSafeArea(edges: .bottom)
|
||||
.navigationBarBackButtonHidden()
|
||||
.task {
|
||||
await self.favorModel.loadData(userId: self.userId)
|
||||
}
|
||||
|
||||
@ -47,10 +47,8 @@ final class IndexModel {
|
||||
|
||||
struct IndexResponse: Codable {
|
||||
let update_dramas: [UpdateDramaGroup]
|
||||
let dramas: [DramaItem]
|
||||
}
|
||||
|
||||
var dramas: [DramaItem]
|
||||
var selectedDate: String
|
||||
|
||||
// 保存原始的更新数据
|
||||
@ -60,7 +58,6 @@ final class IndexModel {
|
||||
private var isLoaded = false
|
||||
|
||||
init() {
|
||||
self.dramas = []
|
||||
self.selectedDate = ""
|
||||
}
|
||||
|
||||
@ -75,7 +72,6 @@ final class IndexModel {
|
||||
case .error(let code, let message):
|
||||
print("index load data get error_code: \(code), message: \(message)")
|
||||
case .result(let result):
|
||||
self.dramas = result.dramas
|
||||
self.updateDramaGroups = result.update_dramas
|
||||
}
|
||||
self.isLoaded = true
|
||||
@ -320,10 +316,6 @@ extension IndexView {
|
||||
.foregroundColor(Color(hex: "#999999"))
|
||||
}
|
||||
|
||||
ForEach(indexModel.dramas, id: \.id) { drama in
|
||||
DramaCellView(dramaItem: drama)
|
||||
}
|
||||
|
||||
// 基于日期的更新列表
|
||||
VStack(alignment: .center, spacing: 10) {
|
||||
ForEach(indexModel.updateDramaGroups, id: \.group_id) { group in
|
||||
@ -391,82 +383,6 @@ extension IndexView {
|
||||
}
|
||||
}
|
||||
|
||||
// 显示剧集的列表信息
|
||||
struct DramaCellView: View {
|
||||
let dramaItem: IndexModel.DramaItem
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
|
||||
NavigationLink(destination: DetailView(id: dramaItem.id)) {
|
||||
Text(dramaItem.title)
|
||||
.font(.system(size: 20))
|
||||
.foregroundColor(Color(hex: "#333333"))
|
||||
}
|
||||
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
LazyHStack(alignment: .center, spacing: 5) {
|
||||
ForEach(dramaItem.episodes) { item in
|
||||
VStack(alignment: .center) {
|
||||
GeometryReader { geometry in
|
||||
|
||||
AsyncImage(url: URL(string: item.thumb)) { phase in
|
||||
switch phase {
|
||||
case .empty:
|
||||
ProgressView()
|
||||
case .success(let image):
|
||||
image
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: geometry.frame(in: .local).width, height: 80)
|
||||
.clipped()
|
||||
default:
|
||||
Image("ph_img_medium")
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: geometry.frame(in: .local).width, height: 80)
|
||||
.clipped()
|
||||
}
|
||||
}
|
||||
.frame(width: geometry.frame(in: .local).width, height: 80)
|
||||
.overlay(alignment: .topLeading) {
|
||||
if !item.num_name.isEmpty {
|
||||
HStack(alignment: .center) {
|
||||
Text(item.num_name)
|
||||
.font(.system(size: 12))
|
||||
.foregroundColor(.white)
|
||||
.lineLimit(1)
|
||||
}
|
||||
.padding(3)
|
||||
.background(
|
||||
Color.black.opacity(0.6)
|
||||
)
|
||||
.cornerRadius(3)
|
||||
.padding(3)
|
||||
} else {
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text(item.name)
|
||||
.font(.system(size: 12))
|
||||
.foregroundColor(Color(hex: "#333333"))
|
||||
.lineLimit(1)
|
||||
}
|
||||
.frame(width: 120, height: 100)
|
||||
.onTapGesture {
|
||||
if let playUrl = URL(string: item.play) {
|
||||
UIApplication.shared.open(playUrl)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 显示分组信息
|
||||
struct DramaGroupView: View {
|
||||
let group: IndexModel.UpdateDramaGroup
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user