@@ -137,22 +137,7 @@ impl ActionBar {
137
137
/// mode can only return `ActionBarMsg::Prev` and `ActionBarMsg::Next`
138
138
/// messages.
139
139
pub fn new_paginate_only ( ) -> Self {
140
- Self :: new (
141
- Mode :: PaginateOnly ,
142
- Some (
143
- Button :: with_icon ( theme:: ICON_CHEVRON_UP )
144
- . with_expanded_touch_area ( Self :: BUTTON_EXPAND_TOUCH )
145
- . with_content_offset ( Self :: BUTTON_CONTENT_OFFSET )
146
- . initially_enabled ( false ) ,
147
- ) ,
148
- Some (
149
- Button :: with_icon ( theme:: ICON_CHEVRON_DOWN )
150
- . with_expanded_touch_area ( Self :: BUTTON_EXPAND_TOUCH )
151
- . with_content_offset ( Self :: BUTTON_CONTENT_OFFSET . neg ( ) )
152
- . initially_enabled ( false ) ,
153
- ) ,
154
- None ,
155
- )
140
+ Self :: new ( Mode :: PaginateOnly , None , None , None )
156
141
}
157
142
158
143
pub fn new_text_only ( text : TString < ' static > ) -> Self {
@@ -196,9 +181,33 @@ impl ActionBar {
196
181
let new_is_last = new_pager. is_last ( ) ;
197
182
let old_is_first = self . pager . is_first ( ) ;
198
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 ( ) ;
199
186
200
187
self . pager = new_pager;
201
- 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) {
202
211
self . place_buttons ( self . area ) ;
203
212
}
204
213
}
@@ -351,10 +360,10 @@ impl ActionBar {
351
360
Mode :: PaginateOnly => {
352
361
// Equal-sized `next_button` and `prev_button`
353
362
let ( left_area, _, right_area) = bounds. split_center ( Self :: SPACER_WIDTH ) ;
354
- self . left_button . place ( left_area) ;
355
- self . right_button . place ( right_area) ;
356
363
self . prev_button . place ( left_area) ;
357
364
self . next_button . place ( right_area) ;
365
+ self . left_button . place ( left_area) ;
366
+ self . right_button . place ( right_area) ;
358
367
}
359
368
}
360
369
}
@@ -469,7 +478,7 @@ impl Component for ActionBar {
469
478
Mode :: Single => !self . pager . is_first ( ) ,
470
479
Mode :: Double { .. } => true ,
471
480
Mode :: Timeout => false ,
472
- Mode :: PaginateOnly => true ,
481
+ Mode :: PaginateOnly => ! self . pager . is_single ( ) ,
473
482
} ;
474
483
if show_divider {
475
484
let pos_divider = self . prev_button . area ( ) . right_center ( ) ;
0 commit comments