npolyak / NP.Avalonia.Visuals

MIT License
33 stars 11 forks source link

Not supported in Avalonia 11-preview4 #5

Open TimB-rain opened 1 year ago

TimB-rain commented 1 year ago

After updating from Avalonia 10 to Avalonia 11-preview4 we have the exception in compiler

SettingsViewModel.cs(26, 34): [CS0012] The type 'IResourceProvider' is defined in an assembly that is not referenced. You must add a reference to assembly 'Avalonia.Styling, Version=0.10.18.0, Culture=neutral, PublicKeyToken=c8d484a7012f9a8b'.

using Avalonia;
using Avalonia.Styling;
using NP.Avalonia.Visuals.Behaviors;
using NP.Avalonia.Visuals.ThemingAndL10N;
using ReactiveUI;
using System;
using System.Reflection;
using System.Threading.Tasks;

namespace QxCode.Projector.Desktop.ViewModels {
    public class SettingsViewModel : ViewModelBase {
        private readonly IWindowsService _ws;
        private readonly ThemeLoader _languageThemeLoader;

        public SettingsViewModel(IWindowsService ws) {
            //some code
            _languageThemeLoader=Application.Current?.Resources.GetThemeLoader("LanguageLoader")!;
            //some code
        }
        //some code
}
TimB-rain commented 1 year ago

Could you please recompile libraries with last version of Avalonia? I have problems with compilation

npolyak commented 1 year ago

I plan to port it soon.

TimB-rain commented 1 year ago

Great! Thanks!)

Abdesol commented 1 year ago

I plan to port it soon.

Still, I am not able to make it work on preview 4

npolyak commented 1 year ago

Hey, sorry, when I said that I'll port it soon, I was told by some people at Avalonia that the 11 RC is coming in December 22 while the full version is coming in Jan. Now they have a very different schedule and they are actually not sure when they are moving to 11 RC and full version. So, I decided to wait longer. I do not have bandwidth to support both versions at the same time. Regards.

npolyak commented 1 year ago

take a look at https://github.com/AvaloniaUI/Avalonia/issues/2239#issuecomment-1427120187

DigitalAdeel commented 1 year ago

same question here. had to update to preview5 and now can't do localization cuz of that same error

npolyak commented 1 year ago

Hey DigitalAdeel, I read that preview5 has a lot of bugs, so I would not want to convert my libraries to a buggy version. Let us wait for 11 RC and I'll convert my libraries several days after.

npolyak commented 1 year ago

Here it is: https://github.com/AvaloniaUI/Avalonia/discussions/10193#discussioncomment-4900247 I quote: "Preview 5 has more issues than any of the previous previews and I'm seeing quite a few more-fundamental problems with controls just not rendering correctly along with various crashes. This is going to get fixed, it's just going to take a bit"

DigitalAdeel commented 1 year ago

Problem with Preview4 is that libvlcsharp gives Avalonia.Styling error if I use preview4 and problem with 0.10.18 is that I can't force it to use dark theme not according to sytem's theme color. Is there any property like RequestedThemeVariant? If yes, then I'll be able to downgrade back to 0.10.18

DigitalAdeel commented 1 year ago

Cuz my client only wants black color for background, I need to force it to use dark theme only.

npolyak commented 1 year ago

For Avalonia built in themes in 0.10.18 version - yes there are ways to switch between light and dark for both Fluent and Default themes. For fluent theme - there is a property Mode that you can change between Light and Dark, e.g.

<Application xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             x:Class="SimpleAvaloniaApp.App">
    <Application.Styles>
        <FluentTheme Mode="Light"/>
    </Application.Styles>
</Application>

For Default theme - it is done differently, by switching between BaseLight.xaml and BaseDark.xaml, e.g

<Application xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             x:Class="NP.Demos.DragBehaviorSample.App">
    <Application.Styles>
        <StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseDark.xaml" />
        <StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml" />
    </Application.Styles>
</Application>

using avares://Avalonia.Themes.Default/Accents/BaseDark.xaml will produce dark theme, while using avares://Avalonia.Themes.Default/Accents/BaseLight.xaml will produce light theme.

npolyak commented 1 year ago

in version 11 - built-in theming is different, BTW.

DigitalAdeel commented 1 year ago

Anyway to force dark theme in 0.10.18?

DigitalAdeel commented 1 year ago

image As you can see, my client sent me buglist yesterday and mentions about it cuz he's using light theme on his pc and I'm using dark

npolyak commented 1 year ago

yes, see my comment above.

npolyak commented 1 year ago

it is all about 0.10.18

DigitalAdeel commented 1 year ago

sorry, missed it somehow 😅

npolyak commented 1 year ago

np:)

DigitalAdeel commented 1 year ago

Well, I tried with setting it's mode to dark but it was still switching to light theme

DigitalAdeel commented 1 year ago

:(

DigitalAdeel commented 1 year ago

I got old backup with 0.10.18 version, so I'll test it again

DigitalAdeel commented 1 year ago

tested but as you can see, still light theme even I set it to dark with 0.10.18 :( image

npolyak commented 1 year ago

looks dark to me - background is dark and foreground is light. To apply the theme globally, put it into App.axaml file.

DigitalAdeel commented 1 year ago

Same issue with putting em in App.axaml image

image 151-06877754-86ef-4e3a-8045-26b14d6e4b32.png)

DigitalAdeel commented 1 year ago

and why background is dark cuz as I said earlier client wants black bg image

DigitalAdeel commented 1 year ago

in preview5, all I had to was to set RequestedThemeVariant property to Dark

npolyak commented 1 year ago

I am sorry, I am not supporting Avalonia. I am not part of Avalonia team. Based on the quote about 11.preview-5 version you should not be switching to it yet. You can create your own custom theme and change the background the way you want. Take a look the way it is done in Avalonia.

DigitalAdeel commented 1 year ago

Okay. Thanks for your help :)

DigitalAdeel commented 1 year ago

Well, I'm gonna play some witcher 3 now 😂

npolyak commented 1 year ago

not a problem :)

DigitalAdeel commented 1 year ago

@npolyak Hi, btw was able to find the culprit behind it. It was FluentAvaloniaTheme's PrefereSystemTheme property and setting it to False fixed it 😁

image

DigitalAdeel commented 1 year ago

@npolyak Now, no need to wait for Avalonia 11 to become stable 😂

image

Edit: I added Remember Password checkbox when I was using Avalonia 11, so now gonna add string for it in Resource Files 😅

TETYYS commented 1 year ago

preview6 is out, is it possible to get it updated?

DigitalAdeel commented 1 year ago

preview6 is out, is it possible to get it updated?

Same question here cuz we don't how much time it's gonna take before Avalonia 11 becomes stable

Kokoreff081 commented 1 year ago

So, Avalonia 11 now released, any information about updating your package?

blahetal commented 1 year ago

Avalonia is out 11.0.1, @npolyak could you update the package please