I’m making an attempt to align my components mechanically in SwiftUI. The textual content is barely off from the vertical facet of the circle picture. And the entire aspect appears to be too shrank in direction of center, I wish to stretch it little additional throughout the horizon. I do know solely methods to do it manually by adjusting the values, however it does not appear to be dependable as I’ll have extra information later.
struct ContentView: View {
@StateObject non-public var viewModel = WebViewModel()
@State non-public var urlString = ""
var physique: some View {
VStack {
ScrollView {
ForEach(viewModel.contents) { content material in
HStack(alignment: .high) {
if let urlString = content material.imageThumbnail {
ImageView(urlString: urlString)
.aspectRatio(contentMode: .match)
.body(width: 100, peak: 100)
.clipShape(RoundedRectangle(cornerRadius: 5))
}
VStack(alignment: .main) {
HStack(alignment: .high) {
if let profilePicURLString = content material.userProfilePic {
ImageView(urlString: profilePicURLString)
.body(width: 20, peak: 20)
.clipShape(Circle())
}
}
.body(peak: 20)
if let title = content material.title {
Textual content(title)
.font(.system(dimension: 12))
.foregroundColor(.black)
.lineLimit(4)
.padding(.main, 5) // Regulate padding as wanted
}
}
Spacer()
}
.padding(.horizontal)
}
}
Spacer()
HStack {
TextField("Enter URL", textual content: $urlString)
.textFieldStyle(RoundedBorderTextFieldStyle())
.padding()
Button("Load") {
viewModel.loadPage(urlString: urlString)
}
.padding()
}
.background(Coloration.white)
.cornerRadius(10)
.shadow(radius: 1)
.padding(.backside, 20)
.body(peak: 36)
}
.padding()
}
}