fix:UI对齐demo

This commit is contained in:
jingyun
2026-06-18 18:08:29 +08:00
parent f42ad566e0
commit 2d7523f901
14 changed files with 1613 additions and 355 deletions
@@ -49,6 +49,56 @@ class AssetPortfolioController extends StateNotifier<PortfolioSummary> {
);
}
void updateHolding(GoldAssetHolding holding) {
final index = _holdings.indexWhere((item) => item.id == holding.id);
if (index == -1) return;
_holdings[index] = holding;
state = _buildSummary(
holdings: _holdings,
spotPriceFor: _spotPriceFor,
changeFor: _changeFor,
recycleDiscount: recycleDiscount,
);
}
void removeHolding(String id) {
_holdings.removeWhere((item) => item.id == id);
state = _buildSummary(
holdings: _holdings,
spotPriceFor: _spotPriceFor,
changeFor: _changeFor,
recycleDiscount: recycleDiscount,
);
}
void markHoldingSold(String id) {
final index = _holdings.indexWhere((item) => item.id == id);
if (index == -1) return;
final holding = _holdings[index];
_holdings[index] = GoldAssetHolding(
id: holding.id,
name: holding.name,
metal: holding.metal,
category: holding.category,
purity: holding.purity,
purityLabel: holding.purityLabel,
weightGram: holding.weightGram,
costAmount: holding.costAmount,
purchaseDate: holding.purchaseDate,
channel: holding.channel,
note: holding.note,
createdAt: holding.createdAt,
updatedAt: DateTime.now(),
status: HoldingStatus.sold,
);
state = _buildSummary(
holdings: _holdings,
spotPriceFor: _spotPriceFor,
changeFor: _changeFor,
recycleDiscount: recycleDiscount,
);
}
static PortfolioSummary _buildSummary({
required List<GoldAssetHolding> holdings,
required double Function(MetalType metal) spotPriceFor,