FurryChat/lib/main.dart

89 lines
2.8 KiB
Dart
Raw Normal View History

2020-01-01 18:10:13 +00:00
import 'package:famedlysdk/famedlysdk.dart';
2020-01-20 12:46:39 +00:00
import 'package:fluffychat/i18n/i18n.dart';
2020-01-09 21:52:27 +00:00
import 'package:fluffychat/views/sign_up.dart';
2020-02-05 10:26:00 +00:00
import 'package:flutter/foundation.dart';
2020-01-01 18:10:13 +00:00
import 'package:flutter/material.dart';
2020-01-02 21:31:39 +00:00
import 'package:flutter/services.dart';
2020-01-20 08:50:49 +00:00
import 'package:flutter_localizations/flutter_localizations.dart';
2020-02-05 10:26:00 +00:00
import 'package:universal_html/prefer_universal/html.dart' as html;
2020-01-01 18:10:13 +00:00
import 'components/matrix.dart';
import 'views/chat_list.dart';
2020-01-02 21:31:39 +00:00
void main() {
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(statusBarColor: Colors.white),
);
runApp(App());
}
2020-01-01 18:10:13 +00:00
2020-01-02 21:31:39 +00:00
class App extends StatelessWidget {
2020-01-01 18:10:13 +00: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:00:20 +00:00
secondaryHeaderColor: Color(0xFFECECF2),
scaffoldBackgroundColor: Colors.white,
dialogTheme: DialogTheme(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
2020-01-01 18:10:13 +00:00
),
popupMenuTheme: PopupMenuThemeData(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
2020-01-01 18:10:13 +00:00
),
appBarTheme: AppBarTheme(
brightness: Brightness.light,
color: Colors.white,
2020-02-09 15:26:24 +00:00
//elevation: 1,
textTheme: TextTheme(
2020-02-09 15:00:24 +00:00
title: TextStyle(
2020-01-27 10:12:33 +00:00
color: Colors.black,
2020-02-14 13:34:28 +00:00
fontSize: 20,
2020-01-27 10:12:33 +00:00
),
),
iconTheme: IconThemeData(color: Colors.black),
2020-01-01 18:10:13 +00:00
),
),
localizationsDelegates: [
AppLocalizationsDelegate(),
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [
const Locale('en'), // English
const Locale('de'), // German
],
2020-02-05 10:26:00 +00:00
locale: kIsWeb
? Locale(html.window.navigator.language.split("-").first)
: null,
home: FutureBuilder<LoginState>(
2020-01-08 13:19:15 +00:00
future: Matrix.of(context).client.onLoginStateChanged.stream.first,
2020-01-01 18:10:13 +00:00
builder: (context, snapshot) {
2020-01-02 21:31:39 +00:00
if (!snapshot.hasData) {
2020-01-01 18:10:13 +00:00
return Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
);
2020-01-02 21:31:39 +00:00
}
2020-01-01 18:10:13 +00:00
if (Matrix.of(context).client.isLogged()) return ChatListView();
2020-01-09 21:52:27 +00:00
return SignUp();
2020-01-01 18:10:13 +00:00
},
),
),
),
);
}
}