diff --git a/docs/drawio/component_lifecycle.drawio b/docs/drawio/component_lifecycle.drawio
new file mode 100644
index 0000000..2038147
--- /dev/null
+++ b/docs/drawio/component_lifecycle.drawio
@@ -0,0 +1 @@
+7Vxbc6M2FP41nmkf2gGEMDwmTtLOdNN2Jp1205cMBhmrwYgKsbb3168wwlxEbOIEZOLNS5CQZOkcfd+5SPYEzFabX6gbL++Jj8KJofmbCbiZGIYOocb/ZTXbvMZ2YF4RUOyLRmXFA/6KRKXoF6TYR0mtISMkZDiuV3okipDHanUupWRdb7YgYf1TYzdAUsWD54Zy7T/YZ0uxCmNa1v+KcLAsPlm3nPzNyi0ai5UkS9cn60oVuJ2AGSWE5U+rzQyFmfAKueT97l54u58YRRHr0iFBd49//Wv8hmafV08PC+p8ur/5CeSjfHHDVCz4ymP4C2ZbMWm2LSTBR+NC54Xr9RIz9BC7XvZmzfXO65ZsFfKSzh89ssKeeF7gMJyRkNDdGMDz0dye8/qEUfKMKm+ABRzgZz1IxMQ20C1eFhNElKHNiyvX9/LkGxGRFWKUL0ATHQoNiC1oiuK61KdeNFlWdGmLOldsoWA/cCll/iAE/QqhF3u7Klyf7zpRJJQtSUAiN7wta68pSSMfZcNqvFS2+URILIT9H2JsK2TnpozU1YI2mH3Ouv8MRemx8uZmI0beFbZFIeLrrXTKio/Vd2W3Xano167EbJGHVchlQlLqoQPCE8BjLg0QO9DObt8SFIUu3+D1eby7hqcSrB74hNnpmHKTOGe3Bd5km6AOsoa0G6BDu7+DoHsHkIGpeQxl9qAgA0pBVoFYCbjRgMzuCDLdUIkyW0JZwI0p7xTFKf9vhXzq13PKn4LsCX3ZyeFO2hd0SVbzNHmlZTsMug6W7j1AZ1o10OnTFtsGLBl2utYb7qyxGLce8ZPjoguAoEoAFdOsIIhEP/woKZC7rnH2GFPioaQDUOau9xzslPpHykIcoRMA5CG4WPQNIN2u+4Z7e3TMObR6w48p6eSRB0BNlfAls4aLEOIg4s8eXzriorrOBIN5JHMlXqyw7+doQwn+6s53Q2VAiAmO2G4d8HoCb7KxOMASoZuefHJLrzOXY0qCN1vkbvQld2M0vHWG/oIOO/KdodRhKKbZGu423YWC7HgonwTnQYmD+BRNSjQ15ZQoh1P3LSp5mRJDtGBnT4iwLnZgyWKHgxIiVEqIJwVQNTos2VEBIXaOoN7qAO66XlHqbisNxAYuR/4zq6hgvJESc5q5wyPtTaA19lc+g3K37ZfyBtjL8V0a+y5DF+2h2o5qOi4+rNWKapxfw9e4q6Pg5kaYvSfiqg60QclZv3QdWIZyHThKDeS4Iwaja4bEUJrIB1OVOtYnpzhB49NxnqFUpeNimhUu5V5ATKJswVJYSNH/KaZZRqb5JndOPlaCWZ8aNdaFuvIEs3EZCbKm39dm7wZNkAG1B2ojN3dd40GgNEFmtBypIfbEo6o4ueioy2rJxgwbdYHL8/gbGTFbedQFzO8UeDIFgq7eoK7W45e9wXv3GfGaCK2zpWdceB5MqOQ4YNp2xWBQJjSVOiIjj8kKX/0oCk2ljoipNrdyKTpWy7SWxLTJkqSh/5SuuCbl25K9hNGDuJMQNA732q6ZDBtGA9nV/528woMcRxQNGoKHxTUPZVG0I4n9Dkc4Wcp893HuBkNo17Sga0De/4PeDjblaOojJpEsu37LytR0tdvfVJpPH3kEZXbOpztvtOsnXSqYWnWu5bbr8K0C6DRpod6hn2sFhRSr1wp2/saZJLgWC89znL4peao1ElzKL76acl5/Vh7DnGocD30Z7bjrN0BeX/m30Uz5UuTfOEt19CDyDnu7B5E3vW/lIofGdyt4uhXsepQCX9gVA2Uw5PiKr9VH9EzMzDCBrwnqJh4qNzPFIcLHjntNp0l5ih1/OJrT4x6pCxa/YHCeDrx5xB8/EwceyrF7zqzylRw3G+0cyHaQo5om2U6VH1pD2ad/3Tc3xsG2jcDXafnGzDt9dYMXy18MyQFV/u4KuP0G
\ No newline at end of file
diff --git a/src/ui/layout/components/file_list.rs b/src/ui/layout/components/file_list.rs
index 77ad081..79bf8ee 100644
--- a/src/ui/layout/components/file_list.rs
+++ b/src/ui/layout/components/file_list.rs
@@ -24,7 +24,7 @@
*/
// locals
-use super::{Component, InputEvent, Msg, Payload, Props, PropsBuilder, States, Widget};
+use super::{Component, InputEvent, Msg, Payload, Props, PropsBuilder, Render, States};
// ext
use crossterm::event::KeyCode;
use tui::{
@@ -131,7 +131,7 @@ impl Component for FileList {
///
/// Based on the current properties and states, return a Widget instance for the Component
/// Returns None if the component is hidden
- fn render(&self) -> Option> {
+ fn render(&self) -> Option {
match self.props.visible {
false => None,
true => {
@@ -152,25 +152,28 @@ impl Component for FileList {
None => String::new(),
};
// Render
- Some(Box::new(
- List::new(list_item)
- .block(
- Block::default()
- .borders(Borders::ALL)
- .border_style(match self.props.focus {
- true => Style::default().fg(self.props.foreground),
- false => Style::default(),
- })
- .title(title),
- )
- .start_corner(Corner::TopLeft)
- .highlight_style(
- Style::default()
- .bg(bg)
- .fg(fg)
- .add_modifier(self.props.get_modifiers()),
- ),
- ))
+ Some(Render {
+ widget: Box::new(
+ List::new(list_item)
+ .block(
+ Block::default()
+ .borders(Borders::ALL)
+ .border_style(match self.props.focus {
+ true => Style::default().fg(self.props.foreground),
+ false => Style::default(),
+ })
+ .title(title),
+ )
+ .start_corner(Corner::TopLeft)
+ .highlight_style(
+ Style::default()
+ .bg(bg)
+ .fg(fg)
+ .add_modifier(self.props.get_modifiers()),
+ ),
+ ),
+ value: self.get_value(),
+ })
}
}
}
@@ -247,6 +250,13 @@ impl Component for FileList {
}
}
+ /// ### get_value
+ ///
+ /// Return component value
+ fn get_value(&self) -> Payload {
+ Payload::Unumber(self.states.get_list_index())
+ }
+
// -- events
/// ### should_umount
diff --git a/src/ui/layout/components/mod.rs b/src/ui/layout/components/mod.rs
index 0cfd141..e30eb07 100644
--- a/src/ui/layout/components/mod.rs
+++ b/src/ui/layout/components/mod.rs
@@ -24,7 +24,7 @@
*/
// imports
-use super::{Component, InputEvent, Msg, Payload, Props, PropsBuilder, States, Widget};
+use super::{Component, InputEvent, Msg, Payload, Props, PropsBuilder, Render, States};
// exports
pub mod file_list;
diff --git a/src/ui/layout/mod.rs b/src/ui/layout/mod.rs
index 8c983b7..d425205 100644
--- a/src/ui/layout/mod.rs
+++ b/src/ui/layout/mod.rs
@@ -64,8 +64,8 @@ pub enum Payload {
///
/// Render is the object which contains data related to the component render
pub struct Render {
- widget: Box,
- value: Payload,
+ pub widget: Box,
+ pub value: Payload,
}
// -- States