This commit is contained in:
anlicheng 2025-02-22 00:59:12 +08:00
parent 35a85b2a8a
commit b1a2a13789
4 changed files with 56 additions and 42 deletions

View File

@ -153,9 +153,7 @@ struct DetailView: View {
}
HStack(alignment: .center) {
Button {
print("click me")
} label: {
NavigationLink(destination: ListView()) {
Rectangle()
.frame(width: 180, height: 50)
.foregroundColor(Color.yellow)
@ -166,7 +164,6 @@ struct DetailView: View {
Text("展开全部剧集")
}
}
}
Spacer()

View File

@ -128,14 +128,18 @@ struct IndexView: View {
var body: some View {
VStack(alignment: .center) {
HStack(alignment: .center) {
Spacer()
Text("亚次元")
.padding(.top, 5)
.padding(.bottom, 5)
Spacer()
Color.clear
.overlay {
Text("亚次元")
.font(.system(size: 16))
.padding([.top, .bottom], 5)
}
}
.background(Color.red)
.frame(height: 50)
.background(Color.yellow)
.border(Color.red)
HStack(alignment: .center) {
Spacer()
@ -150,36 +154,38 @@ struct IndexView: View {
//
ScrollView(.vertical, showsIndicators: false) {
LazyVStack {
VStack(alignment: .center, spacing: 20) {
ForEach(indexModel.showUpdateDramas, id: \.id) { drama in
switch drama.element {
case .group(let group):
Text(group.groupName)
.onTapGesture {
selectGroupId = group.groupId
print("current group_id: \(self.selectGroupId)")
indexModel.selectedDate = group.groupId
showDateNavPopover = true
}
case .item(let item):
VStack(alignment: .center) {
AsyncImage(url: URL(string: item.thumb)) { image in
image.resizable()
} placeholder: {
ProgressView()
}
.frame(width: 80, height: 80)
.overlay {
VStack(alignment: .leading) {
Text(item.name)
.lineLimit(1)
Text(item.desc)
.lineLimit(1)
HStack {
Spacer()
Text(group.groupName)
.font(.system(size: 30))
.fontWeight(.regular)
.onTapGesture {
selectGroupId = group.groupId
print("current group_id: \(self.selectGroupId)")
indexModel.selectedDate = group.groupId
showDateNavPopover = true
}
}
case .item(let item):
AsyncImage(url: URL(string: item.thumb)) { image in
image.resizable()
} placeholder: {
ProgressView()
}
.frame(width: 370, height: 180)
.overlay {
VStack(alignment: .leading) {
Text(item.name)
.lineLimit(1)
Text(item.desc)
.lineLimit(1)
}
}
.frame(width: 100, height: 120)
}
}
}
@ -215,6 +221,8 @@ struct IndexView: View {
}
}
}
.frame(width: 370)
.edgesIgnoringSafeArea(.bottom)
.task {
await self.indexModel.loadData()
}
@ -245,8 +253,11 @@ extension IndexView {
var body: some View {
VStack(alignment: .leading) {
Text(dramaItem.title)
.font(.system(size: 20))
NavigationLink(destination: DetailView()) {
Text(dramaItem.title)
.font(.system(size: 20))
}
ScrollView(.horizontal, showsIndicators: false) {
HStack(alignment: .center, spacing: 10) {

View File

@ -77,6 +77,7 @@ final class ListModel {
}
struct ListView: View {
@Environment(\.presentationMode) var presentationMode
@State var detailModel = DetailModel()
var body: some View {
@ -90,6 +91,10 @@ struct ListView: View {
.fontWeight(.bold)
Text("返回")
.font(.system(size: 14))
.onTapGesture {
self.presentationMode.wrappedValue.dismiss()
}
}
Spacer()
}
@ -135,7 +140,7 @@ struct ListView: View {
HStack(alignment: .center) {
Button {
print("click me")
self.presentationMode.wrappedValue.dismiss()
} label: {
Rectangle()
.frame(width: 180, height: 50)

View File

@ -25,9 +25,10 @@ struct dimensionhubApp: App {
var body: some Scene {
WindowGroup {
//IndexView()
//DetailView()
ListView()
NavigationStack {
IndexView()
}
.navigationViewStyle(.stack)
}
.modelContainer(sharedModelContainer)
}