-
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.
- Loading branch information
1 parent
46ff890
commit 0439524
Showing
5 changed files
with
228 additions
and
7 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
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 +1,4 @@ | ||
pub mod clone; | ||
pub mod config; | ||
pub mod open; | ||
pub mod workspaces; |
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,40 @@ | ||
use cosmic::{iced::Length, theme, widget, Apply, Element}; | ||
|
||
#[derive(Debug, Default)] | ||
pub struct ConfigPage {} | ||
|
||
#[derive(Debug, Clone)] | ||
pub enum Message {} | ||
|
||
pub enum Command {} | ||
|
||
impl ConfigPage { | ||
pub fn new() -> Self { | ||
Self::default() | ||
} | ||
|
||
fn header(&self) -> Element<Message> { | ||
widget::row::with_capacity(2) | ||
.push(widget::text::title2("Config")) | ||
.into() | ||
} | ||
|
||
pub fn view(&self) -> Element<Message> { | ||
let spacing = theme::active().cosmic().spacing; | ||
|
||
widget::column::with_capacity(2) | ||
.push(self.header()) | ||
.spacing(spacing.space_xxs) | ||
.apply(widget::container) | ||
.height(Length::Shrink) | ||
.apply(widget::scrollable) | ||
.height(Length::Fill) | ||
.into() | ||
} | ||
|
||
pub fn update(&self, message: Message) -> Vec<Command> { | ||
let mut commands = vec![]; | ||
match message {} | ||
commands | ||
} | ||
} |
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,74 @@ | ||
use cosmic::{ | ||
iced::{Alignment, Length}, | ||
theme, widget, Apply, Element, | ||
}; | ||
use slotmap::{DefaultKey, SecondaryMap, SlotMap}; | ||
|
||
#[derive(Debug, Default)] | ||
pub struct Repository { | ||
url: String, | ||
selected: bool, | ||
} | ||
|
||
#[derive(Debug, Default)] | ||
pub struct OpenPage { | ||
projects: Vec<String>, | ||
} | ||
|
||
#[derive(Debug, Clone)] | ||
pub enum Message { | ||
Select(String), | ||
} | ||
|
||
pub enum Command {} | ||
|
||
impl OpenPage { | ||
pub fn new() -> Self { | ||
Self::default() | ||
} | ||
|
||
fn header(&self) -> Element<Message> { | ||
widget::row::with_capacity(2) | ||
.push(widget::text::title2("Open")) | ||
.into() | ||
} | ||
|
||
pub fn view(&self) -> Element<Message> { | ||
let spacing = theme::active().cosmic().spacing; | ||
|
||
let mut items = widget::list::list_column() | ||
.style(theme::Container::ContextDrawer) | ||
.spacing(spacing.space_xxxs) | ||
.padding([spacing.space_none, spacing.space_xxs]); | ||
|
||
for item in &self.projects { | ||
let item_text = widget::text(item).width(Length::Fill); | ||
|
||
let row = widget::row::with_capacity(4) | ||
.align_items(Alignment::Center) | ||
.spacing(spacing.space_xxs) | ||
.padding([spacing.space_xxxs, spacing.space_xxs]) | ||
.push(item_text); | ||
|
||
items = items.add(row); | ||
} | ||
|
||
widget::column::with_capacity(2) | ||
.push(self.header()) | ||
.push(items) | ||
.spacing(spacing.space_xxs) | ||
.apply(widget::container) | ||
.height(Length::Shrink) | ||
.apply(widget::scrollable) | ||
.height(Length::Fill) | ||
.into() | ||
} | ||
|
||
pub fn update(&self, message: Message) -> Vec<Command> { | ||
let mut commands = vec![]; | ||
match message { | ||
Message::Select(_) => todo!(), | ||
} | ||
commands | ||
} | ||
} |
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,89 @@ | ||
use cosmic::{ | ||
iced::{Alignment, Length}, | ||
theme, widget, Apply, Element, | ||
}; | ||
use slotmap::{DefaultKey, SecondaryMap, SlotMap}; | ||
|
||
#[derive(Debug, Default)] | ||
pub struct WorkspacesPage { | ||
workspaces: SlotMap<DefaultKey, String>, | ||
editing: SecondaryMap<DefaultKey, bool>, | ||
workspace_input_ids: SecondaryMap<DefaultKey, widget::Id>, | ||
} | ||
|
||
#[derive(Debug, Clone)] | ||
pub enum Message { | ||
EditMode(DefaultKey, bool), | ||
TitleUpdate(DefaultKey, String), | ||
TitleSubmit(DefaultKey), | ||
} | ||
|
||
pub enum Command {} | ||
|
||
impl WorkspacesPage { | ||
pub fn new() -> Self { | ||
let mut workspaces = SlotMap::new(); | ||
let mut workspace_input_ids = SecondaryMap::new(); | ||
let id = workspaces.insert("tasks".into()); | ||
workspace_input_ids.insert(id, widget::Id::unique()); | ||
Self { | ||
workspaces, | ||
workspace_input_ids, | ||
..Default::default() | ||
} | ||
} | ||
|
||
fn header(&self) -> Element<Message> { | ||
widget::row::with_capacity(2) | ||
.push(widget::text::title2("Workspaces")) | ||
.into() | ||
} | ||
|
||
pub fn view(&self) -> Element<Message> { | ||
let spacing = theme::active().cosmic().spacing; | ||
|
||
let mut items = widget::list::list_column() | ||
.style(theme::Container::ContextDrawer) | ||
.spacing(spacing.space_xxxs) | ||
.padding([spacing.space_none, spacing.space_xxs]); | ||
|
||
for (id, item) in &self.workspaces { | ||
let item_text = widget::editable_input( | ||
"", | ||
item, | ||
*self.editing.get(id).unwrap_or(&false), | ||
move |editing| Message::EditMode(id, editing), | ||
) | ||
.id(self.workspace_input_ids[id].clone()) | ||
.on_submit(Message::TitleSubmit(id)) | ||
.on_input(move |text| Message::TitleUpdate(id, text)) | ||
.width(Length::Fill); | ||
|
||
let row = widget::row::with_capacity(4) | ||
.align_items(Alignment::Center) | ||
.spacing(spacing.space_xxs) | ||
.padding([spacing.space_xxxs, spacing.space_xxs]) | ||
.push(item_text); | ||
|
||
items = items.add(row); | ||
} | ||
|
||
widget::column::with_capacity(2) | ||
.push(self.header()) | ||
.push(items) | ||
.spacing(spacing.space_xxs) | ||
.apply(widget::container) | ||
.height(Length::Shrink) | ||
.apply(widget::scrollable) | ||
.height(Length::Fill) | ||
.into() | ||
} | ||
|
||
pub fn update(&self, message: Message) -> Vec<Command> { | ||
match message { | ||
Message::TitleSubmit(_) => todo!(), | ||
Message::TitleUpdate(_, _) => todo!(), | ||
Message::EditMode(_, _) => todo!(), | ||
} | ||
} | ||
} |