@@ -56,11 +56,6 @@ impl Widget for Bar {
56
56
if let Some ( Movement :: X ( x) ) = move_cursor ( key, area) {
57
57
self . idx = self
58
58
. idx
59
- // TODO: this isn't a great solution, it effectively means that if the middle tab
60
- // has an error, you can never get to the last tab. It should be
61
- // possible to navigate between things when an error is displayed.
62
- // This gets weird though when you think about scrolling the error
63
- // dialog.
64
59
. wrapping_add_signed ( x. into ( ) )
65
60
. clamp ( 0 , self . items . len ( ) . saturating_sub ( 1 ) ) ;
66
61
@@ -131,37 +126,41 @@ impl TabbedView {
131
126
items : tabs,
132
127
}
133
128
}
129
+
130
+ fn select ( & mut self , idx : usize , buffer : & Buffer ) {
131
+ let start = if self . current < idx {
132
+ Start :: Left
133
+ } else {
134
+ Start :: Right
135
+ } ;
136
+
137
+ self . current = idx;
138
+
139
+ // TODO: this is *probably* a valid assumption, but it might need to be actually
140
+ // checked.
141
+ self . view . pop ( ) ;
142
+ self . view . push (
143
+ Animated :: builder ( )
144
+ . widget ( self . items [ idx] . widget ( ) )
145
+ . effect ( fx:: parallel ( & [
146
+ fx:: coalesce ( EffectTimer :: from_ms ( 500 , Interpolation :: SineInOut ) ) ,
147
+ horizontal_wipe ( )
148
+ . buffer ( buffer. clone ( ) )
149
+ . timer ( EffectTimer :: from_ms ( 500 , Interpolation :: SineInOut ) )
150
+ . start ( start)
151
+ . call ( ) ,
152
+ ] ) )
153
+ . build ( )
154
+ . boxed ( ) ,
155
+ ) ;
156
+ }
134
157
}
135
158
136
159
impl Widget for TabbedView {
137
160
fn dispatch ( & mut self , event : & Event , buffer : & Buffer , area : Rect ) -> Result < Broadcast > {
138
161
match self . view . dispatch ( event, buffer, area) ? {
139
162
Broadcast :: Selected ( idx) => {
140
- let start = if self . current < idx {
141
- Start :: Left
142
- } else {
143
- Start :: Right
144
- } ;
145
-
146
- self . current = idx;
147
-
148
- // TODO: this is *probably* a valid assumption, but it might need to be actually
149
- // checked.
150
- self . view . pop ( ) ;
151
- self . view . push (
152
- Animated :: builder ( )
153
- . widget ( self . items [ idx] . widget ( ) )
154
- . effect ( fx:: parallel ( & [
155
- fx:: coalesce ( EffectTimer :: from_ms ( 500 , Interpolation :: SineInOut ) ) ,
156
- horizontal_wipe ( )
157
- . buffer ( buffer. clone ( ) )
158
- . timer ( EffectTimer :: from_ms ( 500 , Interpolation :: SineInOut ) )
159
- . start ( start)
160
- . call ( ) ,
161
- ] ) )
162
- . build ( )
163
- . boxed ( ) ,
164
- ) ;
163
+ self . select ( idx, buffer) ;
165
164
166
165
Ok ( Broadcast :: Consumed )
167
166
}
0 commit comments