Skip to content

Commit

Permalink
Last minute polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
aetherstrata committed Feb 19, 2024
1 parent 42e524f commit 8a1e34f
Show file tree
Hide file tree
Showing 41 changed files with 226 additions and 218 deletions.
2 changes: 1 addition & 1 deletion Aosta.Ava/Aosta.Ava/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
</Application.DataTemplates>

<Application.Styles>
<styling:FluentAvaloniaTheme CustomAccentColor="{StaticResource BaseColor}"/>
<StyleInclude Source="/Assets/Styles/DefaultStyles.axaml"/>
<StyleInclude Source="/Assets/Styles/TemplatedControls.axaml"/>
<styling:FluentAvaloniaTheme CustomAccentColor="{StaticResource BaseColor}"/>
</Application.Styles>
</Application>
5 changes: 3 additions & 2 deletions Aosta.Ava/Aosta.Ava/Assets/Localization/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

"AnimeList.Header.NoAnime" : "The list is empty",
"AnimeList.Header.AnimeCount" : "{0} Anime",
"AnimeList.SearchWatermark": "Search your list",

"EpisodeDetails.Notes.Header": "Notes",
"EpisodeDetails.Notes.TitleWatermark": "Insert the title",
Expand Down Expand Up @@ -51,8 +52,9 @@
"Label.LocalizationLookupError": "Localization not found for {0}",
"Label.NotAvailable.Long" : "Not available",
"Label.NotAvailable.Short" : "N/A",
"Label.NotGraded": "No score",
"Label.Online": "Online",
"label.OpenOnMal": "Open on MyAnimeList",
"Label.OpenOnMal": "Open on MyAnimeList",
"Label.PrimaryButton": "OK",
"Label.Recap": "Recap",
"Label.Score": "Score",
Expand All @@ -78,7 +80,6 @@
"Enum.AnimeSearchOrderBy.NoSorting": "No sorting",
"Enum.AnimeSearchOrderBy.Title": "Title",
"Enum.AnimeSearchOrderBy.Score": "Score",
"Enum.AnimeSearchOrderBy.Type": "Tipo",
"Enum.AnimeSearchOrderBy.ScoredBy": "Voters",
"Enum.AnimeSearchOrderBy.Members": "Members",
"Enum.AnimeSearchOrderBy.Favorites": "Favorites",
Expand Down
5 changes: 3 additions & 2 deletions Aosta.Ava/Aosta.Ava/Assets/Localization/it-IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

"AnimeDetails.Menu.Remove": "Rimuovi dalla lista",
"AnimeDetails.Score.PopupTitle": "Voto",
"AnimeDetails.Score.Watermark": "Dai un voto a questo anime",
"AnimeDetails.Score.Watermark": "Dai un voto",
"AnimeDetails.ToolTip.AddToRealm": "Aggiungi questo anime alla tua lista",

"AnimeList.Header.NoAnime" : "La lista è vuota",
"AnimeList.Header.AnimeCount" : "{0} Anime",
"AnimeList.SearchWatermark": "Cerca nella tua lista",

"EpisodeDetails.Notes.Header": "Note",
"EpisodeDetails.Notes.TitleWatermark": "Inserisci il titolo",
Expand Down Expand Up @@ -49,6 +50,7 @@
"Label.LocalizationLookupError": "Localizzazione non trovata per {0}",
"Label.NotAvailable.Long" : "Non disponibile",
"Label.NotAvailable.Short" : "N/D",
"Label.NotGraded": "Non votato",
"Label.Online": "Online",
"Label.OpenOnMal": "Apri su MyAnimeList",
"Label.PrimaryButton": "OK",
Expand Down Expand Up @@ -76,7 +78,6 @@
"Enum.AnimeSearchOrderBy.NoSorting": "Nessun ordine",
"Enum.AnimeSearchOrderBy.Title": "Titolo",
"Enum.AnimeSearchOrderBy.Score": "Voto",
"Enum.AnimeSearchOrderBy.Type": "Tipo",
"Enum.AnimeSearchOrderBy.ScoredBy": "Votanti",
"Enum.AnimeSearchOrderBy.Members": "Membri",
"Enum.AnimeSearchOrderBy.Favorites": "Preferiti",
Expand Down
29 changes: 9 additions & 20 deletions Aosta.Ava/Aosta.Ava/Assets/Resources/DataTemplates.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
xmlns:localize="clr-namespace:Aosta.Ava.Localization"
xmlns:vm="clr-namespace:Aosta.Ava.ViewModels"
xmlns:detailsPill="clr-namespace:Aosta.Ava.ViewModels.DetailsPill"
xmlns:converters="clr-namespace:Aosta.Ava.Converters">
xmlns:converters="clr-namespace:Aosta.Ava.Converters"
xmlns:response="clr-namespace:Aosta.Jikan.Models.Response;assembly=Aosta.Jikan">
<!-- Add Resources Here -->


