Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colloscope #35

Merged
merged 13 commits into from
Dec 22, 2023
4 changes: 2 additions & 2 deletions .idea/libraries/Flutter_Plugins.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/onyx/assets/colloscope_ids.enc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LIakTbYkwghdaZ75ZPK/OV22gu/xdsbNtps5di0HmMFICTDrnuk+TQkk1uRc3rVbOrjx6bVWu9P0pX/+l1saWXetR6n4c93pREmEMgAl9EWzQTQ0eCM8FExli+5CAtvE
206 changes: 113 additions & 93 deletions apps/onyx/lib/app.dart
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:lyon1tomussclient/lyon1tomussclient.dart';
import 'package:onyx/core/widgets/core_widget_export.dart';
import 'package:onyx/screens/settings/states/theme_cubit.dart';
import 'package:responsive_sizer/responsive_sizer.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:lyon1agendaclient/lyon1agendaclient.dart';
import 'package:lyon1casclient/lyon1casclient.dart';
import 'package:lyon1mailclient/lyon1mailclient.dart';
import 'package:lyon1tomussclient/lyon1tomussclient.dart';
import 'package:onyx/core/cache_service.dart';
import 'package:onyx/core/initialisations/initialisations_export.dart';
import 'package:onyx/core/screens/home/home_export.dart';
import 'package:onyx/core/theme/theme_export.dart';
import 'package:onyx/core/widgets/core_widget_export.dart';
import 'package:onyx/screens/agenda/agenda_export.dart';
import 'package:onyx/screens/colloscope/states/colloscope_cubit.dart';
import 'package:onyx/screens/izly/izly_export.dart';
import 'package:onyx/screens/login/login_export.dart';
import 'package:onyx/screens/mails/mails_export.dart';
import 'package:onyx/screens/map/map_export.dart';
import 'package:onyx/screens/settings/settings_export.dart';
import 'package:onyx/screens/settings/states/theme_cubit.dart';
import 'package:onyx/screens/tomuss/tomuss_export.dart';
import 'package:responsive_sizer/responsive_sizer.dart';

import 'core/widgets/states_displaying/state_displaying_widget_export.dart';

