diff --git a/src/ui/widget/common.rs b/src/ui/widget/common.rs
index 7947fd3c..bfad2f5f 100644
--- a/src/ui/widget/common.rs
+++ b/src/ui/widget/common.rs
@@ -1,5 +1,6 @@
pub mod container;
pub mod context;
+pub mod form;
pub mod label;
pub mod list;
diff --git a/src/ui/widget/common/form.rs b/src/ui/widget/common/form.rs
new file mode 100644
index 00000000..88940abb
--- /dev/null
+++ b/src/ui/widget/common/form.rs
@@ -0,0 +1,83 @@
+use tui_realm_stdlib::Input;
+use tuirealm::command::{Cmd, CmdResult};
+use tuirealm::tui::layout::{Constraint, Direction, Rect};
+use tuirealm::{AttrValue, Attribute, Frame, MockComponent, Props, State};
+
+use crate::ui::state::FormState;
+use crate::ui::theme::Theme;
+use crate::ui::widget::WidgetComponent;
+
+pub struct Form {
+ // This form's fields: title, tags, assignees, description.
+ inputs: Vec,
+ /// State that holds the current focus etc.
+ state: FormState,
+}
+
+impl Form {
+ pub fn new(_theme: Theme, inputs: Vec) -> Self {
+ let state = FormState::new(Some(0), inputs.len());
+
+ Self { inputs, state }
+ }
+}
+
+impl WidgetComponent for Form {
+ fn view(&mut self, properties: &Props, frame: &mut Frame, area: Rect) {
+ use tuirealm::props::Layout;
+ // Clear and set current focus
+ let focus = self.state.focus().unwrap_or(0);
+ for input in &mut self.inputs {
+ input.attr(Attribute::Focus, AttrValue::Flag(false));
+ }
+ if let Some(input) = self.inputs.get_mut(focus) {
+ input.attr(Attribute::Focus, AttrValue::Flag(true));
+ }
+
+ let layout = Layout::default()
+ .direction(Direction::Vertical)
+ .constraints(
+ &self
+ .inputs
+ .iter()
+ .map(|_| Constraint::Length(3))
+ .collect::>(),
+ );
+ let layout = properties
+ .get_or(Attribute::Layout, AttrValue::Layout(layout))
+ .unwrap_layout();
+ let layout = layout.chunks(area);
+
+ for (index, area) in layout.iter().enumerate().take(self.inputs.len()) {
+ if let Some(input) = self.inputs.get_mut(index) {
+ input.view(frame, *area);
+ }
+ }
+ }
+
+ fn state(&self) -> State {
+ State::None
+ }
+
+ fn perform(&mut self, _properties: &Props, cmd: Cmd) -> CmdResult {
+ use tuirealm::command::Direction;
+ match cmd {
+ Cmd::Move(Direction::Up) => {
+ self.state.focus_previous();
+ CmdResult::None
+ }
+ Cmd::Move(Direction::Down) => {
+ self.state.focus_next();
+ CmdResult::None
+ }
+ _ => {
+ let focus = self.state.focus().unwrap_or(0);
+ if let Some(input) = self.inputs.get_mut(focus) {
+ input.perform(cmd)
+ } else {
+ CmdResult::None
+ }
+ }
+ }
+ }
+}
diff --git a/src/ui/widget/issue.rs b/src/ui/widget/issue.rs
index 758b35fe..902d34a4 100644
--- a/src/ui/widget/issue.rs
+++ b/src/ui/widget/issue.rs
@@ -11,10 +11,9 @@ use tuirealm::tui::layout::Constraint;
use tuirealm::tui::layout::Direction;
use tuirealm::tui::layout::Layout;
-use super::common::container::Container;
-use super::common::container::LabeledContainer;
-use super::common::context::ContextBar;
-use super::common::context::Progress;
+use super::common::container::{Container, LabeledContainer};
+use super::common::context::{ContextBar, Progress};
+use super::common::form::Form;
use super::common::label::Textarea;
use super::common::list::List;
use super::common::list::Property;
@@ -23,7 +22,6 @@ use super::Widget;
use crate::ui::cob;
use crate::ui::cob::IssueItem;
use crate::ui::context::Context;
-use crate::ui::state::FormState;
use crate::ui::theme::Theme;
use super::*;
@@ -252,14 +250,14 @@ impl WidgetComponent for CommentBody {
pub struct NewForm {
/// The issue this form writes its input values to.
_issue: Issue,
- // This form's fields: title, tags, assignees, description.
- inputs: Vec,
- /// State that holds the current focus etc.
- state: FormState,
+ /// The actual form.
+ form: Widget