TF-3344 Handle separator when submit list of mail addresses in text
This commit is contained in:
committed by
Dat H. Pham
parent
68b9291e68
commit
3d1b4bdfbb
@@ -9,6 +9,7 @@ import 'package:core/presentation/utils/responsive_utils.dart';
|
|||||||
import 'package:core/presentation/views/button/tmail_button_widget.dart';
|
import 'package:core/presentation/views/button/tmail_button_widget.dart';
|
||||||
import 'package:core/utils/app_logger.dart';
|
import 'package:core/utils/app_logger.dart';
|
||||||
import 'package:core/utils/platform_info.dart';
|
import 'package:core/utils/platform_info.dart';
|
||||||
|
import 'package:core/utils/string_convert.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||||
@@ -501,11 +502,27 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
|||||||
void _handleSubmitTagAction(
|
void _handleSubmitTagAction(
|
||||||
String value,
|
String value,
|
||||||
StateSetter stateSetter
|
StateSetter stateSetter
|
||||||
) {
|
) => _createMailTag(value, stateSetter);
|
||||||
final textTrim = value.trim();
|
|
||||||
if (!_isDuplicatedRecipient(textTrim)) {
|
void _createMailTag(String value, StateSetter stateSetter) {
|
||||||
stateSetter(() => _currentListEmailAddress.add(EmailAddress(null, textTrim)));
|
final listString = StringConvert.extractStrings(value.trim()).toSet();
|
||||||
|
|
||||||
|
if (listString.isEmpty && !_isDuplicatedRecipient(value)) {
|
||||||
|
stateSetter(() => _currentListEmailAddress.add(EmailAddress(null, value)));
|
||||||
_updateListEmailAddressAction();
|
_updateListEmailAddressAction();
|
||||||
|
} else if (listString.isNotEmpty) {
|
||||||
|
final listStringNotExist = listString
|
||||||
|
.where((text) => !_isDuplicatedRecipient(text))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
if (listStringNotExist.isNotEmpty) {
|
||||||
|
final listAddress = listStringNotExist
|
||||||
|
.map((text) => EmailAddress(null, text))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
stateSetter(() => _currentListEmailAddress.addAll(listAddress));
|
||||||
|
_updateListEmailAddressAction();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user