about summary refs log tree commit diff
path: root/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-01-24 02:31:56 +0100
committerRory& <root@rory.gay>2024-01-24 17:05:25 +0100
commit03313562d21d5db9bf6a14ebbeab80e06c883d3a (patch)
treee000546a2ee8e6a886a7ed9fd01ad674178fb7cb /MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs
parentMake RMU installable (diff)
downloadMatrixUtils-03313562d21d5db9bf6a14ebbeab80e06c883d3a.tar.xz
MRU->RMU, fixes, cleanup
Diffstat (limited to 'MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs')
-rw-r--r--MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs72
1 files changed, 0 insertions, 72 deletions
diff --git a/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs b/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs
deleted file mode 100644

index 92c617b..0000000 --- a/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs +++ /dev/null
@@ -1,72 +0,0 @@ -using Avalonia.Controls; -using Avalonia.Interactivity; -using Avalonia.Markup.Xaml; - -namespace MatrixRoomUtils.Desktop.Components; - -public partial class NavigationStack : UserControl { - public NavigationStack() { - InitializeComponent(); - } - - // private void InitializeComponent() { - // AvaloniaXamlLoader.Load(this); - // buildView(); - // } - - protected override void OnLoaded(RoutedEventArgs e) { - base.OnLoaded(e); - buildView(); - } - - private void buildView() { - if (navPanel is null) { - Console.WriteLine("NavigationStack buildView called while navpanel is null!"); - // await Task.Delay(100); - // if (navPanel is null) - // await buildView(); - // else Console.WriteLine("navpanel is not null!"); - } - navPanel.Children.Clear(); - foreach (var item in _stack) { - Button btn = new() { - Content = item.Name - }; - btn.Click += (_, _) => { - PopTo(_stack.IndexOf(item)); - buildView(); - }; - navPanel.Children.Add(btn); - } - content.Content = Current?.View ?? new UserControl(); - } - - - public class NavigationStackItem { - public string Name { get; set; } - public string Description { get; set; } = ""; - public UserControl View { get; set; } - } - - private List<NavigationStackItem> _stack = new(); - - public NavigationStackItem? Current => _stack.LastOrDefault(); - - public void Push(string name, UserControl view) { - _stack.Add(new NavigationStackItem { - Name = name, - View = view - }); - buildView(); - } - - public void Pop() { - _stack.RemoveAt(_stack.Count - 1); - buildView(); - } - - public void PopTo(int index) { - _stack.RemoveRange(index, _stack.Count - index); - buildView(); - } -}