Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added splashscreen with animated svg and threaded the splashscreen to… #19

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions public/bg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/splashscreen.webp
Binary file not shown.
12 changes: 12 additions & 0 deletions splashscreen.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body data-tauri-drag-region style="background-image: url('/splashscreen.webp'); background-size: contain; display: flex; flex-direction: column; justify-content: center; align-items: center; overflow: hidden;">
<div data-tauri-drag-region style="display: flex; flex-direction: row;justify-content: center;align-items: center;">
<object type="image/svg+xml" data="/bg.svg"></object>
</div>
</body>
</html>
20 changes: 10 additions & 10 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "_Glassy_Notes"
version = "0.1.1"
name = "glassy_notes"
version = "0.1.3"
description = "Better Notes"
authors = ["you"]
license = ""
Expand Down
30 changes: 29 additions & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,44 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

use tauri::{Manager, Window};

// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust and SuvanGS the creator!", name)
}

#[tauri::command]
async fn close_splashscreen(window: Window) {
if let Some(splashscreen) = window.get_window("splashscreen") {
splashscreen.close().unwrap();
}
// window.get_window("splashscreen").expect("no window labeled 'splashscreen' found").close().unwrap();

window.get_window("main").expect("no window labeled 'main' found").show().unwrap();
}


fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![greet])
.invoke_handler(tauri::generate_handler![greet, close_splashscreen])
.setup(|app| {
let splashscreen_window = app.get_window("splashscreen").unwrap();
let main_window = app.get_window("main").unwrap();

tauri::async_runtime::spawn(async move {

println!("Initializing...");
std::thread::sleep(std::time::Duration::from_secs(2));
println!("Done initializing.");


splashscreen_window.close().unwrap();
main_window.show().unwrap();
});
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
11 changes: 10 additions & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,16 @@
"resizable": true,
"title": "Glassy Notes",
"width": 1080,
"height": 720
"height": 720,
"visible": false
},
{
"width": 800,
"height": 600,
"resizable": false,
"decorations": false,
"url": "/splashscreen.html",
"label": "splashscreen"
}
]
}
Expand Down
6 changes: 6 additions & 0 deletions src/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import "./styles.css";
import { invoke } from "@tauri-apps/api/tauri";
import { appWindow } from "@tauri-apps/api/window";

document.addEventListener('DOMContentLoaded', () => {
invoke('close_splashscreen')
})

ReactDOM.createRoot(document.getElementById("root")).render(
<React.StrictMode>
<App />
Expand Down