copinism-ios/copinism/Views/ArticleDetail/ArticleDetailView.swift
2024-06-04 09:41:01 +08:00

235 lines
8.0 KiB
Swift

import SwiftUI
import Kingfisher
struct ArticleDetailView: View {
@State var contentText = "" //
@State var dragValues = 0 //
@Binding var isShowArticleDetail: Bool //
// @EnvironmentObject var myCardDatas: CardDataModel //
var data: CardData = .init(id: 1, name: "标题1" , image: URL(string: "avatar")!,total: 1)
var body: some View {
// NavigationStack {
VStack {
//
HStack {
Button {
// withAnimation {
isShowArticleDetail.toggle()
// }
} label: {
Image(systemName: "chevron.backward")
.foregroundStyle(.black)
}
KFImage(data.image)
.resizable()
.placeholder {
ProgressView()
}
.frame(width: 50, height: 50)
// .resizable()
// .aspectRatio(contentMode: .fit)
// .frame(width: UIScreen.main.bounds.width)
// Image(data.image)
// .CircleImage(size: 25)
Text(data.name)
Spacer()
Button {} label: {
Text("关注")
.SetTextStyle(size: 13, color: .red)
.padding(.vertical, 8)
.padding(.horizontal, 12)
.background(.white)
.padding(1)
.background(.red, in: RoundedRectangle(cornerRadius: 15))
}
Button {} label: {
Image(systemName: "square.and.arrow.up")
.foregroundStyle(.black)
}
}
.padding(.horizontal, 12)
.padding(.vertical, 8)
.background(.white)
//
ScrollView {
//
Image("image-1")
.resizable()
.resizable()
.frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.width)
.aspectRatio(contentMode: .fill)
.clipped()
// .matchedGeometryEffect(id: "articleBanner", in: namespace)
//
VStack(alignment: .leading) {
//
HStack {
Text(data.name)
.font(.title2)
.bold()
}
.padding(.top, 4)
//
HStack {
Text(data.name)
.SetTextStyle(size: 16, color: .black.opacity(0.8))
}
.padding(.top, 4)
//
HStack {
Button {} label: {
Text("#蓝天")
}
Button {} label: {
Text("#摄影")
}
Button {} label: {
Text("#春天")
}
}
.padding(.top, 4)
//
Text("02:12 浙江")
.SetTextStyle(size: 13, color: .gray)
.padding(.top, 6)
// 线
Divider()
//
Text("共12条评论")
.SetTextStyle(size: 16, color: .black.opacity(0.7))
.padding(.top, 4)
//
HStack {
Image("avatar")
.CircleImage(size: 30)
Button {} label: {
Text("让大家听到你的声音")
.padding(.horizontal, 15)
.padding(.vertical, 6)
.multilineTextAlignment(.leading)
.frame(width: 300)
.background(.gray.opacity(0.1), in: RoundedRectangle(cornerRadius: 18))
.foregroundStyle(.gray)
.font(.system(size: 14))
}
}
//
VStack {
ForEach(0 ..< 12) { index in
HStack {
Image("avatar")
.CircleImage(size: 30)
VStack(alignment: .leading) {
//
HStack {
Text("用户名\(index)")
.SetTextStyle(size: 13, color: .gray)
Spacer()
Image(systemName: "heart")
}
//
HStack {
Text("评论内容\(index)")
.SetTextStyle(size: 16, color: .black.opacity(0.8))
Text("3天前 浙江")
.SetTextStyle(size: 12, color: .black.opacity(0.6))
}
}
}
}
}
.padding(.top, 8)
}
.padding(.horizontal, 8)
}
//
HStack {
Button {} label: {
HStack {
Image(systemName: "pencil")
.foregroundStyle(.gray)
.font(.system(size: 15))
Text("说点什么...")
.SetTextStyle(size: 15, color: .gray)
}
.padding(.vertical, 6)
.padding(.horizontal, 22)
.background(.gray.opacity(0.1), in: RoundedRectangle(cornerRadius: 20))
}
.foregroundStyle(.black)
Spacer()
HStack {
HStack {
Button {} label: {
Image(systemName: "heart")
Text("61")
}
}
HStack {
Button {} label: {
Image(systemName: "star")
Text("12")
}
}
HStack {
Button {} label: {
Image(systemName: "message")
Text("评论")
}
}
}
.foregroundStyle(.black)
.font(.system(size: 15))
}
.padding(.horizontal, 14)
.padding(.top, 2)
}
.background(.white)
//
.onAppear {
print("页面显示了")
}
.gesture(
DragGesture()
.onChanged { dragValue in
dragValues = Int(dragValue.location.x)
if dragValues > 100 {
print("123")
}
}
)
// }
// .toolbar(.hidden)
}
}
#Preview {
ArticleDetailView(isShowArticleDetail: .constant(false))
}