mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Shrink notification and device list page sizes on phones
On phone-width layouts (< Breakpoints.medium) the notification and device lists now request fewer items per page so the list and its pagination bar fit on screen together on common current phones. Notifications use 4 items and devices 6 on phones; wider layouts keep 5 and 10 respectively. The initial fetch is deferred to didChangeDependencies so the page size can read the screen width from MediaQuery. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
8b8fa5ce89
commit
0a899b7890
@@ -14,7 +14,11 @@ import '../widgets/pagination_bar.dart';
|
||||
import '../widgets/skeleton.dart';
|
||||
import 'notification_card.dart';
|
||||
|
||||
const _pageSize = 5;
|
||||
// Phones show fewer notifications so the list and its pagination controls fit
|
||||
// on screen at once on the common current phones (e.g. iPhone 15, Pixel 8);
|
||||
// wider layouts have the vertical room for a couple more.
|
||||
const _phonePageSize = 4;
|
||||
const _widePageSize = 5;
|
||||
|
||||
enum _NotificationFilter {
|
||||
newOnly('New'),
|
||||
@@ -47,8 +51,13 @@ class _NotificationsListState extends State<NotificationsList>
|
||||
Timer? _notificationTimer;
|
||||
|
||||
int _currentPage = 0;
|
||||
bool _didInitialFetch = false;
|
||||
List<oott_model.Notification> _items = [];
|
||||
bool _isLoading = false;
|
||||
|
||||
int get _pageSize => MediaQuery.sizeOf(context).width < Breakpoints.medium
|
||||
? _phonePageSize
|
||||
: _widePageSize;
|
||||
bool _hasNextPage = false;
|
||||
String? _error;
|
||||
CancelToken? _fetchToken;
|
||||
@@ -58,7 +67,6 @@ class _NotificationsListState extends State<NotificationsList>
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
_fetchPage(0);
|
||||
_startTimer();
|
||||
}
|
||||
|
||||
@@ -69,6 +77,12 @@ class _NotificationsListState extends State<NotificationsList>
|
||||
if (route is ModalRoute<void>) {
|
||||
routeObserver.subscribe(this, route);
|
||||
}
|
||||
// Deferred from initState so the page size can read the screen width from
|
||||
// MediaQuery, which is only available once dependencies are in place.
|
||||
if (!_didInitialFetch) {
|
||||
_didInitialFetch = true;
|
||||
_fetchPage(0);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user