@@ -10,7 +10,6 @@ use crossterm::{
1010 execute,
1111 terminal:: { EnterAlternateScreen , LeaveAlternateScreen , SetTitle , disable_raw_mode, enable_raw_mode} ,
1212} ;
13- use rand:: prelude:: * ;
1413use ratatui:: {
1514 Frame , Terminal ,
1615 backend:: CrosstermBackend ,
@@ -206,13 +205,17 @@ impl Player {
206205 }
207206
208207 let next_index = if self . random_mode {
209- let mut rng = rand:: rng ( ) ;
208+ // Simple random selection using timestamp
209+ let timestamp = std:: time:: SystemTime :: now ( )
210+ . duration_since ( std:: time:: UNIX_EPOCH )
211+ . unwrap_or_default ( )
212+ . as_nanos ( ) as usize ;
210213 let mut indices: Vec < usize > = ( 0 ..self . songs . len ( ) ) . collect ( ) ;
211- indices. remove ( self . current_index ) ;
214+ indices. retain ( | & i| i != self . current_index ) ;
212215 if indices. is_empty ( ) {
213216 self . current_index
214217 } else {
215- * indices. choose ( & mut rng ) . unwrap ( )
218+ indices[ timestamp % indices . len ( ) ]
216219 }
217220 } else if self . current_index + 1 >= self . songs . len ( ) {
218221 if self . loop_mode { 0 } else { self . current_index }
@@ -229,13 +232,17 @@ impl Player {
229232 }
230233
231234 let prev_index = if self . random_mode {
232- let mut rng = rand:: rng ( ) ;
235+ // Simple random selection using timestamp
236+ let timestamp = std:: time:: SystemTime :: now ( )
237+ . duration_since ( std:: time:: UNIX_EPOCH )
238+ . unwrap_or_default ( )
239+ . as_nanos ( ) as usize ;
233240 let mut indices: Vec < usize > = ( 0 ..self . songs . len ( ) ) . collect ( ) ;
234- indices. remove ( self . current_index ) ;
241+ indices. retain ( | & i| i != self . current_index ) ;
235242 if indices. is_empty ( ) {
236243 self . current_index
237244 } else {
238- * indices. choose_mut ( & mut rng ) . unwrap ( )
245+ indices[ timestamp % indices . len ( ) ]
239246 }
240247 } else if self . current_index == 0 {
241248 if self . loop_mode { self . songs . len ( ) - 1 } else { 0 }
@@ -463,13 +470,15 @@ fn ui(f: &mut Frame, player: &Player) {
463470 0.0
464471 } ;
465472
473+
466474 let progress_label_text = if let Some ( duration) = total {
467- format ! ( "{}/{}" , Player :: format_duration( elapsed) , Player :: format_duration( duration) )
475+ format ! ( " {}/{} " , Player :: format_duration( elapsed) , Player :: format_duration( duration) )
468476 } else {
469- Player :: format_duration ( elapsed)
477+ format ! ( " {} " , Player :: format_duration( elapsed) )
470478 } ;
471479
472- let progress_label = Span :: styled ( progress_label_text, Style :: default ( ) . fg ( Color :: White ) ) ;
480+ let progress_bar_style = Style :: default ( ) . fg ( PRIMARY_COLOR ) . bg ( Color :: default ( ) ) ;
481+ let progress_label = Span :: styled ( progress_label_text, progress_bar_style) ;
473482
474483 let progress_bar = Gauge :: default ( )
475484 . block (
@@ -478,7 +487,7 @@ fn ui(f: &mut Frame, player: &Player) {
478487 . title ( "Progress" )
479488 . border_style ( Style :: default ( ) . fg ( PRIMARY_COLOR ) ) ,
480489 )
481- . gauge_style ( Style :: default ( ) . fg ( PRIMARY_COLOR ) )
490+ . gauge_style ( progress_bar_style )
482491 . ratio ( progress_ratio)
483492 . label ( progress_label) ;
484493 f. render_widget ( progress_bar, chunks[ 2 ] ) ;
0 commit comments