mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-13 23:49:29 +01:00
b6d2ddaf7d
BREAKING CHANGE: This introduces that it might require up to 2 compiles for locals to work. Also only arb files shall be checked into git. Took 19 minutes
47 lines
1.3 KiB
Dart
47 lines
1.3 KiB
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 StatelessWidget {
|
|
final String authType;
|
|
final String session;
|
|
final Function onAuthDone;
|
|
|
|
const AuthWebView(this.authType, this.session, this.onAuthDone);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final url = Matrix.of(context).client.homeserver.toString() +
|
|
'/_matrix/client/r0/auth/$authType/fallback/web?session=$session';
|
|
if (kIsWeb) launch(url);
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text(L10n.of(context).authentication),
|
|
leading: IconButton(
|
|
icon: Icon(Icons.close),
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
onAuthDone();
|
|
},
|
|
),
|
|
),
|
|
body: Column(
|
|
children: <Widget>[
|
|
LinearProgressIndicator(),
|
|
Expanded(
|
|
child: kIsWeb
|
|
? Center(child: Icon(Icons.link))
|
|
: WebView(
|
|
initialUrl: url,
|
|
javascriptMode: JavascriptMode.unrestricted,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|