| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="ShellDrawerActionExtensions.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using MyNet.UI.ViewModels.Shell; |
| | | 8 | | |
| | | 9 | | #pragma warning disable IDE0130 |
| | | 10 | | namespace MyNet.UI.ViewModels; |
| | | 11 | | #pragma warning restore IDE0130 |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Helpers for <see cref="ShellDrawerAction"/>. |
| | | 15 | | /// </summary> |
| | | 16 | | public static class ShellDrawerActionExtensions |
| | | 17 | | { |
| | | 18 | | extension(ShellDrawerAction action) |
| | | 19 | | { |
| | | 20 | | /// <summary> |
| | | 21 | | /// Returns whether the action opens the drawer from the given state. |
| | | 22 | | /// </summary> |
| | | 23 | | public bool WillOpen(bool isOpen) |
| | 12 | 24 | | => action switch |
| | 12 | 25 | | { |
| | 6 | 26 | | ShellDrawerAction.Show => true, |
| | 0 | 27 | | ShellDrawerAction.Hide => false, |
| | 6 | 28 | | ShellDrawerAction.Toggle => !isOpen, |
| | 0 | 29 | | _ => false |
| | 12 | 30 | | }; |
| | | 31 | | |
| | | 32 | | /// <summary> |
| | | 33 | | /// Applies a drawer visibility action to the current open state. |
| | | 34 | | /// </summary> |
| | | 35 | | public bool ApplyToOpenState(bool isOpen) |
| | 12 | 36 | | => action switch |
| | 12 | 37 | | { |
| | 6 | 38 | | ShellDrawerAction.Show => true, |
| | 0 | 39 | | ShellDrawerAction.Hide => false, |
| | 6 | 40 | | ShellDrawerAction.Toggle => !isOpen, |
| | 0 | 41 | | _ => isOpen |
| | 12 | 42 | | }; |
| | | 43 | | } |
| | | 44 | | } |
| | | 45 | | |