From 28fc338c41e9cf04b0a721837e30d3ff52773e42 Mon Sep 17 00:00:00 2001 From: nalka Date: Tue, 7 Jan 2025 22:51:41 +0100 Subject: [PATCH] Add search bar in games list --- .../ViewModels/MainViewModel.cs | 27 ++-- MelonLoader.Installer/Views/MainView.axaml | 128 +++++++++--------- 2 files changed, 78 insertions(+), 77 deletions(-) diff --git a/MelonLoader.Installer/ViewModels/MainViewModel.cs b/MelonLoader.Installer/ViewModels/MainViewModel.cs index 35c81a4..f2ae8bd 100644 --- a/MelonLoader.Installer/ViewModels/MainViewModel.cs +++ b/MelonLoader.Installer/ViewModels/MainViewModel.cs @@ -1,22 +1,21 @@ -using System.Collections.ObjectModel; +using CommunityToolkit.Mvvm.ComponentModel; +using System.Collections.ObjectModel; namespace MelonLoader.Installer.ViewModels; -public class MainViewModel : ViewModelBase +public partial class MainViewModel : ViewModelBase { - private static bool _ready; + [ObservableProperty] + private bool ready; - public bool Ready - { - get => _ready; - set - { - _ready = value; - OnPropertyChanged(); - } - } + [ObservableProperty] + private string? search; - public ObservableCollection Games => GameManager.Games; + [ObservableProperty] + private ObservableCollection games = GameManager.Games; - public string Version => Program.VersionName; + partial void OnSearchChanged(string? value) + { + Games = new(GameManager.Games.Where(x => string.IsNullOrEmpty(value) || x.Name.Contains(value, StringComparison.CurrentCultureIgnoreCase))); + } } diff --git a/MelonLoader.Installer/Views/MainView.axaml b/MelonLoader.Installer/Views/MainView.axaml index 77e3e73..e3e497c 100644 --- a/MelonLoader.Installer/Views/MainView.axaml +++ b/MelonLoader.Installer/Views/MainView.axaml @@ -4,79 +4,81 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:vm="clr-namespace:MelonLoader.Installer.ViewModels" xmlns:views="clr-namespace:MelonLoader.Installer.Views" + xmlns:root="clr-namespace:MelonLoader.Installer" mc:Ignorable="d" d:DesignWidth="450" d:DesignHeight="650" x:Class="MelonLoader.Installer.Views.MainView" x:DataType="vm:MainViewModel"> - - - - + + - - + + - - - - - To install MelonLoader, click on one of the games below. + + + + + To install MelonLoader, click on one of the games below. If you can't find your game on the list, add it manually. - - - - - - - - - - - - + + + + + + + + + + + + + No Unity games have been found on your device. Please add one manually using the button below. - - Loading... - - + + Loading... + + + + + + + + + - - - - - - - + + + \ No newline at end of file