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-01 19:10:13 +01:00
|
|
|
|
|
|
|
import 'components/matrix.dart';
|
|
|
|
import 'views/chat_list.dart';
|
|
|
|
import 'views/login.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(
|
2020-01-04 13:53:49 +01:00
|
|
|
clientName: "FluffyChat",
|
2020-01-01 19:10:13 +01:00
|
|
|
child: MaterialApp(
|
2020-01-04 13:53:49 +01:00
|
|
|
title: 'FluffyChat',
|
2020-01-01 19:10:13 +01:00
|
|
|
theme: ThemeData(
|
2020-01-03 11:47:31 +01:00
|
|
|
brightness: Brightness.light,
|
2020-01-01 19:10:13 +01:00
|
|
|
primaryColor: Color(0xFF5625BA),
|
|
|
|
backgroundColor: Colors.white,
|
2020-01-03 11:57:00 +01:00
|
|
|
secondaryHeaderColor: Color(0xFFF2F2F2),
|
2020-01-01 19:10:13 +01:00
|
|
|
scaffoldBackgroundColor: Colors.white,
|
|
|
|
dialogTheme: DialogTheme(
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(8.0),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
popupMenuTheme: PopupMenuThemeData(
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(8.0),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
appBarTheme: AppBarTheme(
|
2020-01-03 11:47:31 +01:00
|
|
|
brightness: Brightness.light,
|
2020-01-01 19:10:13 +01:00
|
|
|
color: Colors.white,
|
|
|
|
elevation: 1,
|
|
|
|
textTheme: TextTheme(
|
|
|
|
title: TextStyle(color: Colors.black),
|
|
|
|
),
|
|
|
|
iconTheme: IconThemeData(color: Colors.black),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
home: Builder(
|
|
|
|
builder: (BuildContext context) => StreamBuilder<LoginState>(
|
2020-01-02 15:10:21 +01:00
|
|
|
stream: Matrix.of(context).client.onLoginStateChanged.stream,
|
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();
|
|
|
|
return LoginPage();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|