mirror of
https://github.com/pcvolkmer/cert-tools.git
synced 2025-04-19 17:06:49 +00:00
chore: use text_input to prevent line wrap
This commit is contained in:
parent
41ba88c0b6
commit
741f15b7e1
@ -2,10 +2,11 @@
|
|||||||
|
|
||||||
use cert_tools::{Chain, PrivateKey};
|
use cert_tools::{Chain, PrivateKey};
|
||||||
use iced::border::Radius;
|
use iced::border::Radius;
|
||||||
|
use iced::widget::text::Shaping;
|
||||||
use iced::widget::text_editor::{default, Content, Status};
|
use iced::widget::text_editor::{default, Content, Status};
|
||||||
use iced::widget::{
|
use iced::widget::{
|
||||||
button, column, container, horizontal_rule, horizontal_space, row, text, text_editor,
|
button, column, container, horizontal_rule, horizontal_space, row, text, text_editor,
|
||||||
Container, Scrollable,
|
text_input, Container, Scrollable,
|
||||||
};
|
};
|
||||||
use iced::{
|
use iced::{
|
||||||
alignment, application, clipboard, color, Background, Border, Color, Element, Font, Length,
|
alignment, application, clipboard, color, Background, Border, Color, Element, Font, Length,
|
||||||
@ -239,32 +240,39 @@ impl Ui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn view(&self) -> Element<Message> {
|
fn view(&self) -> Element<Message> {
|
||||||
fn grey_style() -> text::Style {
|
fn filename_text<'a>(
|
||||||
text::Style {
|
placeholder: &'a str,
|
||||||
color: Some(color!(0x888888)),
|
file: &'a File,
|
||||||
}
|
) -> text_input::TextInput<'a, Message> {
|
||||||
}
|
let text = match file {
|
||||||
|
File::Invalid(ref file)
|
||||||
|
| File::Certificates(ref file, _)
|
||||||
|
| File::PrivateKey(ref file, _) => file.display().to_string(),
|
||||||
|
_ => String::new(),
|
||||||
|
};
|
||||||
|
|
||||||
fn red_style() -> text::Style {
|
match file {
|
||||||
text::Style {
|
File::Certificates(_, _) | File::PrivateKey(_, _) => text_input(placeholder, &text),
|
||||||
color: Some(color!(0xaa0000)),
|
File::Invalid(_) => text_input(placeholder, &text),
|
||||||
|
_ => text_input(placeholder, &text),
|
||||||
}
|
}
|
||||||
|
.width(Length::Fill)
|
||||||
|
.style(move |theme, status| text_input::Style {
|
||||||
|
background: Background::Color(Color::WHITE),
|
||||||
|
placeholder: color!(0x888888),
|
||||||
|
value: match file {
|
||||||
|
File::Certificates(_, _) | File::PrivateKey(_, _) => Color::BLACK,
|
||||||
|
File::Invalid(_) => color!(0xaa0000),
|
||||||
|
File::None => color!(0x888888),
|
||||||
|
},
|
||||||
|
..text_input::default(theme, status)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let cert_file_input = {
|
let cert_file_input = {
|
||||||
row![
|
row![
|
||||||
text("Certificate: ").width(100),
|
text("Certificate: ").width(100),
|
||||||
text(match self.cert_file {
|
filename_text("No certificate file", &self.cert_file),
|
||||||
File::Invalid(ref file) | File::Certificates(ref file, _) =>
|
|
||||||
file.display().to_string(),
|
|
||||||
_ => "No certificate file".to_string(),
|
|
||||||
})
|
|
||||||
.style(|_| match self.cert_file {
|
|
||||||
File::Certificates(_, _) => text::Style::default(),
|
|
||||||
File::Invalid(_) => red_style(),
|
|
||||||
_ => grey_style(),
|
|
||||||
}),
|
|
||||||
horizontal_space(),
|
|
||||||
if self.cert_file.is_some() {
|
if self.cert_file.is_some() {
|
||||||
button("x")
|
button("x")
|
||||||
.on_press(Message::ClearCertFile)
|
.on_press(Message::ClearCertFile)
|
||||||
@ -283,17 +291,7 @@ impl Ui {
|
|||||||
let ca_file_input = {
|
let ca_file_input = {
|
||||||
row![
|
row![
|
||||||
text("CA: ").width(100),
|
text("CA: ").width(100),
|
||||||
text(match self.ca_file {
|
filename_text("No CA file", &self.ca_file),
|
||||||
File::Invalid(ref file) | File::Certificates(ref file, _) =>
|
|
||||||
file.display().to_string(),
|
|
||||||
_ => "No CA file".to_string(),
|
|
||||||
})
|
|
||||||
.style(|_| match self.ca_file {
|
|
||||||
File::Certificates(_, _) => text::Style::default(),
|
|
||||||
File::Invalid(_) => red_style(),
|
|
||||||
_ => grey_style(),
|
|
||||||
}),
|
|
||||||
horizontal_space(),
|
|
||||||
if self.ca_file.is_some() {
|
if self.ca_file.is_some() {
|
||||||
button("x")
|
button("x")
|
||||||
.on_press(Message::ClearCaFile)
|
.on_press(Message::ClearCaFile)
|
||||||
@ -316,17 +314,7 @@ impl Ui {
|
|||||||
let key_file_input = {
|
let key_file_input = {
|
||||||
row![
|
row![
|
||||||
text("Key: ").width(100),
|
text("Key: ").width(100),
|
||||||
text(match self.key_file {
|
filename_text("No key file", &self.key_file),
|
||||||
File::Invalid(ref file) | File::PrivateKey(ref file, _) =>
|
|
||||||
file.display().to_string(),
|
|
||||||
_ => "No key file".to_string(),
|
|
||||||
})
|
|
||||||
.style(|_| match self.key_file {
|
|
||||||
File::PrivateKey(_, _) => text::Style::default(),
|
|
||||||
File::Invalid(_) => red_style(),
|
|
||||||
_ => grey_style(),
|
|
||||||
}),
|
|
||||||
horizontal_space(),
|
|
||||||
if self.key_file.is_some() {
|
if self.key_file.is_some() {
|
||||||
button("x")
|
button("x")
|
||||||
.on_press(Message::ClearKeyFile)
|
.on_press(Message::ClearKeyFile)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user