Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More stability fixes related to update #67

Merged
merged 2 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions crates/core/src/theme/text_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,26 @@ impl text_input::StyleSheet for Theme {
}
}

fn disabled(&self, style: &Self::Style) -> text_input::Appearance {
match style {
TextInputStyle::AddonsQuery => text_input::Appearance {
background: Background::Color(self.palette.base.foreground),
border_radius: 2.0.into(),
border_width: 1.0,
border_color: Color {
a: 0.5,
..self.palette.normal.primary
},
icon_color: Color {
a: 1.0,
..self.palette.normal.primary
}
},
_ => todo!("default"),
}
}


fn placeholder_color(&self, style: &Self::Style) -> Color {
match style {
TextInputStyle::AddonsQuery => self.palette.normal.surface,
Expand Down Expand Up @@ -74,10 +94,6 @@ impl text_input::StyleSheet for Theme {
}
}

fn disabled(&self, style: &Self::Style) -> text_input::Appearance {
todo!("default")
}

/// Produces the style of an hovered text input.
fn hovered(&self, style: &Self::Style) -> text_input::Appearance {
self.focused(style)
Expand Down
21 changes: 7 additions & 14 deletions src/gui/element/wallet/operation/chart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,8 @@ use std::{borrow::Borrow, collections::VecDeque};
const CHART_CAPTION_HEAD: u16 = 20;
const CHART_CAPTION_SUB: u16 = 12;

/*const FONT_REGULAR: Font = Font::External {
name: "sans-serif-regular",
bytes: include_bytes!("../../../../../fonts/notosans-regular.ttf"),
};

const FONT_BOLD: Font = Font::External {
name: "sans-serif-bold",
bytes: include_bytes!("../../../../../fonts/notosans-bold.ttf"),
};*/
const FONT_REGULAR: Font = Font::with_name("notosans-regular.ttf");
const FONT_BOLD: Font = Font::with_name("notosans-bold.ttf");

#[derive(Default)]
pub struct BalanceChart {
Expand All @@ -65,19 +58,19 @@ impl BalanceChart {
caption_index,
};


Container::new(
Column::new()
.width(Length::Fill)
.height(Length::Fill)
.spacing(5)
/* .push(
ChartWidget::new(chart).height(Length::Fill).resolve_font(
.push(
ChartWidget::new(chart).height(Length::Fill)/* .resolve_font(
|_, style| match style {
plotters_backend::FontStyle::Bold => FONT_BOLD,
_ => FONT_REGULAR,
},
),
),*/
},*/
),
)
.width(Length::Fill)
.height(Length::Fill)
Expand Down
31 changes: 17 additions & 14 deletions src/gui/element/wallet/operation/create_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ pub fn handle_message<'a>(
.operation_state
.show_slatepack_state
.desc = localized_string("tx-create-success-desc");

// create a directory to which files will be output, if it doesn't exist
if let Some(dir) = grin_gui.config.get_wallet_slatepack_dir() {
let out_file_name = format!("{}/{}.slatepack", dir, unencrypted_slate.id);
Expand Down Expand Up @@ -206,10 +206,10 @@ pub fn data_container<'a>(config: &'a Config, state: &'a StateContainer) -> Cont
let header_row = Row::new().push(title_container);

let header_container = Container::new(header_row).padding(iced::Padding::from([
0, // top
0, // right
0, // top
0, // right
DEFAULT_PADDING as u16, // bottom
0, // left
0, // left
]));

let recipient_address = Text::new(localized_string("recipient-address"))
Expand All @@ -219,15 +219,16 @@ pub fn data_container<'a>(config: &'a Config, state: &'a StateContainer) -> Cont
let recipient_address_container = Container::new(recipient_address)
.style(grin_gui_core::theme::ContainerStyle::NormalBackground);

let recipient_address_input = TextInput::new("", &state.recipient_address_value,/* |s| {
Interaction::WalletOperationCreateTxViewInteraction(LocalViewInteraction::RecipientAddress(
s,
))
}*/)
.size(DEFAULT_FONT_SIZE)
.padding(6)
.width(Length::Fixed(400.0))
.style(grin_gui_core::theme::TextInputStyle::AddonsQuery);
let recipient_address_input = TextInput::new("", &state.recipient_address_value)
.on_input(|s| {
Interaction::WalletOperationCreateTxViewInteraction(
LocalViewInteraction::RecipientAddress(s),
)
})
.size(DEFAULT_FONT_SIZE)
.padding(6)
.width(Length::Fixed(400.0))
.style(grin_gui_core::theme::TextInputStyle::AddonsQuery);

let recipient_address_input: Element<Interaction> = recipient_address_input.into();

Expand All @@ -250,8 +251,10 @@ pub fn data_container<'a>(config: &'a Config, state: &'a StateContainer) -> Cont
// &mut state.amount_input_state,
"",
&state.amount_value,
//|s| Interaction::WalletOperationCreateTxViewInteraction(LocalViewInteraction::Amount(s)),
)
.on_input(|s| {
Interaction::WalletOperationCreateTxViewInteraction(LocalViewInteraction::Amount(s))
})
.size(DEFAULT_FONT_SIZE)
.padding(6)
.width(Length::Fixed(100.0))
Expand Down
33 changes: 15 additions & 18 deletions src/gui/element/wallet/operation/open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,18 @@ pub fn handle_message<'a>(

LocalViewInteraction::WalletOpenError(err) => {
//grin_gui.error = err.write().unwrap().take();
// display wallet message to user
// display wallet message to user
state.wallet_message = localized_string("open-wallet-error");
err.write().unwrap().take().and_then(|e| Some(log_error(&e)));
err.write()
.unwrap()
.take()
.and_then(|e| Some(log_error(&e)));
}
}
Ok(Command::none())
}

