fix index color

This commit is contained in:
anlicheng 2025-02-22 23:20:55 +08:00
parent 8d2d972ac6
commit c44067db1b
2 changed files with 55 additions and 12 deletions

View File

@ -0,0 +1,28 @@
//
// ColorExtension.swift
// dimensionhub
//
// Created by on 2025/2/22.
//
import SwiftUI
extension Color {
init(hex: String, opacity: Double = 1) {
let hex = hex.trimmingCharacters(in: CharacterSet.alphanumerics.inverted)
let characters = Array(hex)
let r = Int(String(characters[0..<2]), radix: 16)!
let g = Int(String(characters[2..<4]), radix: 16)!
let b = Int(String(characters[4..<6]), radix: 16)!
self.init(
.sRGB,
red: Double(r) / 255,
green: Double(g) / 255,
blue: Double(b) / 255,
opacity: opacity
)
}
}

View File

@ -138,13 +138,13 @@ struct IndexView: View {
} }
} }
.frame(height: 50) .frame(height: 50)
.background(Color.yellow) .background(Color(hex: "#F2F2F2"), ignoresSafeAreaEdges: .bottom)
.border(Color.red)
HStack(alignment: .center) { HStack(alignment: .center) {
Spacer() Spacer()
Text("番剧补完计划") Text("番剧补完计划")
.font(.system(size: 24)) .font(.system(size: 24))
.foregroundColor(Color(hex: "#999999"))
} }
ForEach(indexModel.dramas, id: \.id) { drama in ForEach(indexModel.dramas, id: \.id) { drama in
@ -154,14 +154,14 @@ struct IndexView: View {
// //
ScrollView(.vertical, showsIndicators: false) { ScrollView(.vertical, showsIndicators: false) {
VStack(alignment: .center, spacing: 20) { VStack(alignment: .center, spacing: 10) {
ForEach(indexModel.showUpdateDramas, id: \.id) { drama in ForEach(indexModel.showUpdateDramas, id: \.id) { drama in
switch drama.element { switch drama.element {
case .group(let group): case .group(let group):
HStack { HStack {
Spacer() Spacer()
Text(group.groupName) Text(group.groupName)
.font(.system(size: 30)) .font(.system(size: 18))
.fontWeight(.regular) .fontWeight(.regular)
.onTapGesture { .onTapGesture {
selectGroupId = group.groupId selectGroupId = group.groupId
@ -179,20 +179,22 @@ struct IndexView: View {
.frame(width: 370, height: 180) .frame(width: 370, height: 180)
.overlay { .overlay {
HStack { HStack {
VStack(alignment: .leading, spacing: 10) { VStack(alignment: .leading, spacing: 8) {
Text(item.name) Text(item.name)
.font(.system(size: 24)) .font(.system(size: 16))
.foregroundColor(Color(hex: "#333333"))
.lineLimit(1) .lineLimit(1)
Text(item.desc) Text(item.desc)
.font(.system(size: 12))
.foregroundColor(Color(hex: "#333333"))
.lineLimit(1) .lineLimit(1)
Spacer() Spacer()
} }
Spacer() Spacer()
} }
.padding([.top, .leading], 15) .padding([.top, .leading], 10)
.border(Color.red)
} }
} }
} }
@ -230,7 +232,7 @@ struct IndexView: View {
} }
} }
.frame(width: 370) .frame(width: 370)
.edgesIgnoringSafeArea(.bottom) .ignoresSafeArea(edges: .bottom)
.task { .task {
await self.indexModel.loadData() await self.indexModel.loadData()
} }
@ -265,6 +267,7 @@ extension IndexView {
NavigationLink(destination: DetailView()) { NavigationLink(destination: DetailView()) {
Text(dramaItem.title) Text(dramaItem.title)
.font(.system(size: 20)) .font(.system(size: 20))
.foregroundColor(Color(hex: "#333333"))
} }
ScrollView(.horizontal, showsIndicators: false) { ScrollView(.horizontal, showsIndicators: false) {
@ -279,14 +282,26 @@ extension IndexView {
} }
.frame(width: geometry.frame(in: .local).width, height: 80) .frame(width: geometry.frame(in: .local).width, height: 80)
.overlay { .overlay {
VStack {
HStack(alignment: .center) {
Text(item.numName) Text(item.numName)
.font(.system(size: 12))
.foregroundColor(Color(hex: "#333333"))
Spacer()
}
Spacer()
}
.padding([.top, .leading], 5)
} }
} }
Text(item.name) Text(item.name)
.font(.system(size: 12))
.foregroundColor(Color(hex: "#333333"))
.lineLimit(1) .lineLimit(1)
} }
.frame(width: 120, height: 120) .frame(width: 120, height: 100)
} }
} }
} }