Split ui.rs into modules based on UI element #200

Merged
wojtek merged 13 commits from 135---split-ui-rs-into-modules-based-on-ui-element into main 2024-08-29 17:21:52 +02:00
2 changed files with 8 additions and 8 deletions
Showing only changes of commit 2b92ab73e1 - Show all commits

View File

@ -1,15 +1,15 @@
use musichoard::collection::album::Album; use musichoard::collection::album::Album;
use ratatui::widgets::{List, ListItem}; use ratatui::widgets::{List, ListItem};
use crate::tui::{lib::interface::musicbrainz::Match, ui::display::UiDisplay}; use crate::tui::{app::WidgetState, lib::interface::musicbrainz::Match, ui::display::UiDisplay};
#[derive(Default)] pub struct AlbumMatchesState<'a, 'b> {
pub struct AlbumMatchesState<'a> {
pub list: List<'a>, pub list: List<'a>,
pub state: &'b mut WidgetState,
} }
impl<'a> AlbumMatchesState<'a> { impl<'a, 'b> AlbumMatchesState<'a, 'b> {
pub fn new(matches: &[Match<Album>]) -> Self { pub fn new(matches: &[Match<Album>], state: &'b mut WidgetState) -> Self {
let list = List::new( let list = List::new(
matches matches
.iter() .iter()
@ -18,6 +18,6 @@ impl<'a> AlbumMatchesState<'a> {
.collect::<Vec<ListItem>>(), .collect::<Vec<ListItem>>(),
); );
AlbumMatchesState { list } AlbumMatchesState { list, state }
} }
} }

View File

@ -293,8 +293,8 @@ impl Ui {
) { ) {
let area = OverlayBuilder::default().build(frame.size()); let area = OverlayBuilder::default().build(frame.size());
let matching_string = UiDisplay::display_matching_info(matching); let matching_string = UiDisplay::display_matching_info(matching);
let st = matches.map(AlbumMatchesState::new).unwrap_or_default(); let st = AlbumMatchesState::new(matches.unwrap_or_default(), state);
Self::render_overlay_list_widget(&matching_string, st.list, state, true, area, frame) Self::render_overlay_list_widget(&matching_string, st.list, st.state, true, area, frame)
} }
fn render_reload_overlay(frame: &mut Frame) { fn render_reload_overlay(frame: &mut Frame) {