Expand Down Expand Up @@ -111,12 +112,13 @@
</Border>
</DataTemplate>

<DataTemplate x:Key="JikanAnimeCard" DataType="card:JikanAnimeCardViewModel">
<DataTemplate x:Key="JikanAnimeCard" DataType="response:AnimeResponse">
<Button Padding="5"
Background="CornflowerBlue"
BorderThickness="0"
CornerRadius="5"
Command="{Binding GoToDetails}">
Command="{Binding $parent[ListBox].((vm:HomePageViewModel)DataContext).GoToDetails}"
CommandParameter="{Binding }">
<Grid RowDefinitions="Auto"
VerticalAlignment="Top">
<Border Grid.Row="0"
Expand All @@ -132,32 +134,19 @@
VerticalAlignment="Center" />
<fluent:FontIcon Glyph="{StaticResource StarGlyph}"
FontFamily="{StaticResource SymbolThemeFontFamily}"
Foreground="Gold" />
Foreground="Gold"
ZIndex="1"/>
</StackPanel>
</Border>
<Image Grid.Row="0"
async:ImageLoader.Source="{Binding BannerUrl}"
async:ImageLoader.Source="{Binding Images.JPG.ImageUrl, FallbackValue={x:Static card:IOnlineCard.PORTRAIT_PLACEHOLDER}}"
Width="{StaticResource AnimeCardWidth}"
Height="{StaticResource AnimeCardHeight}"
Stretch="UniformToFill"
ZIndex="-1" />
Stretch="UniformToFill"/>
</Grid>
</Button>
</DataTemplate>

<DataTemplate x:Key="RealmAnimeCard" DataType="card:AnimeListCardViewModel">
<Button Padding="5"
Background="CornflowerBlue"
BorderThickness="0"
CornerRadius="5"
Command="{Binding GoToDetails}">
<Image async:ImageLoader.Source="{Binding BannerUrl}"
Width="{StaticResource AnimeCardWidth}"
Height="{StaticResource AnimeCardHeight}"
Stretch="UniformToFill" />
</Button>
</DataTemplate>

<DataTemplate x:Key="JikanEpisodeEntry" DataType="vm:OnlineEpisodeEntry">
<Button Command="{Binding GoToDetails}"
HorizontalAlignment="Stretch"
Expand Down
1 change: 1 addition & 0 deletions Aosta.Ava/Aosta.Ava/Assets/Resources/Glyphs.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<x:String x:Key="FilterGlyph">&#xE16E;</x:String>
<x:String x:Key="MoreVerticalGlyph">&#xF809E;</x:String>
<x:String x:Key="PlusGlyph">&#xE109;</x:String>
<x:String x:Key="SearchGlyph">&#xE721;</x:String>
<x:String x:Key="SettingGlyph">&#xE115;</x:String>
<x:String x:Key="StarGlyph">&#xE1CF;</x:String>
</ResourceDictionary>
1 change: 1 addition & 0 deletions Aosta.Ava/Aosta.Ava/Assets/Styles/DefaultStyles.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<Style Selector="TextBox">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
</Style>

