đ´ Let's Build Twitter with SwiftUI (iOS 15, Xcode 13, Firebase, SwiftUI 3.0)
.background(
NavigationLink(destination: ProfileView(), isActive: $showProfileView, label: {
EmptyView()
})
)
@State
íëĄíźí° ę°ě í ę¸ë§, í´ëš ę°ě ę´ě°°í¨ěźëĄě¨ íšě 롰뼟 ë¤ëšę˛ě´ě
í¸ěŹí ě§ ę˛°ě ę°ëĽimport SwiftUI
struct ExploreView: View {
@State private var showProfileView: Bool = false
@State private var selectedUser: String = "user"
var body: some View {
NavigationView {
ZStack {
VStack {
ScrollView {
LazyVStack {
ForEach(0..<25, id: \.self) { _ in
UserRowView()
.onTapGesture {
showProfileView.toggle()
}
}
}
}
}
.navigationTitle("Explore")
.navigationBarTitleDisplayMode(.inline)
}
.background(
NavigationLink(destination: ProfileView(), isActive: $showProfileView, label: {
EmptyView()
})
)
}
}
}
ForEach
ë´ěěě ë¤ëšę˛ě´ě
ë§íŹ ěŹěŠ ě í´ëŚě íě§ ěě ěíŠěě í´ëš ëˇ°ę° ě´ëě
ëźě´ěŚë기 ë돸ě í ě ě¤ě˛ ë° isActive
í ę¸ë§ě íľí´ ě íí ëˇ°ë§ í¸ěŹëĄ ë기기import SwiftUI
struct UserRowView: View {
var body: some View {
HStack(spacing: 12) {
Circle()
.frame(width: 48, height: 48)
VStack(alignment: .leading, spacing: 4) {
Text("SpiderMan")
.font(.subheadline)
.bold()
.foregroundColor(.black)
Text("Peter Parker")
.font(.subheadline)
.foregroundColor(.gray)
}
Spacer()
}
.padding(.horizontal)
.padding(.vertical, 2)
.background(Color(.systemBackground).opacity(0.001))
}
}