fix detail

This commit is contained in:
anlicheng 2025-02-22 23:50:11 +08:00
parent c44067db1b
commit 676885375c

View File

@ -82,37 +82,57 @@ struct DetailView: View {
var body: some View { var body: some View {
VStack(alignment: .center) { VStack(alignment: .center) {
VStack(alignment: .leading, spacing: 20) { VStack(alignment: .leading, spacing: 10) {
Text(detailModel.name) Text(detailModel.name)
.font(.system(size: 30)) .font(.system(size: 28))
.fontWeight(.bold) .fontWeight(.bold)
.foregroundColor(Color(hex: "#333333"))
HStack(alignment: .center, spacing: 0) { HStack(alignment: .center, spacing: 0) {
ForEach(Array(detailModel.voiceActors.enumerated()), id: \.offset) { index, actor in ForEach(Array(detailModel.voiceActors.enumerated()), id: \.offset) { index, actor in
if index > 0 { if index > 0 {
Text("") Text("")
.font(.system(size: 13))
.foregroundColor(Color(hex: "#999999"))
} }
Text(actor.name) Text(actor.name)
.font(.system(size: 16)) .font(.system(size: 13))
.foregroundColor(Color(hex: "#999999"))
} }
Text("") Text("")
.font(.system(size: 13))
.foregroundColor(Color(hex: "#999999"))
Spacer() Spacer()
} }
} }
.background(Color.yellow) .padding([.top, .leading], 10)
.background(Color(hex: "#F2F2F2"), ignoresSafeAreaEdges: [.bottom])
HStack { HStack {
Spacer() Spacer()
switch detailModel.status { switch detailModel.status {
case 0: case 0:
Text("补完") FollowButtonView(title: "补完", bgColor: .black, fontColor: .white) {
}
case 1: case 1:
Text("追番") FollowButtonView(title: "追番", bgColor: .black, fontColor: .white) {
}
case 2: case 2:
Text("前排站位") FollowButtonView(title: "前排站位", bgColor: .black, fontColor: .white) {
}
case 3:
FollowButtonView(title: "弃番", bgColor: .black, fontColor: .white) {
}
default: default:
Text("追番") FollowButtonView(title: "追番", bgColor: .white, fontColor: Color(hex: "#333333")) {
}
} }
} }
@ -120,14 +140,15 @@ struct DetailView: View {
HStack(alignment: .center, spacing: 15) { HStack(alignment: .center, spacing: 15) {
ForEach(Array(detailModel.channels.enumerated()), id: \.offset) { idx, channel in ForEach(Array(detailModel.channels.enumerated()), id: \.offset) { idx, channel in
Text(channel.name) Text(channel.name)
.font(.system(size: 16)) .font(.system(size: 13))
.foregroundColor(idx == detailModel.selectedChannelIdx ? .blue : .black) .foregroundColor(idx == detailModel.selectedChannelIdx ? Color(hex: "#169BD5") : Color(hex: "#666666"))
.onTapGesture { .onTapGesture {
detailModel.toggleChannel(channelIdx: idx) detailModel.toggleChannel(channelIdx: idx)
} }
} }
Spacer() Spacer()
} }
.padding(.leading, 10)
// //
ScrollView(.horizontal, showsIndicators: false) { ScrollView(.horizontal, showsIndicators: false) {
@ -141,10 +162,21 @@ struct DetailView: View {
} }
.frame(width: 90, height: 70) .frame(width: 90, height: 70)
.overlay { .overlay {
VStack {
HStack {
Text(episode.numName) Text(episode.numName)
.font(.system(size: 12))
.foregroundColor(Color(hex: "#333333"))
Spacer()
}
Spacer()
}
.padding([.top, .leading], 8)
} }
Text(episode.name) Text(episode.name)
.font(.system(size: 12))
.foregroundColor(Color(hex: "#333333"))
.lineLimit(1) .lineLimit(1)
} }
.frame(width: 90, height: 120) .frame(width: 90, height: 120)
@ -155,20 +187,23 @@ struct DetailView: View {
HStack(alignment: .center) { HStack(alignment: .center) {
NavigationLink(destination: ListView()) { NavigationLink(destination: ListView()) {
Rectangle() Rectangle()
.frame(width: 180, height: 50) .frame(width: 200, height: 25)
.foregroundColor(Color.yellow) .foregroundColor(Color(hex: "#F2F2F2"))
.cornerRadius(10) //.cornerRadius(5)
.overlay { .overlay {
RoundedRectangle(cornerRadius: 10) // RoundedRectangle(cornerRadius: 5)
.stroke(Color.black, lineWidth: 1) // .stroke(Color.black, lineWidth: 1)
Text("展开全部剧集") Text("展开全部剧集")
.font(.system(size: 13))
.foregroundColor(Color(hex: "#999999"))
.fontWeight(.regular)
} }
} }
} }
Spacer() Spacer()
} }
.border(Color.red)
.frame(width: 370, alignment: .center) .frame(width: 370, alignment: .center)
.task { .task {
await detailModel.loadData(dramaId: 124) await detailModel.loadData(dramaId: 124)
@ -178,6 +213,36 @@ struct DetailView: View {
} }
extension DetailView {
struct FollowButtonView: View {
let title: String
let bgColor: Color
let fontColor: Color
let onTap: () -> Void
var body: some View {
Rectangle()
.frame(width: 140, height: 40)
.foregroundColor(bgColor)
.cornerRadius(5)
.overlay {
RoundedRectangle(cornerRadius: 5)
.stroke(Color.black, lineWidth: 1)
Text(title)
.font(.system(size: 13))
.foregroundColor(fontColor)
.fontWeight(.regular)
}
.onTapGesture {
onTap()
}
}
}
}
#Preview { #Preview {
DetailView() DetailView()
} }