feat(orders-ui): alinhar lista/detalhe ao layout e corrigir build

This commit is contained in:
Daniel Arantes Loverde
2026-03-05 10:23:04 -03:00
parent 1407f0b9de
commit 83882538c2
3 changed files with 259 additions and 92 deletions

View File

@@ -15,16 +15,24 @@ struct OrderDetailsView: View {
if hasAddressInfo {
addressCard
}
reorderButton
helpFooter
}
.padding(.horizontal, 20)
.padding(.top, 14)
.padding(.bottom, UIDevice.bottomNotch + 24)
.padding(.bottom, UIDevice.bottomNotch + 110)
}
.background(AppColors.backgroundLight)
.navigationTitle("Detalhes do Pedido")
.navigationBarTitleDisplayMode(.inline)
.safeAreaInset(edge: .bottom) {
VStack {
reorderButton
.padding(.horizontal, 20)
.padding(.top, 10)
.padding(.bottom, max(10, UIDevice.bottomNotch))
}
.background(AppColors.backgroundLight.opacity(0.94))
}
}
private var statusCard: some View {
@@ -66,7 +74,7 @@ struct OrderDetailsView: View {
Text(order.storeName?.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty == false ? (order.storeName ?? "Loja") : "Loja")
.font(AppTypography.heading2)
.foregroundStyle(AppColors.textPrimary)
Text("Pedido #\(displayOrderTitle)")
Text(storeSubtitle)
.font(AppTypography.body)
.foregroundStyle(AppColors.textMuted)
}
@@ -130,11 +138,31 @@ struct OrderDetailsView: View {
.font(AppTypography.body)
.foregroundStyle(AppColors.textMuted)
Spacer()
Text(formatCurrency(subtotal))
Text(formatCurrency(subtotalValue))
.font(AppTypography.body)
.foregroundStyle(AppColors.textMuted)
}
HStack {
Text("Taxa de entrega")
.font(AppTypography.body)
.foregroundStyle(AppColors.textMuted)
Spacer()
Text(formatCurrency(deliveryFeeValue))
.font(AppTypography.body)
.foregroundStyle(AppColors.textMuted)
}
HStack {
Text("Desconto")
.font(AppTypography.body)
.foregroundStyle(AppColors.textMuted)
Spacer()
Text("- \(formatCurrency(discountValue))")
.font(AppTypography.body)
.foregroundStyle(Color(hex: "#18A957"))
}
Divider()
HStack {
@@ -142,15 +170,15 @@ struct OrderDetailsView: View {
.font(AppTypography.heading2)
.foregroundStyle(AppColors.textPrimary)
Spacer()
Text(formatCurrency(order.total ?? subtotal))
Text(formatCurrency(totalValue))
.font(AppTypography.heading1)
.foregroundStyle(AppColors.textPrimary)
}
}
.frame(maxWidth: .infinity, alignment: .leading)
.padding(16)
.background(AppColors.surface)
.clipShape(RoundedRectangle(cornerRadius: AppLayout.radiusLG, style: .continuous))
.padding(16)
.background(AppColors.surface)
.clipShape(RoundedRectangle(cornerRadius: AppLayout.radiusLG, style: .continuous))
}
private var addressCard: some View {
@@ -217,6 +245,26 @@ struct OrderDetailsView: View {
}
}
private var subtotalValue: Double {
order.subtotal ?? subtotal
}
private var deliveryFeeValue: Double {
max(0, order.deliveryFee ?? 0)
}
private var discountValue: Double {
max(0, order.discount ?? 0)
}
private var totalValue: Double {
if let total = order.total {
return total
}
let calculated = subtotalValue + deliveryFeeValue - discountValue
return max(0, calculated)
}
private var hasAddressInfo: Bool {
deliveryAddressLine.isEmpty == false || deliveryAddressLine2.isEmpty == false
}
@@ -241,6 +289,13 @@ struct OrderDetailsView: View {
.joined(separator: "")
}
private var storeSubtitle: String {
if deliveryAddressLine2.isEmpty == false {
return deliveryAddressLine2
}
return "Pedido #\(displayOrderTitle)"
}
private var statusTitle: String {
let status = normalized(order.status)
if status.contains("CANCEL") { return "Pedido cancelado" }