Skip to content

Commit

Permalink
feat: fix hide settings
Browse files Browse the repository at this point in the history
  • Loading branch information
thehrz committed Sep 28, 2024
1 parent 100fa49 commit a38e6a0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions EarthquakeWaring.App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public static void ConfigureServices(IServiceCollection service)
service.AddTransient<EarthQuakesListPage>();
service.AddTransient<EarthQuakeDetail>();
service.AddTransient<SettingsPageViewModel>();
service.AddTransient<MainWindowViewModel>();

service.AddSingleton<ITrayIconHolder, TrayIconHolder>();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using EarthquakeWaring.App.Infrastructure.Models.SettingModels;
using EarthquakeWaring.App.Infrastructure.ServiceAbstraction;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace EarthquakeWaring.App.Infrastructure.Models.ViewModels;

public class MainWindowViewModel : INotifyPropertyChanged
{
{
public ISetting<UpdaterSetting>? UpdateSetting { get; set; }


private bool _isHideSettings = false;
public bool IsHideSettings
Expand All @@ -28,4 +32,11 @@ protected bool SetField<T>(ref T field, T value, [CallerMemberName] string? prop
OnPropertyChanged(propertyName);
return true;
}

public MainWindowViewModel(
ISetting<UpdaterSetting>? updateSetting)
{
UpdateSetting = updateSetting;
_isHideSettings = UpdateSetting?.Setting?.HideSettings ?? false;
}
}
3 changes: 0 additions & 3 deletions EarthquakeWaring.App/Windows/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
Closed="MainWindow_OnClosed"
Style="{StaticResource UiWindow}"
WindowStartupLocation="CenterScreen">
<Window.DataContext>
<viewModels:MainWindowViewModel/>
</Window.DataContext>
<Window.Resources>
<extensions:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
</Window.Resources>
Expand Down
6 changes: 5 additions & 1 deletion EarthquakeWaring.App/Windows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using EarthquakeWaring.App.Infrastructure.Models.SettingModels;
using EarthquakeWaring.App.Infrastructure.Models.ViewModels;
using EarthquakeWaring.App.Infrastructure.ServiceAbstraction;
using EarthquakeWaring.App.Pages;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Windows;
using Wpf.Ui.Mvvm.Interfaces;

namespace EarthquakeWaring.App.Windows
{
Expand All @@ -18,7 +20,9 @@ public partial class MainWindow : Window
public MainWindow(IServiceProvider services)
{
_services = services;
InitializeComponent();
InitializeComponent();

this.DataContext = new MainWindowViewModel(_services.GetService<ISetting<UpdaterSetting>>());
}

protected override void OnInitialized(EventArgs e)
Expand Down

0 comments on commit a38e6a0

Please sign in to comment.