@@ -9,10 +9,10 @@ use ratatui::text::Line;
99use crate :: { state:: Episode , utils:: format_duration} ;
1010
1111use super :: {
12- config, utils, utils:: construct_and_render_block, Album , Artist , ArtistFocusState , Borders ,
12+ config, utils, utils:: construct_and_render_block, Album , Alignment , Artist , ArtistFocusState , Borders ,
1313 BrowsePageUIState , Cell , Constraint , Context , ContextPageUIState , DataReadGuard , Frame , Id ,
1414 Layout , LibraryFocusState , MutableWindowState , Orientation , PageState , Paragraph ,
15- PlaylistFolderItem , Rect , Row , SearchFocusState , SharedState , Style , Table , Track ,
15+ PlaylistFolderItem , Rect , Row , SearchFocusState , SharedState , Style , Table , Text , Track ,
1616 UIStateGuard ,
1717} ;
1818use crate :: state:: BidiDisplay ;
@@ -972,18 +972,20 @@ fn render_track_table(
972972 . into_iter ( )
973973 . enumerate ( )
974974 . map ( |( id, t) | {
975- let ( id, style) = if playing_track_uri == t. id . uri ( ) {
975+ let track_no = ( id +1 ) . to_string ( ) ;
976+ let ( play_pause, style) = if playing_track_uri == t. id . uri ( ) {
976977 ( playing_id. to_string ( ) , ui. theme . current_playing ( ) )
977978 } else {
978- ( ( id + 1 ) . to_string ( ) , Style :: default ( ) )
979+ ( "" . to_string ( ) , Style :: default ( ) )
979980 } ;
980981 Row :: new ( vec ! [
981982 if data. user_data. is_liked_track( t) {
982983 Cell :: from( & configs. app_config. liked_icon as & str ) . style( ui. theme. like( ) )
983984 } else {
984985 Cell :: from( "" )
985986 } ,
986- Cell :: from( id) ,
987+ Cell :: from( Text :: from( track_no) . alignment( Alignment :: Right ) ) ,
988+ Cell :: from( play_pause) ,
987989 Cell :: from( to_bidi_string( & t. display_name( ) ) ) ,
988990 Cell :: from( to_bidi_string( & t. artists_info( ) ) ) ,
989991 Cell :: from( to_bidi_string( & t. album_info( ) ) ) ,
@@ -1009,11 +1011,18 @@ fn render_track_table(
10091011 . style ( style)
10101012 } )
10111013 . collect :: < Vec < _ > > ( ) ;
1014+
1015+ let n_play_pause_chars = std:: cmp:: max (
1016+ configs. app_config . play_icon . chars ( ) . count ( ) ,
1017+ configs. app_config . pause_icon . chars ( ) . count ( ) ,
1018+ ) as u16 ;
1019+ let n_track_digits = ( n_tracks. ilog10 ( ) +1 ) as u16 ;
10121020 let track_table = Table :: new (
10131021 rows,
10141022 [
10151023 Constraint :: Length ( configs. app_config . liked_icon . chars ( ) . count ( ) as u16 ) ,
1016- Constraint :: Length ( 4 ) ,
1024+ Constraint :: Length ( n_track_digits) ,
1025+ Constraint :: Length ( n_play_pause_chars) ,
10171026 Constraint :: Fill ( 4 ) ,
10181027 Constraint :: Fill ( 3 ) ,
10191028 Constraint :: Fill ( 5 ) ,
@@ -1028,7 +1037,8 @@ fn render_track_table(
10281037 . header (
10291038 Row :: new ( vec ! [
10301039 Cell :: from( "" ) ,
1031- Cell :: from( "#" ) ,
1040+ Cell :: from( Text :: from( "#" ) . alignment( Alignment :: Right ) ) ,
1041+ Cell :: from( "" ) ,
10321042 Cell :: from( "Title" ) ,
10331043 Cell :: from( "Artists" ) ,
10341044 Cell :: from( "Album" ) ,
0 commit comments