LCOV - code coverage report
Current view: top level - lib/_classes/herald - app_design.dart Coverage Total Hit
Test: lcov.info Lines: 66.7 % 21 14
Test Date: 2026-11-14 15:08:11 Functions: - 0 0

            Line data    Source code
       1              : // Copyright 2023 The terCAD team. All rights reserved.
       2              : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.
       3              : 
       4              : import 'package:app_finance/_classes/storage/app_preferences.dart';
       5              : import 'package:app_finance/_configs/design_type.dart';
       6              : import 'package:app_finance/l10n/index.dart';
       7              : import 'package:material_ui/material_ui.dart';
       8              : 
       9              : class AppDesign extends ValueNotifier<AppDesignType> {
      10            4 :   static AppDesignType _state = find(AppPreferences.get(AppPreferences.prefDesign)) ?? AppDesignType.global;
      11              : 
      12            3 :   AppDesign() : super(get());
      13              : 
      14            2 :   static AppDesignType get() => _state;
      15              : 
      16            6 :   static AppDesignType? find(String? name) => AppDesignType.values.where((e) => e.name == name).firstOrNull;
      17              : 
      18            3 :   static String fromLocale(Locale? value) => languageDesign(value?.languageCode);
      19              : 
      20            3 :   static bool isRightToLeft() => get() == AppDesignType.rtlGeneral;
      21              : 
      22            1 :   static getAlignment<T extends Enum>() => switch (T) {
      23            2 :         const (MainAxisAlignment) => isRightToLeft() ? MainAxisAlignment.end : MainAxisAlignment.start,
      24            2 :         const (TextDirection) => isRightToLeft() ? TextDirection.rtl : TextDirection.ltr,
      25            1 :         _ => isRightToLeft() ? CrossAxisAlignment.end : CrossAxisAlignment.start,
      26              :       };
      27              : 
      28            1 :   static getInverseAlignment<T extends Enum>() => switch (T) {
      29            2 :         const (MainAxisAlignment) => isRightToLeft() ? MainAxisAlignment.start : MainAxisAlignment.end,
      30            1 :         const (TextDirection) => isRightToLeft() ? TextDirection.ltr : TextDirection.rtl,
      31            1 :         _ => isRightToLeft() ? CrossAxisAlignment.start : CrossAxisAlignment.end,
      32              :       };
      33              : 
      34            0 :   Future<void> set(String newValue, [Function? callback]) async {
      35            0 :     final change = find(newValue);
      36            0 :     if (change != null && change != value) {
      37            0 :       value = change;
      38              :       _state = change;
      39            0 :       await AppPreferences.set(AppPreferences.prefDesign, newValue);
      40              :       if (callback != null) {
      41            0 :         callback();
      42              :       }
      43            0 :       notifyListeners();
      44              :     }
      45              :   }
      46              : }
        

Generated by: LCOV version 2.0-1