IncomeFormState

Struct IncomeFormState 

Source
pub struct IncomeFormState {
    pub period: Option<BudgetPeriod>,
    pub focused_field: IncomeField,
    pub amount_input: String,
    pub amount_cursor: usize,
    pub notes_input: String,
    pub notes_cursor: usize,
    pub has_existing: bool,
    pub current_amount: Option<Money>,
    pub error_message: Option<String>,
}
Expand description

State for the income dialog

Fields§

§period: Option<BudgetPeriod>

The period being edited

§focused_field: IncomeField

Which field is focused

§amount_input: String

Amount input

§amount_cursor: usize

Amount cursor position

§notes_input: String

Notes input

§notes_cursor: usize

Notes cursor position

§has_existing: bool

Whether there’s an existing income expectation

§current_amount: Option<Money>

Current expected income (for display)

§error_message: Option<String>

Error message

Implementations§

Source§

impl IncomeFormState

Source

pub fn new() -> Self

Source

pub fn init_for_period(&mut self, period: &BudgetPeriod, storage: &Storage)

Initialize the dialog for a period

Source

pub fn reset(&mut self)

Reset the state

Source

pub fn set_focus(&mut self, field: IncomeField)

Set focus to a field

Source

pub fn next_field(&mut self)

Move to next field

Source

pub fn prev_field(&mut self)

Move to previous field

Source

pub fn insert_char(&mut self, c: char)

Insert character into current field

Source

pub fn backspace(&mut self)

Delete character before cursor

Source

pub fn move_left(&mut self)

Move cursor left

Source

pub fn move_right(&mut self)

Move cursor right

Source

pub fn clear_field(&mut self)

Clear current field

Source

pub fn parse_amount(&self) -> Result<Money, String>

Parse the amount input

Source

pub fn get_notes(&self) -> Option<String>

Get notes (None if empty)

Source

pub fn set_error(&mut self, msg: impl Into<String>)

Set error message

Trait Implementations§

Source§

impl Clone for IncomeFormState

Source§

fn clone(&self) -> IncomeFormState

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IncomeFormState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for IncomeFormState

Source§

fn default() -> IncomeFormState

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.