fixed some issues and added label and, or capability
This commit is contained in:
@@ -9,7 +9,7 @@ import '../models/transaction_meta.dart';
|
||||
import '../providers/bank_provider.dart';
|
||||
import '../providers/preferences_provider.dart';
|
||||
import '../providers/tx_meta_provider.dart';
|
||||
import '../screens/transaction_detail_screen.dart';
|
||||
import '../screens/transactions_screen.dart';
|
||||
import '../utils/app_theme.dart';
|
||||
import '../utils/helpers.dart';
|
||||
import '../utils/look_ahead.dart';
|
||||
@@ -337,17 +337,6 @@ class _LookAheadScreenState extends State<LookAheadScreen> {
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
items.isEmpty
|
||||
? 'Create a spending from a transaction, or tap New.'
|
||||
: '${items.length} spending${items.length == 1 ? '' : 's'} · '
|
||||
'projected income ${formatMoney(income, currency)} · '
|
||||
'expenses ${formatMoney(expenses, currency)}.',
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: colors.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
@@ -622,6 +611,46 @@ class _TemplateTile extends StatelessWidget {
|
||||
return null;
|
||||
}
|
||||
|
||||
void _openTransactions(BuildContext context) {
|
||||
final labelIds = item.labelIds.toSet();
|
||||
SimilarMatchCriteria? similar;
|
||||
TxFlowFilter? flow;
|
||||
String? query;
|
||||
|
||||
if (labelIds.isEmpty) {
|
||||
final tx = _sourceTx;
|
||||
if (tx != null) {
|
||||
// Same matching as Look ahead / apply-to-similar for this source tx.
|
||||
similar = SimilarMatchCriteria(
|
||||
pattern: defaultSimilarPattern(tx.description),
|
||||
flow: tx.amount < 0
|
||||
? TxFlowFilter.expense
|
||||
: tx.amount > 0
|
||||
? TxFlowFilter.income
|
||||
: TxFlowFilter.all,
|
||||
);
|
||||
flow = similar.flow;
|
||||
} else if (template != null && template!.merchantKey.isNotEmpty) {
|
||||
query = template!.merchantKey;
|
||||
} else {
|
||||
query = item.description;
|
||||
}
|
||||
}
|
||||
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute<void>(
|
||||
builder: (_) => TransactionsScreen(
|
||||
initialLabelIds: labelIds,
|
||||
initialLabelMatch: LabelMatchMode.or,
|
||||
initialQuery: query,
|
||||
initialFlow: flow,
|
||||
initialSimilarMatch: similar,
|
||||
initialSearchInMonthOnly: false,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
@@ -658,15 +687,7 @@ class _TemplateTile extends StatelessWidget {
|
||||
color: income ? AppTheme.accent : AppTheme.expense,
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
final tx = _sourceTx;
|
||||
if (tx == null) return;
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute<void>(
|
||||
builder: (_) => TransactionDetailScreen(tx: tx),
|
||||
),
|
||||
);
|
||||
},
|
||||
onTap: () => _openTransactions(context),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user