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 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> {
pub struct AlbumMatchesState<'a, 'b> {
pub list: List<'a>,
pub state: &'b mut WidgetState,
}
impl<'a> AlbumMatchesState<'a> {
pub fn new(matches: &[Match<Album>]) -> Self {
impl<'a, 'b> AlbumMatchesState<'a, 'b> {
pub fn new(matches: &[Match<Album>], state: &'b mut WidgetState) -> Self {
let list = List::new(
matches
.iter()
@ -18,6 +18,6 @@ impl<'a> AlbumMatchesState<'a> {
.collect::<Vec<ListItem>>(),
);
AlbumMatchesState { list }
AlbumMatchesState { list, state }
}
}

View File

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