Skip to content

Commit

Permalink
update tauri
Browse files Browse the repository at this point in the history
  • Loading branch information
saboooor committed Dec 18, 2023
1 parent 4ce8085 commit 1e706e2
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 35 deletions.
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

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

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "simplymc"
version = "0.3.5"
version = "0.4.0"
description = "SimplyMC but an app"
authors = ["LuminescentDev"]
license = "AGPL-3.0-or-later"
Expand Down
31 changes: 6 additions & 25 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,38 +1,19 @@
use tauri::{CustomMenuItem, Menu, Submenu};
use tauri::menu::MenuBuilder;

#[tauri::command]
fn greet() -> &'static str { "Hello, Tauri!" }

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
let refresh: CustomMenuItem = CustomMenuItem::new("refresh".to_string(), "Refresh");
let quit: CustomMenuItem = CustomMenuItem::new("quit".to_string(), "Quit");
let simplymc: Submenu = Submenu::new("SimplyMC", Menu::new()
.add_item(refresh)
.add_item(quit)
);
let en_us: CustomMenuItem = CustomMenuItem::new("en-US".to_string(), "English (US)");
let es_es: CustomMenuItem = CustomMenuItem::new("es-ES".to_string(), "Español (Spanish - ES)");
let nl_nl: CustomMenuItem = CustomMenuItem::new("nl-NL".to_string(), "Nederlands (Dutch - NL)");
let pt_pt: CustomMenuItem = CustomMenuItem::new("pt-PT".to_string(), "Português (Portuguese - PT)");
let language: Submenu = Submenu::new("Language", Menu::new()
.add_item(en_us)
.add_item(es_es)
.add_item(nl_nl)
.add_item(pt_pt)
);
let menu: Menu = Menu::new().add_submenu(simplymc).add_submenu(language);
tauri::Builder::default()
.menu(menu)
.on_menu_event(|event| {
match event.menu_item_id() {
"quit" => { std::process::exit(0); }
_ => {}
}
.setup(|app| {
let menu = MenuBuilder::new(app).copy().paste().undo().redo().build()?;
app.set_menu(menu)?;
Ok(())
})
.plugin(tauri_plugin_notification::init())
.plugin(tauri_plugin_window_state::Builder::default().build())
.invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
}
3 changes: 2 additions & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"productName": "SimplyMC",
"version": "0.3.5"
},
"plugins": {},
"tauri": {
"bundle": {
"active": true,
Expand Down Expand Up @@ -58,4 +59,4 @@
}
]
}
}
}
13 changes: 8 additions & 5 deletions src/components/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { version } from '~/../package.json';
import Luminescent from './icons/Luminescent';
import LoadingIcon from './icons/LoadingIcon';

import { Window } from '@tauri-apps/plugin-window';
import { Window } from '@tauri-apps/api/window';
import { sendNotification, isPermissionGranted, requestPermission } from '@tauri-apps/plugin-notification';

export default component$(({ tauriVersion }: any) => {
Expand All @@ -25,7 +25,7 @@ export default component$(({ tauriVersion }: any) => {

return (
<Nav>
<MainNav>
<MainNav tauriVersion={tauriVersion}>
<Dropdown name={t('nav.gradients@@Gradients')} extraClass={{ 'hidden sm:flex': true }}>
<NavButton href="/gradients">
{t('nav.hexGradient@@Hex Gradients')}
Expand Down Expand Up @@ -106,7 +106,7 @@ export default component$(({ tauriVersion }: any) => {
</button>
{tauriVersion && <>
<button title="Minimize" class="transition ease-in-out hover:bg-violet-900/20 hover:text-white p-1 rounded-lg text-3xl hidden sm:flex items-center" onClick$={() => {
Window.getCurrent().minimize();
Window.getzCurrent().minimize();
}}>
<RemoveOutline width="24" />
</button>
Expand Down Expand Up @@ -203,10 +203,13 @@ export const Brand = component$(() => {
);
});

export const MainNav = component$(() => {
export const MainNav = component$(({ tauriVersion }: any) => {
return (
<div class="bg-violet-900/20 px-4 lg:px-6 py-1">
<div class="mx-auto max-w-7xl relative flex h-16 items-center justify-between">
<div class={{
'mx-auto relative flex h-10 items-center justify-between': true,
'max-w-7xl h-16': !tauriVersion,
}}>
<Brand />
<div class="flex flex-1 items-center justify-end">
<div class="flex gap-1 text-gray-300 whitespace-nowrap">
Expand Down
2 changes: 1 addition & 1 deletion src/routes/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { config } from '~/speak-config';

import Nav from '../components/Nav';
import { Button } from '~/components/elements/Button';
import { getVersion } from '@tauri-apps/plugin-app';
import { getVersion } from '@tauri-apps/api/app';

export default component$(() => {
const store = useStore({
Expand Down

0 comments on commit 1e706e2

Please sign in to comment.