Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
fix: Disable email button if there is no email app
Browse files Browse the repository at this point in the history
  • Loading branch information
reasje committed Oct 19, 2023
1 parent bafa7ec commit 16bb77b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ class SplashStoragePage extends SplashBasePage {
icon: MxcIcons.email,
iconSize: 18,
title: FlutterI18n.translate(context, 'email_secured_storage'),
onTap: () => Navigator.of(context).push(
route.featureDialog(
EmailRecoveryPhrasePage(
settingsFlow: settingsFlow,
),
),
),
onTap: ref.watch(state).isEmailAppAvailable == true
? () => Navigator.of(context).push(
route.featureDialog(
EmailRecoveryPhrasePage(
settingsFlow: settingsFlow,
),
),
)
: null,
),
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SplashStoragePresenter extends SplashBasePresenter<SplashBaseState> {
@override
void initState() {
super.initState();

isInstallApps();
checkEmailAppAvailability();
}
}
9 changes: 4 additions & 5 deletions lib/features/splash/splash_base/splash_base_presenter.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '../../../common/common.dart';
import '../../../core/core.dart';
import 'package:appinio_social_share/appinio_social_share.dart';
import 'package:flutter_mailer/flutter_mailer.dart';
Expand All @@ -16,11 +17,9 @@ abstract class SplashBasePresenter<T extends SplashBaseState>
notify(() => state.applist = applist);
}

Future<void> isInstallEmail() async {
final result = await FlutterMailer.canSendMail() ||
await FlutterMailer.isAppInstalled('mailto:');

notify(() => state.isInstallEmail = result);
void checkEmailAppAvailability() async {
final isEmailAppAvailable = await Utils.isEmailAppAvailable();
notify(() => state.isEmailAppAvailable = isEmailAppAvailable);
}
}

Expand Down
5 changes: 3 additions & 2 deletions lib/features/splash/splash_base/splash_base_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import 'package:equatable/equatable.dart';

class SplashBaseState with EquatableMixin {
Map applist = {};
bool isInstallEmail = false;
bool isEmailAppAvailable = false;

bool animate = false;

@override
List<Object?> get props => [applist, isInstallEmail, animate];
List<Object?> get props =>
[applist, animate, isEmailAppAvailable];
}

0 comments on commit 16bb77b

Please sign in to comment.