LCOV - code coverage report
Current view: top level - lib/_configs - screen_helper.dart Coverage Total Hit
Test: lcov.info Lines: 95.8 % 24 23
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/_configs/theme_helper.dart';
       5              : import 'package:material_ui/material_ui.dart';
       6              : 
       7              : typedef ScreenHelperState = ({
       8              :   bool isWide,
       9              :   bool isBottom,
      10              :   bool isWearable,
      11              :   bool isRight,
      12              :   bool isLeftBar,
      13              :   double height,
      14              :   double width,
      15              : });
      16              : 
      17              : class ScreenHelper {
      18              :   static ScreenHelper? _instance;
      19              :   bool isWide = false;
      20              :   bool isBottom = false;
      21              :   bool isWearable = false;
      22              :   bool isRight = false;
      23              :   bool isLeftBar = false;
      24              :   double height = 0;
      25              :   double width = 0;
      26              :   double originWidth = 0;
      27              : 
      28            1 :   @protected
      29              :   ScreenHelper(BuildContext context, BoxConstraints constraints) {
      30            1 :     init(context, constraints);
      31              :   }
      32              : 
      33            1 :   void init(BuildContext context, BoxConstraints constraints) {
      34            2 :     isWide = ThemeHelper.isWideScreen(constraints);
      35            2 :     isBottom = ThemeHelper.isNavBottom(constraints);
      36            2 :     isWearable = ThemeHelper.isWearableMode(context, constraints);
      37            2 :     isRight = ThemeHelper.isNavRight(context, constraints);
      38            2 :     isLeftBar = isRight && ThemeHelper.getHeight(context) < 520;
      39            2 :     height = ThemeHelper.getHeight(context);
      40            2 :     originWidth = ThemeHelper.getWidth(context);
      41            2 :     width = ThemeHelper.getWidth(context, 0, constraints);
      42              :   }
      43              : 
      44            1 :   static ScreenHelperState state() => _instance == null
      45              :       ? (
      46              :           isWide: false,
      47              :           isBottom: false,
      48              :           isWearable: false,
      49              :           isRight: false,
      50              :           isLeftBar: false,
      51              :           height: 0,
      52              :           width: 0,
      53              :         )
      54              :       : (
      55            1 :           isWide: _instance!.isWide,
      56            1 :           isBottom: _instance!.isBottom,
      57            1 :           isWearable: _instance!.isWearable,
      58            1 :           isRight: _instance!.isRight,
      59            1 :           isLeftBar: _instance!.isLeftBar,
      60            1 :           height: _instance!.height,
      61            1 :           width: _instance!.width,
      62              :         );
      63              : 
      64            1 :   static ScreenHelperState getInstance(BuildContext context, BoxConstraints constraints) {
      65            1 :     _instance ??= ScreenHelper(context, constraints);
      66            3 :     if (_instance?.originWidth != ThemeHelper.getWidth(context)) {
      67            0 :       _instance?.init(context, constraints);
      68              :     }
      69            1 :     return state();
      70              :   }
      71              : }
        

Generated by: LCOV version 2.0-1