This commit is contained in:
Daniel Arantes Loverde
2026-03-05 11:00:17 -03:00
parent 83882538c2
commit a98089b48d
2 changed files with 107 additions and 56 deletions

View File

@@ -12,11 +12,6 @@ struct OrdersView: View {
var body: some View {
ScrollView(showsIndicators: false) {
VStack(alignment: .leading, spacing: 14) {
Text("Meus Pedidos")
.font(AppTypography.heading1)
.foregroundStyle(AppColors.textPrimary)
.padding(.top, 6)
if isLoading {
ProgressView()
.frame(maxWidth: .infinity)
@@ -75,44 +70,51 @@ struct OrdersView: View {
return VStack(alignment: .leading, spacing: 14) {
HStack(spacing: 12) {
AsyncStoreImage(imageURL: resolvedMediaURL(order.storeLogoURL))
.frame(width: 88, height: 88)
.clipShape(RoundedRectangle(cornerRadius: 24, style: .continuous))
.background(AppColors.brandSoft, in: RoundedRectangle(cornerRadius: 24, style: .continuous))
.frame(width: 80, height: 80)
.clipShape(RoundedRectangle(cornerRadius: 20, style: .continuous))
.background(AppColors.brandSoft, in: RoundedRectangle(cornerRadius: 20, style: .continuous))
VStack(alignment: .leading, spacing: 5) {
Text(order.storeName?.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty == false ? (order.storeName ?? "Pedido") : "Pedido #\(order.shortId ?? order.id)")
.font(AppTypography.heading2)
.foregroundStyle(AppColors.textPrimary)
.lineLimit(1)
HStack(spacing: 6) {
Text(order.storeName?.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty == false ? (order.storeName ?? "Pedido") : "Pedido #\(order.shortId ?? order.id)")
.font(AppTypography.heading2)
.minimumScaleFactor(0.01)
.foregroundStyle(AppColors.textPrimary)
.lineLimit(1)
Spacer()
Text(status.badgeTitle)
.font(AppTypography.caption)
.minimumScaleFactor(0.01)
.foregroundStyle(status.badgeForeground)
.padding(.horizontal, 10)
.padding(.vertical, 6)
.background(status.badgeBackground)
.clipShape(Capsule())
}
HStack(spacing: 6) {
Text(orderMetaText(order))
.font(AppTypography.body)
.minimumScaleFactor(0.01)
.foregroundStyle(AppColors.textMuted)
.lineLimit(1)
if let rating = storeRating(for: order) {
Text("")
.font(AppTypography.body)
.minimumScaleFactor(0.01)
.foregroundStyle(AppColors.textMuted)
Image(systemName: "star.fill")
.font(.system(size: 11, weight: .bold))
.minimumScaleFactor(0.01)
.foregroundStyle(Color(hex: "#7CF02A"))
Text(String(format: "%.1f", rating).replacingOccurrences(of: ".", with: ","))
.font(AppTypography.body)
.minimumScaleFactor(0.01)
.foregroundStyle(AppColors.textMuted)
}
}
}
Spacer(minLength: 0)
Text(status.badgeTitle)
.font(AppTypography.caption)
.foregroundStyle(status.badgeForeground)
.padding(.horizontal, 10)
.padding(.vertical, 6)
.background(status.badgeBackground)
.clipShape(Capsule())
}
Divider()
@@ -121,11 +123,15 @@ struct OrdersView: View {
Button(status.isCanceled ? "Ajuda" : "Ver Detalhes") {
selectedOrderRoute = route
}
.font(AppTypography.heading2)
.font(AppTypography.heading3)
.foregroundStyle(AppColors.textMuted)
.lineLimit(1)
.minimumScaleFactor(0.01)
.frame(maxWidth: .infinity, alignment: .leading)
.buttonStyle(.plain)
.layoutPriority(2)
Spacer(minLength: 12)
Spacer()
Button {
if status.isInProgress {
@@ -142,11 +148,13 @@ struct OrdersView: View {
HStack(spacing: 8) {
Image(systemName: status.isInProgress ? "truck.box.fill" : "arrow.clockwise")
Text(status.isInProgress ? "Acompanhar" : "Pedir Novamente")
.font(AppTypography.heading2)
.font(AppTypography.heading3)
.lineLimit(1)
}
.lineLimit(1)
.foregroundStyle(status.actionForeground)
.padding(.horizontal, 24)
.padding(.vertical, 12)
.padding(.horizontal, 16)
.padding(.vertical, 11)
.background(status.actionBackground)
.clipShape(Capsule())
}
@@ -167,18 +175,31 @@ struct OrdersView: View {
}
private func orderVisualStatus(for order: AppOrderSummary) -> OrderRowStatusStyle {
let explicitLabel = (order.statusLabel ?? "").trimmingCharacters(in: .whitespacesAndNewlines)
if explicitLabel.isEmpty == false {
let normalizedLabel = explicitLabel.uppercased()
if normalizedLabel.contains("CANCEL") { return .canceled }
if normalizedLabel.contains("ENTREG") || normalizedLabel.contains("COMPLET") { return .delivered }
}
let rawDetailed = (order.statusDetailed ?? "").trimmingCharacters(in: .whitespacesAndNewlines).uppercased()
let rawStatus = (order.status ?? "").trimmingCharacters(in: .whitespacesAndNewlines).uppercased()
let normalized = ((order.statusDetailed ?? order.status) ?? "").uppercased()
if normalized.contains("CANCEL") {
let technical = [rawDetailed, rawStatus].joined(separator: "|")
if technical.contains("CANCEL") || technical.contains("REFUND") {
return .canceled
}
if normalized.contains("COMPLETED") || normalized.contains("DELIVERED") {
if technical.contains("COMPLETED") || technical.contains("DELIVERED") {
return .delivered
}
if technical.contains("IN_DELIVERY")
|| technical.contains("DELIVERING")
|| technical.contains("OUT_FOR_DELIVERY")
|| technical.contains("PENDING")
|| technical.contains("ACCEPTED")
|| technical.contains("PREPAR")
|| technical.contains("READY") {
return .inProgress
}
let label = (order.statusLabel ?? "").trimmingCharacters(in: .whitespacesAndNewlines).uppercased()
if label.contains("CANCEL") {
return .canceled
}
if label.contains("CONCLU") || label.contains("ENTREGUE") {
return .delivered
}
return .inProgress
@@ -440,7 +461,7 @@ struct OrdersView: View {
}
}
private struct OrderRouteContext: Identifiable, Hashable {
struct OrderRouteContext: Identifiable, Hashable {
var id: String { orderId }
let orderId: String
let shortId: String?