diff --git a/dal-api/dal_commons/lib/src/model/dal/commonV4.dart b/dal-api/dal_commons/lib/src/model/dal/commonV4.dart index 525a4db..e1a8577 100644 --- a/dal-api/dal_commons/lib/src/model/dal/commonV4.dart +++ b/dal-api/dal_commons/lib/src/model/dal/commonV4.dart @@ -15,7 +15,7 @@ mixin ToJson { mixin DataUnion { Map toJson(); - static DataUnion? fromJson(DataUnionType type, dynamic json) { + static DataUnion? fromJson(DataUnionType type, dynamic json, dynamic data) { switch (type) { case DataUnionType.character: return CharacterV4Data.fromJson(json); @@ -26,7 +26,7 @@ mixin DataUnion { case DataUnionType.about: return About.fromJson(json); case DataUnionType.friend: - return FriendV4List.fromList(json as List); + return FriendV4List.fromList(json as List, data); case DataUnionType.club: return ClubV4List.fromList(json as List); case DataUnionType.favorites: @@ -67,7 +67,7 @@ class JikanV4Result { JikanV4Result.fromJson(DataUnionType type, Map? json) { if (json == null) return; - data = json['data'] != null ? DataUnion.fromJson(type, json['data']) as T? : null; + data = json['data'] != null ? DataUnion.fromJson(type, json['data'], json) as T? : null; pagination = json['pagination'] != null ? Pagination.fromJson(json['pagination']) : null; diff --git a/dal-api/dal_commons/lib/src/model/dal/friendv4.dart b/dal-api/dal_commons/lib/src/model/dal/friendv4.dart index 7610a9a..21078a2 100644 --- a/dal-api/dal_commons/lib/src/model/dal/friendv4.dart +++ b/dal-api/dal_commons/lib/src/model/dal/friendv4.dart @@ -2,8 +2,10 @@ import 'commonV4.dart'; class FriendV4List implements DataUnion { List? friends; - FriendV4List.fromList(List? list) { + int? count; + FriendV4List.fromList(List? list, data) { friends = list?.map((e) => FriendV4.fromJson(e)).toList() ?? []; + count = data['count']; } FriendV4List.fromJson(Map? json) { if (json == null) return; @@ -11,10 +13,11 @@ class FriendV4List implements DataUnion { .map((e) => FriendV4.fromJson(e)) .toList() ?? []; + count = json['count']; } @override Map toJson() { - return {'friends': friends}; + return {'friends': friends, 'count': count}; } } @@ -25,7 +28,7 @@ class FriendV4 { FriendV4({this.user, this.lastOnline, this.friendsSince}); - FriendV4.fromJson(Map ?json) { + FriendV4.fromJson(Map? json) { if (json == null) return; user = json['user'] != null ? UserV4.fromJson(json['user']) : null; lastOnline = json['last_online']; diff --git a/lib/generated/intl/messages_en_US.dart b/lib/generated/intl/messages_en_US.dart index 8ffd439..839552a 100644 --- a/lib/generated/intl/messages_en_US.dart +++ b/lib/generated/intl/messages_en_US.dart @@ -843,6 +843,8 @@ class MessageLookup extends MessageLookupByLibrary { "Reincarnation": MessageLookupByLibrary.simpleMessage("Reincarnation"), "Related": MessageLookupByLibrary.simpleMessage("Related"), "Related_Anime": MessageLookupByLibrary.simpleMessage("Related Anime"), + "ReleaseStartDate": + MessageLookupByLibrary.simpleMessage("Release Date"), "Remove_Image": MessageLookupByLibrary.simpleMessage("Remove Image from Home Page"), "Remove_Image_desc": MessageLookupByLibrary.simpleMessage( diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index b9c14b1..8f7515b 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -9460,6 +9460,16 @@ class S { ); } + /// `Release Date` + String get ReleaseStartDate { + return Intl.message( + 'Release Date', + name: 'ReleaseStartDate', + desc: '', + args: [], + ); + } + /// `Anime Calendar` String get AnimeCalendar { return Intl.message( diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 80794ff..fac8ff0 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -941,5 +941,6 @@ "Search": "Search", "NextShow": "Next Show", "Show": "Show", + "ReleaseStartDate": "Release Date", "AnimeCalendar": "Anime Calendar" } \ No newline at end of file diff --git a/lib/widgets/listsortfilter.dart b/lib/widgets/listsortfilter.dart index 3fbc389..60dcc4b 100644 --- a/lib/widgets/listsortfilter.dart +++ b/lib/widgets/listsortfilter.dart @@ -281,6 +281,25 @@ List _sortListCustom( n2Value = _getEpisodes(scheduleForMalIds[n2.id]) ?? n2Value; } break; + case 'release_date': + try { + final int? t1 = scheduleForMalIds[n1.id]?.timestamp; + final int? t2 = scheduleForMalIds[n2.id]?.timestamp; + final now = DateTime.now(); + if (t1 != null) { + var dateTime = DateTime.fromMillisecondsSinceEpoch(t1 * 1000); + n1Value = -dateTime.difference(now).inMinutes; + } else { + n1Value = asc ? 100000 : -100000; + } + if (t2 != null) { + var dateTime = DateTime.fromMillisecondsSinceEpoch(t2 * 1000); + n2Value = -dateTime.difference(now).inMinutes; + } else { + n2Value = asc ? 100000 : -100000; + } + } catch (e) {} + break; case 'popularity': final temp = n1Value; n1Value = n2Value; @@ -454,6 +473,10 @@ class SortFilterOptions { name: S.current.broadCastEndDate, value: 'end_date', ), + SortOption( + name: S.current.ReleaseStartDate, + value: 'release_date', + ), ]; } else { return [ diff --git a/lib/widgets/user/contentlistwidget.dart b/lib/widgets/user/contentlistwidget.dart index b2b4fc4..f175a24 100644 --- a/lib/widgets/user/contentlistwidget.dart +++ b/lib/widgets/user/contentlistwidget.dart @@ -273,6 +273,9 @@ Widget buildBaseNodePageItem( bool? showStatus, }) { Widget fromItem(int index, BaseNode node, [HomePageTileSize? tileSize]) { + if (node.content == null) { + return SB.z; + } return _baseBaseNode( category, node, @@ -293,12 +296,13 @@ Widget buildBaseNodePageItem( return fromItem(index, item.rowItems.first); } else { homePageTileSize = _axisTileSizeMap[gridAxisCount]; + final list = _padList(item.rowItems, gridAxisCount); return SizedBox( height: gridHeight, child: Padding( padding: const EdgeInsets.only(bottom: 7.0), child: Row( - children: item.rowItems + children: list .asMap() .entries .map((e) => @@ -310,6 +314,15 @@ Widget buildBaseNodePageItem( } } +List _padList(List list, int gridAxisCount) { + final padCount = gridAxisCount - list.length % gridAxisCount; + final newList = List.from(list); + if (padCount != gridAxisCount) { + newList.addAll(List.generate(padCount, (_) => BaseNode())); + } + return newList; +} + Widget horizontalList({ required String category, required List items, diff --git a/lib/widgets/user/user_header.dart b/lib/widgets/user/user_header.dart index e58e467..d33f3fb 100644 --- a/lib/widgets/user/user_header.dart +++ b/lib/widgets/user/user_header.dart @@ -87,7 +87,14 @@ class UserHeader { future: DalApi.i.getUserFriends(username), builder: (_, snapshot) { if (snapshot.hasData) { - final friends = snapshot.data?.friends ?? []; + final data = snapshot.data; + final friends = data?.friends ?? []; + int count; + if (friends.length == 100) { + count = data?.count ?? friends.length; + } else { + count = friends.length; + } if (friends.isNotEmpty) { return ListView( padding: EdgeInsets.zero, @@ -97,7 +104,7 @@ class UserHeader { ), Padding( padding: EdgeInsets.only(left: 20), - child: title("(${friends.length} ${S.current.friends})", + child: title("($count ${S.current.friends})", fontStyle: FontStyle.italic)), ListView.builder( physics: const NeverScrollableScrollPhysics(),