-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from robgonnella/rendering-refactor
Rendering refactor
- Loading branch information
Showing
21 changed files
with
939 additions
and
534 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod device_info; | ||
pub mod field; | ||
pub mod footer; | ||
pub mod header; | ||
pub mod scrollbar; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use ratatui::{ | ||
layout::Rect, | ||
text::{Line, Span}, | ||
widgets::{Paragraph, Widget, Wrap}, | ||
}; | ||
|
||
use crate::ui::{store::state::State, views::CustomWidget}; | ||
|
||
pub struct Field { | ||
key: String, | ||
value: String, | ||
} | ||
|
||
impl Field { | ||
pub fn new(key: String, value: String) -> Self { | ||
Self { key, value } | ||
} | ||
} | ||
|
||
impl CustomWidget for Field { | ||
fn render(self, area: Rect, buf: &mut ratatui::prelude::Buffer, _state: &State) | ||
where | ||
Self: Sized, | ||
{ | ||
let key = Span::from(format!("{0}: ", self.key)); | ||
let value = Span::from(self.value); | ||
let line = Line::from(vec![key, value]); | ||
let field = Paragraph::new(line).wrap(Wrap { trim: true }); | ||
field.render(area, buf) | ||
} | ||
} |
Oops, something went wrong.