72 lines
2.1 KiB
Swift
72 lines
2.1 KiB
Swift
//
|
||
// 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))
|
||
}
|
||
}
|