Sonnat Project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.2 KiB

2 years ago
  1. import 'dart:ui';
  2. import 'package:data/app_setting_data/repository/app_setting_box_repository_impl.dart';
  3. import 'package:hive_flutter/hive_flutter.dart';
  4. import 'package:local_db_core/lib/boxes/box_list/setting_box/app_setting_box.dart';
  5. import 'package:path_provider/path_provider.dart';
  6. import 'package:repositories/app_setting_box_domain/repository/app_setting_box_repository.dart';
  7. class Initializer {
  8. Initializer.privateConstructor();
  9. final AppSettingBoxRepository _repository = AppSettingBoxRepositoryImpl(appSettingBox: AppSettingBox());
  10. static final Initializer instance = Initializer.privateConstructor();
  11. factory Initializer() {
  12. return instance;
  13. }
  14. Future<void> initialHive() async {
  15. final dir = await getApplicationDocumentsDirectory();
  16. Hive.init(dir.path);
  17. await _repository.openBox();
  18. }
  19. TextDirection getTextDirection() {
  20. String? appDirection = _repository.getAppDirection();
  21. if (appDirection == null || appDirection == 'rtl') return TextDirection.rtl;
  22. return TextDirection.ltr;
  23. }
  24. String? getAppDirection() {
  25. return _repository.getAppDirection();
  26. }
  27. void setAppDirection(String value) {
  28. _repository.setAppDirection(value);
  29. }
  30. }