@@ -181,9 +181,33 @@ impl ActionBar {
181
181
let new_is_last = new_pager. is_last ( ) ;
182
182
let old_is_first = self . pager . is_first ( ) ;
183
183
let new_is_first = new_pager. is_first ( ) ;
184
+ let old_is_single = self . pager . is_single ( ) ;
185
+ let new_is_single = new_pager. is_single ( ) ;
184
186
185
187
self . pager = new_pager;
186
- if ( old_is_last != new_is_last) || ( new_is_first != old_is_first) {
188
+ if self . mode == Mode :: PaginateOnly {
189
+ if new_is_single && !old_is_single {
190
+ // On single page, disable first/last buttons
191
+ self . left_button = None ;
192
+ self . right_button = None ;
193
+ self . place_buttons ( self . area ) ;
194
+ } else if !new_is_single && old_is_single {
195
+ // On multiple pages, enable grayed-out first/last buttons
196
+ self . left_button = Some (
197
+ Button :: with_icon ( theme:: ICON_CHEVRON_UP )
198
+ . with_expanded_touch_area ( Self :: BUTTON_EXPAND_TOUCH )
199
+ . with_content_offset ( Self :: BUTTON_CONTENT_OFFSET )
200
+ . initially_enabled ( false ) ,
201
+ ) ;
202
+ self . right_button = Some (
203
+ Button :: with_icon ( theme:: ICON_CHEVRON_DOWN )
204
+ . with_expanded_touch_area ( Self :: BUTTON_EXPAND_TOUCH )
205
+ . with_content_offset ( Self :: BUTTON_CONTENT_OFFSET . neg ( ) )
206
+ . initially_enabled ( false ) ,
207
+ ) ;
208
+ self . place_buttons ( self . area ) ;
209
+ }
210
+ } else if ( old_is_last != new_is_last) || ( new_is_first != old_is_first) {
187
211
self . place_buttons ( self . area ) ;
188
212
}
189
213
}
@@ -334,25 +358,12 @@ impl ActionBar {
334
358
self . next_button . place ( right_area) ;
335
359
}
336
360
Mode :: PaginateOnly => {
337
- let ( left_area, right_area) = if self . pager . is_first ( ) {
338
- // Only `next_button`
339
- self . next_button . set_content_offset ( Offset :: zero ( ) ) ;
340
- ( Rect :: zero ( ) , bounds)
341
- } else if self . pager . is_last ( ) {
342
- // Only `prev_button`
343
- self . prev_button . set_content_offset ( Offset :: zero ( ) ) ;
344
- ( bounds, Rect :: zero ( ) )
345
- } else {
346
- // Equal-sized `next_button` and `prev_button`
347
- let ( left, _, right) = bounds. split_center ( Self :: SPACER_WIDTH ) ;
348
- self . prev_button
349
- . set_content_offset ( Self :: BUTTON_CONTENT_OFFSET ) ;
350
- self . next_button
351
- . set_content_offset ( Self :: BUTTON_CONTENT_OFFSET . neg ( ) ) ;
352
- ( left, right)
353
- } ;
361
+ // Equal-sized `next_button` and `prev_button`
362
+ let ( left_area, _, right_area) = bounds. split_center ( Self :: SPACER_WIDTH ) ;
354
363
self . prev_button . place ( left_area) ;
355
364
self . next_button . place ( right_area) ;
365
+ self . left_button . place ( left_area) ;
366
+ self . right_button . place ( right_area) ;
356
367
}
357
368
}
358
369
}
@@ -467,7 +478,7 @@ impl Component for ActionBar {
467
478
Mode :: Single => !self . pager . is_first ( ) ,
468
479
Mode :: Double { .. } => true ,
469
480
Mode :: Timeout => false ,
470
- Mode :: PaginateOnly => !self . pager . is_first ( ) && ! self . pager . is_last ( ) ,
481
+ Mode :: PaginateOnly => !self . pager . is_single ( ) ,
471
482
} ;
472
483
if show_divider {
473
484
let pos_divider = self . prev_button . area ( ) . right_center ( ) ;
0 commit comments