TF-1866 Display BottomBar when on long press sending email item
(cherry picked from commit dec400499e44c25a9f622424e5e26949f944b5a0)
This commit is contained in:
@@ -14,6 +14,7 @@ import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
|||||||
import 'package:model/email/email_action_type.dart';
|
import 'package:model/email/email_action_type.dart';
|
||||||
import 'package:model/email/presentation_email.dart';
|
import 'package:model/email/presentation_email.dart';
|
||||||
import 'package:model/extensions/email_extension.dart';
|
import 'package:model/extensions/email_extension.dart';
|
||||||
|
import 'package:model/mailbox/select_mode.dart';
|
||||||
|
|
||||||
class SendingEmail with EquatableMixin {
|
class SendingEmail with EquatableMixin {
|
||||||
final String sendingId;
|
final String sendingId;
|
||||||
@@ -26,6 +27,7 @@ class SendingEmail with EquatableMixin {
|
|||||||
final MailboxName? mailboxNameRequest;
|
final MailboxName? mailboxNameRequest;
|
||||||
final Id? creationIdRequest;
|
final Id? creationIdRequest;
|
||||||
final DateTime createTime;
|
final DateTime createTime;
|
||||||
|
final SelectMode selectMode;
|
||||||
|
|
||||||
SendingEmail({
|
SendingEmail({
|
||||||
required this.sendingId,
|
required this.sendingId,
|
||||||
@@ -37,7 +39,8 @@ class SendingEmail with EquatableMixin {
|
|||||||
this.emailIdAnsweredOrForwarded,
|
this.emailIdAnsweredOrForwarded,
|
||||||
this.identityId,
|
this.identityId,
|
||||||
this.mailboxNameRequest,
|
this.mailboxNameRequest,
|
||||||
this.creationIdRequest
|
this.creationIdRequest,
|
||||||
|
this.selectMode = SelectMode.INACTIVE
|
||||||
});
|
});
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
@@ -70,7 +73,6 @@ class SendingEmail with EquatableMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
factory SendingEmail.fromJson(Map<String, dynamic> json) {
|
factory SendingEmail.fromJson(Map<String, dynamic> json) {
|
||||||
|
|
||||||
return SendingEmail(
|
return SendingEmail(
|
||||||
sendingId: json['sendingId'] as String,
|
sendingId: json['sendingId'] as String,
|
||||||
email: Email.fromJson(jsonDecode(json['email'])),
|
email: Email.fromJson(jsonDecode(json['email'])),
|
||||||
@@ -92,6 +94,8 @@ class SendingEmail with EquatableMixin {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool get isSelected => selectMode == SelectMode.ACTIVE;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object?> get props => [
|
List<Object?> get props => [
|
||||||
sendingId,
|
sendingId,
|
||||||
@@ -103,6 +107,7 @@ class SendingEmail with EquatableMixin {
|
|||||||
emailIdAnsweredOrForwarded,
|
emailIdAnsweredOrForwarded,
|
||||||
identityId,
|
identityId,
|
||||||
mailboxNameRequest,
|
mailboxNameRequest,
|
||||||
creationIdRequest
|
creationIdRequest,
|
||||||
|
selectMode
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
import 'package:tmail_ui_user/features/composer/domain/extensions/sending_email_extension.dart';
|
||||||
|
import 'package:tmail_ui_user/features/composer/domain/model/sending_email.dart';
|
||||||
|
|
||||||
|
extension ListSendingEmailExtension on List<SendingEmail> {
|
||||||
|
List<SendingEmail> toggleSelection({required SendingEmail sendingEmailSelected}) =>
|
||||||
|
map((sendingEmail) => sendingEmailSelected.sendingId == sendingEmail.sendingId
|
||||||
|
? sendingEmail.toggleSelection()
|
||||||
|
: sendingEmail
|
||||||
|
).toList();
|
||||||
|
|
||||||
|
List<SendingEmail> unAllSelected() => map((sendingEmail) => sendingEmail.unSelected()).toList();
|
||||||
|
|
||||||
|
bool isAllSelected() => every((sendingEmail) => sendingEmail.isSelected);
|
||||||
|
|
||||||
|
bool isAllUnSelected() => every((sendingEmail) => !sendingEmail.isSelected);
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
|
||||||
|
import 'package:core/presentation/extensions/color_extension.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||||
|
|
||||||
|
enum SendingEmailActionType {
|
||||||
|
delete;
|
||||||
|
|
||||||
|
String getButtonTitle(BuildContext context) {
|
||||||
|
switch(this) {
|
||||||
|
case SendingEmailActionType.delete:
|
||||||
|
return AppLocalizations.of(context).delete;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String getButtonKey() {
|
||||||
|
switch(this) {
|
||||||
|
case SendingEmailActionType.delete:
|
||||||
|
return 'button_delete_sending_email';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Color getButtonIconColor() {
|
||||||
|
switch(this) {
|
||||||
|
case SendingEmailActionType.delete:
|
||||||
|
return AppColor.colorDeletePermanentlyButton;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Color getButtonTitleColor() {
|
||||||
|
switch(this) {
|
||||||
|
case SendingEmailActionType.delete:
|
||||||
|
return AppColor.colorDeletePermanentlyButton;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
|
||||||
|
import 'package:core/presentation/extensions/color_extension.dart';
|
||||||
|
import 'package:core/presentation/resources/image_paths.dart';
|
||||||
|
import 'package:core/presentation/views/button/button_builder.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:tmail_ui_user/features/composer/domain/model/sending_email.dart';
|
||||||
|
import 'package:tmail_ui_user/features/sending_queue/presentation/model/sending_email_action_type.dart';
|
||||||
|
|
||||||
|
typedef OnHandleSendingEmailActionType = void Function(SendingEmailActionType, List<SendingEmail>);
|
||||||
|
|
||||||
|
class BottomBarSendingQueueWidget extends StatelessWidget {
|
||||||
|
|
||||||
|
final List<SendingEmail> listSendingEmails;
|
||||||
|
final OnHandleSendingEmailActionType? onHandleSendingEmailActionType;
|
||||||
|
|
||||||
|
const BottomBarSendingQueueWidget({
|
||||||
|
super.key,
|
||||||
|
required this.listSendingEmails,
|
||||||
|
this.onHandleSendingEmailActionType,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final imagePaths = Get.find<ImagePaths>();
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
border: Border(top: BorderSide(
|
||||||
|
color: AppColor.lineItemListColor,
|
||||||
|
width: 0.2,
|
||||||
|
)),
|
||||||
|
color: Colors.white
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Expanded(child: (ButtonBuilder(imagePaths.icDeleteComposer)
|
||||||
|
..key(Key(SendingEmailActionType.delete.getButtonKey()))
|
||||||
|
..iconColor(SendingEmailActionType.delete.getButtonIconColor())
|
||||||
|
..padding(const EdgeInsets.all(8))
|
||||||
|
..radiusSplash(8)
|
||||||
|
..textStyle(TextStyle(fontSize: 12, color: SendingEmailActionType.delete.getButtonTitleColor()))
|
||||||
|
..onPressActionClick(() => onHandleSendingEmailActionType?.call(SendingEmailActionType.delete, listSendingEmails))
|
||||||
|
..text(SendingEmailActionType.delete.getButtonTitle(context), isVertical: true)
|
||||||
|
).build())
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user