diff --git a/Pixiview/Illust/RankingPage.xaml b/Pixiview/Illust/RankingPage.xaml
index 7230c85..b13a8a1 100644
--- a/Pixiview/Illust/RankingPage.xaml
+++ b/Pixiview/Illust/RankingPage.xaml
@@ -4,6 +4,7 @@
xmlns:i="clr-namespace:Pixiview.Illust"
xmlns:u="clr-namespace:Pixiview.UI"
xmlns:r="clr-namespace:Pixiview.Resources"
+ xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
x:Class="Pixiview.Illust.RankingPage"
BackgroundColor="{DynamicResource WindowColor}"
Title="{r:Text Ranking}">
@@ -33,8 +34,15 @@
-
+
+
+
+
+
diff --git a/Pixiview/Illust/RankingPage.xaml.cs b/Pixiview/Illust/RankingPage.xaml.cs
index 9ab14c9..a30eda0 100644
--- a/Pixiview/Illust/RankingPage.xaml.cs
+++ b/Pixiview/Illust/RankingPage.xaml.cs
@@ -18,6 +18,10 @@ namespace Pixiview.Illust
nameof(SegmentDate), typeof(int), typeof(RankingPage), propertyChanged: OnSegmentDatePropertyChanged);
public static readonly BindableProperty SegmentTypeProperty = BindableProperty.Create(
nameof(SegmentType), typeof(int), typeof(RankingPage), propertyChanged: OnSegmentTypePropertyChanged);
+ public static readonly BindableProperty MaximumDateProperty = BindableProperty.Create(
+ nameof(MaximumDate), typeof(DateTime), typeof(RankingPage), DateTime.Now);
+ public static readonly BindableProperty SelectedDateProperty = BindableProperty.Create(
+ nameof(SelectedDate), typeof(DateTime), typeof(RankingPage), DateTime.Now);
private static void OnSegmentDatePropertyChanged(BindableObject obj, object old, object @new)
{
@@ -60,12 +64,28 @@ namespace Pixiview.Illust
get => (int)GetValue(SegmentTypeProperty);
set => SetValue(SegmentTypeProperty, value);
}
+ public DateTime MaximumDate
+ {
+ get => (DateTime)GetValue(MaximumDateProperty);
+ set => SetValue(MaximumDateProperty, value);
+ }
+ public DateTime SelectedDate
+ {
+ get => (DateTime)GetValue(SelectedDateProperty);
+ set => SetValue(SelectedDateProperty, value);
+ }
+ public Command ToolbarCommand { get; private set; }
private double lastScrollY = double.MinValue;
+ public bool previousEnabled;
+ public bool dateEnabled;
+ public bool nextEnabled;
private bool isFilterVisible;
private string lastQueryKey;
private string queryDate;
+ private string previousDate;
+ private string nextDate;
private int currentPage;
private int nextPage;
@@ -74,6 +94,7 @@ namespace Pixiview.Illust
public RankingPage()
{
Resources.Add("cardView", GetCardViewTemplate());
+ ToolbarCommand = new Command(OnDateTrigger, OnCanDateTrigger);
InitializeComponent();
gridFilter.TranslationY = -100;
panelFilter.TranslationY = -100;
@@ -81,6 +102,9 @@ namespace Pixiview.Illust
lastQueryKey = QueryKey;
queryDate = null; // $"{now.Year}{now.Month:00}{now.Day:00}";
currentPage = 1;
+
+ datePicker.MinimumDate = new DateTime(2007, 9, 13);
+ MaximumDate = DateTime.Now;
}
protected override void DoIllustsLoaded(IllustCollection collection)
@@ -118,13 +142,56 @@ namespace Pixiview.Illust
nextPage = next;
}
var date = data.date;
- if (date.Length == 8)
+ DateTime now;
+ if (date.Length == 8 && int.TryParse(date, out _))
{
queryDate = date;
- date = date.Substring(0, 4) + "-" + date.Substring(4, 2) + "-" + date.Substring(6, 2);
+ now = new DateTime(
+ int.Parse(date.Substring(0, 4)),
+ int.Parse(date.Substring(4, 2)),
+ int.Parse(date.Substring(6, 2)));
+ SelectedDate = now;
+ date = now.ToShortDateString();
+ }
+ else
+ {
+ now = default;
}
date = ResourceHelper.GetResource(data.mode, date);
- MainThread.BeginInvokeOnMainThread(() => Title = date);
+
+ var prev = data.prev_date;
+ if (int.TryParse(prev, out _))
+ {
+ previousDate = prev;
+ previousEnabled = true;
+ }
+ else
+ {
+ previousDate = null;
+ previousEnabled = false;
+ }
+ var next_ = data.next_date;
+ if (int.TryParse(next_, out _))
+ {
+ nextDate = next_;
+ nextEnabled = true;
+ }
+ else
+ {
+ nextDate = null;
+ nextEnabled = false;
+ if (now != default)
+ {
+ MaximumDate = now;
+ }
+ }
+ dateEnabled = true;
+ MainThread.BeginInvokeOnMainThread(() =>
+ {
+ ToolbarCommand.ChangeCanExecute();
+ Title = date;
+ });
+
}
return data;
}
@@ -157,14 +224,74 @@ namespace Pixiview.Illust
}
}
- private void Refresh_Clicked(object sender, EventArgs e)
+ private void OnDateTrigger(string action)
{
if (IsLoading)
{
return;
}
+ if (action == "select")
+ {
+ datePicker.Focus();
+ }
+ else
+ {
+ var date = action == "prev" ? previousDate : nextDate;
+ if (date == null)
+ {
+ return;
+ }
+ if (isFilterVisible)
+ {
+ ToggleFilterPanel(false);
+ }
+ // release
+ var collection = IllustCollection;
+ if (collection != null)
+ {
+ collection.Running = false;
+ IllustCollection = null;
+ }
+ previousEnabled = false;
+ dateEnabled = false;
+ nextEnabled = false;
+ queryDate = date;
+ currentPage = 1;
+ StartLoad(true);
+ }
+ }
+
+ private bool OnCanDateTrigger(string action)
+ {
+ switch (action)
+ {
+ case "prev":
+ return previousEnabled;
+ case "next":
+ return nextEnabled;
+ default:
+ return dateEnabled;
+ }
+ }
+
+ private void DatePicker_DateSelected(object sender, DateChangedEventArgs e)
+ {
+ if (IsLoading)
+ {
+ return;
+ }
+ // release
+ var collection = IllustCollection;
+ if (collection != null)
+ {
+ collection.Running = false;
+ IllustCollection = null;
+ }
+ previousEnabled = false;
+ dateEnabled = false;
+ nextEnabled = false;
+ queryDate = e.NewDate.ToString("yyyyMMdd");
currentPage = 1;
- IllustCollection = null;
StartLoad(true);
}
@@ -226,10 +353,16 @@ namespace Pixiview.Illust
}
if (lastQueryKey != query)
{
+ // release
+ var collection = IllustCollection;
+ if (collection != null)
+ {
+ collection.Running = false;
+ IllustCollection = null;
+ }
// query changed.
currentPage = 1;
lastQueryKey = query;
- IllustCollection = null;
refresh = true;
App.DebugPrint($"query changed: {query}");
}
diff --git a/Pixiview/Resources/Languages/zh-CN.xml b/Pixiview/Resources/Languages/zh-CN.xml
index b0ee4d2..2ac36a5 100644
--- a/Pixiview/Resources/Languages/zh-CN.xml
+++ b/Pixiview/Resources/Languages/zh-CN.xml
@@ -16,12 +16,12 @@
受男性欢迎
当月截至 {0}
当周截至 {0}
- 当日 {0}
- 受欢迎 {0}
+ {0} 当日
+ {0} 最受欢迎
当月截至 {0}
当周截至 {0}
- 当日 {0}
- 受欢迎 {0}
+ {0} 当日
+ {0} 最受欢迎
一般
R-18
已关注
diff --git a/Pixiview/UI/StyleDefinition.cs b/Pixiview/UI/StyleDefinition.cs
index d2c6400..a5c05ed 100644
--- a/Pixiview/UI/StyleDefinition.cs
+++ b/Pixiview/UI/StyleDefinition.cs
@@ -47,6 +47,9 @@ namespace Pixiview.UI
public const string IconCircleCheck = "\uf058";
public const string IconPlay = "\uf04b";
public const string IconMore = "\uf142";
+ public const string IconCaretCircleLeft = "\uf32e";
+ public const string IconCaretCircleRight = "\uf330";
+ public const string IconCalendarDay = "\uf783";
static StyleDefinition()
{
diff --git a/Pixiview/UI/Theme/ThemeBase.cs b/Pixiview/UI/Theme/ThemeBase.cs
index fb1f8f1..f8e848d 100644
--- a/Pixiview/UI/Theme/ThemeBase.cs
+++ b/Pixiview/UI/Theme/ThemeBase.cs
@@ -14,6 +14,9 @@ namespace Pixiview.UI.Theme
public const string FontIconFavorite = nameof(FontIconFavorite);
public const string FontIconShare = nameof(FontIconShare);
public const string FontIconMore = nameof(FontIconMore);
+ public const string FontIconCaretCircleLeft = nameof(FontIconCaretCircleLeft);
+ public const string FontIconCaretCircleRight = nameof(FontIconCaretCircleRight);
+ public const string FontIconCalendarDay = nameof(FontIconCalendarDay);
public const string IconCircleCheck = nameof(IconCircleCheck);
public const string IconCaretDown = nameof(IconCaretDown);
@@ -57,6 +60,9 @@ namespace Pixiview.UI.Theme
Add(FontIconFavorite, GetSolidIcon(StyleDefinition.IconFavorite, solidFontFamily));
Add(FontIconShare, GetSolidIcon(StyleDefinition.IconShare, solidFontFamily));
Add(FontIconMore, GetSolidIcon(StyleDefinition.IconMore, regularFontFamily));
+ Add(FontIconCaretCircleLeft, GetSolidIcon(StyleDefinition.IconCaretCircleLeft, solidFontFamily));
+ Add(FontIconCaretCircleRight, GetSolidIcon(StyleDefinition.IconCaretCircleRight, solidFontFamily));
+ Add(FontIconCalendarDay, GetSolidIcon(StyleDefinition.IconCalendarDay, regularFontFamily));
Add(IconCircleCheck, StyleDefinition.IconCircleCheck);
Add(IconCaretDown, StyleDefinition.IconCaretDown);
diff --git a/Res/screenshot.png b/Res/screenshot.png
index 6018d2d..f5ea5af 100644
Binary files a/Res/screenshot.png and b/Res/screenshot.png differ