mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-25 15:02:33 +01:00
feature: Deprecated authwebview and use platform browser
This commit is contained in:
parent
41a24574ce
commit
d7aae3aedc
@ -20,6 +20,7 @@ import 'package:future_loading_dialog/future_loading_dialog.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:universal_html/prefer_universal/html.dart' as html;
|
import 'package:universal_html/prefer_universal/html.dart' as html;
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
/*import 'package:fluffychat/views/chat.dart';
|
/*import 'package:fluffychat/views/chat.dart';
|
||||||
import 'package:fluffychat/app_config.dart';
|
import 'package:fluffychat/app_config.dart';
|
||||||
import 'package:dbus/dbus.dart';
|
import 'package:dbus/dbus.dart';
|
||||||
@ -159,15 +160,23 @@ class MatrixState extends State<Matrix> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
await widget.apl.currentState.pushNamed(
|
await launch(
|
||||||
'/authwebview/$stage/${uiaRequest.session}',
|
Matrix.of(context).client.homeserver.toString() +
|
||||||
arguments: () => null,
|
'/_matrix/client/r0/auth/$stage/fallback/web?session=${uiaRequest.session}',
|
||||||
);
|
);
|
||||||
|
if (OkCancelResult.ok ==
|
||||||
|
await showOkCancelAlertDialog(
|
||||||
|
message: L10n.of(context).pleaseFollowInstructionsOnWeb,
|
||||||
|
context: context,
|
||||||
|
okLabel: L10n.of(context).next,
|
||||||
|
cancelLabel: L10n.of(context).cancel,
|
||||||
|
)) {
|
||||||
return uiaRequest.completeStage(
|
return uiaRequest.completeStage(
|
||||||
AuthenticationData(session: uiaRequest.session),
|
AuthenticationData(session: uiaRequest.session),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool webHasFocus = true;
|
bool webHasFocus = true;
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ import 'package:adaptive_page_layout/adaptive_page_layout.dart';
|
|||||||
import 'package:famedlysdk/famedlysdk.dart';
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
import 'package:fluffychat/components/matrix.dart';
|
import 'package:fluffychat/components/matrix.dart';
|
||||||
import 'package:fluffychat/views/archive.dart';
|
import 'package:fluffychat/views/archive.dart';
|
||||||
import 'package:fluffychat/views/auth_web_view.dart';
|
|
||||||
import 'package:fluffychat/views/chat.dart';
|
import 'package:fluffychat/views/chat.dart';
|
||||||
import 'package:fluffychat/views/chat_details.dart';
|
import 'package:fluffychat/views/chat_details.dart';
|
||||||
import 'package:fluffychat/views/chat_encryption_settings.dart';
|
import 'package:fluffychat/views/chat_encryption_settings.dart';
|
||||||
@ -61,16 +60,6 @@ class FluffyRoutes {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
return ViewData(mainView: (_) => SignUp());
|
return ViewData(mainView: (_) => SignUp());
|
||||||
case 'authwebview':
|
|
||||||
if (parts.length == 4) {
|
|
||||||
return ViewData(
|
|
||||||
mainView: (_) => AuthWebView(
|
|
||||||
parts[2],
|
|
||||||
Uri.decodeComponent(parts[3]),
|
|
||||||
settings.arguments,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Routes IF user is logged in
|
// Routes IF user is logged in
|
||||||
@ -138,17 +127,6 @@ class FluffyRoutes {
|
|||||||
mainView: (_) => Archive(),
|
mainView: (_) => Archive(),
|
||||||
emptyView: (_) => EmptyPage(),
|
emptyView: (_) => EmptyPage(),
|
||||||
);
|
);
|
||||||
case 'authwebview':
|
|
||||||
if (parts.length == 4) {
|
|
||||||
return ViewData(
|
|
||||||
mainView: (_) => AuthWebView(
|
|
||||||
parts[2],
|
|
||||||
Uri.decodeComponent(parts[3]),
|
|
||||||
settings.arguments,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'discover':
|
case 'discover':
|
||||||
return ViewData(
|
return ViewData(
|
||||||
mainView: (_) =>
|
mainView: (_) =>
|
||||||
|
@ -142,6 +142,11 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"placeholders": {}
|
"placeholders": {}
|
||||||
},
|
},
|
||||||
|
"pleaseFollowInstructionsOnWeb": "Please follow the instructions on the website and tap on next.",
|
||||||
|
"@pleaseFollowInstructionsOnWeb": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
"youWillBeConnectedTo": "You will be connected to {homeserver}",
|
"youWillBeConnectedTo": "You will be connected to {homeserver}",
|
||||||
"@youWillBeConnectedTo": {
|
"@youWillBeConnectedTo": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@ -149,6 +154,11 @@
|
|||||||
"homeserver": {}
|
"homeserver": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"next": "Next",
|
||||||
|
"@next": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
"cachedKeys": "Keys cached",
|
"cachedKeys": "Keys cached",
|
||||||
"@cachedKeys": {
|
"@cachedKeys": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
|
@ -1,54 +0,0 @@
|
|||||||
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
|
|
||||||
import 'package:fluffychat/components/matrix.dart';
|
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
|
||||||
import 'package:webview_flutter/webview_flutter.dart';
|
|
||||||
|
|
||||||
class AuthWebView extends StatefulWidget {
|
|
||||||
final String authType;
|
|
||||||
final String session;
|
|
||||||
final Function onAuthDone;
|
|
||||||
|
|
||||||
const AuthWebView(this.authType, this.session, this.onAuthDone);
|
|
||||||
|
|
||||||
@override
|
|
||||||
_AuthWebViewState createState() => _AuthWebViewState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _AuthWebViewState extends State<AuthWebView> {
|
|
||||||
bool _isLoading = true;
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final url = Matrix.of(context).client.homeserver.toString() +
|
|
||||||
'/_matrix/client/r0/auth/${widget.authType}/fallback/web?session=${widget.session}';
|
|
||||||
if (kIsWeb) launch(url);
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: Text(L10n.of(context).authentication),
|
|
||||||
leading: IconButton(
|
|
||||||
icon: Icon(Icons.close),
|
|
||||||
onPressed: () {
|
|
||||||
AdaptivePageLayout.of(context).pop();
|
|
||||||
widget.onAuthDone();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
body: Column(
|
|
||||||
children: <Widget>[
|
|
||||||
if (_isLoading) LinearProgressIndicator(),
|
|
||||||
Expanded(
|
|
||||||
child: kIsWeb
|
|
||||||
? Center(child: Icon(Icons.link_outlined))
|
|
||||||
: WebView(
|
|
||||||
onPageFinished: (_) => setState(() => _isLoading = false),
|
|
||||||
initialUrl: url,
|
|
||||||
javascriptMode: JavascriptMode.unrestricted,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -81,12 +81,20 @@ class _SignUpPasswordState extends State<SignUpPassword> {
|
|||||||
);
|
);
|
||||||
if (OkCancelResult.ok ==
|
if (OkCancelResult.ok ==
|
||||||
await showOkCancelAlertDialog(
|
await showOkCancelAlertDialog(
|
||||||
|
message: L10n.of(context).pleaseFollowInstructionsOnWeb,
|
||||||
context: context,
|
context: context,
|
||||||
|
okLabel: L10n.of(context).next,
|
||||||
|
cancelLabel: L10n.of(context).cancel,
|
||||||
)) {
|
)) {
|
||||||
_signUpAction(
|
_signUpAction(
|
||||||
context,
|
context,
|
||||||
auth: AuthenticationData(session: exception.session),
|
auth: AuthenticationData(session: exception.session),
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
loading = false;
|
||||||
|
passwordError = null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user