Skip to content

Commit

Permalink
🎨 Add the Images page.
Browse files Browse the repository at this point in the history
  • Loading branch information
hexawyz committed Jan 15, 2025
1 parent 1b9cbca commit 13f5e6d
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 3 deletions.
28 changes: 28 additions & 0 deletions src/Exo/Ui/Exo.Settings.Ui/ImagesPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<Page
x:Class="Exo.Settings.Ui.ImagesPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Exo.Settings.Ui"
xmlns:lconverters="using:Exo.Settings.Ui.Converters"
xmlns:vm="using:Exo.Settings.Ui.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance vm:SettingsViewModel, IsDesignTimeCreatable=False}">

<Grid>
<ItemsView ItemsSource="{Binding Images.Images}">
<ItemsView.ItemTemplate>
<DataTemplate x:DataType="vm:ImageViewModel">
<ItemContainer AutomationProperties.Name="{Binding Name}">
<TextBox Text="{Binding Name}" />
</ItemContainer>
</DataTemplate>
</ItemsView.ItemTemplate>
<ItemsView.Layout>
<UniformGridLayout />
</ItemsView.Layout>
</ItemsView>
</Grid>
</Page>
17 changes: 17 additions & 0 deletions src/Exo/Ui/Exo.Settings.Ui/ImagesPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Exo.Settings.Ui.ViewModels;
using Microsoft.UI.Xaml.Controls;

namespace Exo.Settings.Ui;

/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class ImagesPage : Page
{
public ImagesPage()
{
InitializeComponent();
}

private SettingsViewModel ViewModel => (SettingsViewModel)DataContext;
}
3 changes: 3 additions & 0 deletions src/Exo/Ui/Exo.Settings.Ui/RootPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ private void Navigate(PageViewModel? page)
case "Lighting":
type = typeof(LightingPage);
break;
case "Images":
type = typeof(ImagesPage);
break;
case "Sensors":
type = typeof(SensorsPage);
break;
Expand Down
5 changes: 4 additions & 1 deletion src/Exo/Ui/Exo.Settings.Ui/Strings/en-US/Pages.resw
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Expand Down Expand Up @@ -129,6 +129,9 @@
<data name="Home" xml:space="preserve">
<value>Home</value>
</data>
<data name="Images" xml:space="preserve">
<value>Images</value>
</data>
<data name="Lighting" xml:space="preserve">
<value>Lighting</value>
</data>
Expand Down
5 changes: 4 additions & 1 deletion src/Exo/Ui/Exo.Settings.Ui/Strings/fr-FR/Pages.resw
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Expand Down Expand Up @@ -129,6 +129,9 @@
<data name="Home" xml:space="preserve">
<value>Accueil</value>
</data>
<data name="Images" xml:space="preserve">
<value>Images</value>
</data>
<data name="Lighting" xml:space="preserve">
<value>Éclairage</value>
</data>
Expand Down
42 changes: 42 additions & 0 deletions src/Exo/Ui/Exo.Settings.Ui/ViewModels/ImagesViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System.Collections.ObjectModel;
using Exo.Ui;

namespace Exo.Settings.Ui.ViewModels;

internal sealed class ImagesViewModel : BindableObject
{
private readonly ObservableCollection<ImageViewModel> _images;
private readonly ReadOnlyObservableCollection<ImageViewModel> _readOnlyImages;

public ImagesViewModel()
{
_images = new();
_readOnlyImages = new(_images);
}

public ReadOnlyObservableCollection<ImageViewModel> Images => _readOnlyImages;

protected void UploadImage() { }
}

internal sealed partial class ImageViewModel : ApplicableResettableBindableObject
{
private string _name;

public override bool IsChanged => false;

public ImageViewModel(string name)
{
_name = name;
}

public string Name
{
get => _name;
set => SetValue(ref _name, value);
}

protected override Task ApplyChangesAsync(CancellationToken cancellationToken) => throw new NotImplementedException();
protected override void Reset() => throw new NotImplementedException();

}
7 changes: 6 additions & 1 deletion src/Exo/Ui/Exo.Settings.Ui/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public event EventHandler? CanExecuteChanged
private readonly DevicesViewModel _devicesViewModel;
private readonly BatteryDevicesViewModel _batteryDevicesViewModel;
private readonly LightingViewModel _lightingViewModel;
private readonly ImagesViewModel _imagesViewModel;
private readonly SensorsViewModel _sensorsViewModel;
private readonly CoolingViewModel _coolingViewModel;
private readonly ProgrammingViewModel _programmingViewModel;
Expand All @@ -75,6 +76,7 @@ public PageViewModel? SelectedNavigationPage
public PageViewModel HomePage { get; }
public PageViewModel DevicesPage { get; }
public PageViewModel LightingPage { get; }
public PageViewModel ImagesPage { get; }
public PageViewModel SensorsPage { get; }
public PageViewModel CoolingPage { get; }
public PageViewModel CustomMenuPage { get; }
Expand Down Expand Up @@ -103,6 +105,7 @@ public SettingsViewModel(SettingsServiceConnectionManager connectionManager, Con
_devicesViewModel = new(ConnectionManager, _metadataService, _navigateCommand);
_batteryDevicesViewModel = new(_devicesViewModel);
_lightingViewModel = new(ConnectionManager, _devicesViewModel, _metadataService);
_imagesViewModel = new();
_sensorsViewModel = new(ConnectionManager, _devicesViewModel, _metadataService);
_coolingViewModel = new(ConnectionManager, _devicesViewModel, _sensorsViewModel, _metadataService);
_programmingViewModel = new(ConnectionManager);
Expand All @@ -111,11 +114,12 @@ public SettingsViewModel(SettingsServiceConnectionManager connectionManager, Con
HomePage = new("Home", "\uE80F");
DevicesPage = new("Devices", "\uE772");
LightingPage = new("Lighting", "\uE781");
ImagesPage = new("Images", "\uE8B9");
SensorsPage = new("Sensors", "\uE9D9");
CoolingPage = new("Cooling", "\uE9CA");
CustomMenuPage = new("CustomMenu", "\uEDE3");
ProgrammingPage = new("Programming", "\uE943");
NavigationPages = [HomePage, DevicesPage, LightingPage, SensorsPage, CoolingPage, CustomMenuPage, ProgrammingPage];
NavigationPages = [HomePage, DevicesPage, LightingPage, ImagesPage, SensorsPage, CoolingPage, CustomMenuPage, ProgrammingPage];
SelectedNavigationPage = HomePage;

connectionViewModel.PropertyChanged += OnConnectionViewModelPropertyChanged;
Expand Down Expand Up @@ -145,6 +149,7 @@ private void OnConnectionViewModelPropertyChanged(object? sender, System.Compone
public BatteryDevicesViewModel BatteryDevices => _batteryDevicesViewModel;
public LightingViewModel Lighting => _lightingViewModel;
public SensorsViewModel Sensors => _sensorsViewModel;
public ImagesViewModel Images => _imagesViewModel;
public CoolingViewModel Cooling => _coolingViewModel;
public ProgrammingViewModel Programming => _programmingViewModel;
public CustomMenuViewModel CustomMenu => _customMenuViewModel;
Expand Down

0 comments on commit 13f5e6d

Please sign in to comment.