Skip to content

Commit

Permalink
WinUI - Flyout for AddSyncLyric
Browse files Browse the repository at this point in the history
  • Loading branch information
nlogozzo committed Nov 7, 2023
1 parent 4453dd4 commit 7897805
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
<releases>
<release version="2023.11.2-next" date="2023-11-05">
<description translatable="no">
<p>- Fixed an issue where specifying the directory separator in Tag to File Name when Limit Filename Characters was enabled caused new directories to not be made</p>
<p>- On GNOME, fixed an issue where specifying the directory separator in Tag to File Name when Limit Filename Characters was enabled caused new directories to not be made</p>
<p>- On WinUI, improved the UX of the Lyrics dialog</p>
<p>- Updated translations (Thanks everyone on Weblate!)</p>
</description>
</release>
Expand Down
2 changes: 1 addition & 1 deletion NickvisionTagger.WinUI/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public App()
InitializeComponent();
_controller = new MainWindowController(Array.Empty<string>());
_controller.AppInfo.Changelog =
@"- Improved the UX of the LyricsDialog
@"- Improved the UX of the Lyrics dialog
- Updated translations (Thanks everyone on Weblate!)";
if (_controller.Theme != Theme.System)
{
Expand Down
14 changes: 12 additions & 2 deletions NickvisionTagger.WinUI/Views/LyricsDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
mc:Ignorable="d" Style="{StaticResource DefaultContentDialogStyle}"
DefaultButton="Primary" Loaded="Dialog_Loaded">

<ScrollViewer x:Name="ScrollViewer" VerticalScrollBarVisibility="Auto" MinWidth="500" SizeChanged="ScrollViewer_SizeChanged">
<ScrollViewer x:Name="ScrollViewer" VerticalScrollBarVisibility="Auto" MinWidth="600" SizeChanged="ScrollViewer_SizeChanged">
<StackPanel x:Name="StackPanel" Orientation="Vertical" Spacing="6">
<TextBlock x:Name="LblConfigure" Style="{StaticResource NavigationViewItemHeaderTextStyle}"/>

Expand Down Expand Up @@ -64,14 +64,24 @@
<TextBlock x:Name="LblEdit" VerticalAlignment="Center" Style="{StaticResource NavigationViewItemHeaderTextStyle}"/>

<StackPanel x:Name="SyncControls" Grid.Column="1" Orientation="Horizontal" Spacing="6">
<Button x:Name="BtnAddSyncLyric" Click="AddSyncLyric">
<Button x:Name="BtnAddSyncLyric">
<Button.Content>
<StackPanel Orientation="Horizontal" Spacing="6">
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" FontSize="16" Glyph="&#xE710;"/>

<TextBlock x:Name="LblBtnAddSyncLyric" TextWrapping="WrapWholeWords"/>
</StackPanel>
</Button.Content>

<Button.Flyout>
<Flyout x:Name="FlyoutAddSyncLyric" Placement="Bottom">
<StackPanel Orientation="Vertical" Spacing="6">
<TextBox x:Name="TxtAddSyncLyric" MinWidth="200" TextChanged="TxtAddSyncLyric_TextChanged"/>

<Button x:Name="BtnAddSyncLyricConfirm" Style="{ThemeResource AccentButtonStyle}" Click="AddSyncLyric"/>
</StackPanel>
</Flyout>
</Button.Flyout>
</Button>

<Button x:Name="BtnClearAllSyncLyrics" Height="32" Click="ClearAllSyncLyrics">
Expand Down
30 changes: 14 additions & 16 deletions NickvisionTagger.WinUI/Views/LyricsDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public LyricsDialog(LyricsDialogController controller, Action<object> initialize
ToolTipService.SetToolTip(BtnApplyOffset, _("Apply"));
LblEdit.Text = _("Edit");
LblBtnAddSyncLyric.Text = _("Add");
TxtAddSyncLyric.Header = _("Timestamp (hh:mm:ss or mm:ss.xx)");
BtnAddSyncLyricConfirm.Content = _("Add");
ToolTipService.SetToolTip(BtnClearAllSyncLyrics, _("Clear All Lyrics"));
ToolTipService.SetToolTip(BtnImportLRC, _("Import from LRC"));
ToolTipService.SetToolTip(BtnExportLRC, _("Export to LRC"));
Expand Down Expand Up @@ -206,29 +208,25 @@ private void ApplyOffset(object sender, RoutedEventArgs e)
}
}

/// <summary>
/// Occurs when TxtAddSyncLyric's text is changed
/// </summary>
/// <param name="sender">object</param>
/// <param name="e">TextChangedEventArgs</param>
private void TxtAddSyncLyric_TextChanged(object sender, TextChangedEventArgs e) => BtnAddSyncLyricConfirm.IsEnabled = TxtAddSyncLyric.Text.TimecodeToMs() != -1;

/// <summary>
/// Occurs when the add sync lyric button is clicked
/// </summary>
/// <param name="sender">object</param>
/// <param name="e">RoutedEventArgs</param>
private async void AddSyncLyric(object sender, RoutedEventArgs e)
private void AddSyncLyric(object sender, RoutedEventArgs e)
{
var entryDialog = new EntryDialog(_("New Synchronized Lyric"), "", _("Timestamp (hh:mm:ss or mm:ss.xx)"), _("Cancel"), _("Add"))
FlyoutAddSyncLyric.Hide();
var ms = TxtAddSyncLyric.Text.TimecodeToMs();
if (ms != -1)
{
Validator = x => x.TimecodeToMs() != -1,
XamlRoot = XamlRoot
};
_showingAnotherDialog = true;
Hide();
var res = await entryDialog.ShowAsync();
_showingAnotherDialog = false;
if (!string.IsNullOrEmpty(res) && res != "NULL")
{
var ms = res.TimecodeToMs();
if (ms != -1)
{
_controller.AddSynchronizedLyric(ms);
}
_controller.AddSynchronizedLyric(ms);
}
}

Expand Down

0 comments on commit 7897805

Please sign in to comment.