Skip to content

Commit

Permalink
refactor: upgrade Avalonia
Browse files Browse the repository at this point in the history
  • Loading branch information
timschneeb committed Dec 14, 2024
1 parent ecbe46b commit bdc73ef
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion GalaxyBudsClient/Application.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

<PropertyGroup>
<!-- Global dependency versions -->
<AvaloniaVersion>11.2.0-beta1</AvaloniaVersion>
<AvaloniaVersion>11.2.2</AvaloniaVersion>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions GalaxyBudsClient/GalaxyBudsClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@
<PackageReference Include="Avalonia.Markup.Xaml.Loader" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.ReactiveUI" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Svg.Skia" Version="11.1.0" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.1.0" />
<PackageReference Include="Avalonia.Svg.Skia" Version="11.2.0.2" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.2.0.1" />
<PackageReference Include="AvaloniaHex" Version="0.1.3" />
<PackageReference Include="BouncyCastle.Cryptography" Version="2.4.0" />
<PackageReference Include="CommandLineParser" Version="2.9.2-ci-210" />
Expand Down
7 changes: 5 additions & 2 deletions GalaxyBudsClient/Interface/Controls/EarbudStatusUnit.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@
Orientation="Horizontal"
HorizontalAlignment="Right">

<TextBlock Text="{Binding LeftBattery, StringFormat={}{0}%}"
<TextBlock Name="LeftBatteryText"
Text="{Binding LeftBattery, StringFormat={}{0}%}"
FontSize="{StaticResource FontSizePercentage}"
MinWidth=""
HorizontalAlignment="Right" />

<ic:SymbolIcon Symbol="{Binding LeftBattery, Converter={StaticResource BatterySymbolConverter}}"
Expand Down Expand Up @@ -129,7 +131,8 @@
</ic:SymbolIcon.RenderTransform>
</ic:SymbolIcon>

<TextBlock Text="{Binding RightBattery, StringFormat={}{0}%}"
<TextBlock Name="RightBatteryText"
Text="{Binding RightBattery, StringFormat={}{0}%}"
FontSize="{StaticResource FontSizePercentage}"
HorizontalAlignment="Left" />
</StackPanel>
Expand Down
17 changes: 14 additions & 3 deletions GalaxyBudsClient/Interface/Controls/EarbudStatusUnit.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using Avalonia.Controls;
using System;
using System.Collections.Specialized;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
using GalaxyBudsClient.Interface.ViewModels.Controls;
using GalaxyBudsClient.Model.Config;
Expand All @@ -11,9 +14,17 @@ public partial class EarbudStatusUnit : Panel
public EarbudStatusUnit()
{
InitializeComponent();
DataContext = new EarbudStatusUnitViewModel();
}
var vm = new EarbudStatusUnitViewModel();
vm.Changed.Subscribe(new Action<object>(_ =>
{
// FIXME: Avalonia bug: After upgrading to Avalonia 11.2.2 from 11.2.0-beta, the label bounds are initially too small
LeftBatteryText.InvalidateMeasure();
RightBatteryText.InvalidateMeasure();
}));

DataContext = vm;
}

private void OnTemperaturePointerPressed(object? sender, PointerPressedEventArgs e)
{
Settings.Data.TemperatureUnit = Settings.Data.TemperatureUnit == TemperatureUnits.Celsius
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel;
using System.Threading.Tasks;
using GalaxyBudsClient.Message;
using GalaxyBudsClient.Message.Decoder;
using GalaxyBudsClient.Model.Config;
Expand Down Expand Up @@ -33,6 +34,13 @@ public EarbudStatusUnitViewModel()
Settings.MainSettingsPropertyChanged += OnMainSettingsPropertyChanged;
Loc.LanguageUpdated += LoadFromCache;
LoadFromCache();

_ = Task.Run(() =>
{
// FIXME: Avalonia bug: After upgrading to Avalonia 11.2.2 from 11.2.0-beta, the label bounds are initially too small
Task.Delay(250);
_ = BluetoothImpl.Instance.SendRequestAsync(MsgIds.DEBUG_GET_ALL_DATA);
});
}

private void OnBluetoothPropertyChanged(object? sender, PropertyChangedEventArgs e)
Expand Down

0 comments on commit bdc73ef

Please sign in to comment.