Skip to content

Commit

Permalink
wip #50
Browse files Browse the repository at this point in the history
  • Loading branch information
rstewa committed Jul 3, 2024
1 parent d5d4f85 commit 5eef007
Show file tree
Hide file tree
Showing 12 changed files with 346 additions and 3 deletions.
8 changes: 6 additions & 2 deletions Audibly.App/AppShell.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,13 @@ public AppShell()
{
InitializeComponent();
// set the title bar
AppShellFrame.Navigate(typeof(LibraryCardPage));
// AppShellFrame.Navigate(typeof(LibraryCardPage));

Loaded += (_, _) => { NavView.SelectedItem = LibraryCardMenuItem; };
Loaded += (_, _) =>
{
AppShellFrame.Navigate(typeof(LibraryCardPage));
NavView.SelectedItem = LibraryCardMenuItem;
};

ViewModel.MessageService.ShowDialogRequested += OnShowDialogRequested;
App.ViewModel.FileImporter.ImportCompleted += HideImportDialog;
Expand Down
6 changes: 6 additions & 0 deletions Audibly.App/Audibly.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<ItemGroup>
<None Remove="Views\ControlPages\ChangelogDialogContent.xaml" />
<None Remove="Views\ControlPages\OnBoardingDialogContent.xaml" />
<None Remove="Views\EditMetadataPage.xaml" />
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -139,6 +140,11 @@
<DependentUpon>Changelog.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Page Update="Views\EditMetadataPage.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="Views\ControlPages\OnBoardingDialogContent.xaml">
<Generator>MSBuild:Compile</Generator>
Expand Down
20 changes: 20 additions & 0 deletions Audibly.App/Services/AppDataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,26 @@ public class AppDataService : IAppDataService
{
private static StorageFolder StorageFolder => ApplicationData.Current.LocalFolder;

public async Task<Tuple<string, string>> WriteCoverImageAsync(string path, string newCoverImagePath)
{
var bookAppdataDir = await StorageFolder.CreateFolderAsync(path,
CreationCollisionOption.OpenIfExists);
var coverImagePath = Path.Combine(bookAppdataDir.Path, "CoverImage.png");
File.Copy(newCoverImagePath, coverImagePath, true);

// create 400x400 thumbnail
var thumbnailPath = Path.Combine(bookAppdataDir.Path, "Thumbnail.jpeg");
var result = await ShrinkAndSaveAsync(coverImagePath, thumbnailPath, 400, 400);
if (!result) thumbnailPath = string.Empty; // return empty string if thumbnail creation failed

// leaving this commented out for now because it increases the import time an absurd amount
// create .ico file
// var coverImagePath = Path.Combine(bookAppdataDir.Path, "CoverImage.png");
// FolderIcon.SetFolderIcon(coverImagePath, bookAppdataDir.Path);

return new Tuple<string, string>(coverImagePath, thumbnailPath);
}

public async Task<Tuple<string, string>> WriteCoverImageAsync(string path, byte[]? imageBytes)
{
var bookAppdataDir = await StorageFolder.CreateFolderAsync(path,
Expand Down
10 changes: 10 additions & 0 deletions Audibly.App/Services/EditMetadataService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Author: rstewa · https://github.com/rstewa
// Created: 06/29/2024
// Updated: 06/29/2024

namespace Audibly.App.Services;

public class EditMetadataService
{

}
1 change: 1 addition & 0 deletions Audibly.App/Services/Interfaces/IAppDataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Audibly.App.Services.Interfaces;

public interface IAppDataService
{
Task<Tuple<string, string>> WriteCoverImageAsync(string path, string newCoverImagePath);
Task<Tuple<string, string>> WriteCoverImageAsync(string path, byte[]? imageBytes);

Task DeleteCoverImageAsync(string path);
Expand Down
10 changes: 10 additions & 0 deletions Audibly.App/Services/Interfaces/IEditMetadataService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Author: rstewa · https://github.com/rstewa
// Created: 06/29/2024
// Updated: 06/29/2024

namespace Audibly.App.Services.Interfaces;

public interface IEditMetadataService
{
// update metadata property for an audiobook
}
4 changes: 4 additions & 0 deletions Audibly.App/UserControls/AudiobookTile.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
<AppBarButton Click="OpenInAppFolder_OnClick" ToolTipService.ToolTip="Open in App Folder">
<FontIcon Glyph="&#xE8E5;" />
</AppBarButton>
<!-- edit metadata -->
<AppBarButton Click="EditMetadata_OnClick" ToolTipService.ToolTip="Edit Metadata">
<FontIcon Glyph="&#xE104;" />
</AppBarButton>
</CommandBarFlyout>
</UserControl.Resources>
<Button
Expand Down
17 changes: 17 additions & 0 deletions Audibly.App/UserControls/AudiobookTile.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.IO;
using System.Linq;
using Audibly.App.ViewModels;
using Audibly.App.Views;
using CommunityToolkit.WinUI;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml;
Expand All @@ -29,6 +30,15 @@ public sealed partial class AudiobookTile : UserControl

private readonly DispatcherQueue _dispatcherQueue = DispatcherQueue.GetForCurrentThread();

public Frame PageFrame
{
get { return (Frame)GetValue(PageFrameProperty); }
set { SetValue(PageFrameProperty, value); }
}

public static readonly DependencyProperty PageFrameProperty =
DependencyProperty.Register("PageFrame", typeof(Frame), typeof(AudiobookTile), new PropertyMetadata(null));

public string Title
{
get => (string)GetValue(TitleProperty);
Expand Down Expand Up @@ -156,4 +166,11 @@ private void OpenInAppFolder_OnClick(object sender, RoutedEventArgs e)
p.StartInfo.Arguments = $"/open, \"{dir}\"";
p.Start();
}

private void EditMetadata_OnClick(object sender, RoutedEventArgs e)
{
var selectedAudiobook = App.ViewModel.Audiobooks.FirstOrDefault(a => a.Title == Title);
// open new edit metadata page
PageFrame.Navigate(typeof(EditMetadataPage), selectedAudiobook);
}
}
110 changes: 110 additions & 0 deletions Audibly.App/Views/EditMetadataPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="utf-8" ?>

<Page
Background="Transparent"
mc:Ignorable="d"
x:Class="Audibly.App.Views.EditMetadataPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Audibly.App.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:media="using:CommunityToolkit.WinUI.Media"
xmlns:winUi="using:CommunityToolkit.WinUI"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- ReSharper disable all Xaml.RedundantResource -->

<RelativePanel x:Name="TrackPropertiesContainer">
<ScrollView RelativePanel.AlignLeftWithPanel="True" RelativePanel.AlignTopWithPanel="True">
<StackPanel Orientation="Vertical">
<!-- cover image -->
<StackPanel Orientation="Horizontal">
<TextBlock
Margin="0,0,12,0"
Text="CoverImage: "
VerticalAlignment="Center" />
<Button
Background="Transparent"
BorderBrush="Transparent"
CornerRadius="8"
Padding="16"
PointerEntered="CoverImageTile_OnPointerEntered"
PointerExited="CoverImageTile_OnPointerExited"
x:Name="ButtonTile">
<Grid>
<Border
BorderThickness="0"
Height="200"
HorizontalAlignment="Left"
Width="200"
x:Name="CoverImage">
<Border
BorderBrush="Transparent"
BorderThickness="0"
CornerRadius="15">
<Image
HorizontalAlignment="Center"
Source="{x:Bind ViewModel.CoverImagePath, Mode=OneWay}"
Stretch="Uniform"
VerticalAlignment="Top" />
</Border>
<winUi:Effects.Shadow>
<media:AttachedCardShadow CornerRadius="15" Offset="4, 4" />
</winUi:Effects.Shadow>
</Border>
<Grid
Grid.Row="0"
Visibility="Collapsed"
x:Name="BlackOverlayGrid">
<Grid.Resources>
<SolidColorBrush x:Key="ButtonBackground">Transparent</SolidColorBrush>
<SolidColorBrush x:Key="ButtonBackgroundPointerOver">Transparent</SolidColorBrush>
<SolidColorBrush x:Key="ButtonBackgroundPressed">Transparent</SolidColorBrush>
<SolidColorBrush x:Key="ButtonBackgroundDisabled">Transparent</SolidColorBrush>
</Grid.Resources>
<Grid
Background="Black"
CornerRadius="15"
Opacity="0.55" />
<Button
BorderThickness="0"
Click="EditCoverImageButton_Click"
HorizontalAlignment="Center"
Tag="play"
ToolTipService.ToolTip="Play"
VerticalAlignment="Center"
x:Name="PlayPauseButton">
<Button.Resources>
<ResourceDictionary>
<StaticResource ResourceKey="AccentFillColorDefaultBrush" x:Key="ButtonForeground" />
<StaticResource ResourceKey="AccentFillColorTertiaryBrush" x:Key="ButtonForegroundPressed" />
<StaticResource ResourceKey="AccentFillColorSecondaryBrush" x:Key="ButtonForegroundPointerOver" />
<StaticResource ResourceKey="AccentFillColorDisabledBrush" x:Key="ButtonForegroundDisabled" />
</ResourceDictionary>
</Button.Resources>
<Viewbox MaxHeight="70" MaxWidth="70">
<FontIcon Glyph="&#xE70F;" />
</Viewbox>
</Button>
</Grid>
</Grid>
</Button>
</StackPanel>

<!-- listview for track properties -->
<ListView
Margin="-12,0,0,0"
SelectionMode="None"
x:Name="TrackPropertiesListView">
<ListView.ItemTemplate>
<DataTemplate x:DataType="local:TrackProperty">
<StackPanel Orientation="Horizontal" Spacing="12">
<TextBlock Text="{x:Bind Name}" VerticalAlignment="Center" />
<TextBox Text="{x:Bind Value, Mode=TwoWay}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
</ScrollView>
</RelativePanel>
</Page>
Loading

0 comments on commit 5eef007

Please sign in to comment.