-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a50239c
commit 517c1d6
Showing
9 changed files
with
165 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
Totoro.Core/ViewModels/Discover/MyAnimeListDiscoverViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
| ||
namespace Totoro.Core.ViewModels.Discover; | ||
|
||
public class MyAnimeListDiscoverViewModel : NavigatableViewModel | ||
{ | ||
private readonly IMyAnimeListService _myAnimeListService; | ||
|
||
public MyAnimeListDiscoverViewModel(IMyAnimeListService myAnimeListService) | ||
{ | ||
_myAnimeListService = myAnimeListService; | ||
} | ||
|
||
[Reactive] public bool IsLoading { get; set; } | ||
public ObservableCollection<NamedAnimeList> Lists { get; } = []; | ||
|
||
|
||
public override async Task OnNavigatedTo(IReadOnlyDictionary<string, object> parameters) | ||
{ | ||
IsLoading = true; | ||
|
||
Lists.Add(new("Top Airing", await _myAnimeListService.GetAiringAnime())); | ||
Lists.Add(new("Upcomming", await _myAnimeListService.GetUpcomingAnime())); | ||
Lists.Add(new("Popular", await _myAnimeListService.GetPopularAnime())); | ||
Lists.Add(new("Recommended", await _myAnimeListService.GetRecommendedAnime())); | ||
|
||
IsLoading = false; | ||
} | ||
} | ||
|
||
public class NamedAnimeList(string name, IEnumerable<AnimeModel> list) | ||
{ | ||
public string Name { get; } = name; | ||
public List<AnimeModel> List { get; } = list.ToList(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
Totoro.WinUI/Views/DiscoverSections/MyAnimeListDiscoverSection.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<discoversections:MyAnimeListDiscoverSectionBase | ||
x:Class="Totoro.WinUI.Views.DiscoverSections.MyAnimeListDiscoverSection" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:ctk="using:CommunityToolkit.WinUI.Controls" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:discover="using:Totoro.Core.ViewModels.Discover" | ||
xmlns:discoversections="using:Totoro.WinUI.Views.DiscoverSections" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:models="using:Totoro.Core.Models" | ||
xmlns:root="using:Totoro.WinUI" | ||
xmlns:uc="using:Totoro.WinUI.UserControls" | ||
mc:Ignorable="d"> | ||
<discoversections:MyAnimeListDiscoverSectionBase.Resources> | ||
<Style x:Key="TitleStyle" TargetType="TextBlock"> | ||
<Setter Property="FontWeight" Value="Bold" /> | ||
<Setter Property="FontSize" Value="20" /> | ||
</Style> | ||
</discoversections:MyAnimeListDiscoverSectionBase.Resources> | ||
|
||
<ctk:SwitchPresenter TargetType="x:Boolean" Value="{x:Bind ViewModel.IsLoading, Mode=OneWay}"> | ||
<ctk:Case Value="True"> | ||
<Grid> | ||
<ProgressRing IsActive="True" /> | ||
</Grid> | ||
</ctk:Case> | ||
<ctk:Case Value="False"> | ||
<Grid Margin="{StaticResource LargeTopMargin}"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="*" /> | ||
</Grid.RowDefinitions> | ||
|
||
<ItemsView | ||
Grid.Row="1" | ||
ItemsSource="{x:Bind ViewModel.Lists, Mode=OneWay}" | ||
SelectionMode="None"> | ||
<ItemsView.ItemTemplate> | ||
<DataTemplate x:DataType="discover:NamedAnimeList"> | ||
<ItemContainer> | ||
<!--<TextBlock Text="test" />--> | ||
<StackPanel Spacing="10"> | ||
<TextBlock Style="{StaticResource TitleStyle}" Text="{x:Bind Name}" /> | ||
<ItemsView ItemsSource="{x:Bind List}"> | ||
<ItemsView.ItemTemplate> | ||
<DataTemplate x:DataType="models:AnimeModel"> | ||
<ItemContainer> | ||
<uc:AnimeCard | ||
Width="270" | ||
Height="380" | ||
Margin="3" | ||
Anime="{x:Bind}" | ||
Command="{x:Bind root:App.Commands.AnimeCard}" /> | ||
</ItemContainer> | ||
</DataTemplate> | ||
</ItemsView.ItemTemplate> | ||
<ItemsView.Layout> | ||
<StackLayout Orientation="Horizontal" /> | ||
</ItemsView.Layout> | ||
</ItemsView> | ||
</StackPanel> | ||
</ItemContainer> | ||
</DataTemplate> | ||
</ItemsView.ItemTemplate> | ||
<ItemsView.Layout> | ||
<StackLayout Orientation="Vertical" Spacing="30" /> | ||
</ItemsView.Layout> | ||
</ItemsView> | ||
|
||
</Grid> | ||
</ctk:Case> | ||
</ctk:SwitchPresenter> | ||
</discoversections:MyAnimeListDiscoverSectionBase> |
14 changes: 14 additions & 0 deletions
14
Totoro.WinUI/Views/DiscoverSections/MyAnimeListDiscoverSection.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Microsoft.UI.Xaml.Controls; | ||
using Totoro.Core.ViewModels.Discover; | ||
|
||
namespace Totoro.WinUI.Views.DiscoverSections; | ||
|
||
public class MyAnimeListDiscoverSectionBase : ReactivePage<MyAnimeListDiscoverViewModel> { } | ||
|
||
public sealed partial class MyAnimeListDiscoverSection : MyAnimeListDiscoverSectionBase | ||
{ | ||
public MyAnimeListDiscoverSection() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} |