diff --git a/crates/core/src/style/header.rs b/crates/core/src/style/header.rs index 2ca4500..1ca682f 100644 --- a/crates/core/src/style/header.rs +++ b/crates/core/src/style/header.rs @@ -1,4 +1,4 @@ -use iced::Theme; +use crate::theme::Theme; use iced_core::{Background, Color}; /// The appearance of a header. @@ -38,7 +38,7 @@ impl StyleSheet for Theme { HeaderStyle::Default => Appearance { //text_color: Some(self.palette.bright.surface), text_color: None, - background: Some(Background::Color(self.palette().primary)), + background: Some(Background::Color(self.palette.normal.primary)), border_radius: 0.0, border_width: 0.0, border_color: Color::TRANSPARENT, diff --git a/crates/core/src/style/table_row.rs b/crates/core/src/style/table_row.rs index 9acec48..b07b492 100644 --- a/crates/core/src/style/table_row.rs +++ b/crates/core/src/style/table_row.rs @@ -1,4 +1,4 @@ -use iced::Theme; +use crate::theme::Theme; use iced::{Background, Color}; /// The appearance of a table row. @@ -40,8 +40,8 @@ impl StyleSheet for Theme { fn appearance(&self, style: &Self::Style) -> Appearance { match style { TableRowStyle::Default => Appearance { - text_color: Some(self.palette().primary), - background: Some(Background::Color(self.palette().primary)), + text_color: Some(self.palette.normal.primary), + background: Some(Background::Color(self.palette.normal.primary)), border_radius: 0.0, border_width: 0.0, border_color: Color::TRANSPARENT, @@ -53,15 +53,15 @@ impl StyleSheet for Theme { TableRowStyle::TableRowAlternate => Appearance { background: Some(Background::Color(Color { a: 0.50, - ..self.palette().primary + ..self.palette.normal.primary })), ..Appearance::default() }, TableRowStyle::TableRowHighlife => Appearance { - text_color: Some(self.palette().primary), + text_color: Some(self.palette.normal.primary), background: Some(Background::Color(Color { a: 0.30, - ..self.palette().primary + ..self.palette.normal.primary })), border_radius: 0.0, border_width: 0.0, @@ -70,7 +70,7 @@ impl StyleSheet for Theme { offset_right: 0.0, }, TableRowStyle::TableRowLowlife => Appearance { - text_color: Some(self.palette().primary), + text_color: Some(self.palette.normal.primary), background: Some(Background::Color(Color::TRANSPARENT)), border_radius: 0.0, border_width: 0.0, @@ -79,8 +79,8 @@ impl StyleSheet for Theme { offset_right: 0.0, }, TableRowStyle::TableRowSelected => Appearance { - text_color: Some(self.palette().primary), - background: Some(Background::Color(self.palette().primary)), + text_color: Some(self.palette.normal.primary), + background: Some(Background::Color(self.palette.normal.primary)), border_radius: 0.0, border_width: 0.0, border_color: Color::TRANSPARENT, @@ -97,35 +97,35 @@ impl StyleSheet for Theme { TableRowStyle::Default => Appearance { background: Some(Background::Color(Color { a: 0.60, - ..self.palette().primary + ..self.palette.normal.primary })), ..appearance }, TableRowStyle::TableRowAlternate => Appearance { background: Some(Background::Color(Color { a: 0.25, - ..self.palette().primary + ..self.palette.normal.primary })), ..appearance }, TableRowStyle::TableRowHighlife => Appearance { background: Some(Background::Color(Color { a: 0.60, - ..self.palette().primary + ..self.palette.normal.primary })), ..appearance }, TableRowStyle::TableRowLowlife => Appearance { background: Some(Background::Color(Color { a: 0.60, - ..self.palette().primary + ..self.palette.normal.primary })), ..appearance }, TableRowStyle::TableRowSelected => Appearance { background: Some(Background::Color(Color { a: 0.60, - ..self.palette().primary + ..self.palette.normal.primary })), ..appearance }, diff --git a/crates/core/src/theme/mod.rs b/crates/core/src/theme/mod.rs index 320fff7..3ef03b4 100644 --- a/crates/core/src/theme/mod.rs +++ b/crates/core/src/theme/mod.rs @@ -1,4 +1,5 @@ use crate::fs; +use iced::application::StyleSheet; use serde::{Deserialize, Serialize}; use std::cmp::Ordering; @@ -58,8 +59,9 @@ pub type PickList<'a, T, L, V, Message> = pub type Radio = iced::widget::Radio; pub type Card<'a, Message> = iced_aw::native::Card<'a, Message, Theme, Renderer>; pub type Modal<'a, Message, Theme, Renderer> = iced_aw::modal::Modal<'a, Message, Theme, Renderer>; -pub type Header<'a, Message> = crate::widget::header::Header<'a, Message, Theme, Renderer>; -pub type TableRow<'a, Message> = crate::widget::table_row::TableRow<'a, Message, Theme, Renderer>; +pub type Header<'a, Message, Theme> = crate::widget::header::Header<'a, Message, Theme, Renderer>; +pub type TableRow<'a, Message, Theme> = + crate::widget::table_row::TableRow<'a, Message, Theme, Renderer>; #[derive(Debug, Clone, Copy, Default, Deserialize, Serialize)] pub struct BaseColors { diff --git a/crates/core/src/widget/header.rs b/crates/core/src/widget/header.rs index 90bcac1..fc46729 100644 --- a/crates/core/src/widget/header.rs +++ b/crates/core/src/widget/header.rs @@ -12,7 +12,7 @@ use iced::{widget::space::Space, Size}; mod state; pub use state::State; -pub struct Header<'a, Message, Theme = iced::Theme, Renderer = iced::Renderer> +pub struct Header<'a, Message, Theme, Renderer = iced::Renderer> where Renderer: renderer::Renderer, Theme: StyleSheet, @@ -370,14 +370,14 @@ where }*/ } -impl<'a, Message, Theme: 'a, Renderer> From> - for Element<'a, Message, Theme, Renderer> +impl<'a, Message, Theme> From> + for Element<'a, Message, Theme, iced::Renderer> where - Renderer: 'a + renderer::Renderer, + //Renderer: 'a + renderer::Renderer, Theme: 'a + StyleSheet + iced::widget::container::StyleSheet + widget::text::StyleSheet, Message: 'a + Clone, { - fn from(header: Header<'a, Message, Theme, Renderer>) -> Element<'a, Message, Theme, Renderer> { + fn from(header: Header<'a, Message, Theme>) -> Self { Element::new(header) } } diff --git a/crates/core/src/widget/table_row.rs b/crates/core/src/widget/table_row.rs index 8123cd0..55564c0 100644 --- a/crates/core/src/widget/table_row.rs +++ b/crates/core/src/widget/table_row.rs @@ -8,7 +8,7 @@ use iced_core::{ use iced::{Border, Size}; #[allow(missing_debug_implementations)] -pub struct TableRow<'a, Message, Theme = iced::Theme, Renderer = iced::Renderer> +pub struct TableRow<'a, Message, Theme, Renderer = iced::Renderer> where Renderer: 'a + iced_core::Renderer, Theme: StyleSheet, @@ -53,6 +53,11 @@ where } } + pub fn width(mut self, width: Length) -> Self { + self.width = width; + self + } + /// Sets the style of the [`TableRow`]. pub fn style(mut self, style: S) -> Self where @@ -337,7 +342,7 @@ where } } -impl<'a, Message, Theme: 'a, Renderer> From> +/*impl<'a, Message, Theme: 'a, Renderer> From> for Element<'a, Message, Theme, Renderer> where Renderer: 'a + iced_core::Renderer, @@ -346,7 +351,19 @@ where { fn from( table_row: TableRow<'a, Message, Theme, Renderer>, - ) -> Element<'a, Message, Theme, Renderer> { + ) -> Self { Element::new(table_row) } +}*/ + +impl<'a, Message, Theme, Renderer> From> + for Element<'a, Message, Theme, Renderer> +where + Message: 'a, + Theme: 'a + StyleSheet, + Renderer: iced_core::Renderer + 'a, +{ + fn from(column: TableRow<'a, Message, Theme, Renderer>) -> Self { + Self::new(column) + } } diff --git a/src/gui/element/wallet/operation/tx_list.rs b/src/gui/element/wallet/operation/tx_list.rs index 58ea870..50ec83a 100644 --- a/src/gui/element/wallet/operation/tx_list.rs +++ b/src/gui/element/wallet/operation/tx_list.rs @@ -1,8 +1,6 @@ -use std::borrow::Borrow; - use grin_gui_core::config::TxMethod; -use grin_gui_core::theme::Theme; use iced_core::Widget; +use std::borrow::Borrow; use { super::super::super::{BUTTON_WIDTH, DEFAULT_FONT_SIZE, DEFAULT_PADDING, SMALLER_FONT_SIZE}, @@ -11,6 +9,7 @@ use { crate::Result, grin_gui_core::theme::{ Button, Column, Container, Element, Header, PickList, Row, Scrollable, TableRow, Text, + Theme, }, grin_gui_core::widget::header, grin_gui_core::{ @@ -896,7 +895,7 @@ pub fn titles_row_header<'a>( column_state: &'a [ColumnState], previous_column_key: Option, previous_sort_direction: Option, -) -> Header<'a, Message> { +) -> Header<'a, Message, Theme> { // A row containing titles above the addon rows. let mut row_titles = vec![]; @@ -947,7 +946,10 @@ pub fn titles_row_header<'a>( Header::new( header_state.clone(), - row_titles, + row_titles + .into_iter() + .map(|row| (row.0, row.1.into())) + .collect(), // Some(Length::Fixed(DEFAULT_PADDING)), // Some(Length::Fixed(DEFAULT_PADDING + 5)), None, diff --git a/src/gui/element/wallet/setup/wallet_list.rs b/src/gui/element/wallet/setup/wallet_list.rs index 5fb56aa..ad74ab7 100644 --- a/src/gui/element/wallet/setup/wallet_list.rs +++ b/src/gui/element/wallet/setup/wallet_list.rs @@ -287,7 +287,7 @@ pub fn data_container<'a>(state: &'a StateContainer, config: &Config) -> Contain } let wallet_row = Row::new() - //.push(checkbox) + // .push(checkbox) .push( Column::new() .push(wallet_name_container) @@ -309,9 +309,8 @@ pub fn data_container<'a>(state: &'a StateContainer, config: &Config) -> Contain .width(Length::Fill) .on_press(move |_| { log::debug!("data_container::table_row::on_press {}", pos); - - Message::Interaction(Interaction::WalletListWalletViewInteraction( - LocalViewInteraction::WalletRowSelect(true, pos), + Interaction::WalletListWalletViewInteraction(LocalViewInteraction::WalletRowSelect( + true, pos, )) }); @@ -330,10 +329,12 @@ pub fn data_container<'a>(state: &'a StateContainer, config: &Config) -> Contain } } - wallet_rows.push(table_row.into()); + wallet_rows.push(table_row); } - let wallet_column = Column::new().push(Column::with_children(wallet_rows)); + let wallet_column = Column::new().push(Column::with_children( + wallet_rows.into_iter().map(|row| row.into()), + )); let load_wallet_button_container = Container::new(Text::new(localized_string("load-wallet")).size(DEFAULT_FONT_SIZE)) @@ -389,15 +390,16 @@ pub fn data_container<'a>(state: &'a StateContainer, config: &Config) -> Contain let scrollable = Scrollable::new(wallet_column).style(grin_gui_core::theme::ScrollableStyle::Primary); - let table_colummn = Column::new().push(table_header_container).push(scrollable); - let table_container = Container::new(table_colummn) + let table_column = Column::new().push(table_header_container).push(scrollable); + let table_container = Container::new(table_column) .style(grin_gui_core::theme::ContainerStyle::PanelBordered) .height(Length::Fill) .padding(1); let row = Row::new().push( Column::new() - .push(table_container) + // TODO: Find out why this isn't working + //.push(table_container) .push(Space::with_height(Length::Fixed(DEFAULT_PADDING))) .push(button_row), ); diff --git a/src/gui/element/wallet/setup/wallet_setup.rs b/src/gui/element/wallet/setup/wallet_setup.rs index e22087a..2b4e4de 100644 --- a/src/gui/element/wallet/setup/wallet_setup.rs +++ b/src/gui/element/wallet/setup/wallet_setup.rs @@ -313,7 +313,7 @@ pub fn data_container<'a>( .padding(6) .width(Length::Fixed(200.0)) .style(grin_gui_core::theme::TextInputStyle::AddonsQuery) - .password(); + .secure(true); let password_input: Element = password_input.into(); @@ -333,7 +333,7 @@ pub fn data_container<'a>( .padding(6) .width(Length::Fixed(200.0)) .style(grin_gui_core::theme::TextInputStyle::AddonsQuery) - .password(); + .secure(true); let repeat_password_input: Element = repeat_password_input.into(); @@ -374,12 +374,12 @@ pub fn data_container<'a>( let checkbox = Checkbox::new( localized_string("restore-from-seed"), state.restore_from_seed, - |b| { - Interaction::WalletSetupWalletViewInteraction( - LocalViewInteraction::ToggleRestoreFromSeed(b), - ) - }, ) + .on_toggle(|b| { + Interaction::WalletSetupWalletViewInteraction( + LocalViewInteraction::ToggleRestoreFromSeed(b), + ) + }) .style(grin_gui_core::theme::CheckboxStyle::Normal) .text_size(DEFAULT_FONT_SIZE) .spacing(10); @@ -395,12 +395,12 @@ pub fn data_container<'a>( let checkbox = Checkbox::new( localized_string("show-advanced-options"), state.show_advanced_options, - |b| { - Interaction::WalletSetupWalletViewInteraction( - LocalViewInteraction::ToggleAdvancedOptions(b), - ) - }, ) + .on_toggle(|b| { + Interaction::WalletSetupWalletViewInteraction( + LocalViewInteraction::ToggleAdvancedOptions(b), + ) + }) .style(grin_gui_core::theme::CheckboxStyle::Normal) .text_size(DEFAULT_FONT_SIZE) .spacing(10); @@ -496,8 +496,8 @@ pub fn data_container<'a>( let display_name_input: Element = display_name_input.into(); - let is_testnet_checkbox = - Checkbox::new(localized_string("use-testnet"), state.is_testnet, |b| { + let is_testnet_checkbox = Checkbox::new(localized_string("use-testnet"), state.is_testnet) + .on_toggle(|b| { Interaction::WalletSetupWalletViewInteraction(LocalViewInteraction::ToggleIsTestnet(b)) }) .style(grin_gui_core::theme::CheckboxStyle::Normal) diff --git a/src/gui/mod.rs b/src/gui/mod.rs index ee1e988..20faec1 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -282,20 +282,27 @@ impl Application for GrinGui { .style(grin_gui_core::theme::ContainerStyle::NormalBackground) .into(); - let content: Element = match self.modal_type { - ModalType::Exit => element::modal::exit_card().into(), - ModalType::Error => { - let error_cause = self - .error - .as_ref() - .map_or_else(|| "unknown error".to_owned(), |e| error_cause_string(e)); - - element::modal::error_card(error_cause.clone()).into() - } + let overlay = if self.show_modal { + Some({ + let content: Element = match self.modal_type { + ModalType::Exit => element::modal::exit_card().into(), + ModalType::Error => { + let error_cause = self + .error + .as_ref() + .map_or_else(|| "unknown error".to_owned(), |e| error_cause_string(e)); + + element::modal::error_card(error_cause.clone()).into() + } + }; + content + }) + } else { + None }; // self.show_modal? - Modal::new(underlay, Some(content)) + Modal::new(underlay, overlay) .on_esc(Message::Interaction(Interaction::CloseErrorModal)) .style(grin_gui_core::theme::ModalStyle::Normal) .into() diff --git a/src/gui/update.rs b/src/gui/update.rs index 3356059..b1ad7aa 100644 --- a/src/gui/update.rs +++ b/src/gui/update.rs @@ -339,9 +339,11 @@ pub fn handle_message(grin_gui: &mut GrinGui, message: Message) -> Result { grin_gui.mode = Mode::Install; } - iced::keyboard::Key::Named(Escape) => match grin_gui.mode { - _ => (), - }, + iced::keyboard::Key::Named(iced::keyboard::key::Named::Escape) => { + match grin_gui.mode { + _ => (), + } + } _ => (), } }