Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
babbys first mvvm
Browse files Browse the repository at this point in the history
  • Loading branch information
NotNite committed Jan 16, 2023
1 parent 5fd2c08 commit b3a1699
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 8 deletions.
6 changes: 5 additions & 1 deletion src/XIVLauncher2/App.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using XIVLauncher2.ViewModels;

namespace XIVLauncher2;

Expand All @@ -15,7 +16,10 @@ public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow();
desktop.MainWindow = new MainWindow()
{
DataContext = new MainWindowViewModel()
};
}

base.OnFrameworkInitializationCompleted();
Expand Down
17 changes: 17 additions & 0 deletions src/XIVLauncher2/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Reactive;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;

namespace XIVLauncher2.ViewModels;

public partial class MainWindowViewModel : ViewModelBase
{
[ObservableProperty]
private string _XIVLauncherText = "XIVLauncher";

[RelayCommand]
private void RunTheThing()
{
this.XIVLauncherText = "XIVLauncher TWO";
}
}
5 changes: 5 additions & 0 deletions src/XIVLauncher2/ViewModels/ViewModelBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace XIVLauncher2.ViewModels;

using CommunityToolkit.Mvvm.ComponentModel;

public class ViewModelBase : ObservableObject { }
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="clr-namespace:Projektanker.Icons.Avalonia;assembly=Projektanker.Icons.Avalonia"
xmlns:vm="using:XIVLauncher2.ViewModels"
mc:Ignorable="d" d:DesignWidth="1000" d:DesignHeight="500"
x:Class="XIVLauncher2.MainWindow"
Title="XIVLauncher2"
Width="1000" Height="500"
MinWidth="1000" MinHeight="500"
MaxWidth="1280" MaxHeight="800"
WindowStartupLocation="CenterScreen"
TransparencyLevelHint="AcrylicBlur"
Background="Transparent"
ExtendClientAreaToDecorationsHint="False">

<Design.DataContext>
<vm:MainWindowViewModel />
</Design.DataContext>

<ExperimentalAcrylicBorder Padding="10">
<ExperimentalAcrylicBorder.Material>
<ExperimentalAcrylicMaterial BackgroundSource="Digger" TintOpacity="1" TintColor="Black"
Expand Down Expand Up @@ -49,8 +52,8 @@
Grid.Column="1">
<StackPanel Width="250" Spacing="10" VerticalAlignment="Center">
<!-- Placeholder logo text -->
<TextBlock Text="XIVLauncher" FontSize="24" FontWeight="Bold" HorizontalAlignment="Center" />

<TextBlock Text="{Binding XIVLauncherText}" FontSize="24" FontWeight="Bold" HorizontalAlignment="Center" />
<!-- Text boxes -->
<TextBox Watermark="ID"></TextBox>
<TextBox Watermark="Password" PasswordChar="*"></TextBox>
Expand All @@ -65,9 +68,12 @@
<!-- Buttons -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center"
Spacing="5">
<Button i:Attached.Icon="fa-play" ToolTip.Tip="Play" Height="40" Width="40" FontSize="20" Background="#1e88e5" />
<Button i:Attached.Icon="fa-user-group" ToolTip.Tip="Accounts" Height="40" Width="40" FontSize="20" />
<Button i:Attached.Icon="fa-cog" ToolTip.Tip="Settings" Height="40" Width="40" FontSize="20" />
<Button i:Attached.Icon="fa-play" ToolTip.Tip="Play" Height="40" Width="40" FontSize="20"
Background="#1e88e5" Command="{Binding RunTheThingCommand}" />
<Button i:Attached.Icon="fa-user-group" ToolTip.Tip="Accounts" Height="40" Width="40"
FontSize="20" />
<Button i:Attached.Icon="fa-cog" ToolTip.Tip="Settings" Height="40" Width="40"
FontSize="20" />
</StackPanel>
</StackPanel>
</Border>
Expand Down
8 changes: 8 additions & 0 deletions src/XIVLauncher2/XIVLauncher2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@
<PackageReference Include="Avalonia" Version="0.10.18" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.18" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.18" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
<PackageReference Include="Projektanker.Icons.Avalonia" Version="5.8.0" />
<PackageReference Include="Projektanker.Icons.Avalonia.FontAwesome" Version="5.8.0" />
<PackageReference Include="XamlNameReferenceGenerator" Version="1.5.1" />
</ItemGroup>

<ItemGroup>
<Compile Update="Views\MainWindow.axaml.cs">
<DependentUpon>MainWindow.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
</Project>

0 comments on commit b3a1699

Please sign in to comment.