Skip to content

Commit

Permalink
Rework dual screen mode and migrate in-app notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Guerra24 committed Nov 1, 2023
1 parent 4137d70 commit 7e2e8c0
Show file tree
Hide file tree
Showing 31 changed files with 354 additions and 340 deletions.
2 changes: 1 addition & 1 deletion LRReader.Shared/ApiConnection.cs
Expand Up @@ -202,7 +202,7 @@ public static async Task<GenericApiResult> GetError(this RestResponse restRespon
}
}*/

private static void ShowNotification(string title, string? content) => WeakReferenceMessenger.Default.Send(new ShowNotification(title, content));
private static void ShowNotification(string title, string? content) => WeakReferenceMessenger.Default.Send(new ShowNotification(title, content, severity: NotificationSeverity.Error));
}

}
12 changes: 10 additions & 2 deletions LRReader.Shared/Messages/Events.cs
Expand Up @@ -20,16 +20,24 @@ public struct Notification
public string? Content { get; }
public int Duration { get; }

public Notification(string title, string? content, int duration)
public NotificationSeverity Severity { get; }

public Notification(string title, string? content, int duration, NotificationSeverity severity = NotificationSeverity.Informational)
{
Title = title;
Content = content;
Duration = duration;
Severity = severity;
}
}

public enum NotificationSeverity
{
Informational, Success, Warning, Error
}

public class ShowNotification : ValueChangedMessage<Notification>
{
public ShowNotification(string title, string? content, int duration = 5000) : base(new Notification(title, content, duration)) { }
public ShowNotification(string title, string? content, int duration = 5000, NotificationSeverity severity = NotificationSeverity.Informational) : base(new Notification(title, content, duration, severity)) { }
}
}
1 change: 1 addition & 0 deletions LRReader.Shared/Models/Main/Archive.cs
Expand Up @@ -22,6 +22,7 @@ public class Archive : IEquatable<Archive>
public string title { get; set; } = null!;
public int pagecount { get; set; }
public int progress { get; set; }
public int? lastreadtime { get; set; }
[JsonIgnore]
public string TagsClean { get; set; } = null!;
[JsonIgnore]
Expand Down
4 changes: 2 additions & 2 deletions LRReader.Shared/Providers/ArchivesProvider.cs
Expand Up @@ -110,7 +110,7 @@ public static async Task<bool> Validate()

if (!string.IsNullOrEmpty(r.ErrorMessage))
{
WeakReferenceMessenger.Default.Send(new ShowNotification("Network Error", r.ErrorMessage));
WeakReferenceMessenger.Default.Send(new ShowNotification("Network Error", r.ErrorMessage, severity: NotificationSeverity.Error));
return null;
}
switch (r.StatusCode)
Expand All @@ -128,7 +128,7 @@ public static async Task<bool> Validate()
return download;
default:
var error = await r.GetError();
WeakReferenceMessenger.Default.Send(new ShowNotification(error.operation, error.error));
WeakReferenceMessenger.Default.Send(new ShowNotification(error.operation, error.error, severity: NotificationSeverity.Error));
return null;
}
}
Expand Down
4 changes: 2 additions & 2 deletions LRReader.Shared/Providers/CategoriesProvider.cs
Expand Up @@ -54,7 +54,7 @@ public static async Task<bool> Validate()

if (!string.IsNullOrEmpty(r.ErrorMessage))
{
WeakReferenceMessenger.Default.Send(new ShowNotification("Network Error", r.ErrorMessage));
WeakReferenceMessenger.Default.Send(new ShowNotification("Network Error", r.ErrorMessage, severity: NotificationSeverity.Error));
return null;
}
if (result.OK)
Expand All @@ -63,7 +63,7 @@ public static async Task<bool> Validate()
}
else
{
WeakReferenceMessenger.Default.Send(new ShowNotification(result?.Error?.operation ?? "", result?.Error?.error));
WeakReferenceMessenger.Default.Send(new ShowNotification(result?.Error?.operation ?? "", result?.Error?.error, severity: NotificationSeverity.Error));
return null;
}
}
Expand Down
4 changes: 2 additions & 2 deletions LRReader.Shared/Providers/DatabaseProvider.cs
Expand Up @@ -72,7 +72,7 @@ public static async Task<bool> DropDatabase()

