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:
|
// Package imports:
|
||||||
import 'package:flutter_redux/flutter_redux.dart';
|
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';
|
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||||
|
|
||||||
// Project imports:
|
// 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(
|
return MouseRegion(
|
||||||
onEnter: (event) => setState(() => _isHovered = true),
|
onEnter: (event) => setState(() => _isHovered = true),
|
||||||
onExit: (event) => setState(() => _isHovered = false),
|
onExit: (event) => setState(() => _isHovered = false),
|
||||||
|
|
@ -121,18 +142,20 @@ class _EntityListTileState extends State<EntityListTile> {
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
subtitle:
|
subtitle: ((widget.subtitle ?? '').isNotEmpty ||
|
||||||
(widget.subtitle ?? '').isEmpty && widget.entity.isActive
|
defaultSubtitle.isNotEmpty ||
|
||||||
? null
|
!entity.isActive)
|
||||||
: Column(
|
? Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
if ((widget.subtitle ?? '').isNotEmpty)
|
if ((widget.subtitle ?? '').isNotEmpty)
|
||||||
Text(widget.subtitle),
|
Text(widget.subtitle)
|
||||||
if (!widget.entity.isActive)
|
else if (defaultSubtitle.isNotEmpty)
|
||||||
EntityStateLabel(widget.entity),
|
Text(defaultSubtitle),
|
||||||
],
|
if (!entity.isActive) EntityStateLabel(widget.entity),
|
||||||
),
|
],
|
||||||
|
)
|
||||||
|
: null,
|
||||||
leading: leading,
|
leading: leading,
|
||||||
trailing: trailing,
|
trailing: trailing,
|
||||||
isThreeLine:
|
isThreeLine:
|
||||||
|
|
|
||||||
|
|
@ -196,19 +196,11 @@ class ExpenseOverview extends StatelessWidget {
|
||||||
EntityListTile(
|
EntityListTile(
|
||||||
entity: invoice,
|
entity: invoice,
|
||||||
isFilter: isFilter,
|
isFilter: isFilter,
|
||||||
subtitle: formatNumber(invoice.amount, context,
|
|
||||||
clientId: invoice.clientId) +
|
|
||||||
' • ' +
|
|
||||||
formatDate(invoice.date, context),
|
|
||||||
),
|
),
|
||||||
EntityListTile(entity: purchaseOrder, isFilter: isFilter),
|
EntityListTile(entity: purchaseOrder, isFilter: isFilter),
|
||||||
EntityListTile(
|
EntityListTile(
|
||||||
entity: transaction,
|
entity: transaction,
|
||||||
isFilter: isFilter,
|
isFilter: isFilter,
|
||||||
subtitle: formatNumber(transaction.amount, context,
|
|
||||||
currencyId: transaction.currencyId) +
|
|
||||||
' • ' +
|
|
||||||
formatDate(transaction.date, context),
|
|
||||||
),
|
),
|
||||||
if ((expense.recurringId ?? '').isNotEmpty)
|
if ((expense.recurringId ?? '').isNotEmpty)
|
||||||
EntityListTile(entity: recurringExpense, isFilter: isFilter),
|
EntityListTile(entity: recurringExpense, isFilter: isFilter),
|
||||||
|
|
|
||||||
|
|
@ -160,10 +160,6 @@ class _PaymentViewState extends State<PaymentView> {
|
||||||
EntityListTile(
|
EntityListTile(
|
||||||
isFilter: widget.isFilter,
|
isFilter: widget.isFilter,
|
||||||
entity: transaction,
|
entity: transaction,
|
||||||
subtitle: formatNumber(transaction.amount, context,
|
|
||||||
currencyId: transaction.currencyId) +
|
|
||||||
' • ' +
|
|
||||||
formatDate(transaction.date, context),
|
|
||||||
),
|
),
|
||||||
payment.privateNotes != null &&
|
payment.privateNotes != null &&
|
||||||
payment.privateNotes.isNotEmpty
|
payment.privateNotes.isNotEmpty
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue