Skip to content

Commit

Permalink
Added a new Splash Screen
Browse files Browse the repository at this point in the history
- The splash screen is highly WIP.
- It has breaking changes.
- The build will pass but the App can't run due to some win32 issue.
  • Loading branch information
CosmicPredator committed Mar 20, 2024
1 parent 0e842e0 commit 0ec0d32
Show file tree
Hide file tree
Showing 19 changed files with 229 additions and 53 deletions.
8 changes: 7 additions & 1 deletion src/AniMoe.App/AniMoe.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<None Remove="Views\RootWindow.xaml" />
<None Remove="Views\SettingsPages\AboutPage.xaml" />
<None Remove="Views\SettingsView.xaml" />
<None Remove="Views\SplashView.xaml" />
<None Remove="Views\StaffView.xaml" />
<None Remove="Views\UserView.xaml" />
</ItemGroup>
Expand Down Expand Up @@ -106,10 +107,12 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Graphics.Win2D" Version="1.0.5.1" />
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.49-beta">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240227000" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.3233" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="PInvoke.User32" Version="0.7.124" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
Expand Down Expand Up @@ -205,6 +208,9 @@
<None Update="Assets\profile.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Page Update="Views\SplashView.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Update="Controls\SettingsViewControls\UpdateDialog.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
Expand Down
3 changes: 3 additions & 0 deletions src/AniMoe.App/AniMoe.App.csproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
<None Update="App.xaml">
<SubType>Designer</SubType>
</None>
<Page Update="Views\SplashView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Controls\SettingsViewControls\UpdateDialog.xaml">
<SubType>Designer</SubType>
</Page>
Expand Down
7 changes: 5 additions & 2 deletions src/AniMoe.App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ public static IServiceProvider ConfigureServices()
.AddScoped<ILocalSettings, LocalSettings>()
.AddScoped<IClipCopier, ClipCopier>()
.AddScoped<INotificationService, NotificationService>()
.AddSingleton<MasterModel>()
.AddSingleton<MasterViewModel>()
.AddSingleton<MediaListStatusModel>()
.AddSingleton(DispatcherQueue.GetForCurrentThread())
.AddSingleton<IMdToHtmlParser, MdToHtmlParser>()
.AddSingleton<AnimeListViewModel>()
.AddSingleton<MangaListViewModel>()
.AddSingleton<ExploreViewModel>()
.AddSingleton<SplashViewModel>()
.AddSingleton<UpdateHandler>();

services.AddHttpClient<IRequestHandler, RequestHandler>();
Expand Down Expand Up @@ -109,8 +111,9 @@ protected override async void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventA
Process.GetProcessById((int)mainInstance.ProcessId).Kill();
Log.Information("Authorization handled successfully and accessToken was saved");
}
m_window = new RootWindow();
m_window.ExtendsContentIntoTitleBar = true;
//m_window = new RootWindow();
m_window = new SplashView();
//m_window.ExtendsContentIntoTitleBar = true;
m_window.Activate();
Log.Information("RootWindow initialized");
}
Expand Down
1 change: 0 additions & 1 deletion src/AniMoe.App/Converters/StringToCategoryString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static PInvoke.User32;

namespace AniMoe.App.Converters
{
Expand Down
4 changes: 2 additions & 2 deletions src/AniMoe.App/Dialogs/ExploreViewFilterDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ namespace AniMoe.App.Dialogs
{
public sealed partial class ExploreViewFilterDialog : ContentDialog
{
public MasterViewModel masterViewModel;
public SplashViewModel masterViewModel;
public List<ExploreFilterModel> FilterList;
public Dictionary<string, dynamic> Filters = new();
public List<EnumValue> FormatList;
public string MediaType;

public ExploreViewFilterDialog(string mediaType)
{
masterViewModel = App.Current.Services.GetRequiredService<MasterViewModel>();
masterViewModel = App.Current.Services.GetRequiredService<SplashViewModel>();
MediaType = mediaType;
InitializeComponent();
LoadFilterList();
Expand Down
4 changes: 2 additions & 2 deletions src/AniMoe.App/Dialogs/MediaListFliterView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public sealed partial class MediaListFliterView : ContentDialog
public MediaListFilterModel Model;
private List<Genre> genreList;
public List<Format> AnimeFormatList;
public MasterViewModel DataModal = App.Current.Services
.GetRequiredService<MasterViewModel>();
public SplashViewModel DataModal = App.Current.Services
.GetRequiredService<SplashViewModel>();
public int Year = DateTime.Now.Year + 1;
public MediaListFliterView()
{
Expand Down
2 changes: 1 addition & 1 deletion src/AniMoe.App/Models/AnimeListModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static partial class Initialize
public static async Task<AnimeListModel> FetchData()
{
IRequestHandler Handler = App.Current.Services.GetService<IRequestHandler>();
MasterViewModel Vm = App.Current.Services.GetRequiredService<MasterViewModel>();
SplashViewModel Vm = App.Current.Services.GetRequiredService<SplashViewModel>();
AnimeListModel Model = await Handler.RequestApi<AnimeListModel>(
Queries.Query.MediaListQuery,
new
Expand Down
2 changes: 1 addition & 1 deletion src/AniMoe.App/Models/MangaListModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static partial class Initialize
public static async Task<MangaListModel> FetchData()
{
IRequestHandler Handler = App.Current.Services.GetService<IRequestHandler>();
MasterViewModel Vm = App.Current.Services.GetRequiredService<MasterViewModel>();
SplashViewModel Vm = App.Current.Services.GetRequiredService<SplashViewModel>();
MangaListModel Model = await Handler.RequestApi<MangaListModel>(
Queries.Query.MediaListQuery,
new
Expand Down
5 changes: 5 additions & 0 deletions src/AniMoe.App/NativeMethods.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://aka.ms/CsWin32.schema.json",
"className": "AniMoeAppNative",
"public": true
}
4 changes: 4 additions & 0 deletions src/AniMoe.App/NativeMethods.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SetWindowPos
GetSystemMetrics
SetWindowLongPtr
WINDOW_STYLE
6 changes: 3 additions & 3 deletions src/AniMoe.App/ViewModels/AnimeListViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace AniMoe.App.ViewModels
public partial class AnimeListViewModel : ObservableObject
{
private AnimeListModel model;
private MasterViewModel StatusModel;
private SplashViewModel StatusModel;
private bool loaded = false;
private bool isLoading = true;
private bool isEmpty = false;
Expand Down Expand Up @@ -135,9 +135,9 @@ public void SearchTextChanged(object sender, TextChangedEventArgs e)
}
}

public AnimeListViewModel(MasterViewModel masterViewModel)
public AnimeListViewModel(SplashViewModel splashViewModel)
{
StatusModel = masterViewModel;
StatusModel = splashViewModel;
LoadView = new AsyncRelayCommand(async() =>
{
await InitView();
Expand Down
6 changes: 3 additions & 3 deletions src/AniMoe.App/ViewModels/MangaListViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace AniMoe.App.ViewModels
public partial class MangaListViewModel : ObservableObject
{
private MangaListModel model;
private MasterViewModel StatusModel;
private SplashViewModel StatusModel;
private bool loaded = false;
private bool isLoading = true;
private bool isEmpty = false;
Expand Down Expand Up @@ -123,9 +123,9 @@ public void SearchTextChanged(object sender, TextChangedEventArgs e)
}
}

public MangaListViewModel(MasterViewModel masterViewModel)
public MangaListViewModel(SplashViewModel splashViewModel)
{
StatusModel = masterViewModel;
StatusModel = splashViewModel;
LoadView = new AsyncRelayCommand(async () =>
{
await InitView();
Expand Down
10 changes: 6 additions & 4 deletions src/AniMoe.App/ViewModels/MasterViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,18 @@ public bool IsVisible

public IAsyncRelayCommand LoadData { get; }

public MasterViewModel()
public MasterViewModel(MasterModel model, MediaListStatusModel _mediaListStatusModel)
{
mediaListStatusModel = _mediaListStatusModel;
Model = model;
LoadData = new AsyncRelayCommand(LoadModel);
}

public async Task LoadModel()

Check warning on line 52 in src/AniMoe.App/ViewModels/MasterViewModel.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 52 in src/AniMoe.App/ViewModels/MasterViewModel.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
IsVisible = false;
NavItemsEnable = true;
await LoadFromApi();
//IsVisible = false;
//NavItemsEnable = true;
//await LoadFromApi();
NavItemsEnable = false;
IsVisible = true;
}
Expand Down
68 changes: 68 additions & 0 deletions src/AniMoe.App/ViewModels/SplashViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using AniMoe.App.Models.MasterModel;
using AniMoe.App.Models.MediaListStatusModel;
using AniMoe.App.Services;
using AniMoe.App.Views;
using CommunityToolkit.Mvvm.ComponentModel;
using Microsoft.UI.Xaml;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace AniMoe.App.ViewModels
{
public partial class SplashViewModel : ObservableObject
{
public MediaListStatusModel mediaListStatusModel;
private readonly ILocalSettings _localSettings;
private RootWindow rootWindow = null;

[ObservableProperty] private MasterModel model;

[ObservableProperty] string _statusText;

public SplashViewModel(MasterModel model, ILocalSettings settings)
{
_localSettings = settings;
StatusText = "Registering Dependencies...";
model = Model;
}

public async void Window_Activated(object sender, WindowActivatedEventArgs args)
{
var ins = Application.Current as App;
var window = ins.m_window;
if (window is SplashView splashView) return;
if (window is RootWindow roowindow) return;
if (_localSettings.IsSettingExists("accessToken"))
await LoadFromApi();
if (rootWindow == null)
{
var mwindow = new RootWindow();
mwindow.ExtendsContentIntoTitleBar = true;
((Window)sender).Close();
mwindow.Activate();
ins.m_window = mwindow;
}
}

public async Task LoadFromApi()
{
StatusText = "Fetching user data...";
Model = await Models.MasterModel.Initialize.FetchData();

StatusText = "Fetching Anime & Manga lists...";
mediaListStatusModel
= await Models.MediaListStatusModel.Initialize.FetchData(Model.Data.User.Id);
EnumValue defaultValue = new EnumValue { Name = "Select One" };
Model.Data.MediaSourceList.EnumValues.Insert(0, defaultValue);
Model.Data.MediaSeasonList.EnumValues.Insert(0, defaultValue);
Model.Data.MediaFormatList.EnumValues.Insert(0, defaultValue);

StatusText = "Launching AniMoe...";
}
}
}
26 changes: 12 additions & 14 deletions src/AniMoe.App/Views/MasterView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:DefaultBindMode="OneWay"
mc:Ignorable="d">
<Interactivity:Interaction.Behaviors>
<!--<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="Loaded">
<Core:InvokeCommandAction Command="{x:Bind ViewModel.LoadData}" />
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</Interactivity:Interaction.Behaviors>-->

<!-- x:Load="{x:Bind ViewModel.IsVisible}" -->

<Grid x:Name="RootGrid">
<NavigationView
x:Name="MasterNavView"
x:Load="{x:Bind ViewModel.IsVisible}"
BackRequested="MasterNavView_BackRequested"
DisplayModeChanged="MasterNavView_DisplayModeChanged"
IsBackEnabled="True"
Expand All @@ -34,32 +36,27 @@
</TransitionCollection>
</NavigationView.Transitions>
<NavigationView.MenuItems>
<NavigationViewItem Content="Home"
x:Name="HomeSection">
<NavigationViewItem x:Name="HomeSection" Content="Home">
<NavigationViewItem.Icon>
<FontIcon Glyph="&#xe10f;" />
</NavigationViewItem.Icon>
</NavigationViewItem>
<NavigationViewItem Content="Anime List"
x:Name="AnimeListSection">
<NavigationViewItem x:Name="AnimeListSection" Content="Anime List">
<NavigationViewItem.Icon>
<FontIcon Glyph="&#xe173;" />
</NavigationViewItem.Icon>
</NavigationViewItem>
<NavigationViewItem Content="Manga List"
x:Name="MangaListSection">
<NavigationViewItem x:Name="MangaListSection" Content="Manga List">
<NavigationViewItem.Icon>
<FontIcon Glyph="&#xe8f1;" />
</NavigationViewItem.Icon>
</NavigationViewItem>
<NavigationViewItem Content="Explore"
x:Name="ExploreSection">
<NavigationViewItem x:Name="ExploreSection" Content="Explore">
<NavigationViewItem.Icon>
<FontIcon Glyph="&#xe138;" />
</NavigationViewItem.Icon>
</NavigationViewItem>
<NavigationViewItem Content="Notifications"
x:Name="NotificationSection">
<NavigationViewItem x:Name="NotificationSection" Content="Notifications">
<NavigationViewItem.Icon>
<FontIcon Glyph="&#xEA8F;" />
</NavigationViewItem.Icon>
Expand Down Expand Up @@ -96,8 +93,9 @@
x:Name="Spinner"
HorizontalAlignment="Center"
VerticalAlignment="Center"
x:Load="{x:Bind ViewModel.NavItemsEnable}"
IsActive="True"
x:Load="False"
IsIndeterminate="True" />
<!-- x:Load="{x:Bind ViewModel.NavItemsEnable}" -->
</Grid>
</Page>
4 changes: 2 additions & 2 deletions src/AniMoe.App/Views/MasterView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ namespace AniMoe.App.Views
{
public sealed partial class MasterView : Page
{
public MasterViewModel ViewModel;
public SplashViewModel ViewModel;
DispatcherQueue dispatcherQueue = DispatcherQueue.GetForCurrentThread();
public MasterView()
{
ViewModel = App.Current.Services.GetRequiredService<MasterViewModel>();
ViewModel = App.Current.Services.GetRequiredService<SplashViewModel>();
this.InitializeComponent();
DataContext = ViewModel;
}
Expand Down
Loading

0 comments on commit 0ec0d32

Please sign in to comment.