mirror of
https://github.com/VGEAREN/Stockbar.git
synced 2026-10-07 15:48:08 +08:00
- New setting: "持仓股单独分组置顶" toggle - When enabled, stocks with holdings are grouped into a "持仓" section at top - Remaining non-held stocks still grouped by A/HK/US market as usual - StockGroupView supports custom title for holdings group Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
41 lines
1.4 KiB
Swift
41 lines
1.4 KiB
Swift
import SwiftUI
|
|
|
|
struct StockGroupView: View {
|
|
let market: Market
|
|
let stocks: [Stock]
|
|
var title: String? = nil
|
|
var onSelect: ((Stock) -> Void)? = nil
|
|
@EnvironmentObject var appState: AppState
|
|
@State private var isExpanded = true
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading, spacing: 2) {
|
|
Button {
|
|
withAnimation(.easeInOut(duration: 0.2)) { isExpanded.toggle() }
|
|
} label: {
|
|
HStack(spacing: 4) {
|
|
Image(systemName: isExpanded ? "chevron.down" : "chevron.right")
|
|
.font(.system(size: 10, weight: .medium))
|
|
Text(title ?? market.rawValue)
|
|
.font(.system(size: 11, weight: .semibold))
|
|
Text("(\(stocks.count))")
|
|
.font(.system(size: 11))
|
|
.foregroundColor(.secondary)
|
|
Spacer()
|
|
}
|
|
.foregroundColor(.accentColor)
|
|
}
|
|
.buttonStyle(.plain)
|
|
.padding(.horizontal, 4)
|
|
|
|
if isExpanded {
|
|
ForEach(stocks) { stock in
|
|
StockRowView(stock: stock, quote: appState.quotes[stock.id],
|
|
onTap: { onSelect?(stock) })
|
|
.id(stock.id)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|