This commit is contained in:
Jack Ye 2026-03-10 13:04:44 -07:00 committed by GitHub
commit a1fb82f889
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 88 additions and 28 deletions

View file

@ -165,6 +165,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings
public bool UseClock { get; set; } = true;
public bool UseDate { get; set; } = false;
public bool UseBattery { get; set; } = false;
public string TimeFormat { get; set; } = "hh:mm tt";
public string DateFormat { get; set; } = "MM'/'dd ddd";
public bool FirstLaunch { get; set; } = true;

View file

@ -147,6 +147,7 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.9" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.9" />
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
<PackageReference Include="PowerStatus" Version="1.0.3" />
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>

View file

@ -328,6 +328,7 @@
<system:String x:Key="AnimationSpeedCustom">Custom</system:String>
<system:String x:Key="Clock">Clock</system:String>
<system:String x:Key="Date">Date</system:String>
<system:String x:Key="Battery">Battery</system:String>
<system:String x:Key="BackdropType">Backdrop Type</system:String>
<system:String x:Key="BackdropInfo">The backdrop effect is not applied in the preview.</system:String>
<system:String x:Key="BackdropTypeDisabledToolTip">Backdrop supported starting from Windows 11 build 22000 and above</system:String>

View file

@ -299,18 +299,29 @@
x:Name="ClockPanel"
IsHitTestVisible="False"
Opacity="{Binding ClockPanelOpacity}"
Orientation="Horizontal"
Style="{DynamicResource ClockPanel}"
Visibility="{Binding ClockPanelVisibility}">
<TextBlock
x:Name="ClockBox"
Style="{DynamicResource ClockBox}"
Text="{Binding ClockText}"
Visibility="{Binding Settings.UseClock, Converter={StaticResource BoolToVisibilityConverter}}" />
<TextBlock
x:Name="DateBox"
Style="{DynamicResource DateBox}"
Text="{Binding DateText}"
Visibility="{Binding Settings.UseDate, Converter={StaticResource BoolToVisibilityConverter}}" />
<StackPanel VerticalAlignment="Center">
<TextBlock
x:Name="ClockBox"
Style="{DynamicResource ClockBox}"
Text="{Binding ClockText}"
Visibility="{Binding Settings.UseClock, Converter={StaticResource BoolToVisibilityConverter}}" />
<TextBlock
x:Name="DateBox"
Style="{DynamicResource DateBox}"
Text="{Binding DateText}"
Visibility="{Binding Settings.UseDate, Converter={StaticResource BoolToVisibilityConverter}}" />
</StackPanel>
<StackPanel VerticalAlignment="Center">
<TextBlock
x:Name="BatteryBox"
Margin="8 0 0 0"
Style="{DynamicResource ClockBox}"
Text="{Binding BatteryText}"
Visibility="{Binding Settings.UseBattery, Converter={StaticResource BoolToVisibilityConverter}}" />
</StackPanel>
</StackPanel>
<Border>
<Grid WindowChrome.IsHitTestVisibleInChrome="True">

View file

@ -296,6 +296,14 @@ public partial class SettingsPaneThemeViewModel : BaseModel
set => Settings.UseDate = value;
}
public bool UseBattery
{
get => Settings.UseBattery;
set => Settings.UseBattery = value;
}
public string BatteryText => "75%";
public FontFamily ClockPanelFont { get; }
public Brush PreviewBackground

View file

@ -333,21 +333,33 @@
<StackPanel
x:Name="ClockPanel"
IsHitTestVisible="False"
Orientation="Horizontal"
Style="{DynamicResource ClockPanel}"
Visibility="Visible">
<!-- Because these two textblock follow SettingWindowFont, we need to revert their font family explictly -->
<TextBlock
x:Name="ClockBox"
FontFamily="{Binding ClockPanelFont, Mode=OneTime}"
Style="{DynamicResource ClockBox}"
Text="{Binding ClockText}"
Visibility="{Binding UseClock, Converter={StaticResource BoolToVisibilityConverter}}" />
<TextBlock
x:Name="DateBox"
FontFamily="{Binding ClockPanelFont, Mode=OneTime}"
Style="{DynamicResource DateBox}"
Text="{Binding DateText}"
Visibility="{Binding UseDate, Converter={StaticResource BoolToVisibilityConverter}}" />
<StackPanel VerticalAlignment="Center">
<TextBlock
x:Name="ClockBox"
FontFamily="{Binding ClockPanelFont, Mode=OneTime}"
Style="{DynamicResource ClockBox}"
Text="{Binding ClockText}"
Visibility="{Binding UseClock, Converter={StaticResource BoolToVisibilityConverter}}" />
<TextBlock
x:Name="DateBox"
FontFamily="{Binding ClockPanelFont, Mode=OneTime}"
Style="{DynamicResource DateBox}"
Text="{Binding DateText}"
Visibility="{Binding UseDate, Converter={StaticResource BoolToVisibilityConverter}}" />
</StackPanel>
<StackPanel VerticalAlignment="Center">
<TextBlock
x:Name="BatteryBox"
Margin="8 0 0 0"
FontFamily="{Binding ClockPanelFont, Mode=OneTime}"
Style="{DynamicResource ClockBox}"
Text="{Binding BatteryText}"
Visibility="{Binding UseBattery, Converter={StaticResource BoolToVisibilityConverter}}" />
</StackPanel>
</StackPanel>
<Canvas Style="{DynamicResource SearchIconPosition}">
<Path
@ -612,6 +624,17 @@
</StackPanel>
</ui:SettingsCard>
<ui:SettingsCard Margin="0 4 0 0" Header="{DynamicResource Battery}">
<ui:SettingsCard.HeaderIcon>
<ui:FontIcon Glyph="&#xEBA7;" />
</ui:SettingsCard.HeaderIcon>
<ui:ToggleSwitch
IsOn="{Binding UseBattery}"
OffContent="{DynamicResource disable}"
OnContent="{DynamicResource enable}" />
</ui:SettingsCard>
<!-- Placeholder text -->
<ui:SettingsExpander
Margin="0 4 0 0"

