From 207297b2261d1aa12f0b79d40aa1a6791e38e514 Mon Sep 17 00:00:00 2001 From: bigfoodk Date: Mon, 14 Oct 2024 02:02:47 +0900 Subject: [PATCH] Add go back buttons --- .../new-client/src/asset_manage_page.rs | 26 ++++++++++++++++--- .../new-client/src/episode_editor/mod.rs | 23 +++++++++++++++- .../new-client/src/new_episode_page.rs | 19 ++++++++++++++ .../new-client/src/new_project_page.rs | 18 +++++++++++++ luda-editor/new-client/src/new_team_page.rs | 16 ++++++++++++ 5 files changed, 97 insertions(+), 5 deletions(-) diff --git a/luda-editor/new-client/src/asset_manage_page.rs b/luda-editor/new-client/src/asset_manage_page.rs index 66c427ce1..e2ba04a3c 100644 --- a/luda-editor/new-client/src/asset_manage_page.rs +++ b/luda-editor/new-client/src/asset_manage_page.rs @@ -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::*; @@ -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); }); } } diff --git a/luda-editor/new-client/src/episode_editor/mod.rs b/luda-editor/new-client/src/episode_editor/mod.rs index aaba3d238..9a1508428 100644 --- a/luda-editor/new-client/src/episode_editor/mod.rs +++ b/luda-editor/new-client/src/episode_editor/mod.rs @@ -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> { @@ -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, @@ -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, @@ -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, @@ -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) + }); } } diff --git a/luda-editor/new-client/src/new_episode_page.rs b/luda-editor/new-client/src/new_episode_page.rs index 7bacb64df..b20070262 100644 --- a/luda-editor/new-client/src/new_episode_page.rs +++ b/luda-editor/new-client/src/new_episode_page.rs @@ -1,4 +1,5 @@ use super::*; +use router::Route; use rpc::episode::create_new_episode::*; pub struct NewEpisodePage<'a> { @@ -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, diff --git a/luda-editor/new-client/src/new_project_page.rs b/luda-editor/new-client/src/new_project_page.rs index 29168bfe3..8be7fefcc 100644 --- a/luda-editor/new-client/src/new_project_page.rs +++ b/luda-editor/new-client/src/new_project_page.rs @@ -1,4 +1,5 @@ use super::*; +use router::Route; use rpc::project::create_new_project::*; pub struct NewProjectPage<'a> { @@ -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, diff --git a/luda-editor/new-client/src/new_team_page.rs b/luda-editor/new-client/src/new_team_page.rs index 05a40885e..52bb5b8af 100644 --- a/luda-editor/new-client/src/new_team_page.rs +++ b/luda-editor/new-client/src/new_team_page.rs @@ -1,4 +1,5 @@ use super::*; +use router::Route; use rpc::team::create_new_team::*; pub struct NewTeamPage; @@ -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,