Skip to content

Commit

Permalink
Add non-functional photo info panel
Browse files Browse the repository at this point in the history
  • Loading branch information
blissd committed Mar 31, 2024
1 parent aa4ce8a commit 1992352
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ impl SimpleComponent for App {
});

let one_photo = OnePhoto::builder()
.launch(repo.clone())
.launch((scan.clone(), repo.clone()))
.detach();

let about_dialog = AboutDialog::builder()
Expand Down
1 change: 1 addition & 0 deletions src/app/components/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ pub mod all_photos;
pub mod month_photos;
pub mod year_photos;
pub mod one_photo;
pub mod photo_info;
35 changes: 25 additions & 10 deletions src/app/components/one_photo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use relm4::gtk::prelude::WidgetExt;
use relm4::*;
use std::sync::{Arc, Mutex};

use crate::app::components::photo_info::PhotoInfo;

#[derive(Debug)]
pub enum OnePhotoInput {
ViewPhoto(PictureId),
Expand All @@ -17,12 +19,14 @@ pub enum OnePhotoInput {
#[derive(Debug)]
pub struct OnePhoto {
repo: Arc<Mutex<photos_core::Repository>>,
photo_info: Controller<PhotoInfo>,
picture: gtk::Picture,

}

#[relm4::component(pub)]
impl SimpleComponent for OnePhoto {
type Init = Arc<Mutex<photos_core::Repository>>;
type Init = (photos_core::Scanner, Arc<Mutex<photos_core::Repository>>);
type Input = OnePhotoInput;
type Output = ();

Expand All @@ -31,33 +35,44 @@ impl SimpleComponent for OnePhoto {
add_top_bar = &adw::HeaderBar,

#[wrap(Some)]
set_content = &gtk::Box {
set_orientation: gtk::Orientation::Vertical,
set_content = &adw::OverlaySplitView {
#[wrap(Some)]
set_sidebar = model.photo_info.widget(),

set_sidebar_position: gtk::PackType::End,

#[wrap(Some)]
set_content = &gtk::Box {
set_orientation: gtk::Orientation::Vertical,

#[local_ref]
picture -> gtk::Picture {
set_can_shrink: true,
set_valign: gtk::Align::Center,
#[local_ref]
picture -> gtk::Picture {
set_can_shrink: true,
set_valign: gtk::Align::Center,
}
}
}
}
}

fn init(
repo: Self::Init,
(scanner, repo): Self::Init,
_root: Self::Root,
_sender: ComponentSender<Self>,
) -> ComponentParts<Self> {

let picture = gtk::Picture::new();

let widgets = view_output!();
let photo_info = PhotoInfo::builder().launch(scanner).detach();

let model = OnePhoto {
repo,
picture,
picture: picture.clone(),
photo_info,
};

let widgets = view_output!();

ComponentParts { model, widgets }
}

Expand Down
53 changes: 53 additions & 0 deletions src/app/components/photo_info.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// SPDX-FileCopyrightText: © 2024 David Bliss
//
// SPDX-License-Identifier: GPL-3.0-or-later

use photos_core::Scanner;
use gtk::prelude::OrientableExt;
use relm4::gtk;
use relm4::*;
use relm4::adw::prelude::PreferencesRowExt;


#[derive(Debug)]
pub struct PhotoInfo {
scanner: Scanner,
}


#[relm4::component(pub)]
impl SimpleComponent for PhotoInfo {
type Init = Scanner;
type Input = ();
type Output = ();

view! {
gtk::Box {
set_orientation: gtk::Orientation::Vertical,

gtk::ListBox {
adw::ActionRow {
set_title: "Test Title",
}
}
}
}

fn init(
scanner: Self::Init,
_root: Self::Root,
_sender: ComponentSender<Self>,
) -> ComponentParts<Self> {

let widgets = view_output!();

let model = PhotoInfo {
scanner,
};

ComponentParts { model, widgets }
}

fn update(&mut self, msg: Self::Input, _sender: ComponentSender<Self>) {}
}

0 comments on commit 1992352

Please sign in to comment.