Skip to content

Commit

Permalink
Merge pull request #143 from YBTopaz8/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
YBTopaz8 authored Nov 13, 2024
2 parents 76b56c3 + 11ce01b commit afa7721
Show file tree
Hide file tree
Showing 27 changed files with 888 additions and 438 deletions.
2 changes: 1 addition & 1 deletion Dimmer/DataAccess/Services/DataBaseService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class DataBaseService : IDataBaseService
}

string filePath = Path.Combine(dbPath, "DimmerDB.realm");
//File.Delete(filePath);
//File.Delete(filePath);
var config = new RealmConfiguration(filePath)
{
SchemaVersion = 0
Expand Down
1 change: 0 additions & 1 deletion Dimmer/Dimmer-MAUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="akgul.Maui.DataGrid" Version="4.0.5" />
<PackageReference Include="CommunityToolkit.Maui" Version="9.1.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.2" />
<PackageReference Include="DevExpress.Maui.CollectionView" Version="24.1.7" />
Expand Down
6 changes: 3 additions & 3 deletions Dimmer/Dimmer-MAUI.csproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IsFirstTimeProjectOpen>False</IsFirstTimeProjectOpen>
<ActiveDebugFramework>net8.0-windows10.0.19041.0</ActiveDebugFramework>
<ActiveDebugProfile>Windows Machine</ActiveDebugProfile>
<SelectedPlatformGroup>PhysicalDevice</SelectedPlatformGroup>
<ActiveDebugFramework>net8.0-android34.0</ActiveDebugFramework>
<ActiveDebugProfile>Pixel 5 - API 34 (Android 14.0 - API 34)</ActiveDebugProfile>
<SelectedPlatformGroup>Emulator</SelectedPlatformGroup>
<DefaultDevice>pixel_5_-_api_34</DefaultDevice>
<UapAppxPackageBuildMode>SideloadOnly</UapAppxPackageBuildMode>
<AppxShowAllApps>False</AppxShowAllApps>
Expand Down
2 changes: 1 addition & 1 deletion Dimmer/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

global using Syncfusion.Maui.Toolkit.Hosting;
global using DevExpress.Maui;

global using DevExpress.Maui.Editors;


global using Dimmer_MAUI.Utilities.OtherUtils;
Expand Down
3 changes: 2 additions & 1 deletion Dimmer/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public static MauiApp CreateMauiApp()
.UseDevExpressCollectionView()
.UseDevExpressControls()
.UseDevExpressDataGrid()
.UseDevExpressEditors().UseDevExpressGauges()
.UseDevExpressEditors()
.UseDevExpressGauges()

.UseMauiCommunityToolkit(options =>
{
Expand Down
3 changes: 1 addition & 2 deletions Dimmer/Platforms/Windows/NativeAudioService.windows.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.ComponentModel;
using Windows.Media;
using Windows.Media;
using Windows.Media.Core;
using Windows.Media.Playback;
using Windows.Storage.Streams;
Expand Down
1 change: 0 additions & 1 deletion Dimmer/Platforms/Windows/PlatSpecificUtils.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.VisualBasic.FileIO;
using Foundation= Windows.Foundation;
using FileSystem = Microsoft.VisualBasic.FileIO.FileSystem;

namespace Dimmer_MAUI.Platforms.Windows;
Expand Down
2 changes: 2 additions & 0 deletions Dimmer/Utilities/Models/SongsModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ public SongsModelView(SongsModel _model)
bool isFavorite;
[ObservableProperty]
string achievement;
[ObservableProperty]
ObservableCollection<LyricPhraseModel> syncLyrics;

// Override Equals to compare based on ObjectId
public override bool Equals(object? obj)
Expand Down
42 changes: 35 additions & 7 deletions Dimmer/Utilities/Services/LyricsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,10 @@ public void InitializeLyrics(string synclyrics)
songSyncLyrics = StringToLyricPhraseModel(lines);
sortedLyrics = songSyncLyrics;
_synchronizedLyricsSubject.OnNext(songSyncLyrics);
if (PlayBackService.CurrentlyPlayingSong.IsPlaying)
if (PlayBackService.CurrentlyPlayingSong is not null && PlayBackService.CurrentlyPlayingSong.IsPlaying)
{
StartLyricIndexUpdateTimer();
StartLyricIndexUpdateTimer();

}
}

Expand Down Expand Up @@ -310,7 +311,6 @@ public void StartLyricIndexUpdateTimer()
}, error => { Debug.WriteLine($"Error in subscription: {error.Message}"); });
}


public void UpdateCurrentLyricIndex(double currentPositionInSeconds)
{
var lyrics = _synchronizedLyricsSubject.Value;
Expand Down Expand Up @@ -652,6 +652,21 @@ public static string SaveOrGetCoverImageToFilePath(string fullfilePath, byte[]?

#endregion

public static (bool,ObservableCollection<LyricPhraseModel>?) HasLyrics(SongsModelView song)
{
if (song is null)
{
return (false, null);
}

var track = new Track(song.FilePath);
if (track.Lyrics.SynchronizedLyrics is null || track.Lyrics.SynchronizedLyrics.Count < 1)
{
return (false, null);
}

return (true, track.Lyrics.SynchronizedLyrics.Select(phrase => new LyricPhraseModel(phrase)).ToObservableCollection());
}

public bool WriteLyricsToLyricsFile(string Lyrics, SongsModelView songObj, bool IsSynched)
{
Expand All @@ -662,10 +677,23 @@ public bool WriteLyricsToLyricsFile(string Lyrics, SongsModelView songObj, bool
if (!IsSynched)
{
songObj.UnSyncLyrics = Lyrics;
songObj.UnSyncLyrics = string.Empty;
}
else
{
var track = new Track(songObj.FilePath);
track.Lyrics.ParseLRC(Lyrics);
songObj.HasSyncedLyrics = IsSynched;

track.Save();

songObj.SyncLyrics = new ObservableCollection<LyricPhraseModel>(
track.Lyrics.SynchronizedLyrics.Select(phrase => new LyricPhraseModel(phrase))
);

}
songObj.UnSyncLyrics=string.Empty;
songObj.HasLyrics = !IsSynched;
songObj.HasSyncedLyrics = IsSynched;
songObj.HasLyrics = IsSynched;

if (PlayBackService.CurrentQueue != 2)
{
SongsManagementService.UpdateSongDetails(songObj);
Expand All @@ -686,7 +714,7 @@ public bool WriteLyricsToLyricsFile(string Lyrics, SongsModelView songObj, bool
}

File.WriteAllText(lrcFilePath, Lyrics); //I had a case one time where an exception was thrown because there was a folder with exact same name alreay existing

return true;

}
Expand Down
5 changes: 1 addition & 4 deletions Dimmer/Utilities/Services/PlaybackUtilsService.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@

using System.Diagnostics;

namespace Dimmer_MAUI.Utilities.Services;
namespace Dimmer_MAUI.Utilities.Services;
public partial class PlaybackUtilsService : ObservableObject, IPlaybackUtilsService
{

Expand Down
2 changes: 1 addition & 1 deletion Dimmer/ViewModels/ArtistsSection.HomePageVM.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Linq;
using WinRT;
//using WinRT;

namespace Dimmer_MAUI.ViewModels;

Expand Down
26 changes: 14 additions & 12 deletions Dimmer/ViewModels/HomePageVM.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using DevExpress.Maui.Controls;
using Dimmer_MAUI.Utilities.OtherUtils.CustomControl.RatingsView.Models;
using System.Diagnostics;
using WinRT;


namespace Dimmer_MAUI.ViewModels;
public partial class HomePageVM : ObservableObject
Expand Down Expand Up @@ -907,6 +907,8 @@ public async Task ShowSingleLyricsPreviewPopup(Content cont, bool IsPlain)
if (result)
{
await SaveSelectedLyricsToFile(!IsPlain, cont);
if (TemporarilyPickedSong is null)
TemporarilyPickedSong = SelectedSongToOpenBtmSheet;
}
}

Expand All @@ -918,17 +920,17 @@ public async Task SaveSelectedLyricsToFile(bool isSync, Content cont) // rework

if (!isSync)
{
TemporarilyPickedSong.HasLyrics = true;
TemporarilyPickedSong.UnSyncLyrics = cont.plainLyrics;
TemporarilyPickedSong.HasSyncedLyrics = false;
isSavedSuccessfully = LyricsManagerService.WriteLyricsToLyricsFile(cont.plainLyrics, TemporarilyPickedSong, isSync);
SelectedSongToOpenBtmSheet.HasLyrics = true;
SelectedSongToOpenBtmSheet.UnSyncLyrics = cont.plainLyrics;
SelectedSongToOpenBtmSheet.HasSyncedLyrics = false;
isSavedSuccessfully = LyricsManagerService.WriteLyricsToLyricsFile(cont.plainLyrics, SelectedSongToOpenBtmSheet, isSync);
}
else
{
TemporarilyPickedSong.HasLyrics = false;
TemporarilyPickedSong.UnSyncLyrics = string.Empty;
TemporarilyPickedSong.HasSyncedLyrics = true;
isSavedSuccessfully = LyricsManagerService.WriteLyricsToLyricsFile(cont.syncedLyrics, TemporarilyPickedSong, isSync);
SelectedSongToOpenBtmSheet.HasLyrics = false;
SelectedSongToOpenBtmSheet.UnSyncLyrics = string.Empty;
SelectedSongToOpenBtmSheet.HasSyncedLyrics = true;
isSavedSuccessfully = LyricsManagerService.WriteLyricsToLyricsFile(cont.syncedLyrics, SelectedSongToOpenBtmSheet, isSync);
}
if (isSavedSuccessfully)
{
Expand All @@ -946,13 +948,13 @@ public async Task SaveSelectedLyricsToFile(bool isSync, Content cont) // rework
return;
}
LyricsManagerService.InitializeLyrics(cont.syncedLyrics);
if (DisplayedSongs.FirstOrDefault(x => x.Id == TemporarilyPickedSong.Id) is not null)
if (DisplayedSongs.FirstOrDefault(x => x.Id == SelectedSongToOpenBtmSheet.Id) is not null)
{
DisplayedSongs.FirstOrDefault(x => x.Id == TemporarilyPickedSong.Id)!.HasLyrics = true;
DisplayedSongs.FirstOrDefault(x => x.Id == SelectedSongToOpenBtmSheet.Id)!.HasLyrics = true;
}
if (PlayBackService.CurrentQueue != 2)
{
SongsMgtService.UpdateSongDetails(TemporarilyPickedSong);
SongsMgtService.UpdateSongDetails(SelectedSongToOpenBtmSheet);
}

}
Expand Down
6 changes: 1 addition & 5 deletions Dimmer/ViewModels/StatsSection.HomePageVM.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@

using System;
using System.Linq;

namespace Dimmer_MAUI.ViewModels;
namespace Dimmer_MAUI.ViewModels;

public partial class HomePageVM
{
Expand Down
9 changes: 9 additions & 0 deletions Dimmer/ViewModels/Utlities.HomePageVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,4 +377,13 @@ async Task DownloadAlbumImage(AlbumModelView album)
var firstSongOfSpectifAlbum = AllArtistsAlbumSongs.FirstOrDefault();
SelectedAlbumOnArtistPage.AlbumImagePath = await LyricsManagerService.FetchAndDownloadCoverImage(firstSongOfSpectifAlbum.Title,firstSongOfSpectifAlbum.ArtistName, firstSongOfSpectifAlbum.AlbumName);
}

[ObservableProperty]
ObservableCollection<string> photoDumps = new ObservableCollection<string>();
public Color[] ShareColors { get; } = new Color[]{
Color.FromArgb("#FF0000"),
Color.FromArgb("#2365BD"),
Color.FromArgb("#4C342F"),
Color.FromArgb("#661D98"),
};
}
Loading

0 comments on commit afa7721

Please sign in to comment.