Skip to content

Commit

Permalink
beggin big cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
hatch01 committed Dec 2, 2023
1 parent a11c2a4 commit 5b2ae0f
Show file tree
Hide file tree
Showing 22 changed files with 611 additions and 645 deletions.
95 changes: 47 additions & 48 deletions apps/onyx/lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,52 +56,50 @@ class OnyxAppState extends State<OnyxApp> {
BlocProvider<TomussCubit>(create: (context) => TomussCubit()),
BlocProvider<MapCubit>(create: (context) => MapCubit()),
BlocProvider<IzlyCubit>(create: (context) => IzlyCubit()),
BlocProvider<ThemeCubit>(
create: (context) => ThemeCubit(OnyxTheme.themesPreset)),
BlocProvider<ThemeCubit>(create: (context) => ThemeCubit()),
],
child: BlocBuilder<ThemeCubit, ThemeState>(
builder: (context, themeState) {
return 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}");
}
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
.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(
lyon1Cas: authState.lyon1Cas,
settings: context.read<SettingsCubit>().state.settings,
force: true,
);
}
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(
lyon1Cas: authState.lyon1Cas,
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 ||
settingsState.status == SettingsStatus.error) {
if ((settingsState.status == SettingsStatus.ready ||
settingsState.status == SettingsStatus.error) &&
(themeState.status != ThemeStateStatus.init)) {
if (authState.status == AuthentificationStatus.initial) {
context
.read<AuthentificationCubit>()
Expand All @@ -121,7 +119,8 @@ class OnyxAppState extends State<OnyxApp> {
navigatorKey: OnyxApp.navigatorKey,
scrollBehavior: const CustomScrollBehavior(),
debugShowCheckedModeBanner: false,
themeMode: settingsState.settings.themeMode.themeMode,
themeMode:
themeState.themesSettings!.themeMode.toThemeMode,
theme: themeState.lightTheme,
darkTheme: themeState.darkTheme,
home: (authState.status ==
Expand All @@ -134,16 +133,16 @@ class OnyxAppState extends State<OnyxApp> {
: LoginPage(key: UniqueKey()),
);
} else {
context.read<ThemeCubit>().init();
context.read<SettingsCubit>().load();
return MaterialApp(
debugShowCheckedModeBanner: false,
themeMode: settingsState.settings.themeMode.themeMode,
theme: themeState.lightTheme,
darkTheme: themeState.darkTheme,
themeMode: ThemeMode.system,
theme: OnyxTheme.lightTheme,
darkTheme: OnyxTheme.darkTheme,
home: Scaffold(
backgroundColor:
themeState.darkTheme?.colorScheme.background ??
OnyxTheme.darkTheme.colorScheme.background,
Theme.of(context).colorScheme.background,
body:
const CustomCircularProgressIndicatorWidget()),
);
Expand Down
24 changes: 12 additions & 12 deletions apps/onyx/lib/core/cache_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ class CacheService {
}

static Future<bool> exist<E>({int index = 0, List<int>? secureKey}) async {
try {
Box box = await Hive.openBox<E>(
"cached_$E",
encryptionCipher: (secureKey != null) ? HiveAesCipher(secureKey) : null,
crashRecovery: false,
);
return box.containsKey("cache$index");
} catch (e) {
Res.logger.e("error while checking existence of cache for $E: $e");
await reset<E>();
return false;
}
// try {
Box box = await Hive.openBox<E>(
"cached_$E",
encryptionCipher: (secureKey != null) ? HiveAesCipher(secureKey) : null,
crashRecovery: false,
);
return box.containsKey("cache$index");
// } catch (e) {
// Res.logger.e("error while checking existence of cache for $E: $e");
// await reset<E>();
// return false;
// }
}

static Future<void> reset<E>() async {
Expand Down
1 change: 1 addition & 0 deletions apps/onyx/lib/core/initialisations/hive_init.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Future<void> hiveInit({String? path}) async {
Hive.registerAdapter(FunctionalitiesAdapter());
Hive.registerAdapter(ThemeModeEnumAdapter());
Hive.registerAdapter(SettingsModelAdapter());
Hive.registerAdapter(ThemeSettingsModelAdapter());

IzlyClient.registerAdapters();
Lyon1TomussClient.registerAdapters();
Expand Down
8 changes: 8 additions & 0 deletions apps/onyx/lib/core/res.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ class Res {

static final logger = Logger(
level: (kDebugMode) ? Level.all : Level.fatal,
printer: PrettyPrinter(
methodCount: 0,
errorMethodCount: 8,
lineLength: 120,
colors: true,
printEmojis: true,
printTime: true,
),
);
}

Expand Down
22 changes: 11 additions & 11 deletions apps/onyx/lib/core/theme/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -225,22 +225,22 @@ class OnyxTheme {
),
);

static List<ThemeInfo> themesPreset = [
ThemeInfo('Dark Default', OnyxTheme.darkTheme),
ThemeInfo('Light Default', OnyxTheme.lightTheme),
ThemeInfo('Nichi Hachi', OnyxTheme.nichihachiTheme),
ThemeInfo('Blue Sky', OnyxTheme.blueSkyTheme),
ThemeInfo('ULTRAKILL', OnyxTheme.ultrakillTheme),
ThemeInfo('Stardew Valley', OnyxTheme.stardewValleyTheme),
ThemeInfo('Bad Apple', OnyxTheme.badappleTheme),
ThemeInfo('Moon Light', OnyxTheme.moonlightTheme),
static List<ThemeModel> themesPreset = [
ThemeModel('Dark Default', OnyxTheme.darkTheme),
ThemeModel('Light Default', OnyxTheme.lightTheme),
ThemeModel('Nichi Hachi', OnyxTheme.nichihachiTheme),
ThemeModel('Blue Sky', OnyxTheme.blueSkyTheme),
ThemeModel('ULTRAKILL', OnyxTheme.ultrakillTheme),
ThemeModel('Stardew Valley', OnyxTheme.stardewValleyTheme),
ThemeModel('Bad Apple', OnyxTheme.badappleTheme),
ThemeModel('Moon Light', OnyxTheme.moonlightTheme),
];

static List<ThemeInfo> themesPresetDark = themesPreset
static List<ThemeModel> themesPresetDark = themesPreset
.where((themeInfo) => themeInfo.theme.brightness == Brightness.dark)
.toList();

static List<ThemeInfo> themesPresetLight = themesPreset
static List<ThemeModel> themesPresetLight = themesPreset
.where((themeInfo) => themeInfo.theme.brightness == Brightness.light)
.toList();
}
4 changes: 2 additions & 2 deletions apps/onyx/lib/screens/izly/pages/izly_login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ class _IzlyLoginPageState extends State<IzlyLoginPage> {
child: Text(
"Confidentialité",
style: Theme.of(context)
.textTheme
.bodySmall!
.textTheme
.bodySmall!
.copyWith(fontSize: 17.sp),
),
),
Expand Down

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

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

Loading

0 comments on commit 5b2ae0f

Please sign in to comment.