Documents
This commit is contained in:
parent
4bfe6e45ba
commit
c20d934239
|
|
@ -3,11 +3,13 @@ import 'package:flutter/material.dart';
|
||||||
|
|
||||||
// Package imports:
|
// Package imports:
|
||||||
import 'package:flutter_redux/flutter_redux.dart';
|
import 'package:flutter_redux/flutter_redux.dart';
|
||||||
|
import 'package:invoiceninja_flutter/constants.dart';
|
||||||
|
|
||||||
// Project imports:
|
// Project imports:
|
||||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||||
|
import 'package:invoiceninja_flutter/ui/app/actions_menu_button.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/dismissible_entity.dart';
|
import 'package:invoiceninja_flutter/ui/app/dismissible_entity.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/entity_state_label.dart';
|
import 'package:invoiceninja_flutter/ui/app/entity_state_label.dart';
|
||||||
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||||
|
|
@ -38,7 +40,8 @@ class DocumentListItem extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final store = StoreProvider.of<AppState>(context);
|
final store = StoreProvider.of<AppState>(context);
|
||||||
final uiState = store.state.uiState;
|
final state = store.state;
|
||||||
|
final uiState = state.uiState;
|
||||||
final documentUIState = uiState.documentUIState;
|
final documentUIState = uiState.documentUIState;
|
||||||
final filterMatch = filter != null && filter.isNotEmpty
|
final filterMatch = filter != null && filter.isNotEmpty
|
||||||
? document.matchesFilterValue(filter)
|
? document.matchesFilterValue(filter)
|
||||||
|
|
@ -56,8 +59,75 @@ class DocumentListItem extends StatelessWidget {
|
||||||
: documentUIState.selectedId),
|
: documentUIState.selectedId),
|
||||||
userCompany: userCompany,
|
userCompany: userCompany,
|
||||||
entity: document,
|
entity: document,
|
||||||
child: ListTile(
|
child: LayoutBuilder(builder: (context, constraints) {
|
||||||
onTap: () => onTap != null ? onTap() : selectEntity(entity: document),
|
return constraints.maxWidth > kTableListWidthCutoff
|
||||||
|
? InkWell(
|
||||||
|
onTap: () =>
|
||||||
|
onTap != null ? onTap() : selectEntity(entity: document),
|
||||||
|
onLongPress: () => onLongPress != null
|
||||||
|
? onLongPress()
|
||||||
|
: selectEntity(entity: document, longPress: true),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
left: 10,
|
||||||
|
right: 28,
|
||||||
|
top: 4,
|
||||||
|
bottom: 4,
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 16),
|
||||||
|
child: showCheckbox
|
||||||
|
? IgnorePointer(
|
||||||
|
ignoring: listUIState.isInMultiselect(),
|
||||||
|
child: Checkbox(
|
||||||
|
value: isChecked,
|
||||||
|
materialTapTargetSize:
|
||||||
|
MaterialTapTargetSize.shrinkWrap,
|
||||||
|
onChanged: (value) =>
|
||||||
|
onCheckboxChanged(value),
|
||||||
|
activeColor:
|
||||||
|
Theme.of(context).colorScheme.secondary,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: ActionMenuButton(
|
||||||
|
entityActions: document.getActions(
|
||||||
|
userCompany: state.userCompany,
|
||||||
|
includeEdit: true,
|
||||||
|
),
|
||||||
|
isSaving: false,
|
||||||
|
entity: document,
|
||||||
|
onSelected: (context, action) =>
|
||||||
|
handleEntityAction(document, action),
|
||||||
|
)),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
document.name,
|
||||||
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
formatDate(
|
||||||
|
convertTimestampToDateString(
|
||||||
|
document.createdAt),
|
||||||
|
context),
|
||||||
|
style: Theme.of(context).textTheme.bodySmall,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(document.prettySize,
|
||||||
|
style: Theme.of(context).textTheme.titleMedium),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: ListTile(
|
||||||
|
onTap: () =>
|
||||||
|
onTap != null ? onTap() : selectEntity(entity: document),
|
||||||
onLongPress: () => onLongPress != null
|
onLongPress: () => onLongPress != null
|
||||||
? onLongPress()
|
? onLongPress()
|
||||||
: selectEntity(entity: document, longPress: true),
|
: selectEntity(entity: document, longPress: true),
|
||||||
|
|
@ -66,7 +136,8 @@ class DocumentListItem extends StatelessWidget {
|
||||||
ignoring: listUIState.isInMultiselect(),
|
ignoring: listUIState.isInMultiselect(),
|
||||||
child: Checkbox(
|
child: Checkbox(
|
||||||
value: isChecked,
|
value: isChecked,
|
||||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
materialTapTargetSize:
|
||||||
|
MaterialTapTargetSize.shrinkWrap,
|
||||||
onChanged: (value) => onCheckboxChanged(value),
|
onChanged: (value) => onCheckboxChanged(value),
|
||||||
activeColor: Theme.of(context).colorScheme.secondary,
|
activeColor: Theme.of(context).colorScheme.secondary,
|
||||||
),
|
),
|
||||||
|
|
@ -86,7 +157,8 @@ class DocumentListItem extends StatelessWidget {
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
formatDate(
|
formatDate(
|
||||||
convertTimestampToDateString(document.createdAt),
|
convertTimestampToDateString(
|
||||||
|
document.createdAt),
|
||||||
context),
|
context),
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
style: Theme.of(context).textTheme.bodySmall,
|
||||||
),
|
),
|
||||||
|
|
@ -111,7 +183,8 @@ class DocumentListItem extends StatelessWidget {
|
||||||
EntityStateLabel(document),
|
EntityStateLabel(document),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue