Skip to content

Commit

Permalink
feat(node-launchpad): discord name widget styling
Browse files Browse the repository at this point in the history
Just centering the title and the input.
  • Loading branch information
mazzi authored and RolandSherwin committed May 16, 2024
1 parent 7568040 commit be20068
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions node-launchpad/src/components/discord_username.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl Component for DiscordUsernameInputBox {
Direction::Vertical,
[
// for the layer 0 border
Constraint::Length(1),
Constraint::Length(2),
// for the input field
Constraint::Min(1),
// for buttons maybe? todo
Expand All @@ -125,30 +125,24 @@ impl Component for DiscordUsernameInputBox {
.borders(Borders::ALL)
.border_type(BorderType::Double)
.border_style(Style::new().bold())
.title("Enter Discord Username"),
.title(" Enter Discord Username ")
.title_alignment(Alignment::Center),
);
f.render_widget(Clear, layer_zero);
f.render_widget(pop_up_border, layer_zero);

// layer one - 1
let width = layer_one[1].width.max(3) - 3;

let scroll = self.discord_input_filed.visual_scroll(width as usize);
let input = Paragraph::new(self.discord_input_filed.value())
.scroll((0, scroll as u16))
// border left so that it doesn't conflict with layer_zero's border
.block(
Block::default()
.borders(Borders::LEFT)
.border_type(BorderType::Double)
.border_style(Style::new().bold()),
);
let input = Paragraph::new(self.discord_input_filed.value()).alignment(Alignment::Center);

f.set_cursor(
// Put cursor past the end of the input text
layer_one[1].x
+ ((self.discord_input_filed.visual_cursor()).max(scroll) - scroll) as u16
+ 1,
layer_one[2].x
+ (layer_one[1].width / 2) as u16
+ (self.discord_input_filed.value().len() / 2) as u16
+ if self.discord_input_filed.value().len() % 2 != 0 {
1
} else {
0
},
layer_one[1].y,
);
f.render_widget(input, layer_one[1]);
Expand Down

0 comments on commit be20068

Please sign in to comment.