Skip to content

Commit

Permalink
now at compilation state, but many things not working
Browse files Browse the repository at this point in the history
  • Loading branch information
yeastplume committed Mar 25, 2024
1 parent 0bdcbf4 commit fa83423
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 68 deletions.
4 changes: 2 additions & 2 deletions crates/core/src/style/header.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use iced::Theme;
use crate::theme::Theme;
use iced_core::{Background, Color};

/// The appearance of a header.
Expand Down Expand Up @@ -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,
Expand Down
28 changes: 14 additions & 14 deletions crates/core/src/style/table_row.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use iced::Theme;
use crate::theme::Theme;
use iced::{Background, Color};

/// The appearance of a table row.
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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
},
Expand Down
6 changes: 4 additions & 2 deletions crates/core/src/theme/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::fs;
use iced::application::StyleSheet;
use serde::{Deserialize, Serialize};
use std::cmp::Ordering;

Expand Down Expand Up @@ -58,8 +59,9 @@ pub type PickList<'a, T, L, V, Message> =
pub type Radio<Message> = iced::widget::Radio<Message, Theme, Renderer>;
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 {
Expand Down
10 changes: 5 additions & 5 deletions crates/core/src/widget/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -370,14 +370,14 @@ where
}*/
}

impl<'a, Message, Theme: 'a, Renderer> From<Header<'a, Message, Theme, Renderer>>
for Element<'a, Message, Theme, Renderer>
impl<'a, Message, Theme> From<Header<'a, Message, Theme>>
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)
}
}
Expand Down
23 changes: 20 additions & 3 deletions crates/core/src/widget/table_row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<S>(mut self, style: S) -> Self
where
Expand Down Expand Up @@ -337,7 +342,7 @@ where
}
}

impl<'a, Message, Theme: 'a, Renderer> From<TableRow<'a, Message, Theme, Renderer>>
/*impl<'a, Message, Theme: 'a, Renderer> From<TableRow<'a, Message, Theme, Renderer>>
for Element<'a, Message, Theme, Renderer>
where
Renderer: 'a + iced_core::Renderer,
Expand All @@ -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<TableRow<'a, Message, Theme, Renderer>>
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)
}
}
12 changes: 7 additions & 5 deletions src/gui/element/wallet/operation/tx_list.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand All @@ -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::{
Expand Down Expand Up @@ -896,7 +895,7 @@ pub fn titles_row_header<'a>(
column_state: &'a [ColumnState],
previous_column_key: Option<ColumnKey>,
previous_sort_direction: Option<SortDirection>,
) -> Header<'a, Message> {
) -> Header<'a, Message, Theme> {
// A row containing titles above the addon rows.
let mut row_titles = vec![];

Expand Down Expand Up @@ -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,
Expand Down
20 changes: 11 additions & 9 deletions src/gui/element/wallet/setup/wallet_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
))
});

Expand All @@ -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))
Expand Down Expand Up @@ -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),
);
Expand Down
28 changes: 14 additions & 14 deletions src/gui/element/wallet/setup/wallet_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Interaction> = password_input.into();

Expand All @@ -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<Interaction> = repeat_password_input.into();

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -496,8 +496,8 @@ pub fn data_container<'a>(

let display_name_input: Element<Interaction> = 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)
Expand Down
Loading

0 comments on commit fa83423

Please sign in to comment.