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

Feature: What's new popup #13269

Merged
merged 7 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
89 changes: 89 additions & 0 deletions src/Files.App/Dialogs/ReleaseNotesDialog.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<!-- Copyright (c) 2023 Files Community. Licensed under the MIT License. See the LICENSE. -->
<ContentDialog
x:Class="Files.App.Dialogs.ReleaseNotesDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:helpers="using:Files.App.Helpers"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
CornerRadius="{StaticResource OverlayCornerRadius}"
DefaultButton="None"
RequestedTheme="{x:Bind helpers:ThemeHelper.RootTheme}"
Style="{StaticResource DefaultContentDialogStyle}"
mc:Ignorable="d">
<ContentDialog.Resources>
<ResourceDictionary>
<Thickness x:Key="ContentDialogPadding">0</Thickness>
</ResourceDictionary>
</ContentDialog.Resources>

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<!-- Titlebar -->
<Grid Grid.Row="0">
<StackPanel
Padding="20"
Orientation="Horizontal"
Spacing="12">
<Image Width="32" Source="\Assets\AppTiles\Dev\Logo.ico" />

<TextBlock
VerticalAlignment="Center"
FontSize="20"
FontWeight="SemiBold"
LineHeight="28"
Text="{helpers:ResourceString Name=WhatsNew}" />
</StackPanel>

<Button
x:Name="CloseDialogButton"
Width="36"
Height="36"
Margin="4"
HorizontalAlignment="Right"
VerticalAlignment="Top"
AutomationProperties.Name="{helpers:ResourceString Name=Close}"
Background="Transparent"
BorderBrush="Transparent"
Click="CloseDialogButton_Click"
ToolTipService.Placement="Bottom"
ToolTipService.ToolTip="{helpers:ResourceString Name=Close}">
<FontIcon FontSize="12" Glyph="&#xE8BB;" />
</Button>
</Grid>

<!-- Markdown Content -->
<ScrollViewer
Grid.Row="1"
MinWidth="440"
MinHeight="200"
Padding="20,0,20,20"
HorizontalScrollMode="Auto"
VerticalScrollMode="Auto">
<controls:MarkdownTextBlock
Background="Transparent"
ListGutterWidth="16"
Text="{x:Bind ViewModel.ReleaseNotesMadrkdown, Mode=OneWay}" />
</ScrollViewer>

<!-- Footer -->
<Border
Grid.Row="2"
Padding="12"
Background="{ThemeResource SolidBackgroundFillColorBase}"
BackgroundSizing="OuterBorderEdge"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
BorderThickness="0,1,0,0">
<HyperlinkButton
HorizontalAlignment="Left"
Content="{helpers:ResourceString Name=SponsorUsOnGitHub}"
NavigateUri="https://github.com/sponsors/yaira2" />
</Border>
</Grid>
</ContentDialog>
41 changes: 41 additions & 0 deletions src/Files.App/Dialogs/ReleaseNotesDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;

namespace Files.App.Dialogs
{
public sealed partial class ReleaseNotesDialog : ContentDialog, IDialog<ReleaseNotesDialogViewModel>
{
public ReleaseNotesDialogViewModel ViewModel
{
get => (ReleaseNotesDialogViewModel)DataContext;
set => DataContext = value;
}

public ReleaseNotesDialog()
{
InitializeComponent();
}

public new async Task<DialogResult> ShowAsync()
{
return (DialogResult)await SetContentDialogRoot(this).TryShowAsync();
}

private void CloseDialogButton_Click(object sender, RoutedEventArgs e)
{
Hide();
}

// WINUI3
private ContentDialog SetContentDialogRoot(ContentDialog contentDialog)
{
if (Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
contentDialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;

return contentDialog;
}
}
}
4 changes: 4 additions & 0 deletions src/Files.App/Files.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
</ItemGroup>

<ItemGroup>
<None Remove="Dialogs\ReleaseNotesDialog.xaml" />
<None Remove="UserControls\Sidebar\SideBarItem.xaml" />
<None Remove="UserControls\Sidebar\SideBarView.xaml" />
</ItemGroup>
Expand Down Expand Up @@ -136,6 +137,9 @@
</ItemGroup>

<ItemGroup>
<Page Update="Dialogs\ReleaseNotesDialog.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="UserControls\SideBarControl\SideBarHost.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/Services/DialogService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public DialogService()
{ typeof(AddBranchDialogViewModel), () => new AddBranchDialog() },
{ typeof(GitHubLoginDialogViewModel), () => new GitHubLoginDialog() },
{ typeof(FileTooLargeDialogViewModel), () => new FileTooLargeDialog() },
{ typeof(ReleaseNotesDialogViewModel), () => new ReleaseNotesDialog() },
};
}

Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -2367,8 +2367,8 @@
<data name="EditSettingsFile" xml:space="preserve">
<value>Edit Settings File</value>
</data>
<data name="ReleaseNotes" xml:space="preserve">
<value>Release Notes</value>
<data name="WhatsNew" xml:space="preserve">
<value>What's new</value>
</data>
<data name="CannotCreateShortcutDialogTitle" xml:space="preserve">
<value>Creating a shortcut in this location requires administrator privileges</value>
Expand Down
43 changes: 2 additions & 41 deletions src/Files.App/UserControls/AddressToolbar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,10 @@
VerticalContentAlignment="Stretch"
x:Load="{x:Bind ViewModel.IsReleaseNotesVisible, Mode=OneWay}"
AccessKey="2"
AutomationProperties.Name="{helpers:ResourceString Name=ReleaseNotes}"
AutomationProperties.Name="{helpers:ResourceString Name=WhatsNew}"
Command="{x:Bind ViewModel.ViewReleaseNotesCommand, Mode=OneWay}"
Style="{StaticResource AddressToolbarButtonStyle}"
ToolTipService.ToolTip="{helpers:ResourceString Name=ReleaseNotes}">
ToolTipService.ToolTip="{helpers:ResourceString Name=WhatsNew}">
<FontIcon
FontSize="14"
Foreground="{ThemeResource SystemAccentColor}"
Expand Down Expand Up @@ -522,45 +522,6 @@
IsOpen="False"
Subtitle="{helpers:ResourceString Name=OngoingTasksTeachingTip/Subtitle}"
Target="{x:Bind OngoingTasks}" />