Expand Down Expand Up @@ -46,114 +47,133 @@ class OnyxAppState extends State<OnyxApp> {
@override
Widget build(BuildContext context) {
return ResponsiveSizer(
builder: (context, orientation, deviceType) => MultiBlocProvider(
providers: [
BlocProvider<AuthentificationCubit>(
create: (context) => AuthentificationCubit()),
BlocProvider<SettingsCubit>(create: (context) => SettingsCubit()),
BlocProvider<EmailCubit>(create: (context) => EmailCubit()),
BlocProvider<AgendaCubit>(create: (context) => AgendaCubit()),
BlocProvider<TomussCubit>(create: (context) => TomussCubit()),
BlocProvider<MapCubit>(create: (context) => MapCubit()),
BlocProvider<IzlyCubit>(create: (context) => IzlyCubit()),
BlocProvider<ThemeCubit>(create: (context) => ThemeCubit()),
],
child: BlocBuilder<AuthentificationCubit, AuthentificationState>(
builder: (context, authState) {
if (kDebugMode) {
print("Device.orientation : ${Device.orientation}");
print("Device.deviceType : ${Device.deviceType}");
print("Device.screenType : ${Device.screenType}");
print("Device.width : ${Device.width}");
print("Device.height : ${Device.height}");
print("Device.boxConstraints : ${Device.boxConstraints}");
print("Device.aspectRatio : ${Device.aspectRatio}");
print("Device.pixelRatio : ${Device.pixelRatio}");
}
builder: (context, orientation, deviceType) =>
MultiBlocProvider(
providers: [
BlocProvider<AuthentificationCubit>(
create: (context) => AuthentificationCubit()),
BlocProvider<SettingsCubit>(create: (context) => SettingsCubit()),
BlocProvider<EmailCubit>(create: (context) => EmailCubit()),
BlocProvider<AgendaCubit>(create: (context) => AgendaCubit()),
BlocProvider<TomussCubit>(create: (context) => TomussCubit()),
BlocProvider<MapCubit>(create: (context) => MapCubit()),
BlocProvider<IzlyCubit>(create: (context) => IzlyCubit()),
BlocProvider<ColloscopeCubit>(
create: (context) => ColloscopeCubit()),
BlocProvider<ThemeCubit>(create: (context) => ThemeCubit()),
],
child: BlocBuilder<AuthentificationCubit, AuthentificationState>(
builder: (context, authState) {
if (kDebugMode) {
print("Device.orientation : ${Device.orientation}");
print("Device.deviceType : ${Device.deviceType}");
print("Device.screenType : ${Device.screenType}");
print("Device.width : ${Device.width}");
print("Device.height : ${Device.height}");
print("Device.boxConstraints : ${Device.boxConstraints}");
print("Device.aspectRatio : ${Device.aspectRatio}");
print("Device.pixelRatio : ${Device.pixelRatio}");
}

if (authState.status == AuthentificationStatus.authentificated) {
CacheService.getEncryptionKey(context
if (authState.status ==
AuthentificationStatus.authentificated) {
CacheService.getEncryptionKey(context
.read<SettingsCubit>()
.state
.settings
.biometricAuth)
.then((key) => CacheService.get<Credential>(secureKey: key)
.then((value) => context.read<EmailCubit>().connect(
username: value!.username,
password: value.password)));
if (AgendaStatus.ready !=
context.read<AgendaCubit>().state.status) {
context.read<AgendaCubit>().load(
lyon1Cas: authState.lyon1Cas,
settings: context.read<SettingsCubit>().state.settings);
}
context.read<TomussCubit>().load(
.then((key) =>
CacheService.get<Credential>(secureKey: key)
.then((value) =>
context.read<EmailCubit>().connect(
username: value!.username,
password: value.password)));
if (AgendaStatus.ready !=
context
.read<AgendaCubit>()
.state
.status) {
context.read<AgendaCubit>().load(
lyon1Cas: authState.lyon1Cas,
settings: context
.read<SettingsCubit>()
.state
.settings);
}
context.read<TomussCubit>().load(
lyon1Cas: authState.lyon1Cas,
settings: context.read<SettingsCubit>().state.settings,
settings: context
.read<SettingsCubit>()
.state
.settings,
force: true,
);
}
return BlocBuilder<ThemeCubit, ThemeState>(
builder: (context, themeState) {
return BlocBuilder<SettingsCubit, SettingsState>(
builder: (context, settingsState) {
if ((settingsState.status == SettingsStatus.ready ||
}
return BlocBuilder<ThemeCubit, ThemeState>(
builder: (context, themeState) {
return BlocBuilder<SettingsCubit, SettingsState>(
builder: (context, settingsState) {
if ((settingsState.status == SettingsStatus.ready ||
settingsState.status == SettingsStatus.error) &&
(themeState.status != ThemeStateStatus.init)) {
if (authState.status == AuthentificationStatus.initial) {
context
.read<AuthentificationCubit>()
.login(settings: settingsState.settings);
} else if (authState.status ==
(themeState.status != ThemeStateStatus.init)) {
if (authState.status ==
AuthentificationStatus.initial) {
context
.read<AuthentificationCubit>()
.login(settings: settingsState.settings);
} else if (authState.status ==
AuthentificationStatus.authentificated &&
settingsState.settings.firstLogin) {
context.read<SettingsCubit>().modify(
settings: context
.read<SettingsCubit>()
.state
.settings
.copyWith(firstLogin: false));
}
return MaterialApp(
title: 'Onyx',
navigatorKey: OnyxApp.navigatorKey,
scrollBehavior: const CustomScrollBehavior(),
debugShowCheckedModeBanner: false,
themeMode:
settingsState.settings.firstLogin) {
context.read<SettingsCubit>().modify(
settings: context
.read<SettingsCubit>()
.state
.settings
.copyWith(firstLogin: false));
}
return MaterialApp(
title: 'Onyx',
navigatorKey: OnyxApp.navigatorKey,
scrollBehavior: const CustomScrollBehavior(),
debugShowCheckedModeBanner: false,
themeMode:
themeState.themesSettings!.themeMode.toThemeMode,
theme: themeState.lightTheme,
darkTheme: themeState.darkTheme,
home: (authState.status ==
AuthentificationStatus.authentificated ||
theme: themeState.lightTheme,
darkTheme: themeState.darkTheme,
home: (authState.status ==
AuthentificationStatus.authentificated ||
authState.status ==
AuthentificationStatus.authentificating ||
(!settingsState.settings.firstLogin &&
!settingsState.settings.biometricAuth))
? const HomePage()
: LoginPage(key: UniqueKey()),
);
} else {
context.read<ThemeCubit>().init();
context.read<SettingsCubit>().load();
return MaterialApp(
debugShowCheckedModeBanner: false,
themeMode: ThemeMode.system,
theme: OnyxTheme.lightTheme,
darkTheme: OnyxTheme.darkTheme,
home: Scaffold(
backgroundColor:
Theme.of(context).colorScheme.background,
body:
? const HomePage()
: LoginPage(key: UniqueKey()),
);
} else {
context.read<ThemeCubit>().init();
context.read<SettingsCubit>().load();
return MaterialApp(
debugShowCheckedModeBanner: false,
themeMode: ThemeMode.system,
theme: OnyxTheme.lightTheme,
darkTheme: OnyxTheme.darkTheme,
home: Scaffold(
backgroundColor:
Theme
.of(context)
.colorScheme
.background,
body:
const CustomCircularProgressIndicatorWidget()),
);
}
);
}
},
);
},
);
},
);
},
),
),
),
),
);
}
}
4 changes: 4 additions & 0 deletions apps/onyx/lib/core/extensions/date_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ extension DateExtension on DateTime {
String toWeekDayName({bool short = false}) =>
short ? weekDaysShort[weekday - 1] : weekDays[weekday - 1];

String toHourMinuteString() {
return "${hour.toFixedLengthString(2)}h${minute.toFixedLengthString(2)}";
}

String toMonthName({bool short = false}) {
return short ? monthNamesShort[month - 1] : monthNames[month - 1];
}
Expand Down
17 changes: 16 additions & 1 deletion apps/onyx/lib/core/extensions/functionalities_extension.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import 'package:flutter/material.dart';
import 'package:onyx/core/res.dart';
import 'package:onyx/screens/agenda/agenda_export.dart';
import 'package:onyx/screens/colloscope/pages/colloscope_page.dart';
import 'package:onyx/screens/colloscope/widgets/colloscope_bottom_nav_bar_icon.dart';
import 'package:onyx/screens/izly/izly_export.dart';
import 'package:onyx/screens/mails/mails_export.dart';
import 'package:onyx/screens/map/map_export.dart';
import 'package:onyx/screens/settings/settings_export.dart';
import 'package:onyx/screens/settings/widgets/screen_settings/colloscope_settings_widget.dart';
import 'package:onyx/screens/settings/widgets/screen_settings/email_settings_widget.dart';
import 'package:onyx/screens/tomuss/tomuss_export.dart';

Expand All @@ -23,6 +26,8 @@ extension FunctionalitiesExtention on Functionalities {
return "Izly";
case Functionalities.settings:
return "Paramètres";
case Functionalities.colloscope:
return "Colloscope";
}
}

Expand All @@ -40,6 +45,8 @@ extension FunctionalitiesExtention on Functionalities {
return Icons.attach_money_rounded;
case Functionalities.settings:
return Icons.settings_rounded;
case Functionalities.colloscope:
return Icons.school_rounded;
}
}

Expand All @@ -57,6 +64,8 @@ extension FunctionalitiesExtention on Functionalities {
return const IzlyPage();
case Functionalities.settings:
return const SettingsPage();
case Functionalities.colloscope:
return const ColloscopePage();
}
}

Expand All @@ -71,9 +80,11 @@ extension FunctionalitiesExtention on Functionalities {
case Functionalities.map:
return MapBottomNavBarIcon(selected: selected);
case Functionalities.izly:
return IzlyBottomNavBarIconWidget(selected: selected);
return IzlyBottomNavBarIcon(selected: selected);
case Functionalities.settings:
return SettingsBottomNavBarIcon(selected: selected);
case Functionalities.colloscope:
return ColloscopeBottomNavBarIcon(selected: selected);
}
}

Expand Down Expand Up @@ -103,6 +114,10 @@ extension FunctionalitiesExtention on Functionalities {
return SettingsSettingsWidget(
key: key,
);
case Functionalities.colloscope:
return ColloscopeSettingsWidget(
key: key,
);
}
}
}
5 changes: 5 additions & 0 deletions apps/onyx/lib/core/generated/res.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions apps/onyx/lib/core/initialisations/hive_init.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:lyon1mailclient/lyon1mailclient.dart';
import 'package:lyon1tomussclient/lyon1tomussclient.dart';
import 'package:onyx/core/res.dart';
import 'package:onyx/screens/settings/settings_export.dart';
import 'package:polytechcolloscopeclient/polytechcolloscopeclient.dart';

Future<void> hiveInit({String? path}) async {
Hive.registerAdapter(FunctionalitiesAdapter());
Expand All @@ -19,6 +20,7 @@ Future<void> hiveInit({String? path}) async {
Lyon1CasClient.registerAdapters(initHive: false);
Lyon1AgendaClient.registerAdapters();
Lyon1MailClient.registerAdapters(initHive: false);
PolytechColloscopeClient.registerAdapters();

if (path != null || kIsWeb) {
Hive.init(path);
Expand All @@ -34,4 +36,5 @@ Future<void> hiveReset({String? path}) async {
await Hive.deleteBoxFromDisk('tomuss');
await Hive.deleteBoxFromDisk('agenda');
await Hive.deleteBoxFromDisk('mails');
await Hive.deleteBoxFromDisk('cached_colloscope_data');
}
Loading
Loading