elCaribe app - customization and branding

This commit is contained in:
2025-12-12 19:09:42 -04:00
parent 9e5d0d8ebf
commit ba7deac9f3
402 changed files with 31833 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
import 'package:news/data/repositories/Settings/settingsLocalDataRepository.dart';
class SettingsRepository {
static final SettingsRepository _settingsRepository = SettingsRepository._internal();
late SettingsLocalDataRepository _settingsLocalDataSource;
factory SettingsRepository() {
_settingsRepository._settingsLocalDataSource = SettingsLocalDataRepository();
return _settingsRepository;
}
SettingsRepository._internal();
Map<String, dynamic> getCurrentSettings() {
return {
"showIntroSlider": _settingsLocalDataSource.getIntroSlider(),
"languageCode": _settingsLocalDataSource.getCurrentLanguageCode(),
"theme": _settingsLocalDataSource.getCurrentTheme(),
"notification": _settingsLocalDataSource.getNotification(),
"token": _settingsLocalDataSource.getFcmToken()
};
}
void changeIntroSlider(bool value) => _settingsLocalDataSource.setIntroSlider(value);
void changeFcmToken(String value) => _settingsLocalDataSource.setFcmToken(value);
void changeNotification(bool value) => _settingsLocalDataSource.setNotification(value);
}

View File

@@ -0,0 +1,75 @@
import 'package:flutter/src/foundation/change_notifier.dart';
import 'package:hive_flutter/adapters.dart';
import 'package:news/utils/hiveBoxKeys.dart';
import 'package:news/utils/uiUtils.dart';
class SettingsLocalDataRepository {
Future<void> setLanguagePreferences({required String code, required String id, required int rtl}) async {
final box = Hive.box(settingsBoxKey);
await Future.wait([
box.put(currentLanguageCodeKey, code),
box.put(currentLanguageIDKey, id),
box.put(currentLanguageRTLKey, rtl),
]);
UiUtils.checkIfValidLocale(langCode: code); // only if you want to validate locale after setting
}
String getCurrentLanguageCode() {
return Hive.box(settingsBoxKey).get(currentLanguageCodeKey) ?? "";
}
String getCurrentLanguageId() {
return Hive.box(settingsBoxKey).get(currentLanguageIDKey) ?? '';
}
int getCurrentLanguageRTL() {
return Hive.box(settingsBoxKey).get(currentLanguageRTLKey) ?? 0;
}
Future<void> setIntroSlider(bool value) async {
Hive.box(settingsBoxKey).put(introSliderKey, value);
}
bool getIntroSlider() {
return Hive.box(settingsBoxKey).get(introSliderKey) ?? true;
}
Future<void> setFcmToken(String value) async {
Hive.box(settingsBoxKey).put(tokenKey, value);
}
String getFcmToken() {
return Hive.box(settingsBoxKey).get(tokenKey) ?? "";
}
Future<void> setCurrentTheme(String value) async {
Hive.box(settingsBoxKey).put(currentThemeKey, value);
}
String getCurrentTheme() {
return Hive.box(settingsBoxKey).get(currentThemeKey) ?? "";
}
Future<void> setNotification(bool value) async {
Hive.box(settingsBoxKey).put(notificationKey, value);
}
bool getNotification() {
return Hive.box(settingsBoxKey).get(notificationKey) ?? true;
}
Future<void> setLocationCityKeys(double? latitude, double? longitude) async {
Hive.box(locationCityBoxKey).put(latitudeKey, latitude);
Hive.box(locationCityBoxKey).put(longitudeKey, longitude);
}
Set<String> getLocationCityValues() {
Set<String> locationValues = {Hive.box(locationCityBoxKey).get(latitudeKey).toString(), Hive.box(locationCityBoxKey).get(longitudeKey).toString()};
return locationValues;
}
ValueListenable<Box> getVideoScreenStyle() {
return Hive.box(videoPreferenceKey).listenable();
}
}