mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-24 04:59:26 +01:00
fix: Close safariviewcontroller on SSO
This commit is contained in:
parent
480b7b45aa
commit
ba685b7a1f
@ -1,5 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import 'package:fluffychat/pages/views/homeserver_picker_view.dart';
|
import 'package:fluffychat/pages/views/homeserver_picker_view.dart';
|
||||||
import 'package:fluffychat/utils/famedlysdk_store.dart';
|
import 'package:fluffychat/utils/famedlysdk_store.dart';
|
||||||
@ -63,6 +64,7 @@ class HomeserverPickerController extends State<HomeserverPicker> {
|
|||||||
|
|
||||||
void _processIncomingUris(String text) async {
|
void _processIncomingUris(String text) async {
|
||||||
if (text == null || !text.startsWith(AppConfig.appOpenUrlScheme)) return;
|
if (text == null || !text.startsWith(AppConfig.appOpenUrlScheme)) return;
|
||||||
|
await browser?.close();
|
||||||
VRouter.of(context).to('/home');
|
VRouter.of(context).to('/home');
|
||||||
final token = Uri.parse(text).queryParameters['loginToken'];
|
final token = Uri.parse(text).queryParameters['loginToken'];
|
||||||
if (token != null) _loginWithToken(token);
|
if (token != null) _loginWithToken(token);
|
||||||
@ -150,7 +152,7 @@ class HomeserverPickerController extends State<HomeserverPicker> {
|
|||||||
final list = (rawProviders as List)
|
final list = (rawProviders as List)
|
||||||
.map((json) => IdentityProvider.fromJson(json))
|
.map((json) => IdentityProvider.fromJson(json))
|
||||||
.toList();
|
.toList();
|
||||||
if (!PlatformInfos.isCupertinoStyle) {
|
if (PlatformInfos.isCupertinoStyle) {
|
||||||
list.sort((a, b) => a.brand == 'apple' ? -1 : 1);
|
list.sort((a, b) => a.brand == 'apple' ? -1 : 1);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
@ -190,6 +192,8 @@ class HomeserverPickerController extends State<HomeserverPicker> {
|
|||||||
return _rawLoginTypes;
|
return _rawLoginTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChromeSafariBrowser browser;
|
||||||
|
|
||||||
static const String ssoHomeserverKey = 'sso-homeserver';
|
static const String ssoHomeserverKey = 'sso-homeserver';
|
||||||
|
|
||||||
void ssoLoginAction(String id) {
|
void ssoLoginAction(String id) {
|
||||||
@ -202,14 +206,21 @@ class HomeserverPickerController extends State<HomeserverPicker> {
|
|||||||
final redirectUrl = kIsWeb
|
final redirectUrl = kIsWeb
|
||||||
? AppConfig.webBaseUrl + '/#/'
|
? AppConfig.webBaseUrl + '/#/'
|
||||||
: AppConfig.appOpenUrlScheme.toLowerCase() + '://login';
|
: AppConfig.appOpenUrlScheme.toLowerCase() + '://login';
|
||||||
launch(
|
final url =
|
||||||
'${Matrix.of(context).client.homeserver?.toString()}/_matrix/client/r0/login/sso/redirect/${Uri.encodeComponent(id)}?redirectUrl=${Uri.encodeQueryComponent(redirectUrl)}',
|
'${Matrix.of(context).client.homeserver?.toString()}/_matrix/client/r0/login/sso/redirect/${Uri.encodeComponent(id)}?redirectUrl=${Uri.encodeQueryComponent(redirectUrl)}';
|
||||||
forceSafariVC: false,
|
if (PlatformInfos.isIOS) {
|
||||||
);
|
browser ??= ChromeSafariBrowser();
|
||||||
|
browser.open(url: Uri.parse(url));
|
||||||
|
} else {
|
||||||
|
launch(redirectUrl, forceWebView: true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void signUpAction() => launch(
|
void signUpAction() => launch(
|
||||||
'${Matrix.of(context).client.homeserver?.toString()}/_matrix/static/client/register');
|
'${Matrix.of(context).client.homeserver?.toString()}/_matrix/static/client/register',
|
||||||
|
forceSafariVC: true,
|
||||||
|
forceWebView: true,
|
||||||
|
);
|
||||||
|
|
||||||
bool _initialized = false;
|
bool _initialized = false;
|
||||||
|
|
||||||
|
17
pubspec.lock
17
pubspec.lock
@ -365,6 +365,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.0"
|
version: "0.7.0"
|
||||||
|
flutter_inappwebview:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_inappwebview
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "5.3.2"
|
||||||
flutter_keyboard_visibility:
|
flutter_keyboard_visibility:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -551,10 +558,12 @@ packages:
|
|||||||
image_picker:
|
image_picker:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: image_picker
|
path: "packages/image_picker/image_picker"
|
||||||
url: "https://pub.dartlang.org"
|
ref: image_picker_camera_on_android11
|
||||||
source: hosted
|
resolved-ref: "6cfc8b8812a71e4eb3480110298d9487da75c560"
|
||||||
version: "0.8.1+3"
|
url: "https://gitlab.com/famedly/company/frontend/flutter-plugins.git"
|
||||||
|
source: git
|
||||||
|
version: "0.8.1+4"
|
||||||
image_picker_for_web:
|
image_picker_for_web:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name: fluffychat
|
name: fluffychat
|
||||||
description: Chat with your friends.
|
description: Chat with your friends.
|
||||||
publish_to: none
|
publish_to: none
|
||||||
version: 0.34.1+0
|
version: 0.34.1+1
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.6.0 <3.0.0"
|
sdk: ">=2.6.0 <3.0.0"
|
||||||
@ -27,6 +27,7 @@ dependencies:
|
|||||||
flutter_app_lock: ^1.5.0
|
flutter_app_lock: ^1.5.0
|
||||||
flutter_blurhash: ^0.6.0
|
flutter_blurhash: ^0.6.0
|
||||||
flutter_cache_manager: ^3.1.2
|
flutter_cache_manager: ^3.1.2
|
||||||
|
flutter_inappwebview: ^5.3.2
|
||||||
flutter_local_notifications: ^6.0.0
|
flutter_local_notifications: ^6.0.0
|
||||||
flutter_localizations:
|
flutter_localizations:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
Loading…
Reference in New Issue
Block a user