fix:持仓详情编辑,资讯下拉加载更多
This commit is contained in:
@@ -50,6 +50,13 @@ class HoldingDetailPage extends ConsumerWidget {
|
||||
holding.name,
|
||||
style: const TextStyle(fontSize: 17, fontWeight: FontWeight.w600),
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () => _showActionsSheet(context, ref, holding),
|
||||
icon: const Icon(Icons.more_horiz, size: 22),
|
||||
color: const Color(0xFF8A8780),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: SafeArea(
|
||||
child: ListView(
|
||||
@@ -232,13 +239,22 @@ class HoldingDetailPage extends ConsumerWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: OutlinedButton(
|
||||
onPressed: () =>
|
||||
_showEditSheet(context, ref, holding),
|
||||
onPressed: () => context.push(
|
||||
'${AppRoutes.assetEdit}?id=${holding.id}',
|
||||
),
|
||||
style: OutlinedButton.styleFrom(
|
||||
side: const BorderSide(color: Color(0xFFE3D6B4)),
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
foregroundColor: const Color(0xFF9A7A2A),
|
||||
),
|
||||
child: const Text('编辑'),
|
||||
),
|
||||
),
|
||||
@@ -246,6 +262,14 @@ class HoldingDetailPage extends ConsumerWidget {
|
||||
Expanded(
|
||||
child: OutlinedButton(
|
||||
onPressed: () => _markSold(context, ref, holding.id),
|
||||
style: OutlinedButton.styleFrom(
|
||||
side: const BorderSide(color: Color(0xFFE6E1D8)),
|
||||
foregroundColor: const Color(0xFF8A8780),
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
),
|
||||
child: const Text('标记卖出 / 转赠'),
|
||||
),
|
||||
),
|
||||
@@ -260,29 +284,73 @@ class HoldingDetailPage extends ConsumerWidget {
|
||||
);
|
||||
}
|
||||
|
||||
void _showEditSheet(
|
||||
void _showActionsSheet(
|
||||
BuildContext context,
|
||||
WidgetRef ref,
|
||||
GoldAssetHolding holding,
|
||||
) {
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.white,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(22)),
|
||||
),
|
||||
builder: (ctx) => _EditHoldingSheet(
|
||||
holding: holding,
|
||||
onSave: (updated) {
|
||||
ref
|
||||
.read(assetPortfolioControllerProvider.notifier)
|
||||
.updateHolding(updated);
|
||||
Navigator.of(ctx).pop();
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(const SnackBar(content: Text('已保存修改 · 总值已重算')));
|
||||
},
|
||||
builder: (ctx) => SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(20, 8, 20, 20),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Center(
|
||||
child: Container(
|
||||
width: 38,
|
||||
height: 4,
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFE3DFD4),
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
),
|
||||
),
|
||||
),
|
||||
_ActionMenuTile(
|
||||
icon: Icons.edit_outlined,
|
||||
label: '编辑持仓',
|
||||
onTap: () {
|
||||
Navigator.of(ctx).pop();
|
||||
context.push('${AppRoutes.assetEdit}?id=${holding.id}');
|
||||
},
|
||||
),
|
||||
const PrototypeDivider(margin: EdgeInsets.zero),
|
||||
_ActionMenuTile(
|
||||
icon: Icons.share_outlined,
|
||||
label: '分享这张的估值卡',
|
||||
onTap: () {
|
||||
Navigator.of(ctx).pop();
|
||||
context.push(AppRoutes.profileShare);
|
||||
},
|
||||
),
|
||||
const PrototypeDivider(margin: EdgeInsets.zero),
|
||||
_ActionMenuTile(
|
||||
icon: Icons.sell_outlined,
|
||||
label: '标记卖出 / 转赠',
|
||||
labelColor: const Color(0xFFC0392B),
|
||||
iconColor: const Color(0xFFC0392B),
|
||||
onTap: () {
|
||||
Navigator.of(ctx).pop();
|
||||
_markSold(context, ref, holding.id);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: OutlinedButton(
|
||||
onPressed: () => Navigator.of(ctx).pop(),
|
||||
child: const Text('取消'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -296,6 +364,47 @@ class HoldingDetailPage extends ConsumerWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class _ActionMenuTile extends StatelessWidget {
|
||||
const _ActionMenuTile({
|
||||
required this.icon,
|
||||
required this.label,
|
||||
required this.onTap,
|
||||
this.iconColor,
|
||||
this.labelColor,
|
||||
});
|
||||
|
||||
final IconData icon;
|
||||
final String label;
|
||||
final VoidCallback onTap;
|
||||
final Color? iconColor;
|
||||
final Color? labelColor;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cs = ShadTheme.of(context).colorScheme;
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 16),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(icon, size: 20, color: iconColor ?? const Color(0xFF8A8780)),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: labelColor ?? cs.foreground,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _InfoRow extends StatelessWidget {
|
||||
const _InfoRow({required this.label, required this.value, this.valueColor});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user