mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-07-03 03:15:51 +02:00
feat(settings): add extension verification browser mode preference
Let users choose whether signed-session verification opens in the external browser or in-app browser first, with automatic fallback to the other mode when launch fails.
This commit is contained in:
@@ -27,7 +27,10 @@ bool _containsHttpStatusCode(String message, String code) {
|
||||
message.contains('$code;');
|
||||
}
|
||||
|
||||
Future<bool> openPendingExtensionVerification(String extensionId) async {
|
||||
Future<bool> openPendingExtensionVerification(
|
||||
String extensionId, {
|
||||
String browserMode = 'external_first',
|
||||
}) async {
|
||||
final normalizedExtensionId = extensionId.trim();
|
||||
if (normalizedExtensionId.isEmpty) return false;
|
||||
|
||||
@@ -41,9 +44,17 @@ Future<bool> openPendingExtensionVerification(String extensionId) async {
|
||||
final uri = Uri.tryParse(authUrl);
|
||||
if (uri == null) return false;
|
||||
|
||||
var launched = await launchUrl(uri, mode: LaunchMode.inAppBrowserView);
|
||||
final preferInApp = browserMode.trim().toLowerCase() == 'in_app_first';
|
||||
final firstMode = preferInApp
|
||||
? LaunchMode.inAppBrowserView
|
||||
: LaunchMode.externalApplication;
|
||||
final fallbackMode = preferInApp
|
||||
? LaunchMode.externalApplication
|
||||
: LaunchMode.inAppBrowserView;
|
||||
|
||||
var launched = await launchUrl(uri, mode: firstMode);
|
||||
if (!launched) {
|
||||
launched = await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||
launched = await launchUrl(uri, mode: fallbackMode);
|
||||
}
|
||||
|
||||
if (launched) {
|
||||
|
||||
Reference in New Issue
Block a user