-
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.
Add launch_configurations and sdk_version component
- Loading branch information
Showing
9 changed files
with
350 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
use std::sync::Arc; | ||
|
||
use crossterm::event::{KeyCode, KeyEvent}; | ||
use ratatui::prelude::Rect; | ||
use ratatui::{prelude::*, widgets::*}; | ||
use redux_rs::Selector; | ||
use tokio::sync::mpsc::UnboundedSender; | ||
|
||
use crate::action::TuiAction; | ||
use crate::redux::action::Action; | ||
use crate::redux::selector::selected_device::selected_device_selector; | ||
use crate::redux::state::{Home, PopUp, State}; | ||
use crate::redux::thunk::ThunkAction; | ||
use crate::redux::ActionOrThunk; | ||
use crate::tui::Frame; | ||
use color_eyre::eyre::{eyre, Result}; | ||
use daemon::flutter::FlutterDaemon; | ||
|
||
use super::Component; | ||
|
||
#[derive(Default)] | ||
pub struct LaunchConfigurationsComponent { | ||
action_tx: Option<UnboundedSender<ActionOrThunk>>, | ||
} | ||
|
||
impl LaunchConfigurationsComponent { | ||
pub fn new() -> Self { | ||
Self::default() | ||
} | ||
} | ||
|
||
impl Component for LaunchConfigurationsComponent { | ||
fn draw(&mut self, f: &mut Frame<'_>, area: Rect, state: &State) { | ||
let items = state | ||
.launch_configurations | ||
.iter() | ||
.enumerate() | ||
.flat_map(|(index, config)| { | ||
let mut items = vec![ListItem::new(format!(" {} ", config.name.clone())).bold()]; | ||
if let Some(program) = &config.program { | ||
items.push(ListItem::new(Line::from(vec![ | ||
Span::from(" Program ").style(Style::default().fg(Color::Yellow)), | ||
Span::from(program), | ||
]))); | ||
} | ||
if let Some(mode) = &config.flutter_mode { | ||
items.push(ListItem::new(Line::from(vec![ | ||
Span::from(" Mode ").style(Style::default().fg(Color::Yellow)), | ||
Span::from(mode), | ||
]))); | ||
} | ||
if let Some(cwd) = &config.cwd { | ||
items.push(ListItem::new(Line::from(vec![ | ||
Span::from(" Directory ").style(Style::default().fg(Color::Yellow)), | ||
Span::from(cwd), | ||
]))); | ||
} | ||
if let Some(args) = &config.args { | ||
items.push(ListItem::new(Line::from(vec![ | ||
Span::from(" Args ").style(Style::default().fg(Color::Yellow)), | ||
Span::from(args.join(" ")), | ||
]))); | ||
} | ||
items | ||
}) | ||
.collect::<Vec<_>>(); | ||
|
||
let block = Block::default() | ||
.title("Launch configurations (from .vscode/launch.json)") | ||
.borders(Borders::ALL) | ||
.border_type(BorderType::Rounded); | ||
|
||
let list = List::new(items).block(block); | ||
|
||
f.render_widget(list, area); | ||
} | ||
} |
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,88 @@ | ||
use std::sync::Arc; | ||
|
||
use crossterm::event::{KeyCode, KeyEvent}; | ||
use ratatui::prelude::Rect; | ||
use ratatui::{prelude::*, widgets::*}; | ||
use redux_rs::Selector; | ||
use tokio::sync::mpsc::UnboundedSender; | ||
|
||
use crate::action::TuiAction; | ||
use crate::redux::action::Action; | ||
use crate::redux::selector::selected_device::selected_device_selector; | ||
use crate::redux::state::{Home, PopUp, State}; | ||
use crate::redux::thunk::ThunkAction; | ||
use crate::redux::ActionOrThunk; | ||
use crate::tui::Frame; | ||
use color_eyre::eyre::{eyre, Result}; | ||
use daemon::flutter::FlutterDaemon; | ||
|
||
use super::Component; | ||
|
||
#[derive(Default)] | ||
pub struct SdkVersionComponent {} | ||
|
||
impl SdkVersionComponent { | ||
pub fn new() -> Self { | ||
Self::default() | ||
} | ||
} | ||
|
||
impl Component for SdkVersionComponent { | ||
fn draw(&mut self, f: &mut Frame<'_>, area: Rect, state: &State) { | ||
let block = Block::default() | ||
.title("SDK Version") | ||
.borders(Borders::ALL) | ||
.padding(Padding::horizontal(1)) | ||
.border_type(BorderType::Rounded); | ||
|
||
let Some(version) = state.sdk_version.as_ref() else { | ||
f.render_widget(block.clone(), area); | ||
return; | ||
}; | ||
|
||
let widths = [Constraint::Length(21), Constraint::Fill(1)]; | ||
|
||
let rows = vec![ | ||
Row::new(vec![ | ||
Cell::from("Flutter Version").style(Style::default().fg(Color::Yellow)), | ||
Cell::from(version.flutter_version.clone()), | ||
]), | ||
Row::new(vec![ | ||
Cell::from("Framework Version").style(Style::default().fg(Color::Yellow)), | ||
Cell::from(version.framework_version.clone()), | ||
]), | ||
Row::new(vec![ | ||
Cell::from("Channel").style(Style::default().fg(Color::Yellow)), | ||
Cell::from(version.channel.clone()), | ||
]), | ||
Row::new(vec![ | ||
Cell::from("Repository URL").style(Style::default().fg(Color::Yellow)), | ||
Cell::from(version.repository_url.clone()), | ||
]), | ||
Row::new(vec![ | ||
Cell::from("Framework Revision").style(Style::default().fg(Color::Yellow)), | ||
Cell::from(version.framework_revision.clone()), | ||
]), | ||
Row::new(vec![ | ||
Cell::from("Framework Commit Date").style(Style::default().fg(Color::Yellow)), | ||
Cell::from(version.framework_commit_date.clone()), | ||
]), | ||
Row::new(vec![ | ||
Cell::from("Engine Revision").style(Style::default().fg(Color::Yellow)), | ||
Cell::from(version.engine_revision.clone()), | ||
]), | ||
Row::new(vec![ | ||
Cell::from("Dart SDK Version").style(Style::default().fg(Color::Yellow)), | ||
Cell::from(version.dart_sdk_version.clone()), | ||
]), | ||
Row::new(vec![ | ||
Cell::from("Flutter Root").style(Style::default().fg(Color::Yellow)), | ||
Cell::from(version.flutter_root.clone()), | ||
]), | ||
]; | ||
|
||
let table = Table::new(rows, widths).block(block); | ||
|
||
f.render_widget(table, area); | ||
} | ||
} |
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
Oops, something went wrong.