1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
use gpui::{Context, Window, div, prelude::*, rgb};
use crate::projects_view::ProjectsView;
use crate::theme;
pub enum Screen {
Projects,
Editor { project_id: String, project_name: String },
}
pub struct OpenCutApp {
pub screen: Screen,
pub projects_view: gpui::Entity<ProjectsView>,
}
impl OpenCutApp {
pub fn new(cx: &mut Context<Self>) -> Self {
let app = cx.weak_entity();
let projects_view = cx.new(|_| ProjectsView::new(app));
Self {
screen: Screen::Projects,
projects_view,
}
}
pub fn open_project(&mut self, project_id: String, project_name: String, cx: &mut Context<Self>) {
self.screen = Screen::Editor {
project_id,
project_name,
};
cx.notify();
}
}
impl Render for OpenCutApp {
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
let content: gpui::AnyElement = match &self.screen {
Screen::Projects => self.projects_view.clone().into_any_element(),
Screen::Editor { project_name, project_id } => div()
.size_full()
.flex()
.flex_col()
.items_center()
.justify_center()
.gap_2()
.child(format!("Editing: {project_name}"))
.child(
div()
.text_sm()
.text_color(rgb(theme::TEXT_SECONDARY))
.child(format!("Editor UI lands here — preview, timeline, panels ({project_id})")),
)
.into_any_element(),
};
div()
.size_full()
.bg(rgb(theme::BACKGROUND))
.text_color(rgb(theme::TEXT_PRIMARY))
.child(content)
}
}
|