fix: Load urls directly

This commit is contained in:
Christian Pauly 2021-06-10 10:20:00 +02:00
parent 22bd6065a3
commit 086209fd39
4 changed files with 36 additions and 6 deletions

View File

@ -17,6 +17,7 @@ import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:universal_html/html.dart' as html;
import 'package:vrouter/vrouter.dart';
import 'widgets/layouts/wait_for_login.dart';
import 'widgets/lock_screen.dart';
import 'widgets/matrix.dart';
import 'config/themes.dart';
@ -126,7 +127,7 @@ class _FluffyChatAppState extends State<FluffyChatApp> {
context: context,
router: _router,
testClient: widget.testClient,
child: child,
child: WaitForInitPage(child),
);
},
);

View File

@ -41,7 +41,7 @@ class OnePageCard extends StatelessWidget {
vertical:
max((MediaQuery.of(context).size.height - 800) / 2, 12),
),
child: SafeArea(child: Card(child: child)),
child: SafeArea(child: Card(elevation: 7, child: child)),
),
);
}

View File

@ -0,0 +1,24 @@
import 'package:famedlysdk/famedlysdk.dart';
import 'package:flutter/material.dart';
import '../matrix.dart';
class WaitForInitPage extends StatelessWidget {
final Widget page;
const WaitForInitPage(this.page, {Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
if (Matrix.of(context).loginState == null) {
return StreamBuilder<LoginState>(
stream: Matrix.of(context).client.onLoginStateChanged.stream,
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Scaffold(body: Center(child: CircularProgressIndicator()));
}
return page;
});
}
return page;
}
}

View File

@ -266,8 +266,8 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
utf8.decode((await http.get(Uri.parse('config.json'))).bodyBytes);
final configJson = json.decode(configJsonString);
AppConfig.loadFromJson(configJson);
} catch (e, s) {
Logs().v('[ConfigLoader] Failed to load config.json', e, s);
} catch (e, _) {
Logs().v('[ConfigLoader] config.json not found', e);
}
}
@ -326,9 +326,14 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
onLoginStateChanged ??= client.onLoginStateChanged.stream.listen((state) {
if (loginState != state) {
loginState = state;
final isInLoginRoutes = {'/home', '/login', '/signup'}
.contains(widget.router.currentState.url);
if (widget.router.currentState.url == '/' ||
(state == LoginState.logged) == isInLoginRoutes) {
widget.router.currentState
.push(loginState == LoginState.logged ? '/rooms' : '/home');
}
}
});
// Cache and resend status message