Fix alignment receive time in email view

This commit is contained in:
dab246
2024-09-16 09:33:20 +07:00
committed by Dat H. Pham
parent cf67fda510
commit f2b1eab5bc
2 changed files with 200 additions and 198 deletions
@@ -147,175 +147,173 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
const SizedBox(width: RecipientComposerWidgetStyle.space), const SizedBox(width: RecipientComposerWidgetStyle.space),
Expanded( Expanded(
child: FocusScope( child: FocusScope(
child: Focus( onFocusChange: (focus) => widget.onFocusEmailAddressChangeAction?.call(widget.prefix, focus),
onFocusChange: (focus) => widget.onFocusEmailAddressChangeAction?.call(widget.prefix, focus), onKeyEvent: PlatformInfo.isWeb ? _recipientInputOnKeyListener : null,
onKeyEvent: PlatformInfo.isWeb ? _recipientInputOnKeyListener : null, child: StatefulBuilder(
child: StatefulBuilder( builder: (context, stateSetter) {
builder: (context, stateSetter) { if (PlatformInfo.isWeb || widget.isTestingForWeb) {
if (PlatformInfo.isWeb || widget.isTestingForWeb) { return DragTarget<DraggableEmailAddress>(
return DragTarget<DraggableEmailAddress>( builder: (context, candidateData, rejectedData) {
builder: (context, candidateData, rejectedData) { return TagEditor<SuggestionEmailAddress>(
return TagEditor<SuggestionEmailAddress>( key: widget.keyTagEditor,
key: widget.keyTagEditor, length: _collapsedListEmailAddress.length,
length: _collapsedListEmailAddress.length, controller: widget.controller,
controller: widget.controller, focusNode: widget.focusNode,
focusNode: widget.focusNode, enableBorder: _isDragging,
enableBorder: _isDragging, focusNodeKeyboard: widget.focusNodeKeyboard,
focusNodeKeyboard: widget.focusNodeKeyboard, borderRadius: RecipientComposerWidgetStyle.enableBorderRadius,
borderRadius: RecipientComposerWidgetStyle.enableBorderRadius, enableBorderColor: RecipientComposerWidgetStyle.enableBorderColor,
enableBorderColor: RecipientComposerWidgetStyle.enableBorderColor, keyboardType: TextInputType.emailAddress,
keyboardType: TextInputType.emailAddress, textInputAction: TextInputAction.done,
textInputAction: TextInputAction.done, debounceDuration: RecipientComposerWidgetStyle.suggestionDebounceDuration,
debounceDuration: RecipientComposerWidgetStyle.suggestionDebounceDuration, tagSpacing: RecipientComposerWidgetStyle.tagSpacing,
tagSpacing: RecipientComposerWidgetStyle.tagSpacing, autofocus: widget.prefix != PrefixEmailAddress.to && _currentListEmailAddress.isEmpty,
autofocus: widget.prefix != PrefixEmailAddress.to && _currentListEmailAddress.isEmpty, minTextFieldWidth: RecipientComposerWidgetStyle.minTextFieldWidth,
minTextFieldWidth: RecipientComposerWidgetStyle.minTextFieldWidth, resetTextOnSubmitted: true,
resetTextOnSubmitted: true, autoScrollToInput: false,
autoScrollToInput: false, autoHideTextInputField: true,
autoHideTextInputField: true, cursorColor: RecipientComposerWidgetStyle.cursorColor,
cursorColor: RecipientComposerWidgetStyle.cursorColor, suggestionsBoxElevation: RecipientComposerWidgetStyle.suggestionsBoxElevation,
suggestionsBoxElevation: RecipientComposerWidgetStyle.suggestionsBoxElevation, suggestionsBoxBackgroundColor: RecipientComposerWidgetStyle.suggestionsBoxBackgroundColor,
suggestionsBoxBackgroundColor: RecipientComposerWidgetStyle.suggestionsBoxBackgroundColor, suggestionsBoxRadius: RecipientComposerWidgetStyle.suggestionsBoxRadius,
suggestionsBoxRadius: RecipientComposerWidgetStyle.suggestionsBoxRadius, suggestionsBoxMaxHeight: RecipientComposerWidgetStyle.suggestionsBoxMaxHeight,
suggestionsBoxMaxHeight: RecipientComposerWidgetStyle.suggestionsBoxMaxHeight, suggestionBoxWidth: _getSuggestionBoxWidth(widget.maxWidth),
suggestionBoxWidth: _getSuggestionBoxWidth(widget.maxWidth), textStyle: RecipientComposerWidgetStyle.inputTextStyle,
textStyle: RecipientComposerWidgetStyle.inputTextStyle, onFocusTagAction: (focused) => _handleFocusTagAction.call(focused, stateSetter),
onFocusTagAction: (focused) => _handleFocusTagAction.call(focused, stateSetter), onDeleteTagAction: () => _handleDeleteLatestTagAction.call(stateSetter),
onDeleteTagAction: () => _handleDeleteLatestTagAction.call(stateSetter), onSelectOptionAction: (item) => _handleSelectOptionAction.call(item, stateSetter),
onSelectOptionAction: (item) => _handleSelectOptionAction.call(item, stateSetter), onSubmitted: (value) => _handleSubmitTagAction.call(value, stateSetter),
onSubmitted: (value) => _handleSubmitTagAction.call(value, stateSetter), onTapOutside: (_) {},
onTapOutside: (_) {}, onFocusTextInput: () {
onFocusTextInput: () { if (_isCollapse) {
if (_isCollapse) { widget.onShowFullListEmailAddressAction?.call(widget.prefix);
widget.onShowFullListEmailAddressAction?.call(widget.prefix); }
} },
}, inputDecoration: const InputDecoration(border: InputBorder.none),
inputDecoration: const InputDecoration(border: InputBorder.none), tagBuilder: (context, index) {
tagBuilder: (context, index) { final currentEmailAddress = _currentListEmailAddress[index];
final currentEmailAddress = _currentListEmailAddress[index]; final isLatestEmail = currentEmailAddress == _currentListEmailAddress.last;
final isLatestEmail = currentEmailAddress == _currentListEmailAddress.last;
return RecipientTagItemWidget( return RecipientTagItemWidget(
index: index, index: index,
imagePaths: widget.imagePaths, imagePaths: widget.imagePaths,
prefix: widget.prefix, prefix: widget.prefix,
currentEmailAddress: currentEmailAddress, currentEmailAddress: currentEmailAddress,
currentListEmailAddress: _currentListEmailAddress, currentListEmailAddress: _currentListEmailAddress,
collapsedListEmailAddress: _collapsedListEmailAddress, collapsedListEmailAddress: _collapsedListEmailAddress,
isLatestEmail: isLatestEmail, isLatestEmail: isLatestEmail,
isCollapsed: _isCollapse, isCollapsed: _isCollapse,
isLatestTagFocused: _lastTagFocused, isLatestTagFocused: _lastTagFocused,
maxWidth: widget.maxWidth, maxWidth: widget.maxWidth,
onDeleteTagAction: (emailAddress) => _handleDeleteTagAction.call(emailAddress, stateSetter), onDeleteTagAction: (emailAddress) => _handleDeleteTagAction.call(emailAddress, stateSetter),
onShowFullAction: widget.onShowFullListEmailAddressAction, onShowFullAction: widget.onShowFullListEmailAddressAction,
); );
}, },
onTagChanged: (value) => _handleOnTagChangeAction.call(value, stateSetter), onTagChanged: (value) => _handleOnTagChangeAction.call(value, stateSetter),
findSuggestions: _findSuggestions, findSuggestions: _findSuggestions,
useDefaultHighlight: false, useDefaultHighlight: false,
suggestionBuilder: (context, tagEditorState, suggestionEmailAddress, index, length, highlight, suggestionValid) { suggestionBuilder: (context, tagEditorState, suggestionEmailAddress, index, length, highlight, suggestionValid) {
return RecipientSuggestionItemWidget( return RecipientSuggestionItemWidget(
imagePaths: widget.imagePaths, imagePaths: widget.imagePaths,
suggestionState: suggestionEmailAddress.state, suggestionState: suggestionEmailAddress.state,
emailAddress: suggestionEmailAddress.emailAddress, emailAddress: suggestionEmailAddress.emailAddress,
suggestionValid: suggestionValid, suggestionValid: suggestionValid,
highlight: highlight, highlight: highlight,
onSelectedAction: (emailAddress) { onSelectedAction: (emailAddress) {
stateSetter(() => _currentListEmailAddress.add(emailAddress)); stateSetter(() => _currentListEmailAddress.add(emailAddress));
_updateListEmailAddressAction(); _updateListEmailAddressAction();
tagEditorState.resetTextField(); tagEditorState.resetTextField();
tagEditorState.closeSuggestionBox(); tagEditorState.closeSuggestionBox();
}, },
); );
}, },
); );
}, },
onAcceptWithDetails: (draggableEmailAddress) => _handleAcceptDraggableEmailAddressAction(draggableEmailAddress.data, stateSetter), onAcceptWithDetails: (draggableEmailAddress) => _handleAcceptDraggableEmailAddressAction(draggableEmailAddress.data, stateSetter),
onLeave: (draggableEmailAddress) { onLeave: (draggableEmailAddress) {
if (_isDragging) { if (_isDragging) {
stateSetter(() => _isDragging = false); stateSetter(() => _isDragging = false);
} }
}, },
onMove: (details) { onMove: (details) {
if (!_isDragging) { if (!_isDragging) {
stateSetter(() => _isDragging = true); stateSetter(() => _isDragging = true);
} }
}, },
); );
} else { } else {
return TagEditor<SuggestionEmailAddress>( return TagEditor<SuggestionEmailAddress>(
key: widget.keyTagEditor, key: widget.keyTagEditor,
length: _collapsedListEmailAddress.length, length: _collapsedListEmailAddress.length,
controller: widget.controller, controller: widget.controller,
focusNode: widget.focusNode, focusNode: widget.focusNode,
focusNodeKeyboard: widget.focusNodeKeyboard, focusNodeKeyboard: widget.focusNodeKeyboard,
keyboardType: TextInputType.emailAddress, keyboardType: TextInputType.emailAddress,
textInputAction: TextInputAction.done, textInputAction: TextInputAction.done,
debounceDuration: RecipientComposerWidgetStyle.suggestionDebounceDuration, debounceDuration: RecipientComposerWidgetStyle.suggestionDebounceDuration,
tagSpacing: RecipientComposerWidgetStyle.tagSpacing, tagSpacing: RecipientComposerWidgetStyle.tagSpacing,
minTextFieldWidth: RecipientComposerWidgetStyle.minTextFieldWidth, minTextFieldWidth: RecipientComposerWidgetStyle.minTextFieldWidth,
resetTextOnSubmitted: true, resetTextOnSubmitted: true,
autoScrollToInput: false, autoScrollToInput: false,
autoHideTextInputField: true, autoHideTextInputField: true,
cursorColor: RecipientComposerWidgetStyle.cursorColor, cursorColor: RecipientComposerWidgetStyle.cursorColor,
suggestionsBoxElevation: RecipientComposerWidgetStyle.suggestionsBoxElevation, suggestionsBoxElevation: RecipientComposerWidgetStyle.suggestionsBoxElevation,
suggestionsBoxBackgroundColor: RecipientComposerWidgetStyle.suggestionsBoxBackgroundColor, suggestionsBoxBackgroundColor: RecipientComposerWidgetStyle.suggestionsBoxBackgroundColor,
suggestionsBoxRadius: RecipientComposerWidgetStyle.suggestionsBoxRadius, suggestionsBoxRadius: RecipientComposerWidgetStyle.suggestionsBoxRadius,
suggestionsBoxMaxHeight: RecipientComposerWidgetStyle.suggestionsBoxMaxHeight, suggestionsBoxMaxHeight: RecipientComposerWidgetStyle.suggestionsBoxMaxHeight,
suggestionBoxWidth: _getSuggestionBoxWidth(widget.maxWidth), suggestionBoxWidth: _getSuggestionBoxWidth(widget.maxWidth),
textStyle: RecipientComposerWidgetStyle.inputTextStyle, textStyle: RecipientComposerWidgetStyle.inputTextStyle,
onFocusTagAction: (focused) => _handleFocusTagAction.call(focused, stateSetter), onFocusTagAction: (focused) => _handleFocusTagAction.call(focused, stateSetter),
onDeleteTagAction: () => _handleDeleteLatestTagAction.call(stateSetter), onDeleteTagAction: () => _handleDeleteLatestTagAction.call(stateSetter),
onSelectOptionAction: (item) => _handleSelectOptionAction.call(item, stateSetter), onSelectOptionAction: (item) => _handleSelectOptionAction.call(item, stateSetter),
onSubmitted: (value) => _handleSubmitTagAction.call(value, stateSetter), onSubmitted: (value) => _handleSubmitTagAction.call(value, stateSetter),
onTapOutside: (_) {}, onTapOutside: (_) {},
onFocusTextInput: () { onFocusTextInput: () {
if (_isCollapse) { if (_isCollapse) {
widget.onShowFullListEmailAddressAction?.call(widget.prefix); widget.onShowFullListEmailAddressAction?.call(widget.prefix);
} }
}, },
inputDecoration: const InputDecoration(border: InputBorder.none), inputDecoration: const InputDecoration(border: InputBorder.none),
tagBuilder: (context, index) { tagBuilder: (context, index) {
final currentEmailAddress = _currentListEmailAddress[index]; final currentEmailAddress = _currentListEmailAddress[index];
final isLatestEmail = currentEmailAddress == _currentListEmailAddress.last; final isLatestEmail = currentEmailAddress == _currentListEmailAddress.last;
return RecipientTagItemWidget( return RecipientTagItemWidget(
index: index, index: index,
imagePaths: widget.imagePaths, imagePaths: widget.imagePaths,
prefix: widget.prefix, prefix: widget.prefix,
currentEmailAddress: currentEmailAddress, currentEmailAddress: currentEmailAddress,
currentListEmailAddress: _currentListEmailAddress, currentListEmailAddress: _currentListEmailAddress,
collapsedListEmailAddress: _collapsedListEmailAddress, collapsedListEmailAddress: _collapsedListEmailAddress,
isLatestEmail: isLatestEmail, isLatestEmail: isLatestEmail,
isCollapsed: _isCollapse, isCollapsed: _isCollapse,
isLatestTagFocused: _lastTagFocused, isLatestTagFocused: _lastTagFocused,
maxWidth: widget.maxWidth, maxWidth: widget.maxWidth,
onDeleteTagAction: (emailAddress) => _handleDeleteTagAction.call(emailAddress, stateSetter), onDeleteTagAction: (emailAddress) => _handleDeleteTagAction.call(emailAddress, stateSetter),
onShowFullAction: widget.onShowFullListEmailAddressAction, onShowFullAction: widget.onShowFullListEmailAddressAction,
); );
}, },
onTagChanged: (value) => _handleOnTagChangeAction.call(value, stateSetter), onTagChanged: (value) => _handleOnTagChangeAction.call(value, stateSetter),
findSuggestions: _findSuggestions, findSuggestions: _findSuggestions,
useDefaultHighlight: false, useDefaultHighlight: false,
suggestionBuilder: (context, tagEditorState, suggestionEmailAddress, index, length, highlight, suggestionValid) { suggestionBuilder: (context, tagEditorState, suggestionEmailAddress, index, length, highlight, suggestionValid) {
return RecipientSuggestionItemWidget( return RecipientSuggestionItemWidget(
imagePaths: widget.imagePaths, imagePaths: widget.imagePaths,
suggestionState: suggestionEmailAddress.state, suggestionState: suggestionEmailAddress.state,
emailAddress: suggestionEmailAddress.emailAddress, emailAddress: suggestionEmailAddress.emailAddress,
suggestionValid: suggestionValid, suggestionValid: suggestionValid,
highlight: highlight, highlight: highlight,
onSelectedAction: (emailAddress) { onSelectedAction: (emailAddress) {
stateSetter(() => _currentListEmailAddress.add(emailAddress)); stateSetter(() => _currentListEmailAddress.add(emailAddress));
_updateListEmailAddressAction(); _updateListEmailAddressAction();
tagEditorState.resetTextField(); tagEditorState.resetTextField();
tagEditorState.closeSuggestionBox(); tagEditorState.closeSuggestionBox();
}, },
); );
}, },
); );
} }
}, },
)
) )
) )
), ),
@@ -58,38 +58,42 @@ class InformationSenderAndReceiverBuilder extends StatelessWidget {
children: [ children: [
if (emailSelected.from?.isNotEmpty == true) if (emailSelected.from?.isNotEmpty == true)
Row(children: [ Row(children: [
Flexible(child: Transform( Expanded(child: Row(
transform: Matrix4.translationValues(-5.0, 0.0, 0.0), children: [
child: EmailSenderBuilder( Flexible(child: Transform(
emailAddress: emailSelected.from!.first, transform: Matrix4.translationValues(-5.0, 0.0, 0.0),
openEmailAddressDetailAction: openEmailAddressDetailAction, child: EmailSenderBuilder(
) emailAddress: emailSelected.from!.first,
)), openEmailAddressDetailAction: openEmailAddressDetailAction,
if (sMimeStatus != null && sMimeStatus != SMimeSignatureStatus.notSigned) )
Tooltip( )),
key: const Key('smime_signature_status_icon'), if (sMimeStatus != null && sMimeStatus != SMimeSignatureStatus.notSigned)
message: sMimeStatus!.getTooltipMessage(context), Tooltip(
child: MouseRegion( key: const Key('smime_signature_status_icon'),
cursor: SystemMouseCursors.click, message: sMimeStatus!.getTooltipMessage(context),
child: SvgPicture.asset( child: MouseRegion(
sMimeStatus!.getIcon(imagePaths), cursor: SystemMouseCursors.click,
fit: BoxFit.fill, child: SvgPicture.asset(
sMimeStatus!.getIcon(imagePaths),
fit: BoxFit.fill,
),
),
), ),
), if (!emailSelected.isSubscribed && emailUnsubscribe != null && !responsiveUtils.isPortraitMobile(context))
), TMailButtonWidget.fromText(
if (!emailSelected.isSubscribed && emailUnsubscribe != null && !responsiveUtils.isPortraitMobile(context)) text: AppLocalizations.of(context).unsubscribe,
TMailButtonWidget.fromText( textStyle: const TextStyle(
text: AppLocalizations.of(context).unsubscribe, fontWeight: FontWeight.normal,
textStyle: const TextStyle( fontSize: 14,
fontWeight: FontWeight.normal, color: AppColor.colorTextBody,
fontSize: 14, decoration: TextDecoration.underline,
color: AppColor.colorTextBody, ),
decoration: TextDecoration.underline, padding: const EdgeInsetsDirectional.symmetric(vertical: 5, horizontal: 8),
), backgroundColor: Colors.transparent,
padding: const EdgeInsetsDirectional.symmetric(vertical: 5, horizontal: 8), onTapActionCallback: () => onEmailActionClick?.call(emailSelected, EmailActionType.unsubscribe),
backgroundColor: Colors.transparent, ),
onTapActionCallback: () => onEmailActionClick?.call(emailSelected, EmailActionType.unsubscribe), ]
), )),
ReceivedTimeBuilder(emailSelected: emailSelected), ReceivedTimeBuilder(emailSelected: emailSelected),
]), ]),
if (emailSelected.numberOfAllEmailAddress() > 0) if (emailSelected.numberOfAllEmailAddress() > 0)