wip custom theme

[?]
May 16, 2025, 10:30 AM
MYGIBRRHHXPKVRAMQQRJTZH74L2XOK3SF7J57JPCRKSVRLZ2D6NQC

Dependencies

  • [2] WT3GA27P add cursor with selection
  • [3] NWJD6VM6 mv libflowers libflorescence
  • [4] GWZGYNIB add view crate
  • [5] 23SFYK4Q big view refactor into a new crate
  • [6] OPXFZKEB view tests setup
  • [7] YBJRDOTC make all repo actions async
  • [8] B4RMW5AE add syntax highlighter to untracked files contents
  • [9] AMPZ2BXK show changed files diffs (only Edit atm)
  • [10] AXSXZQDG fix updating changed file contents, styling
  • [11] SWWE2R6M display basic repo stuff
  • [12] Y5ATDI2H convert changed file diffs and load src only if any needs it
  • [13] 6YZAVBWU Initial commit
  • [14] JE44NYHM display log files diffs

Change contents

  • edit in inflorescence_view/src/util.rs at line 2
    [5.37]
    [5.37]
    use crate::Theme;
  • replacement in inflorescence_view/src/util.rs at line 7
    [5.97][5.97:141]()
    pub fn el<'a, E, M>(e: E) -> Element<'a, M>
    [5.97]
    [5.141]
    pub fn el<'a, E, M>(e: E) -> Element<'a, M, Theme>
  • replacement in inflorescence_view/src/util.rs at line 9
    [5.147][5.147:176]()
    E: Into<Element<'a, M>>,
    [5.147]
    [5.176]
    E: Into<Element<'a, M, Theme>>,
  • replacement in inflorescence_view/src/util.rs at line 11
    [5.178][5.178:210]()
    Into::<Element<M>>::into(e)
    [5.178]
    [5.210]
    Into::<Element<M, Theme>>::into(e)
  • file addition: theme.rs (----------)
    [4.85]
    use libflorescence::prelude::*;
    use iced::{
    advanced::widget::text,
    border, color,
    theme::{self, palette},
    widget::{
    button, container,
    scrollable::{self, Rail},
    text_editor,
    },
    window, Background, Border, Color,
    };
    const DARK_BLUE: Color = color!(0x010032);
    const TEAL: Color = color!(0x3b8588);
    const MAGENTA: Color = color!(0xe933f6);
    const TURQOISE: Color = color!(0x75fad1);
    // TODO not sure if I'll use this?
    const PALETTE: theme::Palette = theme::Palette {
    background: DARK_BLUE,
    text: scale_rgb(TEAL, 1.),
    primary: TURQOISE,
    success: TURQOISE,
    warning: MAGENTA,
    danger: MAGENTA,
    };
    #[derive(Debug, Default)]
    pub struct Theme;
    #[derive(Debug, Clone, Copy)]
    pub enum Button {
    Normal,
    Selected,
    }
    pub fn theme<S>(_state: &S, _window_id: window::Id) -> Theme {
    Theme
    }
    impl theme::Base for Theme {
    fn base(&self) -> theme::Style {
    theme::Style {
    background_color: PALETTE.background,
    text_color: PALETTE.text,
    }
    }
    fn palette(&self) -> Option<theme::Palette> {
    Some(PALETTE)
    }
    }
    impl button::Catalog for Theme {
    type Class<'a> = Button;
    fn default<'a>() -> Self::Class<'a> {
    Button::Normal
    }
    fn style(
    &self,
    class: &Self::Class<'_>,
    status: button::Status,
    ) -> button::Style {
    let primary = palette::Primary::generate(
    PALETTE.primary,
    PALETTE.background,
    PALETTE.text,
    );
    let base = button::Style {
    background: Some(Background::Color(primary.base.color)),
    text_color: primary.base.text,
    border: border::rounded(2),
    ..button::Style::default()
    };
    let base = match status {
    button::Status::Active | button::Status::Pressed => base,
    button::Status::Hovered => button::Style {
    background: Some(Background::Color(primary.strong.color)),
    ..base
    },
    button::Status::Disabled => button::Style {
    background: base
    .background
    .map(|background| background.scale_alpha(0.5)),
    text_color: base.text_color.scale_alpha(0.5),
    ..base
    },
    };
    match class {
    Button::Normal => button::Style {
    border: Border {
    color: Color::TRANSPARENT,
    width: 1.0,
    ..default()
    },
    ..base
    },
    Button::Selected => button::Style {
    background: Some(Background::Color(MAGENTA)),
    border: Border {
    color: Color::WHITE,
    width: 1.0,
    ..default()
    },
    ..base
    },
    }
    }
    }
    impl container::Catalog for Theme {
    type Class<'a> = ();
    fn default<'a>() -> Self::Class<'a> {
    ()
    }
    fn style(&self, class: &Self::Class<'_>) -> container::Style {
    container::Style::default()
    }
    }
    impl scrollable::Catalog for Theme {
    type Class<'a> = ();
    fn default<'a>() -> Self::Class<'a> {
    ()
    }
    fn style(
    &self,
    class: &Self::Class<'_>,
    status: scrollable::Status,
    ) -> scrollable::Style {
    let background =
    palette::Background::new(PALETTE.background, PALETTE.text);
    // TODO not same as default
    let scrollbar = Rail {
    background: Some(background.weak.color.into()),
    border: border::rounded(2),
    scroller: scrollable::Scroller {
    color: background.strong.color,
    border: border::rounded(2),
    },
    };
    scrollable::Style {
    container: container::Style::default(),
    vertical_rail: scrollbar,
    horizontal_rail: scrollbar,
    gap: None,
    }
    }
    }
    impl text::Catalog for Theme {
    type Class<'a> = ();
    fn default<'a>() -> Self::Class<'a> {
    ()
    }
    fn style(&self, item: &Self::Class<'_>) -> text::Style {
    text::Style { color: None }
    }
    }
    impl text_editor::Catalog for Theme {
    type Class<'a> = ();
    fn default<'a>() -> Self::Class<'a> {
    ()
    }
    fn style(
    &self,
    class: &Self::Class<'_>,
    status: text_editor::Status,
    ) -> text_editor::Style {
    // TODO not same as default
    let background =
    palette::Background::new(PALETTE.background, PALETTE.text);
    let primary = palette::Primary::generate(
    PALETTE.primary,
    PALETTE.background,
    PALETTE.text,
    );
    let active = text_editor::Style {
    background: Background::Color(background.base.color),
    border: Border {
    radius: 2.0.into(),
    width: 1.0,
    color: background.strong.color,
    },
    icon: background.weak.text,
    placeholder: background.strong.color,
    value: background.base.text,
    selection: primary.weak.color,
    };
    active
    }
    }
    // pub fn theme<S>(_state: &S, _window_id: window::Id) -> Theme {
    // let text = scale_rgb(TEAL, 2.);
    // Theme::custom(
    // "Inflorescence".to_string(),
    // theme::Palette {
    // background: DARK_BLUE,
    // text,
    // primary: MAGENTA,
    // success: TURQOISE,
    // warning: MAGENTA,
    // danger: MAGENTA,
    // },
    // )
    // }
    const fn scale_rgb(color: Color, scale: f32) -> Color {
    let Color { r, g, b, a } = color;
    Color {
    r: r * scale,
    g: g * scale,
    b: b * scale,
    a,
    }
    }
  • replacement in inflorescence_view/src/testing.rs at line 1
    [6.599][6.600:636]()
    use iced::{window, Element, Theme};
    [6.599]
    [6.636]
    use crate::Theme;
    use iced::{window, Element};
  • replacement in inflorescence_view/src/testing.rs at line 53
    [6.2083][6.2083:2173]()
    let mut sim =
    Simulator::with_size(iced::Settings::default(), size, element);
    [6.2083]
    [6.2173]
    let mut sim = Simulator::<_, Theme, _>::with_size(
    iced::Settings::default(),
    size,
    element,
    );
  • edit in inflorescence_view/src/lib.rs at line 4
    [6.4148]
    [5.273]
    pub mod theme;
  • edit in inflorescence_view/src/lib.rs at line 7
    [4.123]
    [5.311]
    pub use theme::{theme, Theme};
  • edit in inflorescence_view/src/lib.rs at line 9
    [5.329][6.4149:4177](),[6.4177][5.329:415](),[5.329][5.329:415](),[5.415][4.295:297](),[4.295][4.295:297]()
    use iced::{window, Theme};
    pub fn theme<S>(_state: &S, _window_id: window::Id) -> Theme {
    Theme::TokyoNight
    }
  • replacement in inflorescence_view/src/diff.rs at line 6
    [5.549][5.549:564]()
    use crate::el;
    [5.549]
    [5.564]
    use crate::{el, Theme};
  • replacement in inflorescence_view/src/diff.rs at line 122
    [5.3469][5.3469:3549]()
    pub fn view<'a>(state: Option<&'a State>, file: &'a File) -> Element<'a, Msg> {
    [5.3469]
    [5.3549]
    pub fn view<'a>(
    state: Option<&'a State>,
    file: &'a File,
    ) -> Element<'a, Msg, Theme> {
  • replacement in inflorescence_view/src/diff.rs at line 141
    [5.3951][5.3951:3975]()
    ) -> Element<'a, Msg> {
    [5.3951]
    [5.3975]
    ) -> Element<'a, Msg, Theme> {
  • replacement in inflorescence_view/src/diff.rs at line 209
    [5.5962][5.5962:5986]()
    ) -> Element<'a, Msg> {
    [5.5962]
    [5.5986]
    ) -> Element<'a, Msg, Theme> {
  • replacement in inflorescence_view/src/diff.rs at line 228
    [5.6403][5.6403:6477]()
    fn view_diff_with_contents(diff: &DiffWithContents) -> Element<'_, Msg> {
    [5.6403]
    [5.6477]
    fn view_diff_with_contents(diff: &DiffWithContents) -> Element<'_, Msg, Theme> {
  • replacement in inflorescence_view/src/diff.rs at line 296
    [5.8760][5.8760:8840]()
    fn view_diff_without_contents(diff: &DiffWithoutContents) -> Element<'_, Msg> {
    [5.8760]
    [5.8840]
    fn view_diff_without_contents(
    diff: &DiffWithoutContents,
    ) -> Element<'_, Msg, Theme> {
  • replacement in inflorescence_view/src/diff.rs at line 353
    [5.10585][5.10585:10664]()
    fn mono_text<'a>(txt: impl text::IntoFragment<'a>) -> iced::widget::Text<'a> {
    [5.10585]
    [5.10664]
    fn mono_text<'a>(
    txt: impl text::IntoFragment<'a>,
    ) -> iced::widget::Text<'a, Theme> {
  • replacement in inflorescence_view/src/diff.rs at line 362
    [5.10802][5.10802:10878]()
    fn line_num_view<'a>(num: usize, digits: usize) -> iced::widget::Text<'a> {
    [5.10802]
    [5.10878]
    fn line_num_view<'a>(
    num: usize,
    digits: usize,
    ) -> iced::widget::Text<'a, Theme> {
  • replacement in inflorescence_view/src/diff.rs at line 370
    [5.11016][5.11016:11226]()
    .style(move |theme| {
    let palette = theme.extended_palette();
    text::Style {
    color: Some(palette.background.base.text.scale_alpha(0.61)),
    }
    })
    [5.11016]
    [5.11226]
    // TODO replace with class
    // .style(move |theme| {
    // let palette = theme.extended_palette();
    // text::Style {
    // color: Some(palette.background.base.text.scale_alpha(0.61)),
    // }
    // })
  • replacement in inflorescence_view/src/diff.rs at line 392
    [5.11486][5.11486:11510]()
    ) -> Element<'a, Msg> {
    [5.11486]
    [5.11510]
    ) -> Element<'a, Msg, Theme> {
  • replacement in inflorescence_view/src/diff.rs at line 405
    [5.11875][5.11875:12137]()
    LineKind::Added => line.style(|_theme| {
    container::background(Background::from(ADDED_BG_COLOR))
    }),
    LineKind::Deleted => line.style(|_theme| {
    container::background(Background::from(DELETED_BG_COLOR))
    }),
    [5.11875]
    [5.12137]
    LineKind::Added => line,
    // TODO replace with class
    // .style(|_theme| {
    // container::background(Background::from(ADDED_BG_COLOR))
    // })
    LineKind::Deleted => line, // TODO replace with class
    // .style(|_theme| {
    // container::background(Background::from(DELETED_BG_COLOR))
    // })
  • replacement in inflorescence_view/src/app.rs at line 6
    [6.4204][5.12429:12452](),[5.12429][5.12429:12452]()
    use crate::{diff, el};
    [6.4204]
    [5.12452]
    use crate::{diff, el, theme, Theme};
  • replacement in inflorescence_view/src/app.rs at line 9
    [5.12512][5.12512:12583]()
    use iced::{font, window, Border, Color, Element, Font, Length, Theme};
    [5.12512]
    [5.12583]
    use iced::{font, window, Border, Color, Element, Font, Length};
  • replacement in inflorescence_view/src/app.rs at line 150
    [5.15559][5.15559:15581]()
    ) -> Element<'a, Msg>
    [5.15559]
    [5.15581]
    ) -> Element<'a, Msg, Theme>
  • replacement in inflorescence_view/src/app.rs at line 175
    [5.16516][5.16516:16586]()
    .style(selectable_button_style(is_selected)),
    [5.16516]
    [5.16586]
    .class(selectable_button_class(is_selected)),
  • replacement in inflorescence_view/src/app.rs at line 193
    [5.17242][5.17242:17312]()
    .style(selectable_button_style(is_selected)),
    [5.17242]
    [5.17312]
    .class(selectable_button_class(is_selected)),
  • replacement in inflorescence_view/src/app.rs at line 215
    [5.18128][5.18128:18199]()
    .style(selectable_button_style(is_selected))),
    [5.18128]
    [5.18199]
    .class(selectable_button_class(is_selected))),
  • replacement in inflorescence_view/src/app.rs at line 308
    [5.21984][5.21984:22052]()
    }).style(selectable_button_style(is_selected)))
    [5.21984]
    [5.22052]
    }).class(selectable_button_class(is_selected)))
  • replacement in inflorescence_view/src/app.rs at line 371
    [5.24347][5.24347:24410]()
    fn view_diff_header(header: String) -> Element<'static, Msg> {
    [5.24347]
    [5.24410]
    fn view_diff_header(header: String) -> Element<'static, Msg, Theme> {
  • replacement in inflorescence_view/src/app.rs at line 378
    [5.24509][5.24509:25105]()
    fn selectable_button_style(
    is_selected: bool,
    ) -> impl Fn(&Theme, button::Status) -> button::Style {
    move |theme, status| -> button::Style {
    button::Style {
    border: Border {
    color: if is_selected {
    Color::WHITE
    } else {
    Color::TRANSPARENT
    },
    width: 1.0,
    ..default()
    },
    ..button::Catalog::style(
    theme,
    &<Theme as button::Catalog>::default(),
    status,
    )
    }
    [5.24509]
    [5.25105]
    fn selectable_button_class(is_selected: bool) -> theme::Button {
    if is_selected {
    theme::Button::Selected
    } else {
    theme::Button::Normal
  • edit in inflorescence_view/src/app/test.rs at line 106
    [6.5637]
    [6.5637]
    let state = State {
    repo_path: &repo_path,
    repo: repo.as_ref(),
    cursor: &cursor,
    record_msg: record_msg.as_ref(),
    diffs_state: &diffs_state,
    };
    test_view(
    &mut results,
    uniq_name,
    view(state, window_id, |_id| Some(&diff)),
    size,
    );
    // _________________________________________________________________________
    //
    let uniq_name = "app_loaded_selected_untracked";
    let cursor = cursor::State {
    selection: Some(cursor::Selection::UntrackedFile {
    ix: 1,
    path: "".to_string(),
    }),
    };
  • replacement in inflorescence/src/main.rs at line 12
    [5.25389][5.25389:25427]()
    use inflorescence_view::{app, theme};
    [5.25389]
    [3.365]
    use inflorescence_view::{app, theme, Theme};
  • replacement in inflorescence/src/main.rs at line 623
    [2.4175][5.28468:28532]()
    fn view(state: &State, window_id: window::Id) -> Element<Msg> {
    [2.4175]
    [5.28532]
    fn view(state: &State, window_id: window::Id) -> Element<Msg, Theme> {