2020-02-23 08:49:58 +01:00
|
|
|
import 'dart:io';
|
|
|
|
|
2020-01-01 19:10:13 +01:00
|
|
|
import 'package:famedlysdk/famedlysdk.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
2020-01-02 22:31:39 +01:00
|
|
|
import 'package:flutter/services.dart';
|
2020-01-20 09:50:49 +01:00
|
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
2020-01-01 19:10:13 +01:00
|
|
|
|
2020-02-16 15:57:50 +01:00
|
|
|
import 'i18n/i18n.dart';
|
|
|
|
import 'views/sign_up.dart';
|
2020-02-16 20:11:39 +01:00
|
|
|
import 'components/theme_switcher.dart';
|
2020-01-01 19:10:13 +01:00
|
|
|
import 'components/matrix.dart';
|
|
|
|
import 'views/chat_list.dart';
|
|
|
|
|
2020-01-02 22:31:39 +01:00
|
|
|
void main() {
|
|
|
|
SystemChrome.setSystemUIOverlayStyle(
|
2020-02-16 15:57:50 +01:00
|
|
|
SystemUiOverlayStyle(statusBarColor: Colors.transparent));
|
2020-01-02 22:31:39 +01:00
|
|
|
runApp(App());
|
|
|
|
}
|
2020-01-01 19:10:13 +01:00
|
|
|
|
2020-01-02 22:31:39 +01:00
|
|
|
class App extends StatelessWidget {
|
2020-01-01 19:10:13 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Matrix(
|
2020-02-23 08:49:58 +01:00
|
|
|
clientName: "FluffyChat ${Platform.operatingSystem}",
|
2020-01-23 12:11:57 +01:00
|
|
|
child: Builder(
|
2020-02-16 15:57:50 +01:00
|
|
|
builder: (BuildContext context) => ThemeSwitcherWidget(
|
|
|
|
child: Builder(
|
|
|
|
builder: (BuildContext context) => MaterialApp(
|
|
|
|
title: 'FluffyChat',
|
|
|
|
theme: ThemeSwitcherWidget.of(context).themeData,
|
|
|
|
localizationsDelegates: [
|
|
|
|
AppLocalizationsDelegate(),
|
|
|
|
GlobalMaterialLocalizations.delegate,
|
|
|
|
GlobalWidgetsLocalizations.delegate,
|
|
|
|
GlobalCupertinoLocalizations.delegate,
|
|
|
|
],
|
|
|
|
supportedLocales: [
|
|
|
|
const Locale('en'), // English
|
|
|
|
const Locale('de'), // German
|
|
|
|
],
|
|
|
|
home: FutureBuilder<LoginState>(
|
|
|
|
future:
|
|
|
|
Matrix.of(context).client.onLoginStateChanged.stream.first,
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
if (!snapshot.hasData) {
|
|
|
|
return Scaffold(
|
|
|
|
body: Center(
|
|
|
|
child: CircularProgressIndicator(),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (Matrix.of(context).client.isLogged()) {
|
|
|
|
return ChatListView();
|
|
|
|
}
|
|
|
|
return SignUp();
|
|
|
|
},
|
2020-01-23 12:11:57 +01:00
|
|
|
),
|
2020-01-01 19:10:13 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|