Task statuses

This commit is contained in:
Hillel Coren 2023-05-03 22:18:01 +03:00
parent 47a1298eb7
commit c174442090
3 changed files with 82 additions and 72 deletions

View File

@ -63,36 +63,40 @@ class _CompanyGatewayListState extends State<CompanyGatewayList> {
if (state.isSaving) LinearProgressIndicator(), if (state.isSaving) LinearProgressIndicator(),
RefreshIndicator( RefreshIndicator(
onRefresh: () => widget.viewModel.onRefreshed(context), onRefresh: () => widget.viewModel.onRefreshed(context),
child: ReorderableListView( child: Padding(
scrollController: _controller, padding: const EdgeInsets.all(8),
onReorder: (oldIndex, newIndex) { child: ReorderableListView(
// https://stackoverflow.com/a/54164333/497368 scrollController: _controller,
// These two lines are workarounds for ReorderableListView problems onReorder: (oldIndex, newIndex) {
if (newIndex > widget.viewModel.companyGatewayList.length) { // https://stackoverflow.com/a/54164333/497368
newIndex = widget.viewModel.companyGatewayList.length; // These two lines are workarounds for ReorderableListView problems
} if (newIndex > widget.viewModel.companyGatewayList.length) {
if (oldIndex < newIndex) { newIndex = widget.viewModel.companyGatewayList.length;
newIndex--; }
} if (oldIndex < newIndex) {
newIndex--;
}
widget.viewModel.onSortChanged(oldIndex, newIndex); widget.viewModel.onSortChanged(oldIndex, newIndex);
}, },
children: children:
widget.viewModel.companyGatewayList.map((companyGatewayId) { widget.viewModel.companyGatewayList.map((companyGatewayId) {
final companyGateway = final companyGateway =
widget.viewModel.companyGatewayMap[companyGatewayId]; widget.viewModel.companyGatewayMap[companyGatewayId];
return CompanyGatewayListItem( return CompanyGatewayListItem(
key: ValueKey('__company_gateway_$companyGatewayId'), key: ValueKey('__company_gateway_$companyGatewayId'),
user: state.userCompany.user, user: state.userCompany.user,
filter: widget.viewModel.filter, filter: widget.viewModel.filter,
companyGateway: companyGateway, companyGateway: companyGateway,
onRemovePressed: widget onRemovePressed: widget
.viewModel.state.settingsUIState.isFiltered .viewModel.state.settingsUIState.isFiltered
? () => widget.viewModel.onRemovePressed(companyGatewayId) ? () =>
: null, widget.viewModel.onRemovePressed(companyGatewayId)
isChecked: isInMultiselect && : null,
listUIState.isSelected(companyGateway.id)); isChecked: isInMultiselect &&
}).toList(), listUIState.isSelected(companyGateway.id));
}).toList(),
),
), ),
), ),
], ],

View File

@ -63,35 +63,38 @@ class _TaskStatusListState extends State<TaskStatusList> {
if (state.isSaving) LinearProgressIndicator(), if (state.isSaving) LinearProgressIndicator(),
RefreshIndicator( RefreshIndicator(
onRefresh: () => widget.viewModel.onRefreshed(context), onRefresh: () => widget.viewModel.onRefreshed(context),
child: ReorderableListView( child: Padding(
scrollController: _controller, padding: const EdgeInsets.all(8),
onReorder: (oldIndex, newIndex) { child: ReorderableListView(
// https://stackoverflow.com/a/54164333/497368 scrollController: _controller,
// These two lines are workarounds for ReorderableListView problems onReorder: (oldIndex, newIndex) {
if (newIndex > widget.viewModel.taskStatusList.length) { // https://stackoverflow.com/a/54164333/497368
newIndex = widget.viewModel.taskStatusList.length; // These two lines are workarounds for ReorderableListView problems
} if (newIndex > widget.viewModel.taskStatusList.length) {
if (oldIndex < newIndex) { newIndex = widget.viewModel.taskStatusList.length;
newIndex--; }
} if (oldIndex < newIndex) {
newIndex--;
}
widget.viewModel.onSortChanged(oldIndex, newIndex); widget.viewModel.onSortChanged(oldIndex, newIndex);
}, },
children: viewModel.taskStatusList.map((taskStatusId) { children: viewModel.taskStatusList.map((taskStatusId) {
final taskStatus = viewModel.taskStatusMap[taskStatusId]; final taskStatus = viewModel.taskStatusMap[taskStatusId];
return TaskStatusListItem( return TaskStatusListItem(
key: ValueKey('__task_status_$taskStatusId'), key: ValueKey('__task_status_$taskStatusId'),
user: state.userCompany.user, user: state.userCompany.user,
filter: viewModel.filter, filter: viewModel.filter,
taskStatus: taskStatus, taskStatus: taskStatus,
/* /*
onRemovePressed: widget.viewModel.state.settingsUIState.isFiltered onRemovePressed: widget.viewModel.state.settingsUIState.isFiltered
? () => widget.viewModel.onRemovePressed(companyGatewayId) ? () => widget.viewModel.onRemovePressed(companyGatewayId)
: null, : null,
*/ */
isChecked: isChecked: isInMultiselect &&
isInMultiselect && listUIState.isSelected(taskStatus.id)); listUIState.isSelected(taskStatus.id));
}).toList(), }).toList(),
),
), ),
), ),
], ],

View File

@ -13,6 +13,7 @@ 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/redux/task_status/task_status_actions.dart'; import 'package:invoiceninja_flutter/redux/task_status/task_status_actions.dart';
import 'package:invoiceninja_flutter/ui/app/app_bottom_bar.dart'; import 'package:invoiceninja_flutter/ui/app/app_bottom_bar.dart';
import 'package:invoiceninja_flutter/ui/app/buttons/app_text_button.dart';
import 'package:invoiceninja_flutter/ui/app/entities/entity_actions_dialog.dart'; import 'package:invoiceninja_flutter/ui/app/entities/entity_actions_dialog.dart';
import 'package:invoiceninja_flutter/ui/app/list_filter.dart'; import 'package:invoiceninja_flutter/ui/app/list_filter.dart';
import 'package:invoiceninja_flutter/ui/app/list_scaffold.dart'; import 'package:invoiceninja_flutter/ui/app/list_scaffold.dart';
@ -65,22 +66,24 @@ class TaskStatusScreen extends StatelessWidget {
}, },
appBarActions: [ appBarActions: [
if (viewModel.isInMultiselect) if (viewModel.isInMultiselect)
TextButton( AppTextButton(
onPressed: () async { isInHeader: true,
final taskStatusIds = listUIState.selectedIds onPressed: () async {
.map<TaskStatusEntity>( final taskStatusIds = listUIState.selectedIds
(taskStatusId) => viewModel.taskStatusMap[taskStatusId]) .map<TaskStatusEntity>(
.toList(); (taskStatusId) => viewModel.taskStatusMap[taskStatusId])
.toList();
await showEntityActionsDialog( await showEntityActionsDialog(
entities: taskStatusIds, entities: taskStatusIds,
multiselect: true, multiselect: true,
completer: Completer<Null>() completer: Completer<Null>()
..future.then<dynamic>( ..future.then<dynamic>(
(_) => store.dispatch(ClearTaskStatusMultiselect())), (_) => store.dispatch(ClearTaskStatusMultiselect())),
); );
}, },
child: Text(localization.actions)), label: localization.actions,
),
], ],
body: TaskStatusListBuilder(), body: TaskStatusListBuilder(),
bottomNavigationBar: AppBottomBar( bottomNavigationBar: AppBottomBar(