Skip to content

Commit

Permalink
non functional set token
Browse files Browse the repository at this point in the history
  • Loading branch information
exp111 committed Oct 11, 2023
1 parent 993dc0f commit c4a78ca
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Turbulence.Core/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ public async void Receive(SendMessageMsg message) =>
/// <summary>
/// Send a message in the currently selected channel
/// </summary>
public record SendMessageMsg(string Message);
public record SendMessageMsg(string Message);
20 changes: 20 additions & 0 deletions Turbulence.Core/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using CommunityToolkit.Mvvm.Input;
using Microsoft.Extensions.Configuration;
using Turbulence.Discord;

namespace Turbulence.Core.ViewModels;

public partial class SettingsViewModel : ViewModelBase
{
//TODO: save current user?

[RelayCommand]
private void SetToken(string token)
{
//TODO: run in service?
//Messenger.Send(new SetTokenMessage(token));
var config = new ConfigurationManager().AddUserSecrets<Client>().Build();
config["token"] = token;
//TODO: actually save it lmao
}
}
3 changes: 3 additions & 0 deletions Turbulence.Desktop/SettingsWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
WindowStartupLocation="CenterOwner"
x:Class="Turbulence.Desktop.SettingsWindow"
Title="Settings">
<Window.DataContext>
<vm:SettingsViewModel />
</Window.DataContext>
<TabControl TabStripPlacement="Left" Background="#313338" Padding="10,10">
<TabItem Header="General">
<v:GeneralSettingsView/>
Expand Down
8 changes: 7 additions & 1 deletion Turbulence.Desktop/Views/Settings/AccountSettingsView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,11 @@
mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="500"
x:Class="Turbulence.Desktop.Views.Settings.AccountSettingsView"
Background="#313338">
Account
<StackPanel Orientation="Vertical">
<Grid ColumnDefinitions="*,auto,auto">
<TextBox Name="Token" Watermark="Token" PasswordChar="*" Grid.Column="0"/>
<Button Click="OnSetToken" Grid.Column="1">Set Token</Button>
<CheckBox Checked="OnTokenShow" Grid.Column="2">Show</CheckBox>
</Grid>
</StackPanel>
</UserControl>
16 changes: 16 additions & 0 deletions Turbulence.Desktop/Views/Settings/AccountSettingsView.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Avalonia.Controls;
using Avalonia.Interactivity;
using Turbulence.Core.ViewModels;

namespace Turbulence.Desktop.Views.Settings;

Expand All @@ -8,4 +10,18 @@ public AccountSettingsView()
{
InitializeComponent();
}

public void OnSetToken(object? sender, RoutedEventArgs? e)
{
((SettingsViewModel)DataContext!).SetTokenCommand.Execute(Token.Text);
Token.Text = "";
}

public void OnTokenShow(object? sender, RoutedEventArgs? e)
{
if (sender is CheckBox check)
{
Token.RevealPassword = check.IsChecked ?? false;
}
}
}

0 comments on commit c4a78ca

Please sign in to comment.