<Style Selector="ListBoxItem">
Expand Down
6 changes: 5 additions & 1 deletion Aosta.Ava/Aosta.Ava/Controls/TitleBar.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@
FontSize="20"/>
</Button>
<TextBlock Name="PART_TitleText"
Background="Transparent"
Grid.Column="3"
Margin="0,5"
Text="{TemplateBinding Title}"
FontWeight="Bold"
FontSize="24"
VerticalAlignment="Center"/>
<ContentPresenter Grid.Column="5" Content="{TemplateBinding Menu}"></ContentPresenter>
<ContentPresenter Grid.Column="5"
Content="{TemplateBinding Menu}"
Background="Transparent"
ZIndex="2"/>
<Grid.Styles>
<Style Selector="Button">
<Setter Property="Margin" Value="0,9,0,5"/>
Expand Down
5 changes: 1 addition & 4 deletions Aosta.Ava/Aosta.Ava/Controls/TitleBar.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@
using Aosta.Ava.ViewModels;

using Avalonia;
using Avalonia.Collections;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Controls.Templates;
using Avalonia.Media;

using FluentAvalonia.UI.Controls;

namespace Aosta.Ava.Controls;

// ReSharper disable InconsistentNaming //Avalonia convention
Expand Down Expand Up @@ -65,7 +62,7 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
.OfType<TextBlock>()
.First(static x => x.Name == "PART_TitleText");

Tapped += (_, _) =>
textBlock.Tapped += (_, _) =>
{
// ReSharper disable once BitwiseOperatorOnEnumWithoutFlags
textBlock.TextWrapping ^= TextWrapping.WrapWithOverflow;
Expand Down
2 changes: 0 additions & 2 deletions Aosta.Ava/Aosta.Ava/Extensions/JikanExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

using Aosta.Ava.Localization;
using Aosta.Jikan.Enums;
using Aosta.Jikan.Models.Response;
using Aosta.Jikan.Query.Enums;

namespace Aosta.Ava.Extensions;
Expand Down Expand Up @@ -67,7 +66,6 @@ public static class JikanExtensions
AnimeSearchOrderBy.NoSorting => new LocalizedData<AnimeSearchOrderBy>(order, "Enum.AnimeSearchOrderBy.NoSorting"),
AnimeSearchOrderBy.Title => new LocalizedData<AnimeSearchOrderBy>(order, "Enum.AnimeSearchOrderBy.Title"),
AnimeSearchOrderBy.Score => new LocalizedData<AnimeSearchOrderBy>(order, "Enum.AnimeSearchOrderBy.Score"),
AnimeSearchOrderBy.Type => new LocalizedData<AnimeSearchOrderBy>(order, "Enum.AnimeSearchOrderBy.Type"),
AnimeSearchOrderBy.ScoredBy => new LocalizedData<AnimeSearchOrderBy>(order, "Enum.AnimeSearchOrderBy.ScoredBy"),
AnimeSearchOrderBy.Members => new LocalizedData<AnimeSearchOrderBy>(order, "Enum.AnimeSearchOrderBy.Members"),
AnimeSearchOrderBy.Favorites => new LocalizedData<AnimeSearchOrderBy>(order, "Enum.AnimeSearchOrderBy.Favorites"),
Expand Down
37 changes: 20 additions & 17 deletions Aosta.Ava/Aosta.Ava/Extensions/RealmExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,28 @@ public static IObservable<IChangeSet<T>> Connect<T>(this IRealmCollection<T> col
logger.Debug("Initialized the {Type} observable cache with {Count} elements",
typeof(T).Name, sender.Count);
}
else if (changes.IsCleared)
{
cache.Clear();
logger.Debug("Observable cache for {Type} has been cleared", typeof(T).Name);
}
else
{
cache.Edit(update => updateCache(changes, update, sender));
cache.Edit(update =>
{
// Handle deleted elements
for (int index = 0; index < changes.DeletedIndices.Length; index++)
{
int i = changes.DeletedIndices[index] - index;
update.RemoveAt(i);
}

// Handle inserted elements
foreach (int i in changes.InsertedIndices)
{
update.Insert(i, sender[i]);
}
});

logger.Debug("Processed {ChangesCount} changes for {Type} observable cache: [Removed: {Removed}, Added: {Added}, Moved: {Moved}]",
changes.DeletedIndices.Length + changes.InsertedIndices.Length,
Expand All @@ -83,20 +102,4 @@ public static IObservable<IChangeSet<T>> Connect<T>(this IRealmCollection<T> col

return cache.Connect();
}

private static void updateCache<T>(ChangeSet changes, IExtendedList<T> update, IRealmCollection<T> sender)
where T : IRealmObjectBase
{
// Handle deleted elements
foreach (int i in changes.DeletedIndices)
{
update.RemoveAt(i);
}

// Handle inserted elements
foreach (int i in changes.InsertedIndices)
{
update.Insert(i, sender[i]);
}
}
}
1 change: 0 additions & 1 deletion Aosta.Ava/Aosta.Ava/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Aosta.Ava.ViewModels;

using Avalonia;
using Avalonia.Interactivity;
using Avalonia.ReactiveUI;

namespace Aosta.Ava;
Expand Down
60 changes: 50 additions & 10 deletions Aosta.Ava/Aosta.Ava/Pages/AnimeListPage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,67 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:Aosta.Ava.ViewModels"
xmlns:fluent="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
xmlns:controls="clr-namespace:Aosta.Ava.Controls"
xmlns:localize="clr-namespace:Aosta.Ava.Localization"
xmlns:asyncImageLoader="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia"
xmlns:card="clr-namespace:Aosta.Ava.ViewModels.Card"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Aosta.Ava.Pages.AnimeListPage"
x:DataType="vm:AnimeListPageViewModel">

<Grid RowDefinitions="Auto,*"
ColumnDefinitions="*,Auto">
<controls:AnimatedPopup Grid.ColumnSpan="2"
Grid.RowSpan="2"
Name="SearchPopup"
VerticalAlignment="Top"
AnimateWidth="False">
<Border Background="{DynamicResource FloatingPaneBackgroundBrush}"
Width="{Binding $parent[Grid].Bounds.Width}"
Padding="20">
<TextBox Watermark="{localize:Localize AnimeList.SearchWatermark}"
Text="{Binding SearchText}"/>
</Border>
</controls:AnimatedPopup>
<TextBlock Grid.Row="0"
Grid.Column="0"
Text="{Binding AnimeCount}"/>
<fluent:CommandBar Grid.Row="0"
Grid.Column="1">
<fluent:CommandBar.PrimaryCommands>
<fluent:CommandBarButton IsCompact="True"
IconSource="Search" />
</fluent:CommandBar.PrimaryCommands>
</fluent:CommandBar>
Margin="20,20,0,0"
Text="{Binding AnimeCount}"
FontSize="18"
FontWeight="Bold">
</TextBlock>
<Button Grid.Row="0"
Grid.Column="1"
Margin="0,20,20,0"
Command="{Binding #SearchPopup.Open}"
IsEnabled="{Binding !#SearchPopup.IsOpen}"
Background="Transparent"
BorderThickness="0"
ZIndex="10">
<fluent:FontIcon Glyph="{StaticResource SearchGlyph}"
FontFamily="{StaticResource SymbolThemeFontFamily}"
FontSize="24"/>
</Button>
<ListBox Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="2"
ItemsSource="{Binding AnimeList}"
ItemTemplate="{StaticResource RealmAnimeCard}">
ItemsSource="{Binding AnimeList}">
<ListBox.ItemTemplate>
<DataTemplate>
<Button Padding="5"
Margin="5"
Background="CornflowerBlue"
BorderThickness="0"
CornerRadius="5"
Command="{Binding $parent[ListBox].((vm:AnimeListPageViewModel)DataContext).GoToAnime}"
CommandParameter="{Binding}">
<Image asyncImageLoader:ImageLoader.Source="{Binding Images.JPG.ImageUrl, FallbackValue={x:Static card:IOnlineCard.PORTRAIT_PLACEHOLDER}}"
Width="{StaticResource AnimeCardWidth}"
Height="{StaticResource AnimeCardHeight}"
Stretch="UniformToFill" />
</Button>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"
Expand Down
8 changes: 8 additions & 0 deletions Aosta.Ava/Aosta.Ava/Pages/AnimeListPage.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using Aosta.Ava.ViewModels;

using Avalonia.Interactivity;
using Avalonia.ReactiveUI;


Expand All @@ -14,4 +15,11 @@ public AnimeListPage()
{
InitializeComponent();
}

protected override void OnUnloaded(RoutedEventArgs e)
{
base.OnUnloaded(e);

if (ViewModel != null) ViewModel.SearchText = string.Empty;
}
}
Loading

0 comments on commit 8a1e34f

Please sign in to comment.