-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
27 changed files
with
261 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[workspace] | ||
resolver = "2" | ||
members = ["gui", "cli", "egui"] | ||
members = ["cli", "shared", "gui/slint", "gui/iced", "gui/egui"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "iced" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
iced = "0.10.0" | ||
strum = { version = "0.26.1", features = ["derive"] } | ||
devmode-shared = { path = "../../shared" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
use iced::{ | ||
widget::{button, column, container, horizontal_rule, row, text}, | ||
Length, Theme, | ||
}; | ||
use strum::{Display, EnumIter, IntoEnumIterator}; | ||
|
||
use crate::pages::{ClonePanel, OpenPanel, PreferencesPanel, WorkspacesPanel}; | ||
|
||
#[derive(Debug, Default)] | ||
pub struct Devmode { | ||
theme: Theme, | ||
pages: Vec<Page>, | ||
selected: Page, | ||
clone: ClonePanel, | ||
open: OpenPanel, | ||
workspaces: WorkspacesPanel, | ||
preferences: PreferencesPanel, | ||
} | ||
|
||
#[derive(Debug, Clone)] | ||
pub enum Message { | ||
SwitchPage(Page), | ||
SelectRepo(Repository), | ||
} | ||
|
||
#[derive(Debug, Default, PartialEq, EnumIter, Display, Clone)] | ||
enum Page { | ||
#[default] | ||
Clone, | ||
Open, | ||
Workspaces, | ||
Preferences, | ||
} | ||
|
||
#[derive(Debug, Default, PartialEq, Clone)] | ||
pub struct Repository { | ||
pub name: String, | ||
pub url: String, | ||
} | ||
|
||
impl iced::Sandbox for Devmode { | ||
type Message = Message; | ||
|
||
fn new() -> Self { | ||
Devmode { | ||
theme: Theme::Dark, | ||
pages: Page::iter().collect(), | ||
selected: Page::default(), | ||
..Default::default() | ||
} | ||
} | ||
|
||
fn title(&self) -> String { | ||
String::from("Devmode") | ||
} | ||
|
||
fn update(&mut self, message: Self::Message) { | ||
match message { | ||
Message::SwitchPage(page) => self.selected = page, | ||
Message::SelectRepo(repo) => print!("Selected repo: {repo:?}"), | ||
} | ||
} | ||
|
||
fn view(&self) -> iced::Element<'_, Self::Message> { | ||
container(column!(self.tab_bar(), horizontal_rule(1), self.content()).spacing(10.0)) | ||
.padding(10.0) | ||
.into() | ||
} | ||
|
||
fn theme(&self) -> Theme { | ||
self.theme.clone() | ||
} | ||
} | ||
|
||
impl Devmode { | ||
fn tab_bar(&self) -> iced::Element<'_, Message> { | ||
let pages = self | ||
.pages | ||
.iter() | ||
.map(|page| { | ||
button(text(page.to_string())) | ||
.on_press(Message::SwitchPage(page.clone())) | ||
.width(iced::Length::Fill) | ||
.into() | ||
}) | ||
.collect::<Vec<iced::Element<'_, Message>>>(); | ||
|
||
container(row(pages).spacing(5.0)) | ||
.width(Length::Fill) | ||
.into() | ||
} | ||
|
||
fn content(&self) -> iced::Element<'_, Message> { | ||
match self.selected { | ||
Page::Clone => self.clone.ui(), | ||
Page::Open => self.open.ui(), | ||
Page::Workspaces => self.workspaces.ui(), | ||
Page::Preferences => self.preferences.ui(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use app::Devmode; | ||
use iced::Application; | ||
|
||
mod app; | ||
mod pages; | ||
|
||
fn main() -> iced::Result { | ||
Devmode::run(iced::Settings::default()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use iced::widget::{button, column, text}; | ||
|
||
use crate::app::{Message, Repository}; | ||
|
||
#[derive(Debug)] | ||
pub struct ClonePanel { | ||
repositories: Vec<Repository>, | ||
selected: Repository, | ||
url: String, | ||
} | ||
|
||
impl Default for ClonePanel { | ||
fn default() -> Self { | ||
let repositories: Vec<Repository> = (0..20) | ||
.map(|i| Repository { | ||
name: "Test".to_string(), | ||
url: i.to_string(), | ||
}) | ||
.collect(); | ||
Self { | ||
repositories: repositories.clone(), | ||
selected: repositories.first().unwrap().to_owned(), | ||
url: String::default(), | ||
} | ||
} | ||
} | ||
|
||
impl ClonePanel { | ||
pub(crate) fn ui(&self) -> iced::Element<'_, Message> { | ||
let repositories = self | ||
.repositories | ||
.iter() | ||
.map(|repo| { | ||
button(text(&repo.name)) | ||
.on_press(Message::SelectRepo(repo.clone())) | ||
.width(iced::Length::Fill) | ||
.into() | ||
}) | ||
.collect::<Vec<iced::Element<'_, Message>>>(); | ||
column(repositories).into() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
pub mod clone; | ||
pub mod open; | ||
pub mod preferences; | ||
pub mod workspaces; | ||
|
||
pub use clone::ClonePanel; | ||
pub use open::OpenPanel; | ||
pub use preferences::PreferencesPanel; | ||
pub use workspaces::WorkspacesPanel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use iced::widget::text; | ||
|
||
use crate::app::{Message, Repository}; | ||
|
||
#[derive(Debug)] | ||
pub struct OpenPanel { | ||
repositories: Vec<Repository>, | ||
selected: Repository, | ||
} | ||
|
||
impl Default for OpenPanel { | ||
fn default() -> Self { | ||
let repositories: Vec<Repository> = (0..20) | ||
.map(|i| Repository { | ||
name: "Test".to_string(), | ||
url: i.to_string(), | ||
}) | ||
.collect(); | ||
Self { | ||
repositories: repositories.clone(), | ||
selected: repositories.first().unwrap().to_owned(), | ||
} | ||
} | ||
} | ||
|
||
impl OpenPanel { | ||
pub(crate) fn ui(&self) -> iced::Element<'_, Message> { | ||
text("Open").into() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use devmode_shared::{application::Application, editor::Editor, host::Host, settings::Settings}; | ||
use iced::widget::text; | ||
|
||
use crate::app::Message; | ||
|
||
#[derive(Debug)] | ||
pub struct PreferencesPanel { | ||
settings: Settings, | ||
} | ||
|
||
impl Default for PreferencesPanel { | ||
fn default() -> Self { | ||
let settings = Settings::current().unwrap_or_default(); | ||
Self { settings } | ||
} | ||
} | ||
|
||
impl PreferencesPanel { | ||
pub(crate) fn ui(&self) -> iced::Element<'_, Message> { | ||
text("Preferences").into() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use iced::widget::text; | ||
|
||
use crate::app::Message; | ||
|
||
#[derive(Debug)] | ||
pub struct WorkspacesPanel { | ||
workspaces: Vec<Workspace>, | ||
selected: Workspace, | ||
} | ||
|
||
impl Default for WorkspacesPanel { | ||
fn default() -> Self { | ||
let workspaces: Vec<Workspace> = (0..20) | ||
.map(|i| Workspace { | ||
name: i.to_string(), | ||
}) | ||
.collect(); | ||
Self { | ||
workspaces: workspaces.clone(), | ||
selected: workspaces.first().unwrap().to_owned(), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug, Default, PartialEq, Clone)] | ||
pub struct Workspace { | ||
name: String, | ||
} | ||
|
||
impl WorkspacesPanel { | ||
pub(crate) fn ui(&self) -> iced::Element<'_, Message> { | ||
text("Workspaces").into() | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.