OpenContacts/lib/main.dart

56 lines
1.7 KiB
Dart
Raw Normal View History

2023-05-01 13:13:40 -04:00
import 'package:contacts_plus_plus/models/message.dart';
import 'package:contacts_plus_plus/neos_hub.dart';
import 'package:contacts_plus_plus/widgets/home_screen.dart';
import 'package:contacts_plus_plus/widgets/login_screen.dart';
2023-04-29 13:18:46 -04:00
import 'package:flutter/material.dart';
import 'api_client.dart';
import 'models/authentication_data.dart';
void main() {
2023-05-01 13:13:40 -04:00
runApp(const ContactsPlusPlus());
2023-04-29 13:18:46 -04:00
}
2023-05-01 13:13:40 -04:00
class ContactsPlusPlus extends StatefulWidget {
const ContactsPlusPlus({super.key});
2023-04-30 07:39:09 -04:00
@override
2023-05-01 13:13:40 -04:00
State<ContactsPlusPlus> createState() => _ContactsPlusPlusState();
2023-04-30 07:39:09 -04:00
}
2023-05-01 13:13:40 -04:00
class _ContactsPlusPlusState extends State<ContactsPlusPlus> {
2023-04-29 16:21:00 -04:00
final Typography _typography = Typography.material2021(platform: TargetPlatform.android);
2023-04-30 07:39:09 -04:00
AuthenticationData _authData = AuthenticationData.unauthenticated();
2023-04-30 17:14:29 -04:00
final Map<String, MessageCache> _messageCache = {};
2023-04-29 13:18:46 -04:00
@override
Widget build(BuildContext context) {
return HubHolder(
messageCache: _messageCache,
2023-04-30 07:39:09 -04:00
authenticationData: _authData,
child: ClientHolder(
authenticationData: _authData,
2023-04-30 17:14:29 -04:00
child: MaterialApp(
debugShowCheckedModeBanner: false,
2023-05-01 13:13:40 -04:00
title: 'Contacts++',
2023-04-30 17:14:29 -04:00
theme: ThemeData(
useMaterial3: true,
2023-04-30 07:39:09 -04:00
textTheme: _typography.white,
colorScheme: ColorScheme.fromSeed(seedColor: Colors.purple, brightness: Brightness.dark)
2023-04-30 17:14:29 -04:00
),
home: _authData.isAuthenticated ?
const HomeScreen() :
LoginScreen(
onLoginSuccessful: (AuthenticationData authData) async {
2023-04-30 17:14:29 -04:00
if (authData.isAuthenticated) {
setState(() {
_authData = authData;
});
}
},
),
2023-04-30 07:39:09 -04:00
),
2023-04-29 13:18:46 -04:00
),
);
}
}