Skip to content

Commit

Permalink
Add a this week tab to the recent page
Browse files Browse the repository at this point in the history
  • Loading branch information
Bamboooz committed Dec 6, 2023
1 parent 6f9ad32 commit c82ffed
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
16 changes: 12 additions & 4 deletions Gavilya/Models/GameList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Windows;
Expand Down Expand Up @@ -93,11 +94,13 @@ public List<GameList> GetSortedGameLists()
DateTime now = DateTime.Now;
DateTime todayStart = now.Date;
DateTime yesterdayStart = todayStart.AddDays(-1);
DateTime thisMonthStart = new(now.Year, now.Month, 1);
DateTime thisWeekStart = now.AddDays((int)CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek - (int)now.DayOfWeek);
DateTime thisMonthStart = new(now.Year, now.Month, 1);

GameList todayList = new(Properties.Resources.Today);
GameList yesterdayList = new(Properties.Resources.Yesterday);
GameList thisMonthList = new(Properties.Resources.ThisMonth);
GameList yesterdayList = new(Properties.Resources.Yesterday);
GameList thisWeekList = new(Properties.Resources.ThisWeek);
GameList thisMonthList = new(Properties.Resources.ThisMonth);
GameList otherList = new(Properties.Resources.LongTimeAgo);

foreach (Game game in this)
Expand All @@ -112,6 +115,10 @@ public List<GameList> GetSortedGameLists()
{
yesterdayList.Add(game);
}
else if (lastPlayTime >= thisWeekStart)
{
thisWeekList.Add(game);
}
else if (lastPlayTime >= thisMonthStart)
{
thisMonthList.Add(game);
Expand All @@ -126,7 +133,8 @@ public List<GameList> GetSortedGameLists()

if (todayList.Count > 0) sortedGames.Add(todayList);
if (yesterdayList.Count > 0) sortedGames.Add(yesterdayList);
if (thisMonthList.Count > 0) sortedGames.Add(thisMonthList);
if (thisWeekList.Count > 0) sortedGames.Add(thisWeekList);
if (thisMonthList.Count > 0) sortedGames.Add(thisMonthList);
if (otherList.Count > 0) sortedGames.Add(otherList);

return sortedGames;
Expand Down
9 changes: 9 additions & 0 deletions Gavilya/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Gavilya/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1032,4 +1032,7 @@
<data name="AddFavGame" xml:space="preserve">
<value>Add a favorite game</value>
</data>
<data name="ThisWeek" xml:space="preserve">
<value>This Week</value>
</data>
</root>
3 changes: 3 additions & 0 deletions Gavilya/Properties/Resources.fr-FR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1032,4 +1032,7 @@
<data name="AddFavGame" xml:space="preserve">
<value>Ajouter un jeu favori</value>
</data>
<data name="ThisWeek" xml:space="preserve">
<value>Cette Semaine</value>
</data>
</root>
3 changes: 3 additions & 0 deletions Gavilya/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1032,4 +1032,7 @@
<data name="AddFavGame" xml:space="preserve">
<value>Add a favorite game</value>
</data>
<data name="ThisWeek" xml:space="preserve">
<value>This Week</value>
</data>
</root>
3 changes: 3 additions & 0 deletions Gavilya/Properties/Resources.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1032,4 +1032,7 @@
<data name="AddFavGame" xml:space="preserve">
<value>加入最喜歡的遊戲</value>
</data>
<data name="ThisWeek" xml:space="preserve">
<value>本星期</value>
</data>
</root>

0 comments on commit c82ffed

Please sign in to comment.