TF-235 Add presentation for rename a mailbox
This commit is contained in:
@@ -42,12 +42,14 @@ export 'presentation/views/context_menu/simple_context_menu_action_builder.dart'
|
||||
export 'presentation/views/dialog/loading_dialog_builder.dart';
|
||||
export 'presentation/views/dialog/downloading_file_dialog_builder.dart';
|
||||
export 'presentation/views/dialog/confirmation_dialog_builder.dart';
|
||||
export 'presentation/views/dialog/edit_text_dialog_builder.dart';
|
||||
export 'presentation/views/background/background_widget_builder.dart';
|
||||
export 'presentation/views/html_viewer/html_content_viewer_widget.dart';
|
||||
export 'presentation/views/floating_button/scrolling_floating_button_animated.dart';
|
||||
export 'presentation/views/bottom_popup/cupertino_action_sheet_action_builder.dart';
|
||||
export 'presentation/views/bottom_popup/cupertino_action_sheet_builder.dart';
|
||||
export 'presentation/views/bottom_popup/confirmation_dialog_action_sheet_builder.dart';
|
||||
export 'presentation/views/modal_sheets/edit_text_modal_sheet_builder.dart';
|
||||
|
||||
// Resources
|
||||
export 'presentation/resources/assets_paths.dart';
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
typedef OnConfirmButtonEditDialogAction = void Function(String);
|
||||
typedef SetErrorStringEditDialog = String? Function(String);
|
||||
|
||||
class EditTextDialogBuilder {
|
||||
late TextEditingController _textController;
|
||||
|
||||
Key? _key;
|
||||
String _title = '';
|
||||
String _hintText = '';
|
||||
String _confirmText = '';
|
||||
String _cancelText = '';
|
||||
|
||||
OnConfirmButtonEditDialogAction? _onConfirmButtonAction;
|
||||
|
||||
SetErrorStringEditDialog? _setErrorString;
|
||||
String? _error;
|
||||
Timer? _debounce;
|
||||
|
||||
EditTextDialogBuilder();
|
||||
|
||||
void key(Key key) {
|
||||
_key = key;
|
||||
}
|
||||
|
||||
void title(String title) {
|
||||
_title = title;
|
||||
}
|
||||
|
||||
void hintText(String hintText) {
|
||||
_hintText = hintText;
|
||||
}
|
||||
|
||||
void cancelText(String cancelText) {
|
||||
_cancelText = cancelText;
|
||||
}
|
||||
|
||||
void onConfirmButtonAction(String confirmText, OnConfirmButtonEditDialogAction? onConfirmButtonAction) {
|
||||
_confirmText = confirmText;
|
||||
_onConfirmButtonAction = onConfirmButtonAction;
|
||||
}
|
||||
|
||||
void setTextController(TextEditingController textEditingController) {
|
||||
_textController = textEditingController;
|
||||
}
|
||||
|
||||
void setTextSelection(TextSelection textSelection, {required String value}) {
|
||||
_textController = TextEditingController.fromValue(TextEditingValue(text: value, selection: textSelection));
|
||||
}
|
||||
|
||||
void setErrorString(SetErrorStringModelSheets setErrorString) {
|
||||
_setErrorString = setErrorString;
|
||||
}
|
||||
|
||||
void _onTextChanged(String name, StateSetter setState) {
|
||||
if (_debounce?.isActive ?? false) _debounce?.cancel();
|
||||
_debounce = Timer(const Duration(milliseconds: 500), () {
|
||||
setState(() {
|
||||
_error = (_setErrorString != null) ? _setErrorString!(name) : '';
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void _onConfirmButtonPress(BuildContext context) {
|
||||
if (_error == null || (_error != null && _error!.isEmpty)) {
|
||||
Get.back();
|
||||
_onConfirmButtonAction?.call(_textController.text);
|
||||
}
|
||||
}
|
||||
|
||||
void _onCancelButtonPress(BuildContext context) {
|
||||
Get.back();
|
||||
_debounce?.cancel();
|
||||
}
|
||||
|
||||
Widget build() {
|
||||
return Dialog(
|
||||
key: _key,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(20))),
|
||||
insetPadding: EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0),
|
||||
child: Container(
|
||||
margin: EdgeInsets.zero,
|
||||
padding: EdgeInsets.zero,
|
||||
width: 400,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.all(Radius.circular(20))),
|
||||
child: StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
|
||||
return Container(
|
||||
padding: EdgeInsets.only(left: 30, right: 30, top: 30, bottom: 24),
|
||||
child: Wrap(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
_title,
|
||||
style: TextStyle(fontSize: 20, color: AppColor.colorNameEmail, fontWeight: FontWeight.w700),
|
||||
textAlign: TextAlign.center),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 20),
|
||||
child: TextFormField(
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
onChanged: (value) => _onTextChanged(value, setState),
|
||||
autofocus: true,
|
||||
controller: _textController,
|
||||
decoration: InputDecoration(
|
||||
errorText: _error,
|
||||
enabledBorder: UnderlineInputBorder(borderSide: BorderSide(color: AppColor.colorDividerMailbox)),
|
||||
hintText: _hintText),
|
||||
)
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 16, right: 16, top: 24),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildButton(
|
||||
name: _cancelText,
|
||||
bgColor: AppColor.colorContentEmail,
|
||||
action: () => _onCancelButtonPress(context))
|
||||
),
|
||||
SizedBox(width: 20),
|
||||
Expanded(
|
||||
child: _buildButton(
|
||||
name: _confirmText,
|
||||
bgColor: (_error == null || (_error != null && _error!.isEmpty))
|
||||
? AppColor.colorTextButton
|
||||
: AppColor.colorDisableMailboxCreateButton,
|
||||
nameColor: (_error == null || (_error != null && _error!.isEmpty))
|
||||
? Colors.white
|
||||
: AppColor.colorDisableMailboxCreateButton,
|
||||
action: () => _onConfirmButtonPress(context))
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
],
|
||||
)
|
||||
);
|
||||
})
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildButton({
|
||||
String? name, Color? nameColor, Color? bgColor, Function? action
|
||||
}) {
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
height: 48,
|
||||
child: ElevatedButton(
|
||||
onPressed: () => action?.call(),
|
||||
style: ButtonStyle(
|
||||
foregroundColor: MaterialStateProperty.resolveWith<Color>(
|
||||
(Set<MaterialState> states) => bgColor ?? AppColor.colorTextButton),
|
||||
backgroundColor: MaterialStateProperty.resolveWith<Color>(
|
||||
(Set<MaterialState> states) => bgColor ?? AppColor.colorTextButton),
|
||||
shape: MaterialStateProperty.all(RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
side: BorderSide(width: 0, color: bgColor ?? AppColor.colorTextButton),
|
||||
)),
|
||||
padding: MaterialStateProperty.resolveWith<EdgeInsets>(
|
||||
(Set<MaterialState> states) => EdgeInsets.symmetric(horizontal: 16)),
|
||||
elevation: MaterialStateProperty.resolveWith<double>((Set<MaterialState> states) => 0)),
|
||||
child: Text(name ?? '',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: nameColor ?? Colors.white)),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
typedef OnConfirmModelSheetsActionClick = void Function(String);
|
||||
typedef SetErrorStringModelSheets = String? Function(String);
|
||||
|
||||
class EditTextModalSheetBuilder {
|
||||
@protected
|
||||
late TextEditingController _textController;
|
||||
|
||||
@protected
|
||||
late Key _key;
|
||||
|
||||
@protected
|
||||
String _title = '';
|
||||
|
||||
@protected
|
||||
String _cancelText = '';
|
||||
|
||||
@protected
|
||||
String _confirmText = '';
|
||||
|
||||
@protected
|
||||
String _hintText = '';
|
||||
|
||||
@protected
|
||||
OnConfirmModelSheetsActionClick? _onConfirmActionClick;
|
||||
|
||||
@protected
|
||||
SetErrorStringModelSheets? _setErrorString;
|
||||
|
||||
@protected
|
||||
String? _error;
|
||||
|
||||
@protected
|
||||
Timer? _debounce;
|
||||
|
||||
@protected
|
||||
BoxConstraints? _constraints;
|
||||
|
||||
EditTextModalSheetBuilder();
|
||||
|
||||
void key(Key key) {
|
||||
_key = key;
|
||||
}
|
||||
|
||||
void title(String title) {
|
||||
_title = title;
|
||||
}
|
||||
|
||||
void cancelText(String cancelText) {
|
||||
_cancelText = cancelText;
|
||||
}
|
||||
|
||||
void hintText(String hintText) {
|
||||
_hintText = hintText;
|
||||
}
|
||||
|
||||
void boxConstraints(BoxConstraints? constraints) {
|
||||
_constraints = constraints;
|
||||
}
|
||||
|
||||
void setTextController(TextEditingController textEditingController) {
|
||||
_textController = textEditingController;
|
||||
}
|
||||
|
||||
void setTextSelection(TextSelection textSelection, {required String value}) {
|
||||
_textController = TextEditingController.fromValue(TextEditingValue(text: value, selection: textSelection));
|
||||
}
|
||||
|
||||
void setErrorString(SetErrorStringModelSheets setErrorString) {
|
||||
_setErrorString = setErrorString;
|
||||
}
|
||||
|
||||
void onConfirmAction(String confirmText, OnConfirmModelSheetsActionClick onConfirmActionClick) {
|
||||
_onConfirmActionClick = onConfirmActionClick;
|
||||
_confirmText = confirmText;
|
||||
}
|
||||
|
||||
void _onTextChanged(String name, StateSetter setState) {
|
||||
if (_debounce?.isActive ?? false) _debounce?.cancel();
|
||||
_debounce = Timer(const Duration(milliseconds: 500), () {
|
||||
setState(() {
|
||||
_error = (_setErrorString != null) ? _setErrorString!(name) : '';
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void _onConfirmButtonPress(BuildContext context) {
|
||||
if (_error == null || (_error != null && _error!.isEmpty)) {
|
||||
Get.back();
|
||||
_onConfirmActionClick?.call(_textController.text);
|
||||
}
|
||||
}
|
||||
|
||||
void _onCancelButtonPress(BuildContext context) {
|
||||
Get.back();
|
||||
_debounce?.cancel();
|
||||
}
|
||||
|
||||
void show(context) {
|
||||
showModalBottomSheet(
|
||||
isScrollControlled: true,
|
||||
context: context,
|
||||
constraints: _constraints,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(20.0),
|
||||
topRight: Radius.circular(20.0))),
|
||||
builder: (BuildContext context) {
|
||||
return StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
|
||||
return Padding(
|
||||
key: _key,
|
||||
padding: MediaQuery.of(context).viewInsets,
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(left: 50, right: 50, top: 48, bottom: 20),
|
||||
child: Wrap(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
_title,
|
||||
style: TextStyle(fontSize: 20, color: AppColor.colorNameEmail, fontWeight: FontWeight.w700),
|
||||
textAlign: TextAlign.center),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 20),
|
||||
child: TextFormField(
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
onChanged: (value) => _onTextChanged(value, setState),
|
||||
autofocus: true,
|
||||
controller: _textController,
|
||||
decoration: InputDecoration(
|
||||
errorText: _error,
|
||||
enabledBorder: UnderlineInputBorder(borderSide: BorderSide(color: AppColor.colorDividerMailbox)),
|
||||
hintText: _hintText),
|
||||
)
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () => _onCancelButtonPress(context),
|
||||
child: Text(_cancelText.toUpperCase(), style: TextStyle(color: AppColor.colorTextButton)),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => _onConfirmButtonPress(context),
|
||||
child: Text(_confirmText.toUpperCase(),
|
||||
style: TextStyle(
|
||||
color: (_error == null || (_error != null && _error!.isEmpty))
|
||||
? AppColor.colorTextButton
|
||||
: AppColor.colorDisableMailboxCreateButton)),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
)
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import 'package:tmail_ui_user/features/mailbox/domain/usecases/refresh_all_mailb
|
||||
import 'package:tmail_ui_user/features/mailbox/domain/usecases/search_mailbox_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/mailbox_controller.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_tree_builder.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/domain/usecases/verify_name_interactor.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
class MailboxBindings extends BaseBindings {
|
||||
@@ -47,6 +48,7 @@ class MailboxBindings extends BaseBindings {
|
||||
Get.find<CreateNewMailboxInteractor>(),
|
||||
Get.find<SearchMailboxInteractor>(),
|
||||
Get.find<DeleteMultipleMailboxInteractor>(),
|
||||
Get.find<VerifyNameInteractor>(),
|
||||
Get.find<TreeBuilder>(),
|
||||
Get.find<Uuid>(),
|
||||
Get.find<AppToast>(),
|
||||
@@ -77,6 +79,7 @@ class MailboxBindings extends BaseBindings {
|
||||
Get.lazyPut(() => CreateNewMailboxInteractor(Get.find<MailboxRepository>()));
|
||||
Get.lazyPut(() => SearchMailboxInteractor());
|
||||
Get.lazyPut(() => DeleteMultipleMailboxInteractor(Get.find<MailboxRepository>()));
|
||||
Get.lazyPut(() => VerifyNameInteractor());
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -29,6 +29,12 @@ import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_node.d
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_tree.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_tree_builder.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/extensions/list_mailbox_node_extension.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/domain/model/verification/duplicate_name_validator.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/domain/model/verification/empty_name_validator.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/domain/model/verification/special_character_validator.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/domain/state/verify_name_view_state.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/domain/usecases/verify_name_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/presentation/extensions/validator_failure_extension.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/presentation/model/mailbox_creator_arguments.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/presentation/model/new_mailbox_arguments.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/state/remove_email_drafts_state.dart';
|
||||
@@ -53,6 +59,7 @@ class MailboxController extends BaseController {
|
||||
final CreateNewMailboxInteractor _createNewMailboxInteractor;
|
||||
final SearchMailboxInteractor _searchMailboxInteractor;
|
||||
final DeleteMultipleMailboxInteractor _deleteMultipleMailboxInteractor;
|
||||
final VerifyNameInteractor _verifyNameInteractor;
|
||||
final TreeBuilder _treeBuilder;
|
||||
final Uuid _uuid;
|
||||
final AppToast _appToast;
|
||||
@@ -81,6 +88,7 @@ class MailboxController extends BaseController {
|
||||
this._createNewMailboxInteractor,
|
||||
this._searchMailboxInteractor,
|
||||
this._deleteMultipleMailboxInteractor,
|
||||
this._verifyNameInteractor,
|
||||
this._treeBuilder,
|
||||
this._uuid,
|
||||
this._appToast,
|
||||
@@ -465,6 +473,9 @@ class MailboxController extends BaseController {
|
||||
case MailboxActions.delete:
|
||||
_openConfirmationDialogDeleteMailboxAction(context, selectionMailbox.first);
|
||||
break;
|
||||
case MailboxActions.rename:
|
||||
_openDialogRenameMailboxAction(context, selectionMailbox.first);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -535,6 +546,78 @@ class MailboxController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
void _openDialogRenameMailboxAction(BuildContext context, PresentationMailbox presentationMailbox) {
|
||||
if (responsiveUtils.isMobile(context) || responsiveUtils.isMobileDevice(context)) {
|
||||
(EditTextModalSheetBuilder()
|
||||
..key(Key('rename_mailbox_modal_sheet'))
|
||||
..title(AppLocalizations.of(context).rename_mailbox)
|
||||
..cancelText(AppLocalizations.of(context).cancel)
|
||||
..boxConstraints(responsiveUtils.isMobileDevice(context) && responsiveUtils.isLandscape(context)
|
||||
? BoxConstraints(maxWidth: 400)
|
||||
: null)
|
||||
..onConfirmAction(AppLocalizations.of(context).rename,
|
||||
(value) => _renameMailboxAction(presentationMailbox, value))
|
||||
..setErrorString((value) => getErrorInputNameStringRenameMailbox(context, value))
|
||||
..setTextController(TextEditingController.fromValue(
|
||||
TextEditingValue(
|
||||
text: presentationMailbox.name?.name ?? '',
|
||||
selection: TextSelection(
|
||||
baseOffset: 0,
|
||||
extentOffset: presentationMailbox.name?.name.length ?? 0
|
||||
)
|
||||
))))
|
||||
.show(context);
|
||||
} else {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
|
||||
builder: (BuildContext context) => (EditTextDialogBuilder()
|
||||
..key(Key('rename_mailbox_dialog'))
|
||||
..title(AppLocalizations.of(context).rename_mailbox)
|
||||
..cancelText(AppLocalizations.of(context).cancel)
|
||||
..setErrorString((value) => getErrorInputNameStringRenameMailbox(context, value))
|
||||
..setTextController(TextEditingController.fromValue(
|
||||
TextEditingValue(
|
||||
text: presentationMailbox.name?.name ?? '',
|
||||
selection: TextSelection(
|
||||
baseOffset: 0,
|
||||
extentOffset: presentationMailbox.name?.name.length ?? 0
|
||||
)
|
||||
)))
|
||||
..onConfirmButtonAction(AppLocalizations.of(context).rename,
|
||||
(value) => _renameMailboxAction(presentationMailbox, value)))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
String? getErrorInputNameStringRenameMailbox(BuildContext context, String newName) {
|
||||
final listName = allMailboxes
|
||||
.where((mailbox) => !(mailbox.name.isBlank == true))
|
||||
.map((mailbox) => mailbox.name!.name).toList();
|
||||
|
||||
return _verifyNameInteractor.execute(
|
||||
newName,
|
||||
[
|
||||
EmptyNameValidator(),
|
||||
DuplicateNameValidator(listName),
|
||||
SpecialCharacterValidator(),
|
||||
]
|
||||
).fold(
|
||||
(failure) {
|
||||
if (failure is VerifyNameFailure) {
|
||||
return failure.getMessage(context, actions: MailboxActions.rename);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
(success) => null
|
||||
);
|
||||
}
|
||||
|
||||
void _renameMailboxAction(PresentationMailbox presentationMailbox, String newName) {
|
||||
|
||||
}
|
||||
|
||||
void closeMailboxScreen(BuildContext context) {
|
||||
_cancelSelectMailbox();
|
||||
mailboxDashBoardController.closeDrawer();
|
||||
|
||||
@@ -6,6 +6,7 @@ enum MailboxActions {
|
||||
create,
|
||||
moveEmail,
|
||||
delete,
|
||||
rename,
|
||||
}
|
||||
|
||||
extension MailboxActionsExtension on MailboxActions {
|
||||
|
||||
@@ -45,23 +45,29 @@ class BottomBarSelectionMailboxWidget {
|
||||
..key(Key('button_move_all_mailbox'))
|
||||
..paddingIcon(EdgeInsets.all(8))
|
||||
..textStyle(TextStyle(fontSize: 12, color: AppColor.colorTextButton.withOpacity(0.3)))
|
||||
..iconColor(AppColor.colorTextButton.withOpacity(0.5))
|
||||
..iconColor(AppColor.colorTextButton.withOpacity(0.3))
|
||||
..onPressActionClick(() => {})
|
||||
..text(AppLocalizations.of(_context).move, isVertical: true))
|
||||
.build(),
|
||||
(ButtonBuilder(_imagePaths.icRenameMailbox)
|
||||
..key(Key('button_rename_mailbox'))
|
||||
..paddingIcon(EdgeInsets.all(8))
|
||||
..textStyle(TextStyle(fontSize: 12, color: AppColor.colorTextButton.withOpacity(0.3)))
|
||||
..iconColor(AppColor.colorTextButton.withOpacity(0.5))
|
||||
..onPressActionClick(() => {})
|
||||
..textStyle(TextStyle(
|
||||
fontSize: 12,
|
||||
color: _isRenameMailboxValid ? AppColor.colorTextButton : AppColor.colorTextButton.withOpacity(0.3)))
|
||||
..iconColor(_isRenameMailboxValid ? AppColor.colorTextButton : AppColor.colorTextButton.withOpacity(0.3))
|
||||
..onPressActionClick(() {
|
||||
if (_isRenameMailboxValid) {
|
||||
_onMailboxActionsClick?.call(MailboxActions.rename, _listSelectionMailbox);
|
||||
}
|
||||
})
|
||||
..text(AppLocalizations.of(_context).rename, isVertical: true))
|
||||
.build(),
|
||||
(ButtonBuilder(_imagePaths.icReadV2)
|
||||
..key(Key('button_mark_read_all_mailbox'))
|
||||
..paddingIcon(EdgeInsets.all(8))
|
||||
..textStyle(TextStyle(fontSize: 12, color: AppColor.colorTextButton.withOpacity(0.3)))
|
||||
..iconColor(AppColor.colorTextButton.withOpacity(0.5))
|
||||
..iconColor(AppColor.colorTextButton.withOpacity(0.3))
|
||||
..onPressActionClick(() => {})
|
||||
..text(AppLocalizations.of(_context).mark_as_read, isVertical: true))
|
||||
.build(),
|
||||
@@ -85,5 +91,7 @@ class BottomBarSelectionMailboxWidget {
|
||||
|
||||
bool get _isDeleteMailboxValid => _listSelectionMailbox.length == 1 && _isAllFolderMailbox;
|
||||
|
||||
bool get _isRenameMailboxValid => _listSelectionMailbox.length == 1 && _isAllFolderMailbox;
|
||||
|
||||
bool get _isAllFolderMailbox => _listSelectionMailbox.every((mailbox) => !mailbox.hasRole());
|
||||
}
|
||||
@@ -60,7 +60,9 @@ class MailBoxFolderTileBuilder {
|
||||
data: MediaQueryData(padding: EdgeInsets.zero),
|
||||
child: Column(children: [
|
||||
ListTile(
|
||||
onTap: () => _onOpenMailboxFolderClick?.call(_mailboxNode),
|
||||
onTap: () => allSelectMode == SelectMode.ACTIVE
|
||||
? _onSelectMailboxFolderClick?.call(_mailboxNode)
|
||||
: _onOpenMailboxFolderClick?.call(_mailboxNode),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: allSelectMode == SelectMode.ACTIVE
|
||||
? _buildSelectModeIcon()
|
||||
|
||||
@@ -56,7 +56,9 @@ class MailboxTileBuilder {
|
||||
child: Column(children: [
|
||||
ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onTap: () => _onOpenMailboxActionClick?.call(_presentationMailbox),
|
||||
onTap: () => allSelectMode == SelectMode.ACTIVE
|
||||
? _onSelectMailboxActionClick?.call(_presentationMailbox)
|
||||
: _onOpenMailboxActionClick?.call(_presentationMailbox),
|
||||
leading: allSelectMode == SelectMode.ACTIVE
|
||||
? _buildSelectModeIcon()
|
||||
: _buildMailboxIcon(),
|
||||
|
||||
+8
-1
@@ -1,15 +1,22 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_actions.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/domain/exceptions/verify_name_exception.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/domain/state/verify_name_view_state.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
extension ValicatorFailureExtension on VerifyNameFailure {
|
||||
|
||||
String getMessage(BuildContext context) {
|
||||
String getMessage(BuildContext context, {MailboxActions? actions}) {
|
||||
if (exception is EmptyNameException) {
|
||||
if (actions == MailboxActions.rename) {
|
||||
return AppLocalizations.of(context).this_field_cannot_be_blank;
|
||||
}
|
||||
return AppLocalizations.of(context).name_of_mailbox_is_required;
|
||||
} else if (exception is DuplicatedNameException) {
|
||||
if (actions == MailboxActions.rename) {
|
||||
return AppLocalizations.of(context).there_is_already_folder_with_the_same_name;
|
||||
}
|
||||
return AppLocalizations.of(context).this_folder_name_is_already_taken;
|
||||
} else if (exception is SpecialCharacterException) {
|
||||
return AppLocalizations.of(context).mailbox_name_cannot_contain_special_characters;
|
||||
|
||||
@@ -702,4 +702,24 @@ class AppLocalizations {
|
||||
args: [nameMailbox]
|
||||
);
|
||||
}
|
||||
|
||||
String get rename_mailbox {
|
||||
return Intl.message(
|
||||
'Rename mailbox',
|
||||
name: 'rename_mailbox');
|
||||
}
|
||||
|
||||
String get this_field_cannot_be_blank {
|
||||
return Intl.message(
|
||||
'This field cannot be blank',
|
||||
name: 'this_field_cannot_be_blank',
|
||||
);
|
||||
}
|
||||
|
||||
String get there_is_already_folder_with_the_same_name {
|
||||
return Intl.message(
|
||||
'There is already folder with the same name',
|
||||
name: 'there_is_already_folder_with_the_same_name',
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user