Compare commits
No commits in common. "main" and "603dc124dd7872ac62dffc08470bea1bd51cf9d1" have entirely different histories.
main
...
603dc124dd
6 changed files with 21 additions and 3501 deletions
3331
Cargo.lock
generated
3331
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -6,5 +6,3 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
iced = {version = "0.12.1"}
|
|
||||||
rfd = { version = "0.14.1", default-features = false, features = ["gtk3"] }
|
|
||||||
|
|
55
flake.nix
55
flake.nix
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
description = "Doggo flake";
|
description = "Doggo flake";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
fenix = {
|
fenix = {
|
||||||
url = "github:nix-community/fenix";
|
url = "github:nix-community/fenix";
|
||||||
|
@ -10,42 +10,23 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, fenix, nixpkgs }:
|
outputs = { self, fenix, nixpkgs }:
|
||||||
let pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
let
|
||||||
in {
|
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||||
devShell.x86_64-linux = with pkgs;
|
in {
|
||||||
mkShell rec {
|
devShell.x86_64-linux = with pkgs;
|
||||||
nativeBuildInputs = [
|
mkShell {
|
||||||
just
|
nativeBuildInputs = [
|
||||||
pkg-config
|
just
|
||||||
protobuf
|
(fenix.packages.x86_64-linux.fromToolchainFile {
|
||||||
(fenix.packages.x86_64-linux.fromToolchainFile {
|
dir = ./.;
|
||||||
dir = ./.;
|
sha256 = "sha256-3St/9/UKo/6lz2Kfq2VmlzHyufduALpiIKaaKX4Pq0g=";
|
||||||
sha256 = "sha256-7QfkHty6hSrgNM0fspycYkRcB82eEqYa4CoAJ9qA3tU= ";
|
})
|
||||||
})
|
];
|
||||||
fenix.packages.x86_64-linux.rust-analyzer
|
|
||||||
];
|
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
fontconfig
|
];
|
||||||
|
};
|
||||||
|
|
||||||
vulkan-headers
|
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt;
|
||||||
vulkan-loader
|
};
|
||||||
libGL
|
|
||||||
|
|
||||||
libxkbcommon
|
|
||||||
|
|
||||||
wayland
|
|
||||||
|
|
||||||
# rfd
|
|
||||||
gtk3
|
|
||||||
];
|
|
||||||
|
|
||||||
env = {
|
|
||||||
# WAYLAND_DISPLAY = ""; # Window has nor decoration on Wayland
|
|
||||||
LD_LIBRARY_PATH = with pkgs; lib.makeLibraryPath buildInputs;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
BIN
fonts/icons.ttf
BIN
fonts/icons.ttf
Binary file not shown.
10
justfile
10
justfile
|
@ -4,12 +4,4 @@ build:
|
||||||
|
|
||||||
alias r := run
|
alias r := run
|
||||||
run:
|
run:
|
||||||
nixVulkanIntel cargo run
|
cargo run
|
||||||
|
|
||||||
fmt:
|
|
||||||
nix fmt flake.nix
|
|
||||||
|
|
||||||
# See https://github.com/zed-industries/zed/blob/main/docs/src/developing_zed__building_zed_linux.md
|
|
||||||
alias e := edit
|
|
||||||
edit:
|
|
||||||
WALYAND_DISPLAY= nixVulkanIntel zed .
|
|
||||||
|
|
124
src/main.rs
124
src/main.rs
|
@ -1,123 +1,3 @@
|
||||||
use iced::{
|
fn main() {
|
||||||
alignment,
|
println!("Hello, world!");
|
||||||
widget::{button, column, container, row, scrollable, text, text_input, Column},
|
|
||||||
Element, Length, Padding, Sandbox, Settings,
|
|
||||||
};
|
|
||||||
use rfd::FileDialog;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
enum Message {
|
|
||||||
InputValue(String),
|
|
||||||
Submitted,
|
|
||||||
DeleteItem(usize),
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is your model. It contains all the data needed for your application to work properly.
|
|
||||||
* The model can only be updated with the `update` function.
|
|
||||||
*/
|
|
||||||
struct GroceryList {
|
|
||||||
grocery_items: Vec<String>,
|
|
||||||
input_value: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Sandbox for GroceryList {
|
|
||||||
type Message = Message;
|
|
||||||
|
|
||||||
/* Initialize your app */
|
|
||||||
fn new() -> GroceryList {
|
|
||||||
Self {
|
|
||||||
grocery_items: vec!["Eggs".to_owned(), "Milk".to_owned(), "Flour".to_owned()],
|
|
||||||
input_value: String::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The title of the window. It will show up on the top of your application window.
|
|
||||||
*/
|
|
||||||
fn title(&self) -> String {
|
|
||||||
String::from("Grocery List App")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn update(&mut self, message: Self::Message) {
|
|
||||||
match message {
|
|
||||||
Message::InputValue(value) => self.input_value = value,
|
|
||||||
Message::Submitted => {
|
|
||||||
let input_value = self.input_value.clone();
|
|
||||||
self.input_value = String::default(); // Clear the input value
|
|
||||||
let _file = FileDialog::new()
|
|
||||||
.set_directory("/home/ffreling/Sync")
|
|
||||||
.pick_file();
|
|
||||||
let file_str = _file.and_then(|p| Some(String::from(p.to_str().unwrap())));
|
|
||||||
println!("{:?}", file_str);
|
|
||||||
match file_str {
|
|
||||||
None => (),
|
|
||||||
Some(path_str) => self.grocery_items.push(path_str),
|
|
||||||
}
|
|
||||||
// self.grocery_items.push(input_value);
|
|
||||||
}
|
|
||||||
Message::DeleteItem(item) => {
|
|
||||||
let _files = FileDialog::new()
|
|
||||||
.set_directory("/home/ffreling/Sync")
|
|
||||||
.pick_file();
|
|
||||||
self.grocery_items.remove(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn view(&self) -> Element<Self::Message> {
|
|
||||||
container(
|
|
||||||
column!(
|
|
||||||
items_list_view(&self.grocery_items),
|
|
||||||
row!(
|
|
||||||
text_input("Input grocery item", &self.input_value)
|
|
||||||
.on_input(|value| Message::InputValue(value))
|
|
||||||
.on_submit(Message::Submitted),
|
|
||||||
button("Submit").on_press(Message::Submitted)
|
|
||||||
)
|
|
||||||
.spacing(30)
|
|
||||||
.padding(Padding::from(30))
|
|
||||||
)
|
|
||||||
.align_items(iced::Alignment::Center),
|
|
||||||
)
|
|
||||||
.height(Length::Fill)
|
|
||||||
.width(Length::Fill)
|
|
||||||
.align_x(alignment::Horizontal::Center)
|
|
||||||
.align_y(alignment::Vertical::Center)
|
|
||||||
.into()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn theme(&self) -> iced::Theme {
|
|
||||||
iced::Theme::Dark
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn items_list_view(items: &Vec<String>) -> Element<'static, Message> {
|
|
||||||
let mut column = Column::new()
|
|
||||||
.spacing(20)
|
|
||||||
.align_items(iced::Alignment::Center)
|
|
||||||
.width(Length::Fill);
|
|
||||||
|
|
||||||
for (index, value) in items.into_iter().enumerate() {
|
|
||||||
column = column.push(grocery_item(index, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
scrollable(container(column))
|
|
||||||
.height(250.0)
|
|
||||||
.width(300)
|
|
||||||
.into()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn grocery_item(index: usize, value: &str) -> Element<'static, Message> {
|
|
||||||
row!(
|
|
||||||
text(value),
|
|
||||||
button("Delete").on_press(Message::DeleteItem(index))
|
|
||||||
)
|
|
||||||
.align_items(iced::Alignment::Center)
|
|
||||||
.spacing(30)
|
|
||||||
.into()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn main() -> iced::Result {
|
|
||||||
GroceryList::run(Settings::default())
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue