Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

feat(share-to-multi-contacts-at-once): add new email to list below with selected state

ashilkn987250d4f365
diff --git a/mobile/lib/ui/actions/collection/collection_sharing_actions.dart b/mobile/lib/ui/actions/collection/collection_sharing_actions.dart
index 1e3ac0d95a..dc28197bd8 100644
--- a/mobile/lib/ui/actions/collection/collection_sharing_actions.dart
+++ b/mobile/lib/ui/actions/collection/collection_sharing_actions.dart
@@ -198,6 +198,62 @@ class CollectionActions {
return false;
}
+ Future<bool> doesEmailHaveAccount(
+ BuildContext context,
+ String email, {
+ bool showProgress = false,
+ }) async {
+ ProgressDialog? dialog;
+ String? publicKey;
+ if (showProgress) {
+ dialog = createProgressDialog(
+ context,
+ S.of(context).sharing,
+ isDismissible: true,
+ );
+ await dialog.show();
+ }
+ try {
+ publicKey = await UserService.instance.getPublicKey(email);
+ } catch (e) {
+ await dialog?.hide();
+ logger.severe("Failed to get public key", e);
+ await showGenericErrorDialog(context: context, error: e);
+ return false;
+ }
+ // getPublicKey can return null when no user is associated with given
+ // email id
+ if (publicKey == null || publicKey == '') {
+ // todo: neeraj replace this as per the design where a new screen
+ // is used for error. Do this change along with handling of network errors
+ await showDialogWidget(
+ context: context,
+ title: S.of(context).inviteToEnte,
+ icon: Icons.info_outline,
+ body: S.of(context).emailNoEnteAccount(email),
+ isDismissible: true,
+ buttons: [
+ ButtonWidget(
+ buttonType: ButtonType.neutral,
+ icon: Icons.adaptive.share,
+ labelText: S.of(context).sendInvite,
+ isInAlert: true,
+ onTap: () async {
+ unawaited(
+ shareText(
+ S.of(context).shareTextRecommendUsingEnte,
+ ),
+ );
+ },
+ ),
+ ],
+ );
+ return false;
+ } else {
+ return true;
+ }
+ }
+
// addEmailToCollection returns true if add operation was successful
Future<bool> addEmailToCollection(
BuildContext context,
diff --git a/mobile/lib/ui/components/buttons/button_widget.dart b/mobile/lib/ui/components/buttons/button_widget.dart
index 2d1b170fe1..2e4d2d1dc2 100644
--- a/mobile/lib/ui/components/buttons/button_widget.dart
+++ b/mobile/lib/ui/components/buttons/button_widget.dart
@@ -202,14 +202,14 @@ class _ButtonChildWidgetState extends State<ButtonChildWidget> {
@override
void initState() {
- _setButtonTheme();
super.initState();
+ _setButtonTheme();
}
@override
void didUpdateWidget(covariant ButtonChildWidget oldWidget) {
- _setButtonTheme();
super.didUpdateWidget(oldWidget);
+ _setButtonTheme();
}
@override
diff --git a/mobile/lib/ui/sharing/add_partipant_page.dart b/mobile/lib/ui/sharing/add_partipant_page.dart
index 27c678503d..993005ac70 100644
--- a/mobile/lib/ui/sharing/add_partipant_page.dart
+++ b/mobile/lib/ui/sharing/add_partipant_page.dart
@@ -262,54 +262,81 @@ class _AddParticipantPage extends State<AddParticipantPage> {
}
Widget _enterEmailField() {
- return TextFormField(
- controller: _textController,
- focusNode: textFieldFocusNode,
- style: getEnteTextTheme(context).body,
- autofillHints: const [AutofillHints.email],
- decoration: InputDecoration(
- focusedBorder: OutlineInputBorder(
- borderRadius: const BorderRadius.all(Radius.circular(4.0)),
- borderSide:
- BorderSide(color: getEnteColorScheme(context).strokeMuted),
- ),
- fillColor: getEnteColorScheme(context).fillFaint,
- filled: true,
- hintText: S.of(context).enterEmail,
- contentPadding: const EdgeInsets.symmetric(
- horizontal: 16,
- vertical: 14,
- ),
- border: UnderlineInputBorder(
- borderSide: BorderSide.none,
- borderRadius: BorderRadius.circular(4),
+ return Row(
+ children: [
+ Expanded(
+ child: TextFormField(
+ controller: _textController,
+ focusNode: textFieldFocusNode,
+ style: getEnteTextTheme(context).body,
+ autofillHints: const [AutofillHints.email],
+ decoration: InputDecoration(
+ focusedBorder: OutlineInputBorder(
+ borderRadius: const BorderRadius.all(Radius.circular(4.0)),
+ borderSide:
+ BorderSide(color: getEnteColorScheme(context).strokeMuted),
+ ),
+ fillColor: getEnteColorScheme(context).fillFaint,
+ filled: true,
+ hintText: S.of(context).enterEmail,
+ contentPadding: const EdgeInsets.symmetric(
+ horizontal: 16,
+ vertical: 14,
+ ),
+ border: UnderlineInputBorder(
+ borderSide: BorderSide.none,
+ borderRadius: BorderRadius.circular(4),
+ ),
+ prefixIcon: Icon(
+ Icons.email_outlined,
+ color: getEnteColorScheme(context).strokeMuted,
+ ),
+ suffixIcon: _email == ''
+ ? null
+ : IconButton(
+ onPressed: clearFocus,
+ icon: Icon(
+ Icons.cancel,
+ color: getEnteColorScheme(context).strokeMuted,
+ ),
+ ),
+ ),
+ onChanged: (value) {
+ if (selectedEmail != '') {
+ selectedEmail = '';
+ }
+ _email = value.trim();
+ _emailIsValid = EmailValidator.validate(_email);
+ setState(() {});
+ },
+ autocorrect: false,
+ keyboardType: TextInputType.emailAddress,
+ //initialValue: _email,
+ textInputAction: TextInputAction.next,
+ ),
),
- prefixIcon: Icon(
- Icons.email_outlined,
- color: getEnteColorScheme(context).strokeMuted,
+ const SizedBox(width: 8),
+ ButtonWidget(
+ buttonType: ButtonType.secondary,
+ buttonSize: ButtonSize.small,
+ labelText: "Add",
+ isDisabled: !_emailIsValid,
+ onTap: () async {
+ if (_emailIsValid) {
+ final result = await collectionActions.doesEmailHaveAccount(
+ context,
+ _email,
+ );
+ if (result && mounted) {
+ setState(() {
+ _suggestedUsers.insert(0, User(email: _email));
+ _selectedEmails.add(_email);
+ });
+ }
+ }
+ },
),
- suffixIcon: _email == ''
- ? null
- : IconButton(
- onPressed: clearFocus,
- icon: Icon(
- Icons.cancel,
- color: getEnteColorScheme(context).strokeMuted,
- ),
- ),
- ),
- onChanged: (value) {
- if (selectedEmail != '') {
- selectedEmail = '';
- }
- _email = value.trim();
- _emailIsValid = EmailValidator.validate(_email);
- setState(() {});
- },
- autocorrect: false,
- keyboardType: TextInputType.emailAddress,
- //initialValue: _email,
- textInputAction: TextInputAction.next,
+ ],
);
}