if (!string.IsNullOrEmpty(r.ErrorMessage))
{
WeakReferenceMessenger.Default.Send(new ShowNotification("Network Error", r.ErrorMessage));
WeakReferenceMessenger.Default.Send(new ShowNotification("Network Error", r.ErrorMessage, severity: NotificationSeverity.Error));
return null;
}
switch (r.StatusCode)
Expand All @@ -85,7 +85,7 @@ public static async Task<bool> DropDatabase()
return download;
default:
var error = await r.GetError();
WeakReferenceMessenger.Default.Send(new ShowNotification(error.operation, error.error));
WeakReferenceMessenger.Default.Send(new ShowNotification(error.operation, error.error, severity: NotificationSeverity.Error));
return null;
}
}
Expand Down
4 changes: 2 additions & 2 deletions LRReader.Shared/Services/Archives.cs
Expand Up @@ -140,7 +140,7 @@ public async Task<bool> DeleteArchive(string id)
var result = await ArchivesProvider.DeleteArchive(id);
if (result == null)
{
WeakReferenceMessenger.Default.Send(new ShowNotification("Unable to delete archive", "", 0));
WeakReferenceMessenger.Default.Send(new ShowNotification("Unable to delete archive", "", 0, NotificationSeverity.Error));
return false;
}
if (result.success)
Expand All @@ -154,7 +154,7 @@ public async Task<bool> DeleteArchive(string id)
}
else
{
WeakReferenceMessenger.Default.Send(new ShowNotification("An error ocurred while deleting archive", "Metadata has been deleted, remove file manually.", 0));
WeakReferenceMessenger.Default.Send(new ShowNotification("An error ocurred while deleting archive", "Metadata has been deleted, remove file manually.", 0, NotificationSeverity.Warning));
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion LRReader.Shared/ViewModels/ArchiveEditViewModel.cs
Expand Up @@ -195,7 +195,7 @@ private async Task UsePlugin()
}
else
{
WeakReferenceMessenger.Default.Send(new ShowNotification("Error while fetching tags", result.error, 0));
WeakReferenceMessenger.Default.Send(new ShowNotification("Error while fetching tags", result.error, 0, NotificationSeverity.Error));
}
}
Saving = false;
Expand Down
2 changes: 1 addition & 1 deletion LRReader.Shared/ViewModels/ArchivesPageViewModel.cs
Expand Up @@ -55,7 +55,7 @@ public void LoadBookmarks()
if (archive != null)
Archives.OpenTab(archive, false);
else
WeakReferenceMessenger.Default.Send(new ShowNotification("Bookmarked Archive with ID[" + b.archiveID + "] not found.", ""));
WeakReferenceMessenger.Default.Send(new ShowNotification("Bookmarked Archive with ID[" + b.archiveID + "] not found.", "", severity: NotificationSeverity.Warning));
}
Settings.Profile.MarkedAsNonDuplicated.RemoveAll(hit => !(Archives.HasArchive(hit.Left) && Archives.HasArchive(hit.Right)));
}
Expand Down
2 changes: 1 addition & 1 deletion LRReader.Shared/ViewModels/SettingsPageViewModel.cs
Expand Up @@ -272,7 +272,7 @@ public async Task CheckThumbnailJob()
}
if (status.state!.Equals("finished"))
{
WeakReferenceMessenger.Default.Send(new ShowNotification("Thumbnail generation completed", ""));
WeakReferenceMessenger.Default.Send(new ShowNotification("Thumbnail generation completed", "", severity: NotificationSeverity.Informational));
thumbnailJob = null;
}
}
Expand Down
2 changes: 1 addition & 1 deletion LRReader.UWP.Installer/LRReader.UWP.Installer.csproj
Expand Up @@ -31,7 +31,7 @@
<Version>5.7.0</Version>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.22621.755" />
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.22621.2428" />
<PackageReference Include="WPF-UI">
<Version>3.0.0-preview.8</Version>
</PackageReference>
Expand Down
1 change: 0 additions & 1 deletion LRReader.UWP/App.xaml
Expand Up @@ -11,7 +11,6 @@
<controls:XamlControlsResources.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///Resources/ThemeDictionary.xaml" />
<ResourceDictionary Source="ms-appx:///Resources/Converters.xaml" />
<ResourceDictionary Source="ms-appx:///Resources/NotificationStyle.xaml" />
<ResourceDictionary Source="ms-appx:///Resources/WinUITemplates.xaml" />
<Templates xmlns="using:LRReader.UWP.Resources" />
</controls:XamlControlsResources.MergedDictionaries>
Expand Down
36 changes: 18 additions & 18 deletions LRReader.UWP/LRReader.UWP.csproj
Expand Up @@ -30,7 +30,7 @@
<AppxPackageSigningTimestampServerUrl>http://timestamp.digicert.com</AppxPackageSigningTimestampServerUrl>
<Win32Resource>Resources\MiddleClickScrolling-CursorType.res</Win32Resource>
<Nullable>enable</Nullable>
<LangVersion>9.0</LangVersion>
<LangVersion>10.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -161,6 +161,9 @@
<Compile Include="Services\Dispatcher.cs" />
<Compile Include="Services\Updates.cs" />
<Compile Include="Util\IgnoreFocusKeyboardAccelerator.cs" />
<Compile Include="Views\Content\Empty.xaml.cs">
<DependentUpon>Empty.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Content\Settings\Feedback.xaml.cs">
<DependentUpon>Feedback.xaml</DependentUpon>
</Compile>
Expand All @@ -182,6 +185,9 @@
<Compile Include="Views\Content\Tools\Main.xaml.cs">
<DependentUpon>Main.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Content\WebContent.xaml.cs">
<DependentUpon>WebContent.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Controls\ArchiveTags.xaml.cs">
<DependentUpon>ArchiveTags.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -229,9 +235,6 @@
<DependentUpon>CategoryItem.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Items\GenericArchiveItem.cs" />
<Compile Include="Views\Items\NotificationItem.xaml.cs">
<DependentUpon>NotificationItem.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Items\ReaderImage.xaml.cs">
<DependentUpon>ReaderImage.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -416,6 +419,9 @@
<PackageReference Include="CommunityToolkit.Uwp.Animations">
<Version>8.0.230907</Version>
</PackageReference>
<PackageReference Include="CommunityToolkit.Uwp.Behaviors">
<Version>8.0.230907</Version>
</PackageReference>
<PackageReference Include="CommunityToolkit.Uwp.Controls.Primitives">
<Version>8.0.230907</Version>
</PackageReference>
Expand All @@ -437,12 +443,6 @@
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.14</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls.Core">
<Version>7.1.3</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls.Layout">
<Version>7.1.3</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls.Markdown">
<Version>7.1.3</Version>
</PackageReference>
Expand Down Expand Up @@ -472,10 +472,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Resources\NotificationStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Resources\Templates.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand All @@ -488,6 +484,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Content\Empty.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Content\Settings\Feedback.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -516,6 +516,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Content\WebContent.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Controls\ArchiveTags.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -568,10 +572,6 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\Items\NotificationItem.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\Items\ReaderImage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down

0 comments on commit 7e2e8c0

Please sign in to comment.