Set default subtitle for list tiles
This commit is contained in:
parent
1628b317a3
commit
4c495da76a
|
|
@ -4,6 +4,7 @@ import 'package:flutter/rendering.dart';
|
|||
|
||||
// Package imports:
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||
|
||||
// Project imports:
|
||||
|
|
@ -97,6 +98,26 @@ class _EntityListTileState extends State<EntityListTile> {
|
|||
),
|
||||
);
|
||||
|
||||
String defaultSubtitle = '';
|
||||
final entity = widget.entity;
|
||||
|
||||
if (entity is InvoiceEntity) {
|
||||
defaultSubtitle =
|
||||
formatNumber(entity.amount, context, clientId: entity.clientId) +
|
||||
' • ' +
|
||||
formatDate(entity.date, context);
|
||||
} else if (entity is PaymentEntity) {
|
||||
defaultSubtitle =
|
||||
formatNumber(entity.amount, context, clientId: entity.clientId) +
|
||||
' • ' +
|
||||
formatDate(entity.date, context);
|
||||
} else if (entity is TransactionEntity) {
|
||||
defaultSubtitle =
|
||||
formatNumber(entity.amount, context, currencyId: entity.currencyId) +
|
||||
' • ' +
|
||||
formatDate(entity.date, context);
|
||||
}
|
||||
|
||||
return MouseRegion(
|
||||
onEnter: (event) => setState(() => _isHovered = true),
|
||||
onExit: (event) => setState(() => _isHovered = false),
|
||||
|
|
@ -121,18 +142,20 @@ class _EntityListTileState extends State<EntityListTile> {
|
|||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
subtitle:
|
||||
(widget.subtitle ?? '').isEmpty && widget.entity.isActive
|
||||
? null
|
||||
: Column(
|
||||
subtitle: ((widget.subtitle ?? '').isNotEmpty ||
|
||||
defaultSubtitle.isNotEmpty ||
|
||||
!entity.isActive)
|
||||
? Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if ((widget.subtitle ?? '').isNotEmpty)
|
||||
Text(widget.subtitle),
|
||||
if (!widget.entity.isActive)
|
||||
EntityStateLabel(widget.entity),
|
||||
Text(widget.subtitle)
|
||||
else if (defaultSubtitle.isNotEmpty)
|
||||
Text(defaultSubtitle),
|
||||
if (!entity.isActive) EntityStateLabel(widget.entity),
|
||||
],
|
||||
),
|
||||
)
|
||||
: null,
|
||||
leading: leading,
|
||||
trailing: trailing,
|
||||
isThreeLine:
|
||||
|
|
|
|||
|
|
@ -196,19 +196,11 @@ class ExpenseOverview extends StatelessWidget {
|
|||
EntityListTile(
|
||||
entity: invoice,
|
||||
isFilter: isFilter,
|
||||
subtitle: formatNumber(invoice.amount, context,
|
||||
clientId: invoice.clientId) +
|
||||
' • ' +
|
||||
formatDate(invoice.date, context),
|
||||
),
|
||||
EntityListTile(entity: purchaseOrder, isFilter: isFilter),
|
||||
EntityListTile(
|
||||
entity: transaction,
|
||||
isFilter: isFilter,
|
||||
subtitle: formatNumber(transaction.amount, context,
|
||||
currencyId: transaction.currencyId) +
|
||||
' • ' +
|
||||
formatDate(transaction.date, context),
|
||||
),
|
||||
if ((expense.recurringId ?? '').isNotEmpty)
|
||||
EntityListTile(entity: recurringExpense, isFilter: isFilter),
|
||||
|
|
|
|||
|
|
@ -160,10 +160,6 @@ class _PaymentViewState extends State<PaymentView> {
|
|||
EntityListTile(
|
||||
isFilter: widget.isFilter,
|
||||
entity: transaction,
|
||||
subtitle: formatNumber(transaction.amount, context,
|
||||
currencyId: transaction.currencyId) +
|
||||
' • ' +
|
||||
formatDate(transaction.date, context),
|
||||
),
|
||||
payment.privateNotes != null &&
|
||||
payment.privateNotes.isNotEmpty
|
||||
|
|
|
|||
Loading…
Reference in New Issue