Skip to content

Commit

Permalink
settings window + menu bar
Browse files Browse the repository at this point in the history
ugly
  • Loading branch information
exp111 committed Oct 11, 2023
1 parent 2d4829c commit a087621
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Turbulence.Core/ViewModels/TextInputViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Turbulence.Core.ViewModels;
public partial class TextInputViewModel : ViewModelBase
{
[ObservableProperty]
private string? _typingStatus;
private string? _typingStatus = "";

[RelayCommand]
private void SendMessage(string message)
Expand Down
25 changes: 17 additions & 8 deletions Turbulence.Desktop/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,21 @@
<Window.DataContext>
<vm:MainWindowViewModel />
</Window.DataContext>
<Grid ColumnDefinitions="75,200,*">
<v:ServerListView />
<v:ChannelListView Grid.Column="1" />
<DockPanel Grid.Column="2">
<v:TextInputView DockPanel.Dock="Bottom" />
<v:MessagesView />
</DockPanel>
</Grid>
<DockPanel>
<Menu DockPanel.Dock="Top" Background="#23272a">
<MenuItem Header="_File">
<MenuItem Header="_Settings" Click="OnSettings"/>
<Separator/>
<MenuItem Header="_Exit" Click="OnExit"/>
</MenuItem>
</Menu>
<Grid ColumnDefinitions="75,200,*">
<v:ServerListView />
<v:ChannelListView Grid.Column="1" />
<DockPanel Grid.Column="2">
<v:TextInputView DockPanel.Dock="Bottom" />
<v:MessagesView />
</DockPanel>
</Grid>
</DockPanel>
</Window>
22 changes: 22 additions & 0 deletions Turbulence.Desktop/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Interactivity;

namespace Turbulence.Desktop;

public partial class MainWindow : Window
{
SettingsWindow? _settingsWindow;
public MainWindow()
{
InitializeComponent();
}

public async void OnSettings(object? _1, RoutedEventArgs _2)
{
//TODO: instead show as a independent window?
_settingsWindow = new();
await _settingsWindow.ShowDialog(this);
}

public void OnExit(object? _1, RoutedEventArgs _2)
{
var current = Application.Current;
if (current == null)
return;

var lifetime = current.ApplicationLifetime;
if (lifetime is IClassicDesktopStyleApplicationLifetime desktop)
desktop.Shutdown();
}
}
3 changes: 2 additions & 1 deletion Turbulence.Desktop/Program.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;

Expand All @@ -8,7 +9,7 @@ internal class Program : Application
{
public static void Main(string[] args)
{
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args, ShutdownMode.OnMainWindowClose);
}

private static AppBuilder BuildAvaloniaApp()
Expand Down
12 changes: 12 additions & 0 deletions Turbulence.Desktop/SettingsWindow.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="600" d:DesignHeight="500"
Width="600" Height="500"
MinWidth="600" MinHeight="500"
WindowStartupLocation="CenterOwner"
x:Class="Turbulence.Desktop.SettingsWindow"
Title="Settings">
Welcome to Avalonia!
</Window>
12 changes: 12 additions & 0 deletions Turbulence.Desktop/SettingsWindow.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Avalonia.Controls;

namespace Turbulence.Desktop
{
public partial class SettingsWindow : Window
{
public SettingsWindow()
{
InitializeComponent();
}
}
}
1 change: 0 additions & 1 deletion Turbulence.Discord/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public async Task Start()
_ = Task.Run(ReceiveTask);
_ = Task.Run(HeartbeatTask);
_ = Task.Run(SendTask);
// TODO: implement a send queue, to issue gateway commands async
}

public void SetWebsocketHeaders()
Expand Down

0 comments on commit a087621

Please sign in to comment.