fluffychat/lib/main.dart

88 lines
2.8 KiB
Dart
Raw Normal View History

2020-01-01 19:10:13 +01:00
import 'package:famedlysdk/famedlysdk.dart';
2020-01-20 13:46:39 +01:00
import 'package:fluffychat/i18n/i18n.dart';
2020-01-09 22:52:27 +01:00
import 'package:fluffychat/views/sign_up.dart';
2020-02-05 11:26:00 +01:00
import 'package:flutter/foundation.dart';
2020-01-01 19:10:13 +01:00
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-02-05 11:26:00 +01:00
import 'package:universal_html/prefer_universal/html.dart' as html;
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(
SystemUiOverlayStyle(statusBarColor: Colors.white),
);
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(
clientName: "FluffyChat",
child: Builder(
builder: (BuildContext context) => MaterialApp(
title: 'FluffyChat',
theme: ThemeData(
brightness: Brightness.light,
primaryColor: Color(0xFF5625BA),
backgroundColor: Colors.white,
2020-02-07 19:44:16 +01:00
secondaryHeaderColor: Color(0xFFF6F0F6),
scaffoldBackgroundColor: Colors.white,
dialogTheme: DialogTheme(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
2020-01-01 19:10:13 +01:00
),
popupMenuTheme: PopupMenuThemeData(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
2020-01-01 19:10:13 +01:00
),
appBarTheme: AppBarTheme(
brightness: Brightness.light,
color: Colors.white,
elevation: 1,
textTheme: TextTheme(
2020-01-27 11:12:33 +01:00
title: TextStyle(
color: Colors.black,
),
),
iconTheme: IconThemeData(color: Colors.black),
2020-01-01 19:10:13 +01:00
),
),
localizationsDelegates: [
AppLocalizationsDelegate(),
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [
const Locale('en'), // English
const Locale('de'), // German
],
2020-02-05 11:26:00 +01:00
locale: kIsWeb
? Locale(html.window.navigator.language.split("-").first)
: null,
home: FutureBuilder<LoginState>(
2020-01-08 14:19:15 +01:00
future: Matrix.of(context).client.onLoginStateChanged.stream.first,
2020-01-01 19:10:13 +01:00
builder: (context, snapshot) {
2020-01-02 22:31:39 +01:00
if (!snapshot.hasData) {
2020-01-01 19:10:13 +01:00
return Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
);
2020-01-02 22:31:39 +01:00
}
2020-01-01 19:10:13 +01:00
if (Matrix.of(context).client.isLogged()) return ChatListView();
2020-01-09 22:52:27 +01:00
return SignUp();
2020-01-01 19:10:13 +01:00
},
),
),
),
);
}
}