mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-01-12 15:26:28 +01:00
good feedback from reivew
This commit is contained in:
@@ -5,10 +5,11 @@
|
||||
using System.Text.Json;
|
||||
using AdaptiveCards.ObjectModel.WinUI3;
|
||||
using AdaptiveCards.Templating;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Microsoft.CmdPal.Extensions;
|
||||
using Microsoft.CmdPal.UI.ViewModels.Messages;
|
||||
using Microsoft.CmdPal.UI.ViewModels.Models;
|
||||
using Windows.Data.Json;
|
||||
using Windows.System;
|
||||
|
||||
namespace Microsoft.CmdPal.UI.ViewModels;
|
||||
|
||||
@@ -71,7 +72,7 @@ public partial class FormViewModel(IForm _form, IPageContext context) : Extensio
|
||||
{
|
||||
if (action is AdaptiveOpenUrlAction openUrlAction)
|
||||
{
|
||||
_ = Launcher.LaunchUriAsync(openUrlAction.Url);
|
||||
WeakReferenceMessenger.Default.Send<LaunchUriMessage>(new(openUrlAction.Url));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.CmdPal.Extensions;
|
||||
using Microsoft.CmdPal.UI.ViewModels.Models;
|
||||
|
||||
namespace Microsoft.CmdPal.UI.ViewModels.Messages;
|
||||
|
||||
public record LaunchUriMessage(Uri Uri)
|
||||
{
|
||||
}
|
||||
@@ -6,7 +6,6 @@ using AdaptiveCards.ObjectModel.WinUI3;
|
||||
using AdaptiveCards.Rendering.WinUI3;
|
||||
using Microsoft.CmdPal.UI.ViewModels;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Windows.UI.ViewManagement;
|
||||
|
||||
namespace Microsoft.CmdPal.UI.Controls;
|
||||
|
||||
@@ -19,20 +18,17 @@ public sealed partial class FormControl : UserControl
|
||||
|
||||
static FormControl()
|
||||
{
|
||||
// yep this is the way to check if you're in light theme or dark.
|
||||
// yep it's this dumb
|
||||
var settings = new UISettings();
|
||||
var foreground = settings.GetColorValue(UIColorType.Foreground);
|
||||
var lightTheme = foreground.R < 128;
|
||||
_renderer = new AdaptiveCardRenderer
|
||||
{
|
||||
HostConfig = lightTheme ? AdaptiveCardsConfig.Light : AdaptiveCardsConfig.Dark,
|
||||
};
|
||||
_renderer = new AdaptiveCardRenderer();
|
||||
}
|
||||
|
||||
public FormControl()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
var lightTheme = ActualTheme == Microsoft.UI.Xaml.ElementTheme.Light;
|
||||
_renderer.HostConfig = lightTheme ? AdaptiveCardsConfig.Light : AdaptiveCardsConfig.Dark;
|
||||
|
||||
// TODO in the future, we should handle ActualThemeChanged and replace
|
||||
// our rendered card with one for that theme. But today is not that day
|
||||
}
|
||||
|
||||
private void AttachViewModel(FormViewModel? vm)
|
||||
|
||||
@@ -37,12 +37,10 @@
|
||||
</controls:Case>
|
||||
|
||||
<controls:Case IsDefault="True" Value="Loading">
|
||||
<TextBlock Text="I am a loading form page" />
|
||||
</controls:Case>
|
||||
|
||||
<controls:Case Value="Error">
|
||||
<StackPanel Orientation="Vertical" Margin="16">
|
||||
<TextBlock Text="I am an error form page" />
|
||||
<TextBlock Text="Error on page" FontSize="18" Foreground="{ThemeResource SystemErrorTextColor}" />
|
||||
<TextBlock Text="{x:Bind ViewModel.ErrorMessage, Mode=OneWay}" IsTextSelectionEnabled="True"/>
|
||||
</StackPanel>
|
||||
|
||||
@@ -10,6 +10,7 @@ using Microsoft.CmdPal.UI.ViewModels.Messages;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Media.Animation;
|
||||
using Windows.System;
|
||||
|
||||
namespace Microsoft.CmdPal.UI;
|
||||
|
||||
@@ -22,7 +23,8 @@ public sealed partial class ShellPage :
|
||||
IRecipient<NavigateToDetailsMessage>,
|
||||
IRecipient<PerformCommandMessage>,
|
||||
IRecipient<ShowDetailsMessage>,
|
||||
IRecipient<HideDetailsMessage>
|
||||
IRecipient<HideDetailsMessage>,
|
||||
IRecipient<LaunchUriMessage>
|
||||
{
|
||||
private readonly DrillInNavigationTransitionInfo _drillInNavigationTransitionInfo = new();
|
||||
|
||||
@@ -44,6 +46,8 @@ public sealed partial class ShellPage :
|
||||
WeakReferenceMessenger.Default.Register<ShowDetailsMessage>(this);
|
||||
WeakReferenceMessenger.Default.Register<HideDetailsMessage>(this);
|
||||
|
||||
WeakReferenceMessenger.Default.Register<LaunchUriMessage>(this);
|
||||
|
||||
RootFrame.Navigate(typeof(LoadingPage), ViewModel);
|
||||
}
|
||||
|
||||
@@ -145,4 +149,6 @@ public sealed partial class ShellPage :
|
||||
public void Receive(HideDetailsMessage message) => HideDetails();
|
||||
|
||||
private void HideDetails() => ViewModel.IsDetailsVisible = false;
|
||||
|
||||
public void Receive(LaunchUriMessage message) => _ = Launcher.LaunchUriAsync(message.Uri);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user