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)
|
self.config = DisplayConfig(name: "前排占位", bgColor: .black, fontColor: .white)
|
||||||
case "following":
|
case "following":
|
||||||
self.status = rawValue
|
self.status = rawValue
|
||||||
self.config = DisplayConfig(name: "追番", bgColor: .black, fontColor: .white)
|
self.config = DisplayConfig(name: "♡ 追番", bgColor: .black, fontColor: .white)
|
||||||
case "catching_up":
|
case "catching_up":
|
||||||
self.status = rawValue
|
self.status = rawValue
|
||||||
self.config = DisplayConfig(name: "补番", bgColor: .black, fontColor: .white)
|
self.config = DisplayConfig(name: "补番", bgColor: .black, fontColor: .white)
|
||||||
|
|||||||
@ -78,6 +78,7 @@ final class FavorModel {
|
|||||||
|
|
||||||
struct FavorView: View {
|
struct FavorView: View {
|
||||||
@AppStorage("userId") private var userId: String = Utils.defaultUserId()
|
@AppStorage("userId") private var userId: String = Utils.defaultUserId()
|
||||||
|
@Environment(\.dismiss) private var dismiss
|
||||||
|
|
||||||
@State var favorModel = FavorModel()
|
@State var favorModel = FavorModel()
|
||||||
@State var isMoreLoading: Bool = false
|
@State var isMoreLoading: Bool = false
|
||||||
@ -87,68 +88,63 @@ struct FavorView: View {
|
|||||||
|
|
||||||
HStack(alignment: .center) {
|
HStack(alignment: .center) {
|
||||||
Color.clear
|
Color.clear
|
||||||
.overlay {
|
.overlay(alignment: .leading) {
|
||||||
HStack(alignment: .center) {
|
Text("< 番剧补完计划")
|
||||||
Text("亚次元")
|
.font(.system(size: 16))
|
||||||
.font(.system(size: 16))
|
.foregroundColor(Color(hex: "#999999"))
|
||||||
.padding([.top, .bottom], 5)
|
.padding([.top, .bottom], 5)
|
||||||
Spacer()
|
.padding([.leading], 15)
|
||||||
|
.onTapGesture {
|
||||||
HStack {
|
dismiss()
|
||||||
Text("♡ 12")
|
|
||||||
.font(.system(size: 16))
|
|
||||||
.padding([.top, .bottom], 5)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
.padding([.leading, .trailing], 15)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.frame(height: 50)
|
.frame(height: 50)
|
||||||
.background(Color(hex: "#F2F2F2"), ignoresSafeAreaEdges: .top)
|
.background(Color(hex: "#F2F2F2"), ignoresSafeAreaEdges: .top)
|
||||||
|
|
||||||
VStack(alignment: .center) {
|
if favorModel.dramas.count > 0 {
|
||||||
|
VStack(alignment: .center) {
|
||||||
|
ScrollView(.vertical, showsIndicators: false) {
|
||||||
|
ForEach(favorModel.dramas, id: \.id) { drama in
|
||||||
|
DramaCellView(dramaItem: drama)
|
||||||
|
}
|
||||||
|
|
||||||
ScrollView(.vertical, showsIndicators: false) {
|
Rectangle()
|
||||||
HStack(alignment: .center) {
|
.frame(height: 0)
|
||||||
Spacer()
|
.background(GeometryReader {
|
||||||
Text("番剧补完计划")
|
geometry in
|
||||||
.font(.system(size: 24))
|
Color.clear.onChange(of: geometry.frame(in: .global).minY) {_, offset in
|
||||||
.foregroundColor(Color(hex: "#999999"))
|
|
||||||
}
|
|
||||||
|
|
||||||
ForEach(favorModel.dramas, id: \.id) { drama in
|
let frame = geometry.frame(in: .global)
|
||||||
DramaCellView(dramaItem: drama)
|
let screenBounds = UIScreen.main.bounds
|
||||||
}
|
let contextFrame = geometry.frame(in: .named("indexScrollView"))
|
||||||
|
|
||||||
Rectangle()
|
if screenBounds.height - frame.minY > 50 && contextFrame.minY > 0 && !isMoreLoading {
|
||||||
.frame(height: 0)
|
Task {
|
||||||
.background(GeometryReader {
|
self.isMoreLoading = true
|
||||||
geometry in
|
await self.favorModel.loadMoreFavorDramas(userId: userId)
|
||||||
Color.clear.onChange(of: geometry.frame(in: .global).minY) {_, offset in
|
self.isMoreLoading = false
|
||||||
|
}
|
||||||
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 {
|
if self.isMoreLoading {
|
||||||
ProgressView()
|
ProgressView()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
.coordinateSpace(name: "indexScrollView")
|
||||||
|
}
|
||||||
|
.frame(width: 370)
|
||||||
|
} else {
|
||||||
|
VStack {
|
||||||
|
Text("你还没有")
|
||||||
|
Spacer()
|
||||||
}
|
}
|
||||||
.coordinateSpace(name: "indexScrollView")
|
|
||||||
}
|
}
|
||||||
.frame(width: 370)
|
|
||||||
}
|
}
|
||||||
.ignoresSafeArea(edges: .bottom)
|
.ignoresSafeArea(edges: .bottom)
|
||||||
|
.navigationBarBackButtonHidden()
|
||||||
.task {
|
.task {
|
||||||
await self.favorModel.loadData(userId: self.userId)
|
await self.favorModel.loadData(userId: self.userId)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,10 +47,8 @@ final class IndexModel {
|
|||||||
|
|
||||||
struct IndexResponse: Codable {
|
struct IndexResponse: Codable {
|
||||||
let update_dramas: [UpdateDramaGroup]
|
let update_dramas: [UpdateDramaGroup]
|
||||||
let dramas: [DramaItem]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var dramas: [DramaItem]
|
|
||||||
var selectedDate: String
|
var selectedDate: String
|
||||||
|
|
||||||
// 保存原始的更新数据
|
// 保存原始的更新数据
|
||||||
@ -60,7 +58,6 @@ final class IndexModel {
|
|||||||
private var isLoaded = false
|
private var isLoaded = false
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
self.dramas = []
|
|
||||||
self.selectedDate = ""
|
self.selectedDate = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +72,6 @@ final class IndexModel {
|
|||||||
case .error(let code, let message):
|
case .error(let code, let message):
|
||||||
print("index load data get error_code: \(code), message: \(message)")
|
print("index load data get error_code: \(code), message: \(message)")
|
||||||
case .result(let result):
|
case .result(let result):
|
||||||
self.dramas = result.dramas
|
|
||||||
self.updateDramaGroups = result.update_dramas
|
self.updateDramaGroups = result.update_dramas
|
||||||
}
|
}
|
||||||
self.isLoaded = true
|
self.isLoaded = true
|
||||||
@ -320,10 +316,6 @@ extension IndexView {
|
|||||||
.foregroundColor(Color(hex: "#999999"))
|
.foregroundColor(Color(hex: "#999999"))
|
||||||
}
|
}
|
||||||
|
|
||||||
ForEach(indexModel.dramas, id: \.id) { drama in
|
|
||||||
DramaCellView(dramaItem: drama)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 基于日期的更新列表
|
// 基于日期的更新列表
|
||||||
VStack(alignment: .center, spacing: 10) {
|
VStack(alignment: .center, spacing: 10) {
|
||||||
ForEach(indexModel.updateDramaGroups, id: \.group_id) { group in
|
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 {
|
struct DramaGroupView: View {
|
||||||
let group: IndexModel.UpdateDramaGroup
|
let group: IndexModel.UpdateDramaGroup
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user