Initial project import
This commit is contained in:
@@ -0,0 +1,214 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:miaoji_zhang/features/home/pages/transaction_edit_page.dart';
|
||||
import 'package:miaoji_zhang/shared/services/transaction_events.dart';
|
||||
import 'package:miaoji_zhang/shared/api/business_api.dart';
|
||||
import 'package:miaoji_zhang/shared/theme/app_theme.dart';
|
||||
import 'package:miaoji_zhang/shared/services/shanghai_time.dart';
|
||||
import 'package:miaoji_zhang/shared/widgets/category_icon.dart';
|
||||
import 'package:miaoji_zhang/shared/widgets/app_icons.dart';
|
||||
|
||||
/// P11 账单详情:金额、分类、来源追溯(AI 原话)、时间、支付方式
|
||||
class TxDetailPage extends StatelessWidget {
|
||||
final TxItem tx;
|
||||
const TxDetailPage({super.key, required this.tx});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('账单详情'),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: AppIcons.icon(
|
||||
AppIcons.edit,
|
||||
size: 18,
|
||||
color: context.jz.text2,
|
||||
),
|
||||
onPressed: () async {
|
||||
final updated = await Navigator.push<TxItem>(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => TransactionEditPage(transaction: tx),
|
||||
),
|
||||
);
|
||||
if (updated != null && context.mounted) {
|
||||
TransactionEvents.notifyChanged();
|
||||
Navigator.pop(context, true);
|
||||
}
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: AppIcons.icon(AppIcons.trash, size: 18, color: AppTheme.red),
|
||||
onPressed: () async {
|
||||
await TxApi.delete(tx.id);
|
||||
TransactionEvents.notifyChanged();
|
||||
if (context.mounted) {
|
||||
Navigator.pop(context, true);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
// 金额头部
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 28),
|
||||
margin: const EdgeInsets.only(bottom: 14),
|
||||
decoration: BoxDecoration(
|
||||
color: context.jz.card,
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
border: Border.all(color: context.jz.line, width: 0.5),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
'${tx.isIncome ? '+' : '-'}¥${tx.amount.toStringAsFixed(2)}',
|
||||
style: TextStyle(
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: tx.isIncome ? AppTheme.primary : context.jz.text,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 6),
|
||||
Text(
|
||||
ShanghaiTime.formatCivil(tx.occurredAt),
|
||||
style: TextStyle(fontSize: 12, color: context.jz.text3),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// 分类
|
||||
_Row(
|
||||
k: '分类',
|
||||
child: Row(
|
||||
children: [
|
||||
CategoryIconBox(
|
||||
iconKey: tx.categoryIcon,
|
||||
colorKey: tx.categoryColor,
|
||||
size: 30,
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
Text(
|
||||
tx.categoryName,
|
||||
style: TextStyle(fontSize: 13.5, fontWeight: FontWeight.w600),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// 类型
|
||||
_Row(
|
||||
k: '类型',
|
||||
child: Text(
|
||||
tx.isIncome ? '收入' : '支出',
|
||||
style: TextStyle(fontSize: 13.5),
|
||||
),
|
||||
),
|
||||
// 备注
|
||||
if (tx.note != null && tx.note!.isNotEmpty)
|
||||
_Row(
|
||||
k: '备注',
|
||||
child: Text(tx.note!, style: TextStyle(fontSize: 13.5)),
|
||||
),
|
||||
// 支付方式
|
||||
if (tx.paymentMethod != null && tx.paymentMethod!.isNotEmpty)
|
||||
_Row(
|
||||
k: '支付方式',
|
||||
child: Text(tx.paymentMethod!, style: TextStyle(fontSize: 13.5)),
|
||||
),
|
||||
_Row(
|
||||
k: '记账方式',
|
||||
child: Row(
|
||||
children: [
|
||||
if (tx.isAi || tx.isRecognition) ...[
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 7,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: tx.isAi
|
||||
? context.jz.aiBackground
|
||||
: context.jz.primaryBackground,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Text(
|
||||
tx.isAi ? '✦ AI' : '智能识别',
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: tx.isAi ? AppTheme.ai : AppTheme.primary,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 7),
|
||||
],
|
||||
Text(tx.sourceLabel, style: TextStyle(fontSize: 13.5)),
|
||||
],
|
||||
),
|
||||
),
|
||||
if ((tx.isAi || tx.isRecognition) &&
|
||||
tx.sourceText != null &&
|
||||
tx.sourceText!.isNotEmpty)
|
||||
_Row(
|
||||
k: tx.isAi ? 'AI 原话' : '识别依据',
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: tx.isAi
|
||||
? context.jz.aiBackground
|
||||
: context.jz.primaryBackground,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Text(
|
||||
'"${tx.sourceText}"',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: context.jz.text2,
|
||||
height: 1.5,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// 来源标签
|
||||
_Row(
|
||||
k: '来源',
|
||||
child: Text(tx.sourceLabel, style: TextStyle(fontSize: 13.5)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _Row extends StatelessWidget {
|
||||
final String k;
|
||||
final Widget child;
|
||||
const _Row({required this.k, required this.child});
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 13),
|
||||
margin: const EdgeInsets.only(bottom: 9),
|
||||
decoration: BoxDecoration(
|
||||
color: context.jz.card,
|
||||
borderRadius: BorderRadius.circular(13),
|
||||
border: Border.all(color: context.jz.line, width: 0.5),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 70,
|
||||
child: Text(
|
||||
k,
|
||||
style: TextStyle(fontSize: 12, color: context.jz.text3),
|
||||
),
|
||||
),
|
||||
Expanded(child: child),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user