TF-1915 Update state action of sending email item
(cherry picked from commit b23e3389432ec4e385da0d08b79f1727405f0503)
This commit is contained in:
@@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
enum ButtonState {
|
||||||
|
enabled,
|
||||||
|
disabled;
|
||||||
|
|
||||||
|
double get opacity {
|
||||||
|
switch(this) {
|
||||||
|
case ButtonState.enabled:
|
||||||
|
return 1.0;
|
||||||
|
case ButtonState.disabled:
|
||||||
|
return 0.4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -156,7 +156,7 @@ class LocalNotificationManager {
|
|||||||
id.hashCode,
|
id.hashCode,
|
||||||
title,
|
title,
|
||||||
message,
|
message,
|
||||||
LocalNotificationConfig.instance.generateNotificationDetails(),
|
LocalNotificationConfig.instance.generateNotificationDetails(styleInformation: const DefaultStyleInformation(true, true)),
|
||||||
payload: payload
|
payload: payload
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,4 +18,6 @@ extension ListSendingEmailExtension on List<SendingEmail> {
|
|||||||
List<SendingEmail> listSelected() => where((sendingEmail) => sendingEmail.isSelected).toList();
|
List<SendingEmail> listSelected() => where((sendingEmail) => sendingEmail.isSelected).toList();
|
||||||
|
|
||||||
bool isAllNotReadySendingState() => every((sendingEmail) => !sendingEmail.isReady);
|
bool isAllNotReadySendingState() => every((sendingEmail) => !sendingEmail.isReady);
|
||||||
|
|
||||||
|
bool isAllNotDeliveringSendingState() => every((sendingEmail) => !sendingEmail.isDelivering);
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
import 'package:core/presentation/extensions/color_extension.dart';
|
import 'package:core/presentation/extensions/color_extension.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:tmail_ui_user/features/base/state/button_state.dart';
|
||||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||||
|
|
||||||
enum SendingEmailActionType {
|
enum SendingEmailActionType {
|
||||||
@@ -30,25 +31,25 @@ enum SendingEmailActionType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Color getButtonIconColor() {
|
Color getButtonIconColor(ButtonState buttonState) {
|
||||||
switch(this) {
|
switch(this) {
|
||||||
case SendingEmailActionType.delete:
|
case SendingEmailActionType.delete:
|
||||||
return AppColor.colorDeletePermanentlyButton;
|
return AppColor.colorDeletePermanentlyButton.withOpacity(buttonState.opacity);
|
||||||
case SendingEmailActionType.edit:
|
case SendingEmailActionType.edit:
|
||||||
return AppColor.primaryColor;
|
return AppColor.primaryColor.withOpacity(buttonState.opacity);
|
||||||
case SendingEmailActionType.create:
|
case SendingEmailActionType.create:
|
||||||
return Colors.transparent;
|
return Colors.transparent.withOpacity(buttonState.opacity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Color getButtonTitleColor() {
|
Color getButtonTitleColor(ButtonState buttonState) {
|
||||||
switch(this) {
|
switch(this) {
|
||||||
case SendingEmailActionType.delete:
|
case SendingEmailActionType.delete:
|
||||||
return AppColor.colorDeletePermanentlyButton;
|
return AppColor.colorDeletePermanentlyButton.withOpacity(buttonState.opacity);
|
||||||
case SendingEmailActionType.edit:
|
case SendingEmailActionType.edit:
|
||||||
return AppColor.primaryColor;
|
return AppColor.primaryColor.withOpacity(buttonState.opacity);
|
||||||
case SendingEmailActionType.create:
|
case SendingEmailActionType.create:
|
||||||
return Colors.transparent;
|
return Colors.transparent.withOpacity(buttonState.opacity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,7 +38,6 @@ class SendingQueueController extends BaseController with MessageDialogActionMixi
|
|||||||
final _appToast = getBinding<AppToast>();
|
final _appToast = getBinding<AppToast>();
|
||||||
|
|
||||||
final listSendingEmailController = ScrollController();
|
final listSendingEmailController = ScrollController();
|
||||||
final listSendingEmailSelected = <SendingEmail>[].obs;
|
|
||||||
|
|
||||||
final selectionState = Rx<SelectMode>(SelectMode.INACTIVE);
|
final selectionState = Rx<SelectMode>(SelectMode.INACTIVE);
|
||||||
|
|
||||||
@@ -73,8 +72,6 @@ class SendingQueueController extends BaseController with MessageDialogActionMixi
|
|||||||
selectionState.value = newListSendingEmail.isAllUnSelected()
|
selectionState.value = newListSendingEmail.isAllUnSelected()
|
||||||
? SelectMode.INACTIVE
|
? SelectMode.INACTIVE
|
||||||
: SelectMode.ACTIVE;
|
: SelectMode.ACTIVE;
|
||||||
|
|
||||||
listSendingEmailSelected.value = newListSendingEmail.listSelected();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleSelectionSendingEmail(SendingEmail sendingEmail) {
|
void toggleSelectionSendingEmail(SendingEmail sendingEmail) {
|
||||||
@@ -84,12 +81,12 @@ class SendingQueueController extends BaseController with MessageDialogActionMixi
|
|||||||
selectionState.value = newListSendingEmail.isAllUnSelected()
|
selectionState.value = newListSendingEmail.isAllUnSelected()
|
||||||
? SelectMode.INACTIVE
|
? SelectMode.INACTIVE
|
||||||
: SelectMode.ACTIVE;
|
: SelectMode.ACTIVE;
|
||||||
|
|
||||||
listSendingEmailSelected.value = newListSendingEmail.listSelected();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get isAllUnSelected => dashboardController!.listSendingEmails.isAllUnSelected();
|
bool get isAllUnSelected => dashboardController!.listSendingEmails.isAllUnSelected();
|
||||||
|
|
||||||
|
bool get isConnectedNetwork => _networkConnectionController?.isNetworkConnectionAvailable() == true;
|
||||||
|
|
||||||
void _refreshSendingQueue({bool needToReopen = false}) {
|
void _refreshSendingQueue({bool needToReopen = false}) {
|
||||||
dashboardController!.getAllSendingEmails(needToReopen: needToReopen);
|
dashboardController!.getAllSendingEmails(needToReopen: needToReopen);
|
||||||
}
|
}
|
||||||
@@ -114,7 +111,7 @@ class SendingQueueController extends BaseController with MessageDialogActionMixi
|
|||||||
_deleteSendingEmailAction(context, listSendingEmails);
|
_deleteSendingEmailAction(context, listSendingEmails);
|
||||||
break;
|
break;
|
||||||
case SendingEmailActionType.edit:
|
case SendingEmailActionType.edit:
|
||||||
if (_networkConnectionController?.isNetworkConnectionAvailable() == false) {
|
if (!isConnectedNetwork) {
|
||||||
_editSendingEmailAction(listSendingEmails.first);
|
_editSendingEmailAction(listSendingEmails.first);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
import 'package:core/presentation/extensions/color_extension.dart';
|
import 'package:core/presentation/extensions/color_extension.dart';
|
||||||
import 'package:core/utils/app_logger.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tmail_ui_user/features/base/mixin/app_loader_mixin.dart';
|
import 'package:tmail_ui_user/features/base/mixin/app_loader_mixin.dart';
|
||||||
import 'package:tmail_ui_user/features/base/widget/compose_floating_button.dart';
|
import 'package:tmail_ui_user/features/base/widget/compose_floating_button.dart';
|
||||||
@@ -26,7 +25,7 @@ class SendingQueueView extends GetWidget<SendingQueueController> with AppLoaderM
|
|||||||
children: [
|
children: [
|
||||||
Obx(() {
|
Obx(() {
|
||||||
return AppBarSendingQueueWidget(
|
return AppBarSendingQueueWidget(
|
||||||
listSendingEmails: controller.listSendingEmailSelected,
|
listSendingEmailSelected: controller.dashboardController!.listSendingEmails.listSelected(),
|
||||||
onOpenMailboxMenu: controller.openMailboxMenu,
|
onOpenMailboxMenu: controller.openMailboxMenu,
|
||||||
onBackAction: controller.disableSelectionMode,
|
onBackAction: controller.disableSelectionMode,
|
||||||
selectMode: controller.selectionState.value,
|
selectMode: controller.selectionState.value,
|
||||||
@@ -46,7 +45,8 @@ class SendingQueueView extends GetWidget<SendingQueueController> with AppLoaderM
|
|||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
} else {
|
} else {
|
||||||
return BottomBarSendingQueueWidget(
|
return BottomBarSendingQueueWidget(
|
||||||
listSendingEmails: controller.listSendingEmailSelected,
|
listSendingEmailSelected: controller.dashboardController!.listSendingEmails.listSelected(),
|
||||||
|
isConnectedNetwork: controller.isConnectedNetwork,
|
||||||
onHandleSendingEmailActionType: (actionType, listSendingEmails) => controller.handleSendingEmailActionType(context, actionType, listSendingEmails),
|
onHandleSendingEmailActionType: (actionType, listSendingEmails) => controller.handleSendingEmailActionType(context, actionType, listSendingEmails),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -60,22 +60,24 @@ class SendingQueueView extends GetWidget<SendingQueueController> with AppLoaderM
|
|||||||
|
|
||||||
Widget _buildListSendingEmails(BuildContext context) {
|
Widget _buildListSendingEmails(BuildContext context) {
|
||||||
return Obx(() {
|
return Obx(() {
|
||||||
if (controller.dashboardController!.listSendingEmails.isNotEmpty) {
|
final listSendingEmails = controller.dashboardController!.listSendingEmails;
|
||||||
return LayoutBuilder(builder: (context, constraints) {
|
if (listSendingEmails.isNotEmpty) {
|
||||||
log('SendingQueueView::_buildListSendingEmails(): MAX_WIDTH: ${constraints.maxWidth}');
|
return ListView.builder(
|
||||||
return ListView.builder(
|
controller: controller.listSendingEmailController,
|
||||||
controller: controller.listSendingEmailController,
|
itemCount: listSendingEmails.length,
|
||||||
itemCount: controller.dashboardController!.listSendingEmails.length,
|
itemBuilder: (context, index) {
|
||||||
itemBuilder: (context, index) {
|
return SendingEmailTileWidget(
|
||||||
return Obx(() => SendingEmailTileWidget(
|
sendingEmail: listSendingEmails[index],
|
||||||
sendingEmail: controller.dashboardController!.listSendingEmails[index],
|
selectMode: controller.selectionState.value,
|
||||||
selectMode: controller.selectionState.value,
|
onLongPressAction: controller.handleOnLongPressAction,
|
||||||
onLongPressAction: controller.handleOnLongPressAction,
|
onSelectLeadingAction: controller.toggleSelectionSendingEmail,
|
||||||
onSelectLeadingAction: controller.toggleSelectionSendingEmail,
|
onTapAction: (actionType, sendingEmail) {
|
||||||
onTapAction: (actionType, listSendingEmails) => controller.handleSendingEmailActionType(context, actionType, [listSendingEmails])));
|
if (!controller.isConnectedNetwork && sendingEmail.isReady) {
|
||||||
}
|
controller.handleSendingEmailActionType(context, actionType, [sendingEmail]);
|
||||||
);
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ class AppBarSendingQueueWidget extends StatelessWidget {
|
|||||||
final VoidCallback? onBackAction;
|
final VoidCallback? onBackAction;
|
||||||
final VoidCallback? onOpenMailboxMenu;
|
final VoidCallback? onOpenMailboxMenu;
|
||||||
final SelectMode selectMode;
|
final SelectMode selectMode;
|
||||||
final List<SendingEmail> listSendingEmails;
|
final List<SendingEmail> listSendingEmailSelected;
|
||||||
|
|
||||||
const AppBarSendingQueueWidget({
|
const AppBarSendingQueueWidget({
|
||||||
super.key,
|
super.key,
|
||||||
required this.listSendingEmails,
|
required this.listSendingEmailSelected,
|
||||||
this.onBackAction,
|
this.onBackAction,
|
||||||
this.onOpenMailboxMenu,
|
this.onOpenMailboxMenu,
|
||||||
this.selectMode = SelectMode.INACTIVE
|
this.selectMode = SelectMode.INACTIVE
|
||||||
@@ -71,7 +71,7 @@ class AppBarSendingQueueWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Text(
|
Text(
|
||||||
listSendingEmails.length.toString(),
|
listSendingEmailSelected.length.toString(),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
overflow: CommonTextStyle.defaultTextOverFlow,
|
||||||
softWrap: CommonTextStyle.defaultSoftWrap,
|
softWrap: CommonTextStyle.defaultSoftWrap,
|
||||||
|
|||||||
+33
-17
@@ -4,6 +4,7 @@ import 'package:core/presentation/resources/image_paths.dart';
|
|||||||
import 'package:core/presentation/views/button/button_builder.dart';
|
import 'package:core/presentation/views/button/button_builder.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:tmail_ui_user/features/base/state/button_state.dart';
|
||||||
import 'package:tmail_ui_user/features/sending_queue/domain/model/sending_email.dart';
|
import 'package:tmail_ui_user/features/sending_queue/domain/model/sending_email.dart';
|
||||||
import 'package:tmail_ui_user/features/sending_queue/presentation/extensions/list_sending_email_extension.dart';
|
import 'package:tmail_ui_user/features/sending_queue/presentation/extensions/list_sending_email_extension.dart';
|
||||||
import 'package:tmail_ui_user/features/sending_queue/presentation/model/sending_email_action_type.dart';
|
import 'package:tmail_ui_user/features/sending_queue/presentation/model/sending_email_action_type.dart';
|
||||||
@@ -12,13 +13,15 @@ typedef OnHandleSendingEmailActionType = void Function(SendingEmailActionType, L
|
|||||||
|
|
||||||
class BottomBarSendingQueueWidget extends StatelessWidget {
|
class BottomBarSendingQueueWidget extends StatelessWidget {
|
||||||
|
|
||||||
final List<SendingEmail> listSendingEmails;
|
final List<SendingEmail> listSendingEmailSelected;
|
||||||
final OnHandleSendingEmailActionType? onHandleSendingEmailActionType;
|
final OnHandleSendingEmailActionType? onHandleSendingEmailActionType;
|
||||||
|
final bool isConnectedNetwork;
|
||||||
|
|
||||||
const BottomBarSendingQueueWidget({
|
const BottomBarSendingQueueWidget({
|
||||||
super.key,
|
super.key,
|
||||||
required this.listSendingEmails,
|
required this.listSendingEmailSelected,
|
||||||
this.onHandleSendingEmailActionType,
|
this.onHandleSendingEmailActionType,
|
||||||
|
this.isConnectedNetwork = true
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -36,27 +39,40 @@ class BottomBarSendingQueueWidget extends StatelessWidget {
|
|||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
if (!listSendingEmails.isAllSelected() || listSendingEmails.length < 2)
|
Expanded(child: (ButtonBuilder(imagePaths.icEdit)
|
||||||
Expanded(child: (ButtonBuilder(imagePaths.icEdit)
|
..key(Key(SendingEmailActionType.edit.getButtonKey()))
|
||||||
..key(Key(SendingEmailActionType.edit.getButtonKey()))
|
..iconColor(SendingEmailActionType.edit.getButtonIconColor(_isEditable ? ButtonState.enabled : ButtonState.disabled))
|
||||||
..iconColor(SendingEmailActionType.edit.getButtonIconColor())
|
|
||||||
..padding(const EdgeInsets.all(8))
|
|
||||||
..radiusSplash(8)
|
|
||||||
..textStyle(TextStyle(fontSize: 12, color: SendingEmailActionType.edit.getButtonTitleColor()))
|
|
||||||
..onPressActionClick(() => onHandleSendingEmailActionType?.call(SendingEmailActionType.edit, listSendingEmails))
|
|
||||||
..text(SendingEmailActionType.edit.getButtonTitle(context), isVertical: true)
|
|
||||||
).build()),
|
|
||||||
Expanded(child: (ButtonBuilder(imagePaths.icDeleteComposer)
|
|
||||||
..key(Key(SendingEmailActionType.delete.getButtonKey()))
|
|
||||||
..iconColor(SendingEmailActionType.delete.getButtonIconColor())
|
|
||||||
..padding(const EdgeInsets.all(8))
|
..padding(const EdgeInsets.all(8))
|
||||||
..radiusSplash(8)
|
..radiusSplash(8)
|
||||||
..textStyle(TextStyle(fontSize: 12, color: SendingEmailActionType.delete.getButtonTitleColor()))
|
..textStyle(TextStyle(fontSize: 12, color: SendingEmailActionType.edit.getButtonTitleColor(_isEditable ? ButtonState.enabled : ButtonState.disabled)))
|
||||||
..onPressActionClick(() => onHandleSendingEmailActionType?.call(SendingEmailActionType.delete, listSendingEmails))
|
..onPressActionClick(() {
|
||||||
|
if (_isEditable) {
|
||||||
|
onHandleSendingEmailActionType?.call(SendingEmailActionType.edit, listSendingEmailSelected);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
..text(SendingEmailActionType.edit.getButtonTitle(context), isVertical: true)
|
||||||
|
).build()),
|
||||||
|
Expanded(child: (ButtonBuilder(imagePaths.icDeleteComposer)
|
||||||
|
..key(Key(SendingEmailActionType.delete.getButtonKey()))
|
||||||
|
..iconColor(SendingEmailActionType.delete.getButtonIconColor(_isCanBeDeleted ? ButtonState.enabled : ButtonState.disabled))
|
||||||
|
..padding(const EdgeInsets.all(8))
|
||||||
|
..radiusSplash(8)
|
||||||
|
..textStyle(TextStyle(fontSize: 12, color: SendingEmailActionType.delete.getButtonTitleColor(_isCanBeDeleted ? ButtonState.enabled : ButtonState.disabled)))
|
||||||
|
..onPressActionClick(() {
|
||||||
|
if (_isCanBeDeleted) {
|
||||||
|
onHandleSendingEmailActionType?.call(SendingEmailActionType.delete, listSendingEmailSelected);
|
||||||
|
}
|
||||||
|
})
|
||||||
..text(SendingEmailActionType.delete.getButtonTitle(context), isVertical: true)
|
..text(SendingEmailActionType.delete.getButtonTitle(context), isVertical: true)
|
||||||
).build())
|
).build())
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool get _isEditable => !isConnectedNetwork &&
|
||||||
|
listSendingEmailSelected.length == 1 &&
|
||||||
|
listSendingEmailSelected.first.isReady;
|
||||||
|
|
||||||
|
bool get _isCanBeDeleted => listSendingEmailSelected.isAllNotDeliveringSendingState();
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ class SendingEmailTileWidget extends StatelessWidget {
|
|||||||
return Material(
|
return Material(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () => onTapAction?.call(SendingEmailActionType.edit ,sendingEmail),
|
onTap: () => onTapAction?.call(SendingEmailActionType.edit, sendingEmail),
|
||||||
onLongPress: () => onLongPressAction?.call(sendingEmail),
|
onLongPress: () => onLongPressAction?.call(sendingEmail),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
|||||||
Reference in New Issue
Block a user