From 54167c7fd1b30e6fc70a9ccda1ed13df3543ef61 Mon Sep 17 00:00:00 2001 From: Corentin LEMAIRE Date: Fri, 9 Jun 2023 14:08:10 +0200 Subject: [PATCH] Enhance footer --- Sources/Linaris/Converters.cs | 26 +++++++++++-------- Sources/Linaris/FooterPage.xaml.cs | 18 ++++++++----- Sources/Linaris/Linaris.csproj | 1 + Sources/Linaris/LocalFilesPage.xaml | 12 ++++----- Sources/Linaris/LocalFilesPage.xaml.cs | 3 +-- .../Platforms/Android/AndroidManifest.xml | 9 ++----- Sources/Linaris/PlaylistPage.xaml | 10 +++---- Sources/Linaris/PlaylistPage.xaml.cs | 6 +++-- Sources/Linaris/Resources/Styles/Styles.xaml | 24 +++-------------- 9 files changed, 50 insertions(+), 59 deletions(-) diff --git a/Sources/Linaris/Converters.cs b/Sources/Linaris/Converters.cs index f55ecc2..f4e0f12 100644 --- a/Sources/Linaris/Converters.cs +++ b/Sources/Linaris/Converters.cs @@ -1,22 +1,26 @@ using System; -namespace Linaris.Converters +namespace Linaris.Converters; + +public class InverseBooleanConverter : IValueConverter { - public class InverseBooleanConverter : IValueConverter + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { - public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + if (value is bool boolValue) { - if (value is bool boolValue) - { - return !boolValue; - } - - return value; + return !boolValue; } - public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + return value; + } + + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + if (value is bool boolValue) { - throw new NotImplementedException(); + return !boolValue; } + + return value; } } \ No newline at end of file diff --git a/Sources/Linaris/FooterPage.xaml.cs b/Sources/Linaris/FooterPage.xaml.cs index 55d0534..e79d555 100644 --- a/Sources/Linaris/FooterPage.xaml.cs +++ b/Sources/Linaris/FooterPage.xaml.cs @@ -2,6 +2,7 @@ using CommunityToolkit.Maui.Core.Primitives; using Model; using Model.Stub; using System.ComponentModel; +using System.Configuration; namespace Linaris; @@ -111,9 +112,14 @@ public partial class FooterPage : ContentView, INotifyPropertyChanged private void TimeSlider_ValueChanged(object sender, ValueChangedEventArgs e) { + if ((TimeSlider.Value * music.Duration.TotalSeconds) - music.Position.TotalSeconds <= 1 && (TimeSlider.Value * music.Duration.TotalSeconds) - music.Position.TotalSeconds >= -1) + { + return; + } TimeSpan PositionTimeSpan = TimeSpan.FromSeconds(TimeSlider.Value * music.Duration.TotalSeconds); music.SeekTo(PositionTimeSpan); Position = music.Position.ToString(@"hh\:mm\:ss"); + Duration = music.Duration.ToString(@"hh\:mm\:ss"); } private void Music_StateChanged(object sender, MediaStateChangedEventArgs e) @@ -135,8 +141,8 @@ public partial class FooterPage : ContentView, INotifyPropertyChanged Manager.PreviousTitle(); Dispatcher.DispatchAsync(() => { - CurrentPlaying = Manager.CurrentPlaying; - music.Source = CurrentPlaying.Path; + string encodedFilePath = Manager.CurrentPlaying.Path.Replace(" ", "\\ "); + music.Source = encodedFilePath; Duration = music.Duration.ToString(@"hh\:mm\:ss"); }); } @@ -147,8 +153,8 @@ public partial class FooterPage : ContentView, INotifyPropertyChanged Manager.NextTitle(); Dispatcher.DispatchAsync(() => { - CurrentPlaying = Manager.CurrentPlaying; - music.Source = CurrentPlaying.Path; + string encodedFilePath = Manager.CurrentPlaying.Path.Replace(" ", "\\ "); + music.Source = encodedFilePath; Duration = music.Duration.ToString(@"hh\:mm\:ss"); }); } @@ -169,8 +175,8 @@ public partial class FooterPage : ContentView, INotifyPropertyChanged Manager.NextTitle(); Dispatcher.DispatchAsync(() => { - CurrentPlaying = Manager.CurrentPlaying; - music.Source = CurrentPlaying.Path; + string encodedFilePath = Manager.CurrentPlaying.Path.Replace(" ", "\\ "); + music.Source = encodedFilePath; Duration = music.Duration.ToString(@"hh\:mm\:ss"); }); } diff --git a/Sources/Linaris/Linaris.csproj b/Sources/Linaris/Linaris.csproj index 8adecf0..5461e41 100644 --- a/Sources/Linaris/Linaris.csproj +++ b/Sources/Linaris/Linaris.csproj @@ -55,6 +55,7 @@ + diff --git a/Sources/Linaris/LocalFilesPage.xaml b/Sources/Linaris/LocalFilesPage.xaml index ca1ffb2..39a3210 100644 --- a/Sources/Linaris/LocalFilesPage.xaml +++ b/Sources/Linaris/LocalFilesPage.xaml @@ -33,19 +33,19 @@ -