feat: Enhanced configuration
This commit is contained in:
parent
11c2a8bb26
commit
8eb2e2fb9d
22 changed files with 191 additions and 236 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/utils/sentry_controller.dart';
|
||||
|
|
@ -13,9 +12,10 @@ import 'package:universal_html/prefer_universal/html.dart' as html;
|
|||
|
||||
import 'components/matrix.dart';
|
||||
import 'components/theme_switcher.dart';
|
||||
import 'app_config.dart';
|
||||
import 'views/chat_list.dart';
|
||||
|
||||
void main() {
|
||||
void main() async {
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
SystemUiOverlayStyle(statusBarColor: Colors.transparent));
|
||||
FlutterError.onError = (FlutterErrorDetails details) =>
|
||||
|
|
@ -27,49 +27,50 @@ void main() {
|
|||
}
|
||||
|
||||
class App extends StatelessWidget {
|
||||
final String platform = kIsWeb ? 'Web' : Platform.operatingSystem;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Matrix(
|
||||
clientName: 'FluffyChat $platform',
|
||||
child: Builder(
|
||||
builder: (BuildContext context) => ThemeSwitcherWidget(
|
||||
child: Builder(
|
||||
builder: (BuildContext context) => MaterialApp(
|
||||
title: 'FluffyChat',
|
||||
theme: ThemeSwitcherWidget.of(context).themeData,
|
||||
localizationsDelegates: L10n.localizationsDelegates,
|
||||
supportedLocales: L10n.supportedLocales,
|
||||
locale: kIsWeb
|
||||
? Locale(html.window.navigator.language.split('-').first)
|
||||
: null,
|
||||
home: FutureBuilder<LoginState>(
|
||||
future:
|
||||
Matrix.of(context).client.onLoginStateChanged.stream.first,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasError) {
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((_) => FlushbarHelper.createError(
|
||||
title: L10n.of(context).oopsSomethingWentWrong,
|
||||
message: snapshot.error.toString(),
|
||||
).show(context));
|
||||
return HomeserverPicker();
|
||||
}
|
||||
if (!snapshot.hasData) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (Matrix.of(context).client.isLogged()) {
|
||||
return ChatListView();
|
||||
}
|
||||
return HomeserverPicker();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
builder: (context) => MaterialApp(
|
||||
title: '${AppConfig.applicationName}',
|
||||
theme: ThemeSwitcherWidget.of(context).themeData,
|
||||
localizationsDelegates: L10n.localizationsDelegates,
|
||||
supportedLocales: L10n.supportedLocales,
|
||||
locale: kIsWeb
|
||||
? Locale(
|
||||
html.window.navigator.language.split('-').first)
|
||||
: null,
|
||||
home: FutureBuilder<LoginState>(
|
||||
future: Matrix.of(context)
|
||||
.client
|
||||
.onLoginStateChanged
|
||||
.stream
|
||||
.first,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasError) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) =>
|
||||
FlushbarHelper.createError(
|
||||
title: L10n.of(context).oopsSomethingWentWrong,
|
||||
message: snapshot.error.toString(),
|
||||
).show(context));
|
||||
return HomeserverPicker();
|
||||
}
|
||||
if (!snapshot.hasData) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (Matrix.of(context).client.isLogged()) {
|
||||
return ChatListView();
|
||||
}
|
||||
return HomeserverPicker();
|
||||
},
|
||||
),
|
||||
)),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue