Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v11-Prev 5 - Theme Fixes #46

Merged
merged 2 commits into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Prism.Avalonia.sln
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ViewDiscovery", "samples\Vi
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DummyModules", "DummyModules", "{E03DB670-BFA9-4E7B-A69C-D1E6B8E1691F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModulesSample", "samples\ModulesSample\ModulesSample.csproj", "{DCC68F88-29C9-44EF-90E3-685666AFD6AD}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModulesSampleApp", "samples\ModulesSample\ModulesSampleApp.csproj", "{DCC68F88-29C9-44EF-90E3-685666AFD6AD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DummyModule1", "samples\DummyModule1\DummyModule1.csproj", "{2B315287-FDAE-4092-9A80-7DA07D934BF1}"
EndProject
Expand Down
1 change: 1 addition & 0 deletions Upgrading-to-Avalonia-11.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Check out Avalonia's [Breaking Changes](https://github.com/AvaloniaUI/Avalonia/w
* The case was for "_single view platforms_" and not just Desktops which have a `Window` object.
* Themes:
* Themes must be download as part of a separate package and `App.axaml` implementation has changed.
* User MUST set a theme in `App.axaml`, otherwise the window's contents may be transparent
* See, [PR# 8148](https://github.com/AvaloniaUI/Avalonia/pull/8166), [PR #8166](https://github.com/AvaloniaUI/Avalonia/pull/8166), [Issue #5593](https://github.com/AvaloniaUI/Avalonia/issues/5593)
* NEW: `<SimpleTheme />`
* OLD: `<SimpleTheme Mode="Light" />`
Expand Down
4 changes: 3 additions & 1 deletion samples/BootstrapperShellSample/App.axaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="BootstrapperShellSample.App">
x:Class="BootstrapperShellSample.App"
RequestedThemeVariant="Light">
<Application.Styles>
<FluentTheme />
<!--<StyleInclude Source="resm:Avalonia.Themes.Default.DefaultTheme.xaml?assembly=Avalonia.Themes.Default"/>
<StyleInclude Source="resm:Avalonia.Themes.Default.Accents.BaseLight.xaml?assembly=Avalonia.Themes.Default"/>-->
</Application.Styles>
Expand Down
4 changes: 3 additions & 1 deletion samples/ModulesSample/App.axaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ModulesSample.App">
x:Class="ModulesSample.App"
RequestedThemeVariant="Light">
<Application.Styles>
<FluentTheme />
<!--<StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml"/>-->
<!--<StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseLight.xaml"/>-->
</Application.Styles>
Expand Down
2 changes: 0 additions & 2 deletions samples/ModulesSample/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
using System.Threading;
using Avalonia.Dialogs;
using ModulesSample.Infrastructure;
using static System.Net.WebRequestMethods;
using System.Security.Policy;

namespace ModulesSample
{
Expand Down
29 changes: 26 additions & 3 deletions samples/SampleMvvmApp/ViewModels/DashboardViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Avalonia;
using Avalonia.Styling;
using Prism.Commands;
using Prism.Regions;
using SampleMvvmApp.Services;

namespace SampleMvvmApp.ViewModels
Expand All @@ -12,10 +14,14 @@ public class DashboardViewModel : ViewModelBase
private int _listItemSelected = -1;
private ObservableCollection<string> _listItems = new();
private string _listItemText;
private ThemeVariant _themeSelected;
private int _themeSelectedIndex = 0;

public DashboardViewModel(IRegionManager regionManager, INotificationService notifyService)
public DashboardViewModel(INotificationService notifyService)
{
_notification = notifyService;

ThemeSelected = Application.Current!.RequestedThemeVariant;
}

public DelegateCommand CmdAddItem => new(() =>
Expand Down Expand Up @@ -68,5 +74,22 @@ public ObservableCollection<string> ListItems
get => _listItems;
set => SetProperty(ref _listItems, value);
}

public ThemeVariant ThemeSelected
{
get => _themeSelected;
set
{
SetProperty(ref _themeSelected, value);
Application.Current!.RequestedThemeVariant = _themeSelected;
}
}

public List<ThemeVariant> ThemeStyles => new()
{
ThemeVariant.Default,
ThemeVariant.Dark,
ThemeVariant.Light,
};
}
}
12 changes: 12 additions & 0 deletions samples/SampleMvvmApp/Views/DashboardView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
<Button Content="Add Item" Command="{Binding CmdAddItem}" />
<Button Content="Clear" Command="{Binding CmdClearItems}" />
<Button Content="Notification Pop-up" Command="{Binding CmdNotification}" />

<ComboBox VerticalAlignment="Center"
HorizontalAlignment="Stretch"
Items="{Binding ThemeStyles}"
SelectedItem="{Binding ThemeSelected}">
<!--SelectedIndex="{Binding ThemeSelectedIndex}" >-->
<ComboBox.ItemTemplate>
<DataTemplate x:DataType="x:String">
<TextBlock Text="{Binding TargetNullValue=Unset}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</StackPanel>

<StackPanel Grid.Row="2" Orientation="Horizontal">
Expand Down