fix:UI对齐demo
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user