Showcase new TextInput::password in tour
This commit is contained in:
parent
34bdfe9416
commit
cdee847cea
1 changed files with 33 additions and 11 deletions
|
|
@ -140,6 +140,7 @@ impl Steps {
|
||||||
Step::Scrollable,
|
Step::Scrollable,
|
||||||
Step::TextInput {
|
Step::TextInput {
|
||||||
value: String::new(),
|
value: String::new(),
|
||||||
|
is_secure: false,
|
||||||
state: text_input::State::new(),
|
state: text_input::State::new(),
|
||||||
},
|
},
|
||||||
Step::Debugger,
|
Step::Debugger,
|
||||||
|
|
@ -210,6 +211,7 @@ enum Step {
|
||||||
Scrollable,
|
Scrollable,
|
||||||
TextInput {
|
TextInput {
|
||||||
value: String,
|
value: String,
|
||||||
|
is_secure: bool,
|
||||||
state: text_input::State,
|
state: text_input::State,
|
||||||
},
|
},
|
||||||
Debugger,
|
Debugger,
|
||||||
|
|
@ -226,6 +228,7 @@ pub enum StepMessage {
|
||||||
LanguageSelected(Language),
|
LanguageSelected(Language),
|
||||||
ImageWidthChanged(f32),
|
ImageWidthChanged(f32),
|
||||||
InputChanged(String),
|
InputChanged(String),
|
||||||
|
ToggleSecureInput(bool),
|
||||||
DebugToggled(bool),
|
DebugToggled(bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -277,6 +280,12 @@ impl<'a> Step {
|
||||||
*value = new_value;
|
*value = new_value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StepMessage::ToggleSecureInput(toggle) => {
|
||||||
|
if let Step::TextInput { is_secure, .. } = self {
|
||||||
|
*is_secure = toggle;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -328,7 +337,11 @@ impl<'a> Step {
|
||||||
spacing,
|
spacing,
|
||||||
} => Self::rows_and_columns(*layout, spacing_slider, *spacing),
|
} => Self::rows_and_columns(*layout, spacing_slider, *spacing),
|
||||||
Step::Scrollable => Self::scrollable(),
|
Step::Scrollable => Self::scrollable(),
|
||||||
Step::TextInput { value, state } => Self::text_input(value, state),
|
Step::TextInput {
|
||||||
|
value,
|
||||||
|
is_secure,
|
||||||
|
state,
|
||||||
|
} => Self::text_input(value, *is_secure, state),
|
||||||
Step::Debugger => Self::debugger(debug),
|
Step::Debugger => Self::debugger(debug),
|
||||||
Step::End => Self::end(),
|
Step::End => Self::end(),
|
||||||
}
|
}
|
||||||
|
|
@ -582,22 +595,31 @@ impl<'a> Step {
|
||||||
|
|
||||||
fn text_input(
|
fn text_input(
|
||||||
value: &str,
|
value: &str,
|
||||||
|
is_secure: bool,
|
||||||
state: &'a mut text_input::State,
|
state: &'a mut text_input::State,
|
||||||
) -> Column<'a, StepMessage> {
|
) -> Column<'a, StepMessage> {
|
||||||
|
let text_input = TextInput::new(
|
||||||
|
state,
|
||||||
|
"Type something to continue...",
|
||||||
|
value,
|
||||||
|
StepMessage::InputChanged,
|
||||||
|
)
|
||||||
|
.padding(10)
|
||||||
|
.size(30);
|
||||||
Self::container("Text input")
|
Self::container("Text input")
|
||||||
.push(Text::new(
|
.push(Text::new(
|
||||||
"Use a text input to ask for different kinds of information.",
|
"Use a text input to ask for different kinds of information.",
|
||||||
))
|
))
|
||||||
.push(
|
.push(if is_secure {
|
||||||
TextInput::new(
|
text_input.password()
|
||||||
state,
|
} else {
|
||||||
"Type something to continue...",
|
text_input
|
||||||
value,
|
})
|
||||||
StepMessage::InputChanged,
|
.push(Checkbox::new(
|
||||||
)
|
is_secure,
|
||||||
.padding(10)
|
"Enable password mode",
|
||||||
.size(30),
|
StepMessage::ToggleSecureInput,
|
||||||
)
|
))
|
||||||
.push(Text::new(
|
.push(Text::new(
|
||||||
"A text input produces a message every time it changes. It is \
|
"A text input produces a message every time it changes. It is \
|
||||||
very easy to keep track of its contents:",
|
very easy to keep track of its contents:",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue