Skip to content

Commit

Permalink
Add go back buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
bigfoodK committed Oct 13, 2024
1 parent 332f56d commit 207297b
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 5 deletions.
26 changes: 22 additions & 4 deletions luda-editor/new-client/src/asset_manage_page.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
use crate::{server_connection, simple_button, toast};
use crate::{
home,
router::{self, Route},
server_connection, simple_button, toast,
};
use luda_rpc::{asset::reserve_team_asset_upload, AssetKind, AssetTag};
use namui::*;
use namui_prebuilt::table::*;
Expand Down Expand Up @@ -57,10 +61,24 @@ impl Component for AssetManagePage<'_> {
});
};

let top_bar = fixed(24.px(), |wh, ctx| {
let button_wh = Wh::new(128.px(), wh.height);
ctx.add(simple_button(button_wh, "back", |_| {
router::route(Route::Home {
initial_selection: home::Selection::Team {
team_id: team_id.to_string(),
},
});
}));
});

ctx.compose(|ctx| {
vertical([fixed(24.px(), |wh, ctx| {
ctx.add(AssetUploadButton { wh, upload_asset });
})])(screen_wh, ctx);
vertical([
top_bar,
fixed(24.px(), |wh, ctx| {
ctx.add(AssetUploadButton { wh, upload_asset });
}),
])(screen_wh, ctx);
});
}
}
Expand Down
23 changes: 22 additions & 1 deletion luda-editor/new-client/src/episode_editor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::rpc::asset::get_team_asset_docs;
use crate::rpc::episode_editor::join_episode_editor;
use luda_rpc::{AssetDoc, EpisodeEditAction, Scene};
use properties_panel::PropertiesPanel;
use router::Route;
use std::{collections::HashMap, sync::Arc};

pub struct EpisodeEditor<'a> {
Expand Down Expand Up @@ -66,6 +67,7 @@ impl Component for EpisodeEditor<'_> {
match (join_result, asset_result) {
(Ok((join_episode_editor::Response { scenes, texts }, _)), Ok(_)) => {
ctx.add(LoadedEpisodeEditor {
team_id,
project_id,
episode_id,
initial_scenes: scenes,
Expand All @@ -87,6 +89,7 @@ impl Component for EpisodeEditor<'_> {
}

struct LoadedEpisodeEditor<'a> {
team_id: &'a String,
project_id: &'a String,
episode_id: &'a String,
initial_scenes: &'a Vec<Scene>,
Expand All @@ -97,6 +100,7 @@ struct LoadedEpisodeEditor<'a> {
impl Component for LoadedEpisodeEditor<'_> {
fn render(self, ctx: &RenderCtx) {
let Self {
team_id,
project_id,
episode_id,
initial_scenes,
Expand Down Expand Up @@ -333,7 +337,24 @@ impl Component for LoadedEpisodeEditor<'_> {
});
});

ctx.compose(|ctx| horizontal([scene_list, scene_editor, properties_panel])(wh, ctx));
let top_bar = table::fixed(24.px(), |wh, ctx| {
let button_wh = Wh::new(128.px(), wh.height);
ctx.add(simple_button(button_wh, "back", |_| {
router::route(Route::Home {
initial_selection: home::Selection::Project {
team_id: team_id.to_string(),
project_id: project_id.to_string(),
},
});
}));
});

ctx.compose(|ctx| {
vertical([
top_bar,
ratio(1, horizontal([scene_list, scene_editor, properties_panel])),
])(wh, ctx)
});
}
}

Expand Down
19 changes: 19 additions & 0 deletions luda-editor/new-client/src/new_episode_page.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::*;
use router::Route;
use rpc::episode::create_new_episode::*;

pub struct NewEpisodePage<'a> {
Expand Down Expand Up @@ -55,8 +56,26 @@ impl Component for NewEpisodePage<'_> {
},
);

let top_bar = table::fixed(
24.px(),
horizontal([
ratio(1, |_, _| {}),
fixed(24.px(), |wh, ctx| {
ctx.add(simple_button(wh, "X", |_| {
router::route(Route::Home {
initial_selection: home::Selection::Project {
team_id: team_id.to_string(),
project_id: project_id.to_string(),
},
});
}));
}),
]),
);

ctx.compose(|ctx| {
vertical([
top_bar,
fixed(24.px(), |wh, ctx| {
ctx.add(typography::title::left(
wh.height,
Expand Down
18 changes: 18 additions & 0 deletions luda-editor/new-client/src/new_project_page.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::*;
use router::Route;
use rpc::project::create_new_project::*;

pub struct NewProjectPage<'a> {
Expand Down Expand Up @@ -50,8 +51,25 @@ impl Component for NewProjectPage<'_> {
},
);

let top_bar = table::fixed(
24.px(),
horizontal([
ratio(1, |_, _| {}),
fixed(24.px(), |wh, ctx| {
ctx.add(simple_button(wh, "X", |_| {
router::route(Route::Home {
initial_selection: home::Selection::Team {
team_id: team_id.to_string(),
},
});
}));
}),
]),
);

ctx.compose(|ctx| {
vertical([
top_bar,
fixed(24.px(), |wh, ctx| {
ctx.add(typography::title::left(
wh.height,
Expand Down
16 changes: 16 additions & 0 deletions luda-editor/new-client/src/new_team_page.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::*;
use router::Route;
use rpc::team::create_new_team::*;

pub struct NewTeamPage;
Expand Down Expand Up @@ -37,8 +38,23 @@ impl Component for NewTeamPage {
},
);

let top_bar = table::fixed(
24.px(),
horizontal([
ratio(1, |_, _| {}),
fixed(24.px(), |wh, ctx| {
ctx.add(simple_button(wh, "X", |_| {
router::route(Route::Home {
initial_selection: home::Selection::Nothing,
});
}));
}),
]),
);

ctx.compose(|ctx| {
vertical([
top_bar,
fixed(24.px(), |wh, ctx| {
ctx.add(typography::title::left(
wh.height,
Expand Down

0 comments on commit 207297b

Please sign in to comment.