/// Draws the part showing the currently playing batsmen and bowlers, similar to cricbuzz
Draws the part showing the currently playing batsmen and bowlers, similar to cricbuzz
Draws the part showing the currently playing batsmen and bowlers similar to cricbuzz
fn draw_live_feed<B>(f: &mut Frame<B>, area: Rect, app: &App, ui_state: &mut UiState)
where
    B: Backend,
{
    let chunks = Layout::default()
        .constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref())
        .direction(Direction::Horizontal)
        .split(area);
    let curr_match = app.current_match_cricbuzz_info(ui_state.focused_tab);
    let table = Table::new(vec![
        Row::new(vec!["Batsman", "R", "B", "4", "6", "SR"])
            .style(Style::default().add_modifier(Modifier::BOLD)),
        Row::new(vec![
            curr_match.bat_striker_name().to_string() + " *",
            curr_match.bat_striker_runs().to_string(),
            curr_match.bat_striker_balls().to_string(),
            curr_match.bat_striker_fours().to_string(),
            curr_match.bat_striker_sixes().to_string(),
            curr_match.bat_striker_strike_rate().to_string(),
        ]),
        Row::new(vec![
            curr_match.bat_non_striker_name().to_string(),
            curr_match.bat_non_striker_runs().to_string(),
            curr_match.bat_non_striker_balls().to_string(),
            curr_match.bat_non_striker_fours().to_string(),
            curr_match.bat_non_striker_sixes().to_string(),
            curr_match.bat_non_striker_strike_rate().to_string(),
        ])
        .height(2),
        Row::new(vec!["Bowler", "O", "M", "R", "W", "ECO"])
            .style(Style::default().add_modifier(Modifier::BOLD)),
        Row::new(vec![
            curr_match.bowl_striker_name().to_string() + " *",
            curr_match.bowl_striker_ovs().to_string(),
            curr_match.bowl_striker_maidens().to_string(),
            curr_match.bowl_striker_runs().to_string(),
            curr_match.bowl_striker_wkts().to_string(),
            curr_match.bowl_striker_econ().to_string(),
        ]),
        Row::new(vec![
            curr_match.bowl_non_striker_name().to_string(),
            curr_match.bowl_non_striker_ovs().to_string(),
            curr_match.bowl_non_striker_maidens().to_string(),
            curr_match.bowl_non_striker_runs().to_string(),
            curr_match.bowl_non_striker_wkts().to_string(),
            curr_match.bowl_non_striker_econ().to_string(),
        ]),
    ])
    .style(Style::default().fg(Color::White))
    .block(Block::default().borders(Borders::ALL).title("Live"))
    .widths(&[
        Constraint::Length(25),
        Constraint::Length(5),
        Constraint::Length(5),
        Constraint::Length(5),
        Constraint::Length(5),
        Constraint::Length(6),
    ]);
    f.render_widget(table, chunks[0]);
    // Drawing Key Stats to the right
    let mut key_stats: Vec<Spans> = vec![];
    key_stats.push(Spans::from(vec![
        Span::styled(
            "Partnership: ",
            Style::default().add_modifier(Modifier::BOLD),
        ),
        Span::from(format!(
            "{}({})",
            curr_match.partner_ship_runs(),
            curr_match.partner_ship_balls()
        )),
    ]));
    if let Some(l_wkt) = curr_match.last_wicket() {
        key_stats.push(Spans::from(vec![
            Span::styled("Last Wkt: ", Style::default().add_modifier(Modifier::BOLD)),
            Span::from(l_wkt.as_str()),
        ]));
    }
    if let Some(ovs_rem) = &curr_match.overs_rem() {
        key_stats.push(Spans::from(vec![
            Span::styled("Ovs Left: ", Style::default().add_modifier(Modifier::BOLD)),
            Span::from(ovs_rem.to_string()),
        ]));
    }
    key_stats.push(Spans::from(vec![
        Span::styled("Toss: ", Style::default().add_modifier(Modifier::BOLD)),
        Span::from(format!(
            "{} ({})",
            curr_match.toss_winner_name(),
            curr_match.toss_decision()
        )),
    ]));
    let key_stats_block = Block::default().borders(Borders::ALL).title("Key Stats");
    let key_stats_para = Paragraph::new(key_stats)
        .block(key_stats_block)
        .wrap(Wrap { trim: true });
    f.render_widget(key_stats_para, chunks[1]);
}
fn draw_live_feed < B > ( f : & mut Frame < B > , area : Rect , app : & App , ui_state : & mut UiState ) where B : Backend , { let chunks = Layout :: default ( ) . constraints ( [ Constraint :: Percentage ( 50 ) , Constraint :: Percentage ( 50 ) ] . as_ref ( ) ) . direction ( Direction :: Horizontal ) . split ( area ) ; let curr_match = app . current_match_cricbuzz_info ( ui_state . focused_tab ) ; let table = Table :: new ( vec ! [ Row new ( vec [ " " " " " " " " " " " " ] ) style ( Style default ( ) add_modifier ( Modifier BOLD ) ) Row new ( vec [ curr_match bat_striker_name ( ) to_string ( ) " " curr_match bat_striker_runs ( ) to_string ( ) curr_match bat_striker_balls ( ) to_string ( ) curr_match bat_striker_fours ( ) to_string ( ) curr_match bat_striker_sixes ( ) to_string ( ) curr_match bat_striker_strike_rate ( ) to_string ( ) ] ) Row new ( vec [ curr_match bat_non_striker_name ( ) to_string ( ) curr_match bat_non_striker_runs ( ) to_string ( ) curr_match bat_non_striker_balls ( ) to_string ( ) curr_match bat_non_striker_fours ( ) to_string ( ) curr_match bat_non_striker_sixes ( ) to_string ( ) curr_match bat_non_striker_strike_rate ( ) to_string ( ) ] ) height ( 2 ) Row new ( vec [ " " " " " " " " " " " " ] ) style ( Style default ( ) add_modifier ( Modifier BOLD ) ) Row new ( vec [ curr_match bowl_striker_name ( ) to_string ( ) " " curr_match bowl_striker_ovs ( ) to_string ( ) curr_match bowl_striker_maidens ( ) to_string ( ) curr_match bowl_striker_runs ( ) to_string ( ) curr_match bowl_striker_wkts ( ) to_string ( ) curr_match bowl_striker_econ ( ) to_string ( ) ] ) Row new ( vec [ curr_match bowl_non_striker_name ( ) to_string ( ) curr_match bowl_non_striker_ovs ( ) to_string ( ) curr_match bowl_non_striker_maidens ( ) to_string ( ) curr_match bowl_non_striker_runs ( ) to_string ( ) curr_match bowl_non_striker_wkts ( ) to_string ( ) curr_match bowl_non_striker_econ ( ) to_string ( ) ] ) ] ) . style ( Style :: default ( ) . fg ( Color :: White ) ) . block ( Block :: default ( ) . borders ( Borders :: ALL ) . title ( " " ) ) . widths ( & [ Constraint :: Length ( 25 ) , Constraint :: Length ( 5 ) , Constraint :: Length ( 5 ) , Constraint :: Length ( 5 ) , Constraint :: Length ( 5 ) , Constraint :: Length ( 6 ) , ] ) ; f . render_widget ( table , chunks [ 0 ] ) ; // Drawing Key Stats to the right let mut key_stats : Vec < Spans > = vec ! [ ] ; key_stats . push ( Spans :: from ( vec ! [ Span styled ( " " Style default ( ) add_modifier ( Modifier BOLD ) ) Span from ( format ( " " curr_match partner_ship_runs ( ) curr_match partner_ship_balls ( ) ) ) ] ) ) ; if let Some ( l_wkt ) = curr_match . last_wicket ( ) { key_stats . push ( Spans :: from ( vec ! [ Span styled ( " " Style default ( ) add_modifier ( Modifier BOLD ) ) Span from ( l_wkt as_str ( ) ) ] ) ) ; } if let Some ( ovs_rem ) = & curr_match . overs_rem ( ) { key_stats . push ( Spans :: from ( vec ! [ Span styled ( " " Style default ( ) add_modifier ( Modifier BOLD ) ) Span from ( ovs_rem to_string ( ) ) ] ) ) ; } key_stats . push ( Spans :: from ( vec ! [ Span styled ( " " Style default ( ) add_modifier ( Modifier BOLD ) ) Span from ( format ( " " curr_match toss_winner_name ( ) curr_match toss_decision ( ) ) ) ] ) ) ; let key_stats_block = Block :: default ( ) . borders ( Borders :: ALL ) . title ( " " ) ; let key_stats_para = Paragraph :: new ( key_stats ) . block ( key_stats_block ) . wrap ( Wrap { trim : true } ) ; f . render_widget ( key_stats_para , chunks [ 1 ] ) ; }
Draws the part showing the currently playing batsmen and bowlers, similar to cricbuzz
Draws the part showing the currently playing batsmen and bowlers similar to cricbuzz
f
&mut Frame<B>
area
Rect
app
&App
ui_state
&mut UiState