< Summary

Information
Class: Chronicis.Client.Services.DrawerCoordinator
Assembly: Chronicis.Client
File(s): /home/runner/work/chronicis/chronicis/src/Chronicis.Client/Services/DrawerCoordinator.cs
Line coverage
100%
Covered lines: 39
Uncovered lines: 0
Coverable lines: 39
Total lines: 101
Line coverage: 100%
Branch coverage
100%
Covered branches: 38
Total branches: 38
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Current()100%11100%
get_IsForcedOpen()100%11100%
set_IsForcedOpen(...)100%88100%
Open(...)100%1010100%
Close()100%88100%
Toggle(...)100%1212100%

File(s)

/home/runner/work/chronicis/chronicis/src/Chronicis.Client/Services/DrawerCoordinator.cs

#LineLine coverage
 1namespace Chronicis.Client.Services;
 2
 3/// <summary>
 4/// Default implementation for coordinating mutually-exclusive right-side drawers.
 5/// </summary>
 6public class DrawerCoordinator : IDrawerCoordinator
 7{
 8    private DrawerType _current = DrawerType.None;
 9    private bool _isForcedOpen;
 10
 5611    public DrawerType Current => _current;
 12
 13    public bool IsForcedOpen
 14    {
 215        get => _isForcedOpen;
 16        set
 17        {
 818            if (_isForcedOpen == value)
 19            {
 120                return;
 21            }
 22
 723            _isForcedOpen = value;
 24
 725            if (_isForcedOpen && _current != DrawerType.Tutorial)
 26            {
 327                _current = DrawerType.Tutorial;
 28            }
 29
 730            OnChanged?.Invoke();
 231        }
 32    }
 33
 34    public event Action? OnChanged;
 35
 36    public void Open(DrawerType type)
 37    {
 3738        if (type == DrawerType.None)
 39        {
 140            Close();
 141            return;
 42        }
 43
 3644        if (_isForcedOpen && type != DrawerType.Tutorial)
 45        {
 146            type = DrawerType.Tutorial;
 47        }
 48
 3649        if (_current == type)
 50        {
 451            return;
 52        }
 53
 3254        _current = type;
 3255        OnChanged?.Invoke();
 1856    }
 57
 58    public void Close()
 59    {
 1460        if (_isForcedOpen && _current == DrawerType.Tutorial)
 61        {
 162            return;
 63        }
 64
 1365        if (_current == DrawerType.None)
 66        {
 367            return;
 68        }
 69
 1070        _current = DrawerType.None;
 1071        OnChanged?.Invoke();
 672    }
 73
 74    public void Toggle(DrawerType type)
 75    {
 1576        if (type == DrawerType.None)
 77        {
 178            Close();
 179            return;
 80        }
 81
 1482        if (_isForcedOpen && type != DrawerType.Tutorial)
 83        {
 184            Open(DrawerType.Tutorial);
 185            return;
 86        }
 87
 1388        if (_current == type)
 89        {
 590            if (_isForcedOpen && type == DrawerType.Tutorial)
 91            {
 192                return;
 93            }
 94
 495            Close();
 496            return;
 97        }
 98
 899        Open(type);
 8100    }
 101}