View file

@ -131,11 +131,10 @@
<Setter Property="Foreground" Value="#8f8f8f" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="0 0 0 3" />
<Setter Property="Margin" Value="0 1.5 0 1.5" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=DateBox, Path=Visibility}" Value="Visible">
<Setter Property="FontSize" Value="14" />
<Setter Property="Margin" Value="0 0 0 0" />
</DataTrigger>
</Style.Triggers>
</Style>
@ -144,11 +143,10 @@
<Setter Property="Foreground" Value="#8f8f8f" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="0 0 0 0" />
<Setter Property="Margin" Value="0 1.5 0 1.5" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=ClockBox, Path=Visibility}" Value="Visible">
<Setter Property="FontSize" Value="14" />
<Setter Property="Margin" Value="0 0 0 3" />
</DataTrigger>
</Style.Triggers>
</Style>

View file

@ -27,6 +27,7 @@ using Flow.Launcher.Plugin.SharedCommands;
using Flow.Launcher.Storage;
using iNKORE.UI.WPF.Modern;
using Microsoft.VisualStudio.Threading;
using PowerStatus;
namespace Flow.Launcher.ViewModel
{
@ -67,6 +68,8 @@ namespace Flow.Launcher.ViewModel
private bool _taskbarShownByFlow = false;
private readonly PowerStatusProvider _powerStatusProvider = new();
#endregion
#region Constructor
@ -336,6 +339,13 @@ namespace Flow.Launcher.ViewModel
ClockText = DateTime.Now.ToString(Settings.TimeFormat, CultureInfo.CurrentCulture);
if (Settings.UseDate)
DateText = DateTime.Now.ToString(Settings.DateFormat, CultureInfo.CurrentCulture);
if (Settings.UseBattery)
{
var status = _powerStatusProvider.GetStatus();
BatteryText = status.BatteryLifeProportion.HasValue
? $"{(int)(status.BatteryLifeProportion.Value * 100)}%"
: string.Empty;
}
}
}
@ -692,6 +702,7 @@ namespace Flow.Launcher.ViewModel
public Settings Settings { get; }
public string ClockText { get; private set; }
public string DateText { get; private set; }
public string BatteryText { get; private set; }
public ResultsViewModel Results { get; private set; }

View file

@ -135,6 +135,12 @@
"System.ValueTuple": "4.5.0"
}
},
"PowerStatus": {
"type": "Direct",
"requested": "[1.0.3, )",
"resolved": "1.0.3",
"contentHash": "kDqm6puX7icNM9wX6OdmruBXZAM9bX2XwNNBB9KmQf9/D8wqyixYYVnZF6U3WGs+qtyNIpPIflRaQ4wwzoRfJQ=="
},
"PropertyChanged.Fody": {
"type": "Direct",
"requested": "[4.1.0, )",
@ -1619,7 +1625,7 @@
"FSharp.Core": "[9.0.303, )",
"Flow.Launcher.Infrastructure": "[1.0.0, )",
"Flow.Launcher.Localization": "[0.0.6, )",
"Flow.Launcher.Plugin": "[5.0.0, )",
"Flow.Launcher.Plugin": "[5.2.0, )",
"Meziantou.Framework.Win32.Jobs": "[3.4.5, )",
"Microsoft.IO.RecyclableMemoryStream": "[3.0.1, )",
"SemanticVersioning": "[3.0.0, )",
@ -1634,7 +1640,7 @@
"BitFaster.Caching": "[2.5.4, )",
"CommunityToolkit.Mvvm": "[8.4.0, )",
"Flow.Launcher.Localization": "[0.0.6, )",
"Flow.Launcher.Plugin": "[5.0.0, )",
"Flow.Launcher.Plugin": "[5.2.0, )",
"InputSimulator": "[1.0.4, )",
"MemoryPack": "[1.21.4, )",
"Microsoft.VisualStudio.Threading": "[17.14.15, )",