ios: fix some bugs

This commit is contained in:
Emin 2025-01-01 20:43:00 +05:00
parent eb14807513
commit 549ca85c43
2 changed files with 46 additions and 48 deletions

View file

@ -7,7 +7,7 @@ struct LoadImageView: View {
@State var isError = false
var body: some View {
if let urlString = url {
if let urlString = url, urlString != "" {
ZStack(alignment: .center) {
WebImage(url: URL(string: urlString))
.onSuccess(perform: { Image, data, cache in

View file

@ -45,57 +45,55 @@ struct Place: View {
var body: some View {
ZStack() {
LoadImageView(url: place.cover)
VStack {
Spacer()
HStack() {
VStack(alignment: .leading) {
Text(place.name)
.font(.semiBold(size: 15))
.foregroundColor(.white)
.lineLimit(2)
VerticalSpace(height: 4)
HStack(alignment: .center) {
Text(String(format: "%.1f", place.rating ?? 0.0))
.font(.semiBold(size: 15))
.foregroundColor(.white)
Image(systemName: "star.fill")
.resizable()
.foregroundColor(Color.starYellow)
.frame(width: 10, height: 10)
}
}
.padding(12)
Spacer()
}
.frame(width: width)
.background(SwiftUI.Color.black.opacity(0.5))
}
HStack {
Spacer()
VStack {
Button(action: {
onFavoriteChanged(!isFavorite)
}) {
Image(systemName: isFavorite ? "heart.fill" : "heart")
.foregroundColor(.white)
.padding(12)
.background(SwiftUI.Color.white.opacity(0.2))
.clipShape(Circle())
}
Spacer()
}
}
.padding(12)
// cover
LoadImageView(url: place.cover)
.frame(width: width, height: height)
}
.overlay(
// title and rating
HStack() {
VStack(alignment: .leading) {
Text(place.name)
.font(.semiBold(size: 15))
.foregroundColor(.white)
.lineLimit(2)
VerticalSpace(height: 4)
HStack(alignment: .center) {
Text(String(format: "%.1f", place.rating ?? 0.0))
.font(.semiBold(size: 15))
.foregroundColor(.white)
Image(systemName: "star.fill")
.resizable()
.foregroundColor(Color.starYellow)
.frame(width: 10, height: 10)
}
}
.padding(12)
Spacer()
}
.frame(width: width)
.background(SwiftUI.Color.black.opacity(0.5)),
alignment: .bottom
)
.overlay(
// favorite button
Button(action: {
onFavoriteChanged(!isFavorite)
}) {
Image(systemName: isFavorite ? "heart.fill" : "heart")
.foregroundColor(.white)
.padding(12)
.background(SwiftUI.Color.white.opacity(0.2))
.clipShape(Circle())
}
.padding(12),
alignment: .topTrailing
)
.frame(width: width, height: height)
.clipShape(RoundedRectangle(cornerRadius: 16))
.contentShape(Rectangle()) // Add this line
.contentShape(Rectangle())
.onTapGesture(perform: onPlaceClick)
}
}