mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-22 05:22:34 +01:00
fix: Load urls directly
This commit is contained in:
parent
22bd6065a3
commit
086209fd39
@ -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),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
@ -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)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
24
lib/widgets/layouts/wait_for_login.dart
Normal file
24
lib/widgets/layouts/wait_for_login.dart
Normal 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;
|
||||
}
|
||||
}
|
@ -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,8 +326,13 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
||||
onLoginStateChanged ??= client.onLoginStateChanged.stream.listen((state) {
|
||||
if (loginState != state) {
|
||||
loginState = state;
|
||||
widget.router.currentState
|
||||
.push(loginState == LoginState.logged ? '/rooms' : '/home');
|
||||
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');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user