pub fn data_container<'a>(
state: &'a StateContainer,
config: &Config,
) -> Container<'a, Message> {
pub fn data_container<'a>(state: &'a StateContainer, config: &Config) -> Container<'a, Message> {
let mut display_name_string = match config.current_wallet_index {
Some(index) => config.wallets[index].display_name.clone(),
None => "".to_owned(),
Expand All @@ -181,23 +181,21 @@ pub fn data_container<'a>(
let display_name = Text::new(display_name_string)
.size(DEFAULT_HEADER_FONT_SIZE)
.horizontal_alignment(alignment::Horizontal::Center);
let display_name_container = Container::new(display_name)
.style(grin_gui_core::theme::ContainerStyle::BrightBackground);
let display_name_container =
Container::new(display_name).style(grin_gui_core::theme::ContainerStyle::BrightBackground);

let password_column = {
let password_input = TextInput::new(
// &mut state.password_state.input_state,
&localized_string("password")[..],
&state.password_state.input_value,
/*|s| {
Interaction::WalletOperationOpenViewInteraction(
LocalViewInteraction::PasswordInput(s),
)
}*/
)
.on_submit(Interaction::WalletOperationOpenViewInteraction(
LocalViewInteraction::PasswordInputEnterPressed,
))
.on_input(|s| {
Interaction::WalletOperationOpenViewInteraction(LocalViewInteraction::PasswordInput(s))
})
.size(DEFAULT_FONT_SIZE)
.padding(6)
.style(grin_gui_core::theme::TextInputStyle::AddonsQuery)
Expand All @@ -219,7 +217,8 @@ pub fn data_container<'a>(

let description_container = Container::new(description)
.width(Length::Fixed(INPUT_WIDTH))
.style(grin_gui_core::theme::ContainerStyle::NormalBackground).padding(6);
.style(grin_gui_core::theme::ContainerStyle::NormalBackground)
.padding(6);

let submit_button_label_container =
Container::new(Text::new(localized_string("open")).size(DEFAULT_FONT_SIZE))
Expand Down Expand Up @@ -277,16 +276,14 @@ pub fn data_container<'a>(
let input_container = Container::new(
Column::new()
.push(description_container)
.push(Space::with_height(Length::Fixed(UNIT_SPACE/2.0)))
.push(Space::with_height(Length::Fixed(UNIT_SPACE / 2.0)))
.push(password_column),
)
.width(Length::Fixed(INPUT_WIDTH));

let column = Column::new()
.push(display_name_container)
.push(Space::with_height(Length::Fixed(
UNIT_SPACE,
)))
.push(Space::with_height(Length::Fixed(UNIT_SPACE)))
.push(input_container)
.push(Space::with_height(Length::Fixed(
UNIT_SPACE + DEFAULT_PADDING,
Expand Down
8 changes: 5 additions & 3 deletions src/gui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use grin_gui_core::{
node::{NodeInterface, subscriber::{self, UIMessage}, ChainTypes},
};

use iced::{alignment, Alignment, Application, Command, Length, Subscription, Settings, window};
use iced::{alignment, font, Alignment, Application, Command, Length, Subscription, Settings, window};
use iced::widget::{
button, pick_list, scrollable, text_input, Checkbox, Space, TextInput,
};
Expand Down Expand Up @@ -128,6 +128,7 @@ pub enum Message {
Interaction(Interaction),
Tick(chrono::DateTime<chrono::Local>),
RuntimeEvent(iced_core::Event),
FontLoaded(Result<(), font::Error>),
None(()),
}

Expand Down Expand Up @@ -173,8 +174,9 @@ impl Application for GrinGui {
}*/

apply_config(&mut grin_gui, config);

(grin_gui, Command::batch(vec![]))
let load_font_reg = iced::font::load(include_bytes!("../../fonts/notosans-regular.ttf").as_slice()).map(Message::FontLoaded);
let load_font_bold = iced::font::load(include_bytes!("../../fonts/notosans-bold.ttf").as_slice()).map(Message::FontLoaded);
(grin_gui, Command::batch(vec![load_font_reg, load_font_bold]))
}

fn title(&self) -> String {
Expand Down
1 change: 1 addition & 0 deletions src/gui/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ pub fn handle_message(grin_gui: &mut GrinGui, message: Message) -> Result<Comman
}

match message {
Message::FontLoaded(f)=> {debug!("Font Loaded: {:?}", f)},
// Ticks, for stuff that happens frequently, like checking wallet status
Message::Tick(time) => {
// Call all views 'registered' for ticks
Expand Down