Files
suixinkan_ios_new/suixinkan/Features/Orders/Views/OrderListHeaderView.swift

72 lines
2.1 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// OrderListHeaderView.swift
// suixinkan
//
// Created by Codex on 2026/6/29.
//
import SwiftUI
/// `.searchable`
struct OrderListHeaderView: View {
let filterTitle: String
let timeFilterTitle: String
let statusFilters: [OrderStatusFilter]
let selectedStatus: Int
let onStatusSelected: (Int) -> Void
let onTimeFilterTap: () -> Void
var body: some View {
HStack(spacing: 8) {
Menu {
ForEach(statusFilters) { filter in
Button(filter.title) {
onStatusSelected(filter.id)
}
}
} label: {
OrderListFilterPill(title: filterTitle, showsChevron: true)
}
Button(action: onTimeFilterTap) {
OrderListFilterPill(title: timeFilterTitle, showsCalendar: true)
}
.buttonStyle(.plain)
}
.padding(16)
.background(.white)
}
}
/// pill
private struct OrderListFilterPill: View {
let title: String
var showsChevron = false
var showsCalendar = false
var body: some View {
HStack(spacing: 4) {
Text(title)
.font(.system(size: 14))
.foregroundStyle(AppDesign.orderLabelColor)
.lineLimit(1)
.minimumScaleFactor(0.75)
Spacer(minLength: 4)
if showsChevron {
Image(systemName: "chevron.down")
.font(.system(size: 12, weight: .semibold))
.foregroundStyle(AppDesign.orderLabelColor)
}
if showsCalendar {
Image(systemName: "calendar")
.font(.system(size: 15))
.foregroundStyle(AppDesign.orderLabelColor)
}
}
.padding(.horizontal, 12)
.frame(maxWidth: .infinity)
.frame(height: 35)
.background(AppDesign.orderInputBackground, in: RoundedRectangle(cornerRadius: 4))
}
}