Fix for showing list items as selected
This commit is contained in:
parent
34389eea27
commit
19a34900bc
|
|
@ -120,6 +120,7 @@ class InvoiceSidebar extends StatelessWidget {
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
return InvoiceListItem(
|
return InvoiceListItem(
|
||||||
invoice: upcomingInvoices[index],
|
invoice: upcomingInvoices[index],
|
||||||
|
showSelected: false,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
separatorBuilder: (context, index) => ListDivider(),
|
separatorBuilder: (context, index) => ListDivider(),
|
||||||
|
|
@ -133,6 +134,7 @@ class InvoiceSidebar extends StatelessWidget {
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
return InvoiceListItem(
|
return InvoiceListItem(
|
||||||
invoice: pastDueInvoices[index],
|
invoice: pastDueInvoices[index],
|
||||||
|
showSelected: false,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
separatorBuilder: (context, index) => ListDivider(),
|
separatorBuilder: (context, index) => ListDivider(),
|
||||||
|
|
@ -150,6 +152,7 @@ class InvoiceSidebar extends StatelessWidget {
|
||||||
? SizedBox()
|
? SizedBox()
|
||||||
: InvoiceListItem(
|
: InvoiceListItem(
|
||||||
invoice: invoice,
|
invoice: invoice,
|
||||||
|
showSelected: false,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
separatorBuilder: (context, index) => ListDivider(),
|
separatorBuilder: (context, index) => ListDivider(),
|
||||||
|
|
@ -184,7 +187,7 @@ class PaymentSidebar extends StatelessWidget {
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
return PaymentListItem(
|
return PaymentListItem(
|
||||||
payment: recentPayments[index],
|
payment: recentPayments[index],
|
||||||
showCheck: false,
|
showSelected: false,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
separatorBuilder: (context, index) => ListDivider(),
|
separatorBuilder: (context, index) => ListDivider(),
|
||||||
|
|
@ -202,7 +205,7 @@ class PaymentSidebar extends StatelessWidget {
|
||||||
? SizedBox()
|
? SizedBox()
|
||||||
: PaymentListItem(
|
: PaymentListItem(
|
||||||
payment: payment,
|
payment: payment,
|
||||||
showCheck: false,
|
showSelected: false,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
separatorBuilder: (context, index) => ListDivider(),
|
separatorBuilder: (context, index) => ListDivider(),
|
||||||
|
|
@ -388,6 +391,7 @@ class ExpenseSidbar extends StatelessWidget {
|
||||||
return ExpenseListItem(
|
return ExpenseListItem(
|
||||||
expense: upcomingExpenses[index],
|
expense: upcomingExpenses[index],
|
||||||
showCheckbox: false,
|
showCheckbox: false,
|
||||||
|
showSelected: false,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
separatorBuilder: (context, index) => ListDivider(),
|
separatorBuilder: (context, index) => ListDivider(),
|
||||||
|
|
@ -402,7 +406,8 @@ class ExpenseSidbar extends StatelessWidget {
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
return ExpenseListItem(
|
return ExpenseListItem(
|
||||||
expense: recentExpenses[index],
|
expense: recentExpenses[index],
|
||||||
showCheck: false,
|
showCheckbox: false,
|
||||||
|
showSelected: false,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
separatorBuilder: (context, index) => ListDivider(),
|
separatorBuilder: (context, index) => ListDivider(),
|
||||||
|
|
@ -420,7 +425,8 @@ class ExpenseSidbar extends StatelessWidget {
|
||||||
? SizedBox()
|
? SizedBox()
|
||||||
: ExpenseListItem(
|
: ExpenseListItem(
|
||||||
expense: expense,
|
expense: expense,
|
||||||
showCheck: false,
|
showCheckbox: false,
|
||||||
|
showSelected: false,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
separatorBuilder: (context, index) => ListDivider(),
|
separatorBuilder: (context, index) => ListDivider(),
|
||||||
|
|
|
||||||
|
|
@ -25,18 +25,20 @@ class ExpenseListItem extends StatelessWidget {
|
||||||
this.filter,
|
this.filter,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
this.onCheckboxChanged,
|
this.onCheckboxChanged,
|
||||||
this.showCheck = false,
|
this.showCheckbox = false,
|
||||||
this.isDismissible = true,
|
this.isDismissible = true,
|
||||||
this.isChecked = false,
|
this.isChecked = false,
|
||||||
|
this.showSelected = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
final Function(bool) onCheckboxChanged;
|
final Function(bool) onCheckboxChanged;
|
||||||
final GestureTapCallback onTap;
|
final GestureTapCallback onTap;
|
||||||
final ExpenseEntity expense;
|
final ExpenseEntity expense;
|
||||||
final String filter;
|
final String filter;
|
||||||
final bool showCheck;
|
final bool showCheckbox;
|
||||||
final bool isDismissible;
|
final bool isDismissible;
|
||||||
final bool isChecked;
|
final bool isChecked;
|
||||||
|
final bool showSelected;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
@ -75,10 +77,10 @@ class ExpenseListItem extends StatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
return DismissibleEntity(
|
return DismissibleEntity(
|
||||||
showMultiselect: showCheck,
|
showMultiselect: showSelected,
|
||||||
isDismissible: isDismissible,
|
isDismissible: isDismissible,
|
||||||
isSelected: isDesktop(context) &&
|
isSelected: isDesktop(context) &&
|
||||||
!showCheck &&
|
showSelected &&
|
||||||
expense.id ==
|
expense.id ==
|
||||||
(uiState.isEditing
|
(uiState.isEditing
|
||||||
? expenseUIState.editing.id
|
? expenseUIState.editing.id
|
||||||
|
|
@ -105,7 +107,7 @@ class ExpenseListItem extends StatelessWidget {
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(right: 16),
|
padding: const EdgeInsets.only(right: 16),
|
||||||
child: showCheck
|
child: showCheckbox
|
||||||
? Padding(
|
? Padding(
|
||||||
padding: const EdgeInsets.only(right: 20),
|
padding: const EdgeInsets.only(right: 20),
|
||||||
child: IgnorePointer(
|
child: IgnorePointer(
|
||||||
|
|
@ -188,7 +190,7 @@ class ExpenseListItem extends StatelessWidget {
|
||||||
onLongPress: () => onTap != null
|
onLongPress: () => onTap != null
|
||||||
? null
|
? null
|
||||||
: selectEntity(entity: expense, longPress: true),
|
: selectEntity(entity: expense, longPress: true),
|
||||||
leading: showCheck
|
leading: showCheckbox
|
||||||
? IgnorePointer(
|
? IgnorePointer(
|
||||||
child: Checkbox(
|
child: Checkbox(
|
||||||
value: isChecked,
|
value: isChecked,
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ class ExpenseListBuilder extends StatelessWidget {
|
||||||
filter: viewModel.filter,
|
filter: viewModel.filter,
|
||||||
expense: expense,
|
expense: expense,
|
||||||
isChecked: listUIState.isSelected(expense.id),
|
isChecked: listUIState.isSelected(expense.id),
|
||||||
showCheck: listUIState.isInMultiselect(),
|
showCheckbox: listUIState.isInMultiselect(),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -237,6 +237,7 @@ class _InvoiceItemSelectorState extends State<InvoiceItemSelector>
|
||||||
final expense = state.expenseState.map[entityId] ?? ExpenseEntity();
|
final expense = state.expenseState.map[entityId] ?? ExpenseEntity();
|
||||||
return ExpenseListItem(
|
return ExpenseListItem(
|
||||||
isDismissible: false,
|
isDismissible: false,
|
||||||
|
showSelected: false,
|
||||||
onCheckboxChanged: (checked) => _toggleEntity(expense),
|
onCheckboxChanged: (checked) => _toggleEntity(expense),
|
||||||
isChecked: _selected.contains(expense),
|
isChecked: _selected.contains(expense),
|
||||||
expense: expense,
|
expense: expense,
|
||||||
|
|
|
||||||
|
|
@ -22,16 +22,18 @@ class InvoiceListItem extends StatelessWidget {
|
||||||
const InvoiceListItem({
|
const InvoiceListItem({
|
||||||
@required this.invoice,
|
@required this.invoice,
|
||||||
this.filter,
|
this.filter,
|
||||||
this.showCheck = false,
|
|
||||||
this.isChecked = false,
|
|
||||||
this.onTap,
|
this.onTap,
|
||||||
|
this.isChecked = false,
|
||||||
|
this.showCheckbox = false,
|
||||||
|
this.showSelected = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
final InvoiceEntity invoice;
|
final InvoiceEntity invoice;
|
||||||
final String filter;
|
final String filter;
|
||||||
final bool showCheck;
|
final bool showCheckbox;
|
||||||
final bool isChecked;
|
final bool isChecked;
|
||||||
final Function onTap;
|
final Function onTap;
|
||||||
|
final bool showSelected;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
@ -71,12 +73,12 @@ class InvoiceListItem extends StatelessWidget {
|
||||||
|
|
||||||
return DismissibleEntity(
|
return DismissibleEntity(
|
||||||
isSelected: isDesktop(context) &&
|
isSelected: isDesktop(context) &&
|
||||||
!showCheck &&
|
showSelected &&
|
||||||
invoice.id ==
|
invoice.id ==
|
||||||
(uiState.isEditing
|
(uiState.isEditing
|
||||||
? invoiceUIState.editing.id
|
? invoiceUIState.editing.id
|
||||||
: invoiceUIState.selectedId),
|
: invoiceUIState.selectedId),
|
||||||
showMultiselect: showCheck,
|
showMultiselect: showSelected,
|
||||||
userCompany: state.userCompany,
|
userCompany: state.userCompany,
|
||||||
entity: invoice,
|
entity: invoice,
|
||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
|
|
@ -87,7 +89,7 @@ class InvoiceListItem extends StatelessWidget {
|
||||||
? onTap()
|
? onTap()
|
||||||
: selectEntity(
|
: selectEntity(
|
||||||
entity: invoice,
|
entity: invoice,
|
||||||
forceView: !showCheck,
|
forceView: !showCheckbox,
|
||||||
),
|
),
|
||||||
onLongPress: () => onTap != null
|
onLongPress: () => onTap != null
|
||||||
? null
|
? null
|
||||||
|
|
@ -103,7 +105,7 @@ class InvoiceListItem extends StatelessWidget {
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(right: 16),
|
padding: const EdgeInsets.only(right: 16),
|
||||||
child: showCheck
|
child: showCheckbox
|
||||||
? IgnorePointer(
|
? IgnorePointer(
|
||||||
child: Checkbox(
|
child: Checkbox(
|
||||||
value: isChecked,
|
value: isChecked,
|
||||||
|
|
@ -188,11 +190,11 @@ class InvoiceListItem extends StatelessWidget {
|
||||||
: ListTile(
|
: ListTile(
|
||||||
onTap: () => onTap != null
|
onTap: () => onTap != null
|
||||||
? onTap()
|
? onTap()
|
||||||
: selectEntity(entity: invoice, forceView: !showCheck),
|
: selectEntity(entity: invoice, forceView: !showCheckbox),
|
||||||
onLongPress: () => onTap != null
|
onLongPress: () => onTap != null
|
||||||
? null
|
? null
|
||||||
: selectEntity(entity: invoice, longPress: true),
|
: selectEntity(entity: invoice, longPress: true),
|
||||||
leading: showCheck
|
leading: showCheckbox
|
||||||
? IgnorePointer(
|
? IgnorePointer(
|
||||||
child: Checkbox(
|
child: Checkbox(
|
||||||
value: isChecked,
|
value: isChecked,
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ class InvoiceListBuilder extends StatelessWidget {
|
||||||
return InvoiceListItem(
|
return InvoiceListItem(
|
||||||
filter: viewModel.filter,
|
filter: viewModel.filter,
|
||||||
invoice: invoice,
|
invoice: invoice,
|
||||||
showCheck: invoiceListState.isInMultiselect(),
|
showCheckbox: invoiceListState.isInMultiselect(),
|
||||||
isChecked: invoiceListState.isSelected(invoice.id),
|
isChecked: invoiceListState.isSelected(invoice.id),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -22,16 +22,18 @@ class PaymentListItem extends StatelessWidget {
|
||||||
const PaymentListItem({
|
const PaymentListItem({
|
||||||
@required this.payment,
|
@required this.payment,
|
||||||
this.filter,
|
this.filter,
|
||||||
this.showCheck = false,
|
this.showCheckbox = false,
|
||||||
this.isChecked = false,
|
this.isChecked = false,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
|
this.showSelected = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
final PaymentEntity payment;
|
final PaymentEntity payment;
|
||||||
final String filter;
|
final String filter;
|
||||||
final bool showCheck;
|
final bool showCheckbox;
|
||||||
final bool isChecked;
|
final bool isChecked;
|
||||||
final Function onTap;
|
final Function onTap;
|
||||||
|
final bool showSelected;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
@ -62,12 +64,12 @@ class PaymentListItem extends StatelessWidget {
|
||||||
|
|
||||||
return DismissibleEntity(
|
return DismissibleEntity(
|
||||||
isSelected: isDesktop(context) &&
|
isSelected: isDesktop(context) &&
|
||||||
!showCheck &&
|
showSelected &&
|
||||||
payment.id ==
|
payment.id ==
|
||||||
(uiState.isEditing
|
(uiState.isEditing
|
||||||
? paymentUIState.editing.id
|
? paymentUIState.editing.id
|
||||||
: paymentUIState.selectedId),
|
: paymentUIState.selectedId),
|
||||||
showMultiselect: showCheck,
|
showMultiselect: showSelected,
|
||||||
userCompany: state.userCompany,
|
userCompany: state.userCompany,
|
||||||
entity: payment,
|
entity: payment,
|
||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
|
|
@ -76,7 +78,7 @@ class PaymentListItem extends StatelessWidget {
|
||||||
? InkWell(
|
? InkWell(
|
||||||
onTap: () => onTap != null
|
onTap: () => onTap != null
|
||||||
? onTap()
|
? onTap()
|
||||||
: selectEntity(entity: payment, forceView: !showCheck),
|
: selectEntity(entity: payment, forceView: !showCheckbox),
|
||||||
onLongPress: () => onTap != null
|
onLongPress: () => onTap != null
|
||||||
? null
|
? null
|
||||||
: selectEntity(entity: payment, longPress: true),
|
: selectEntity(entity: payment, longPress: true),
|
||||||
|
|
@ -91,7 +93,7 @@ class PaymentListItem extends StatelessWidget {
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(right: 16),
|
padding: const EdgeInsets.only(right: 16),
|
||||||
child: showCheck
|
child: showCheckbox
|
||||||
? IgnorePointer(
|
? IgnorePointer(
|
||||||
child: Checkbox(
|
child: Checkbox(
|
||||||
value: isChecked,
|
value: isChecked,
|
||||||
|
|
@ -164,11 +166,11 @@ class PaymentListItem extends StatelessWidget {
|
||||||
: ListTile(
|
: ListTile(
|
||||||
onTap: () => onTap != null
|
onTap: () => onTap != null
|
||||||
? onTap()
|
? onTap()
|
||||||
: selectEntity(entity: payment, forceView: !showCheck),
|
: selectEntity(entity: payment, forceView: !showCheckbox),
|
||||||
onLongPress: () => onTap != null
|
onLongPress: () => onTap != null
|
||||||
? null
|
? null
|
||||||
: selectEntity(entity: payment, longPress: true),
|
: selectEntity(entity: payment, longPress: true),
|
||||||
leading: showCheck
|
leading: showCheckbox
|
||||||
? IgnorePointer(
|
? IgnorePointer(
|
||||||
child: Checkbox(
|
child: Checkbox(
|
||||||
value: isChecked,
|
value: isChecked,
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ class PaymentListBuilder extends StatelessWidget {
|
||||||
return PaymentListItem(
|
return PaymentListItem(
|
||||||
filter: viewModel.filter,
|
filter: viewModel.filter,
|
||||||
payment: payment,
|
payment: payment,
|
||||||
showCheck: paymentListState.isInMultiselect(),
|
showCheckbox: paymentListState.isInMultiselect(),
|
||||||
isChecked: paymentListState.isSelected(payment.id),
|
isChecked: paymentListState.isSelected(payment.id),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -539,7 +539,8 @@ class _MatchDepositsState extends State<_MatchDeposits> {
|
||||||
final payment = _payments[index];
|
final payment = _payments[index];
|
||||||
return PaymentListItem(
|
return PaymentListItem(
|
||||||
payment: payment,
|
payment: payment,
|
||||||
showCheck: true,
|
showCheckbox: true,
|
||||||
|
showSelected: false,
|
||||||
isChecked: (_selectedPayment?.id ?? '') == payment.id,
|
isChecked: (_selectedPayment?.id ?? '') == payment.id,
|
||||||
onTap: () => setState(() {
|
onTap: () => setState(() {
|
||||||
if ((_selectedPayment?.id ?? '') == payment.id) {
|
if ((_selectedPayment?.id ?? '') == payment.id) {
|
||||||
|
|
@ -567,7 +568,8 @@ class _MatchDepositsState extends State<_MatchDeposits> {
|
||||||
final invoice = _invoices[index];
|
final invoice = _invoices[index];
|
||||||
return InvoiceListItem(
|
return InvoiceListItem(
|
||||||
invoice: invoice,
|
invoice: invoice,
|
||||||
showCheck: true,
|
showCheckbox: true,
|
||||||
|
showSelected: false,
|
||||||
isChecked: _selectedInvoices.contains(invoice),
|
isChecked: _selectedInvoices.contains(invoice),
|
||||||
onTap: () => setState(() {
|
onTap: () => setState(() {
|
||||||
if (_selectedInvoices.contains(invoice)) {
|
if (_selectedInvoices.contains(invoice)) {
|
||||||
|
|
@ -1020,7 +1022,8 @@ class _MatchWithdrawalsState extends State<_MatchWithdrawals> {
|
||||||
final expense = _expenses[index];
|
final expense = _expenses[index];
|
||||||
return ExpenseListItem(
|
return ExpenseListItem(
|
||||||
expense: expense,
|
expense: expense,
|
||||||
showCheck: true,
|
showCheckbox: true,
|
||||||
|
showSelected: false,
|
||||||
isChecked: _selectedExpense?.id == expense.id,
|
isChecked: _selectedExpense?.id == expense.id,
|
||||||
onTap: () => setState(() {
|
onTap: () => setState(() {
|
||||||
if (_selectedExpense?.id == expense.id) {
|
if (_selectedExpense?.id == expense.id) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue