Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
jerry08 committed Oct 28, 2023
1 parent ab4d0e2 commit 00f19b6
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 28 deletions.
6 changes: 6 additions & 0 deletions AniStream/Platforms/Android/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ public override void OnRequestPermissionsResult(
AndroidStoragePermission?.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}

protected override void OnResume()
{
base.OnResume();
MediaElementController?.OnResume();
}

protected override void OnPause()
{
base.OnPause();
Expand Down
10 changes: 10 additions & 0 deletions AniStream/ViewModels/EpisodeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using AniStream.ViewModels.Framework;
using AniStream.Views;
using AniStream.Views.BottomSheets;
using Com.Google.Android.Exoplayer2.Source.Chunk;
using CommunityToolkit.Maui.Alerts;
using CommunityToolkit.Maui.Core;
using CommunityToolkit.Mvvm.ComponentModel;
Expand Down Expand Up @@ -110,6 +111,8 @@ public async Task LoadEpisodes(IAnimeInfo anime)
//OnPropertyChanged(nameof(Entity));

var result = await _provider.GetEpisodesAsync(anime.Id);
if (result.Count == 0)
return;

result = result.OrderBy(x => x.Number).ToList();

Expand All @@ -134,6 +137,13 @@ public async Task LoadEpisodes(IAnimeInfo anime)
startIndex += chunk.Count;
}
}
else
{
if (_settingsService.EpisodesDescending)
{
EpisodeChunks[0] = EpisodeChunks[0].Reverse().ToArray();
}
}

result.ForEach(ep => ep.Image = anime.Image);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1003,27 +1003,6 @@ private void ShowM3U8TrackSelector()
trackDialog.Show();
}

//public async Task UpdateProgress()
//{
// if (!CanSaveProgress)
// return;
//
// _playerSettings.WatchedEpisodes.TryGetValue(Episode.Id,
// out var watchedEpisode);
//
// watchedEpisode ??= new();
//
// watchedEpisode.Id = Episode.Id;
// watchedEpisode.AnimeName = Anime.Title;
// watchedEpisode.WatchedPercentage = (float)exoPlayer.CurrentPosition / exoPlayer.Duration * 100f;
// watchedEpisode.WatchedDuration = exoPlayer.CurrentPosition;
//
// _playerSettings.WatchedEpisodes.Remove(Episode.Id);
// _playerSettings.WatchedEpisodes.Add(Episode.Id, watchedEpisode);
//
// _playerSettings.Save();
//}
//
//public async void PlayVideo(VideoSource video)
//{
// if (exoPlayer is not null)
Expand Down Expand Up @@ -1119,6 +1098,11 @@ public void OnTimelineChanged(Timeline? timeline, int reason)
// Platform.CurrentActivity.HideSystemBars();
//}

public void OnResume()
{
Platform.CurrentActivity.HideSystemBars();
}

public void OnPlayerError(PlaybackException? error)
{
//CanSaveProgress = false;
Expand Down
2 changes: 1 addition & 1 deletion AniStream/Views/BottomSheets/EpisodeSelectionSheet.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:berry="https://schemas.jerry08/dotnet/2023/maui"
xmlns:controls="clr-namespace:AniStream.Controls"
xmlns:local="clr-namespace:AniStream.Views.BottomSheets"
xmlns:materialDesign="clr-namespace:MaterialDesign"
xmlns:models="clr-namespace:Juro.Core.Models.Videos;assembly=Juro.Core"
xmlns:the49="https://schemas.the49.com/dotnet/2023/maui"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:viewModels="clr-namespace:AniStream.ViewModels"
xmlns:vmodels="clr-namespace:Juro.Core.Models.Videos;assembly=Juro.Core"
xmlns:controls="clr-namespace:AniStream.Controls"
x:Name="this"
Margin="0"
x:DataType="viewModels:VideoSourceViewModel"
Expand Down
31 changes: 30 additions & 1 deletion AniStream/Views/Episodes/EpisodesTabView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
<viewTemplates:EpisodeTemplateView />
</DataTemplate>

<DataTemplate x:Key="FullEpisodeTemplate">
<viewTemplates:FullEpisodeTemplateView />
</DataTemplate>

<DataTemplate x:Key="SemiEpisodeTemplate">
<viewTemplates:SemiEpisodeTemplateView />
</DataTemplate>
Expand All @@ -44,8 +48,9 @@

<views:MainDataTemplateSelector x:Key="MainDataTemplateSelector" DataTemplate="{StaticResource AnimeInfoDataTemplate}" />
<views:MainDataTemplateSelector x:Key="GenreTemplateSelector" DataTemplate="{StaticResource GenreTemplate}" />
<views:MainDataTemplateSelector x:Key="EpisodeTemplateSelector" DataTemplate="{StaticResource EpisodeTemplate}" />
<views:MainDataTemplateSelector x:Key="FullEpisodeTemplateSelector" DataTemplate="{StaticResource FullEpisodeTemplate}" />
<views:MainDataTemplateSelector x:Key="SemiEpisodeTemplateSelector" DataTemplate="{StaticResource SemiEpisodeTemplate}" />
<views:MainDataTemplateSelector x:Key="EpisodeTemplateSelector" DataTemplate="{StaticResource EpisodeTemplate}" />
<views:MainDataTemplateSelector x:Key="EpisodeRangeTemplateSelector" DataTemplate="{StaticResource EpisodeRangeTemplate}" />
</ResourceDictionary>
</ContentView.Resources>
Expand Down Expand Up @@ -257,6 +262,12 @@
JustifyContent="Center"
Wrap="Wrap">
<FlexLayout.Triggers>
<DataTrigger
Binding="{Binding GridLayoutMode}"
TargetType="FlexLayout"
Value="{x:Static components:GridLayoutMode.Full}">
<Setter Property="IsVisible" Value="False" />
</DataTrigger>
<DataTrigger
Binding="{Binding GridLayoutMode}"
TargetType="FlexLayout"
Expand All @@ -271,5 +282,23 @@
</DataTrigger>
</FlexLayout.Triggers>
</FlexLayout>

<CollectionView
HorizontalOptions="Center"
IsVisible="False"
ItemTemplate="{StaticResource FullEpisodeTemplateSelector}">
<CollectionView.Triggers>
<DataTrigger
Binding="{Binding GridLayoutMode}"
TargetType="CollectionView"
Value="{x:Static components:GridLayoutMode.Full}">
<Setter Property="IsVisible" Value="True" />
<Setter Property="ItemsSource" Value="{Binding Entities}" />
</DataTrigger>
</CollectionView.Triggers>
<CollectionView.ItemsLayout>
<LinearItemsLayout ItemSpacing="0" Orientation="Vertical" />
</CollectionView.ItemsLayout>
</CollectionView>
</VerticalStackLayout>
</ContentView>
4 changes: 2 additions & 2 deletions AniStream/Views/Episodes/OverviewTabView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
<VerticalStackLayout Spacing="4">
<Label
Margin="10,5"
HorizontalTextAlignment="Start"
FontAttributes="Bold"
FontSize="20"
HorizontalTextAlignment="Start"
Opacity="0.8"
FontAttributes="Bold"
Text="Description"
VerticalOptions="Start" />

Expand Down
99 changes: 99 additions & 0 deletions AniStream/Views/Templates/FullEpisodeTemplateView.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8" ?>
<Border
x:Class="AniStream.Views.Templates.FullEpisodeTemplateView"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:berry="https://schemas.jerry08/dotnet/2023/maui"
xmlns:converters="clr-namespace:AniStream.Converters"
xmlns:local="clr-namespace:AniStream"
xmlns:models="clr-namespace:Juro.Core.Models.Anime;assembly=Juro.Core"
x:Name="this"
Margin="3,5"
Padding="0"
x:DataType="models:Episode"
BackgroundColor="Transparent"
HeightRequest="100">
<Border.Resources>
<ResourceDictionary>
<converters:WatchedEpisodeProgressConverter x:Key="WatchedEpisodeProgressConverter" />
<converters:IsWatchedEpisodeProgressVisibleConverter x:Key="IsWatchedEpisodeProgressVisibleConverter" />
</ResourceDictionary>
</Border.Resources>
<Border.StrokeShape>
<RoundRectangle CornerRadius="10" />
</Border.StrokeShape>
<Grid BackgroundColor="Transparent" ColumnDefinitions="auto,*">
<Border StrokeThickness="0">
<Border.StrokeShape>
<RoundRectangle CornerRadius="10" />
</Border.StrokeShape>
<Image
Aspect="AspectFill"
BackgroundColor="Transparent"
Opacity="0.8"
Source="{Binding Image}"
WidthRequest="190">
<Image.Behaviors>
<berry:TouchBehavior NativeAnimation="True" />
<berry:TouchBehavior
Command="{Binding Parent.BindingContext.ItemClickCommand, Source={x:Reference this}}"
CommandParameter="{Binding BindingContext, Source={x:Reference this}}"
LongPressCommand="{Binding Parent.BindingContext.ShowSheetCommand, Source={x:Reference this}}"
LongPressCommandParameter="{Binding BindingContext, Source={x:Reference this}}" />
</Image.Behaviors>
</Image>
</Border>

<!-- Display Progress -->
<Grid IsVisible="{Binding Progress, Converter={StaticResource IsWatchedEpisodeProgressVisibleConverter}}">
<ProgressBar
HeightRequest="5"
Progress="{Binding Progress, Converter={StaticResource WatchedEpisodeProgressConverter}}"
ProgressColor="{StaticResource Primary}"
VerticalOptions="End"
ZIndex="2" />
<Grid
BackgroundColor="White"
HeightRequest="5"
Opacity="0.5"
VerticalOptions="End" />
</Grid>

<Label
Padding="5"
FontAttributes="Bold"
FontSize="15"
HorizontalTextAlignment="Start"
LineBreakMode="TailTruncation"
Opacity="0.9"
Text="{Binding Name}"
TextColor="#E9FFFFFF"
VerticalTextAlignment="Start" />
<Label
Padding="8,5"
FontAttributes="Bold"
FontFamily="SoraBold"
FontSize="25"
HorizontalTextAlignment="End"
LineBreakMode="TailTruncation"
Opacity="0.7"
Text="{Binding Number}"
TextColor="#E9FFFFFF"
VerticalTextAlignment="End" />

<Label
Grid.Column="1"
Padding="8,5"
FontAttributes="Bold"
FontFamily="SoraBold"
FontSize="25"
HorizontalOptions="Center"
HorizontalTextAlignment="End"
LineBreakMode="TailTruncation"
Opacity="0.7"
Text="{Binding Number}"
TextColor="#E9FFFFFF"
VerticalOptions="Center"
VerticalTextAlignment="End" />
</Grid>
</Border>
19 changes: 19 additions & 0 deletions AniStream/Views/Templates/FullEpisodeTemplateView.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Microsoft.Maui.Controls;

namespace AniStream.Views.Templates;

public partial class FullEpisodeTemplateView
{
public FullEpisodeTemplateView()
{
InitializeComponent();
}

protected override void OnBindingContextChanged()
{
base.OnBindingContextChanged();

Scale = 0.4;
this.ScaleTo(1, 150);
}
}
6 changes: 3 additions & 3 deletions AniStream/Views/Templates/SemiEpisodeTemplateView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:berry="https://schemas.jerry08/dotnet/2023/maui"
xmlns:local="clr-namespace:AniStream"
xmlns:converters="clr-namespace:AniStream.Converters"
xmlns:local="clr-namespace:AniStream"
xmlns:models="clr-namespace:Juro.Core.Models.Anime;assembly=Juro.Core"
x:Name="this"
Margin="3,5"
Expand Down Expand Up @@ -44,7 +44,7 @@
LongPressCommandParameter="{Binding BindingContext, Source={x:Reference this}}" />
</Image.Behaviors>
</Image>

<!-- Display Progress -->
<Grid IsVisible="{Binding Progress, Converter={StaticResource IsWatchedEpisodeProgressVisibleConverter}}">
<ProgressBar
Expand All @@ -59,7 +59,7 @@
Opacity="0.5"
VerticalOptions="End" />
</Grid>

<Label
Padding="5"
FontAttributes="Bold"
Expand Down

0 comments on commit 00f19b6

Please sign in to comment.