2023-05-03 11:51:18 -04:00
|
|
|
import 'dart:developer';
|
|
|
|
|
2023-05-03 12:16:40 -04:00
|
|
|
import 'package:contacts_plus_plus/widgets/friends_list.dart';
|
2023-05-01 13:13:40 -04:00
|
|
|
import 'package:contacts_plus_plus/widgets/login_screen.dart';
|
2023-04-29 13:18:46 -04:00
|
|
|
import 'package:flutter/material.dart';
|
2023-05-03 11:51:18 -04:00
|
|
|
import 'package:flutter_phoenix/flutter_phoenix.dart';
|
|
|
|
import 'package:logging/logging.dart';
|
2023-04-29 13:18:46 -04:00
|
|
|
import 'api_client.dart';
|
|
|
|
import 'models/authentication_data.dart';
|
|
|
|
|
|
|
|
void main() {
|
2023-05-03 11:51:18 -04:00
|
|
|
Logger.root.onRecord.listen((event) => log(event.message, name: event.loggerName));
|
|
|
|
runApp(Phoenix(child: 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-29 13:18:46 -04:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-05-02 04:04:54 -04:00
|
|
|
return ClientHolder(
|
2023-04-30 07:39:09 -04:00
|
|
|
authenticationData: _authData,
|
2023-05-02 04:04:54 -04:00
|
|
|
child: MaterialApp(
|
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
title: 'Contacts++',
|
|
|
|
theme: ThemeData(
|
2023-04-30 17:14:29 -04:00
|
|
|
useMaterial3: true,
|
2023-04-30 07:39:09 -04:00
|
|
|
textTheme: _typography.white,
|
|
|
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.purple, brightness: Brightness.dark)
|
2023-05-02 04:04:54 -04:00
|
|
|
),
|
|
|
|
home: _authData.isAuthenticated ?
|
2023-05-03 11:51:18 -04:00
|
|
|
const FriendsList() :
|
2023-05-02 04:04:54 -04:00
|
|
|
LoginScreen(
|
|
|
|
onLoginSuccessful: (AuthenticationData authData) async {
|
|
|
|
if (authData.isAuthenticated) {
|
|
|
|
setState(() {
|
|
|
|
_authData = authData;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2023-04-30 07:39:09 -04:00
|
|
|
),
|
2023-04-29 13:18:46 -04:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|