<!-- Release Notes Teaching Tip -->
<TeachingTip
x:Name="ReleaseNotesTeachingTip"
IsLightDismissEnabled="True"
IsOpen="{x:Bind ViewModel.IsReleaseNotesOpen, Mode=TwoWay}"
Target="{x:Bind ViewReleaseNotesButton}">

<!-- Sponsor Button -->
<TeachingTip.HeroContent>
<Border
Padding="12"
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
BorderThickness="0,1,0,0">

<HyperlinkButton
HorizontalAlignment="Center"
Content="{helpers:ResourceString Name=SponsorUsOnGitHub}"
NavigateUri="https://github.com/sponsors/yaira2" />
</Border>
</TeachingTip.HeroContent>

<!-- Markdown Content -->
<TeachingTip.Content>
<ScrollViewer
MinHeight="300"
MaxHeight="400"
Margin="-12"
Padding="12"
HorizontalScrollMode="Auto"
VerticalScrollMode="Auto">
<controls:MarkdownTextBlock
Background="Transparent"
ListGutterWidth="16"
Text="{x:Bind ViewModel.ReleaseNotes, Mode=OneWay}" />
</ScrollViewer>
</TeachingTip.Content>
</TeachingTip>
</Grid>

<VisualStateManager.VisualStateGroups>
Expand Down
19 changes: 10 additions & 9 deletions src/Files.App/ViewModels/UserControls/ToolbarViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class ToolbarViewModel : ObservableObject, IAddressToolbar, IDisposable
{
private IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetRequiredService<IUserSettingsService>();

private readonly IDialogService _dialogService = Ioc.Default.GetRequiredService<IDialogService>();

private readonly MainPageViewModel mainPageViewModel = Ioc.Default.GetRequiredService<MainPageViewModel>();

private readonly DrivesViewModel drivesViewModel = Ioc.Default.GetRequiredService<DrivesViewModel>();
Expand Down Expand Up @@ -87,13 +89,6 @@ public bool IsReleaseNotesVisible
set => SetProperty(ref isReleaseNotesVisible, value);
}

private bool isReleaseNotesOpen;
public bool IsReleaseNotesOpen
{
get => isReleaseNotesOpen;
set => SetProperty(ref isReleaseNotesOpen, value);
}

private bool canCopyPathInPage;
public bool CanCopyPathInPage
{
Expand Down Expand Up @@ -222,9 +217,15 @@ private async void UpdateService_OnPropertyChanged(object? sender, PropertyChang
await CheckForReleaseNotesAsync();
}

private void DoViewReleaseNotes()
private async void DoViewReleaseNotes()
yaira2 marked this conversation as resolved.
Show resolved Hide resolved
{
IsReleaseNotesOpen = true;
if (ReleaseNotes is null)
return;

var viewModel = new ReleaseNotesDialogViewModel(ReleaseNotes);
var dialog = _dialogService.GetDialog(viewModel);

await dialog.TryShowAsync();
}

public async Task CheckForReleaseNotesAsync()
Expand Down
20 changes: 20 additions & 0 deletions src/Files.Core/ViewModels/Dialogs/ReleaseNotesDialogViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

namespace Files.Core.ViewModels.Dialogs
{
public sealed class ReleaseNotesDialogViewModel : ObservableObject
{
public string _ReleaseNotesMadrkdown = string.Empty;
yaira2 marked this conversation as resolved.
Show resolved Hide resolved
public string ReleaseNotesMadrkdown
{
get => _ReleaseNotesMadrkdown;
set => SetProperty(ref _ReleaseNotesMadrkdown, value);
}

public ReleaseNotesDialogViewModel(string releaseNotesMadrkdown)
{
ReleaseNotesMadrkdown = releaseNotesMadrkdown;
}
}
}