LCOV - code coverage report
Current view: top level - lib/_configs - screen_helper.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 23 24 95.8 %
Date: 2024-10-04 11:09:33 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:flutter/material.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           3 :   @protected
      29             :   ScreenHelper(BuildContext context, BoxConstraints constraints) {
      30           3 :     init(context, constraints);
      31             :   }
      32             : 
      33           3 :   void init(BuildContext context, BoxConstraints constraints) {
      34           6 :     isWide = ThemeHelper.isWideScreen(constraints);
      35           6 :     isBottom = ThemeHelper.isNavBottom(constraints);
      36           6 :     isWearable = ThemeHelper.isWearableMode(context, constraints);
      37           6 :     isRight = ThemeHelper.isNavRight(context, constraints);
      38           9 :     isLeftBar = ThemeHelper.getHeight(context) < 520;
      39           6 :     height = ThemeHelper.getHeight(context);
      40           6 :     originWidth = ThemeHelper.getWidth(context);
      41           6 :     width = ThemeHelper.getWidth(context, 0, constraints);
      42             :   }
      43             : 
      44           3 :   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           3 :           isWide: _instance!.isWide,
      56           3 :           isBottom: _instance!.isBottom,
      57           3 :           isWearable: _instance!.isWearable,
      58           3 :           isRight: _instance!.isRight,
      59           3 :           isLeftBar: _instance!.isLeftBar,
      60           3 :           height: _instance!.height,
      61           3 :           width: _instance!.width,
      62             :         );
      63             : 
      64           3 :   static ScreenHelperState getInstance(BuildContext context, BoxConstraints constraints) {
      65           3 :     _instance ??= ScreenHelper(context, constraints);
      66           9 :     if (_instance?.originWidth != ThemeHelper.getWidth(context)) {
      67           0 :       _instance?.init(context, constraints);
      68             :     }
      69           3 :     return state();
      70             :   }
      71             : }

Generated by: LCOV version 1.14