Skip to content

Commit

Permalink
chore: onboarding -> welcome window
Browse files Browse the repository at this point in the history
  • Loading branch information
clearlysid committed May 3, 2024
1 parent 70b4747 commit a6cbaca
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src-tauri/capabilities/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"editor",
"cropper",
"record",
"onboarding"
"welcome"
],
"permissions": [
"path:default",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/cropper/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub fn init_cropper(app: &AppHandle) {

pub fn toggle_cropper(app: &AppHandle) {
if !scap::has_permission() {
crate::open_onboarding(app);
crate::open_welcome_window(app);
return;
}

Expand Down
22 changes: 11 additions & 11 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use scap::{capturer::Capturer, frame::Frame};
use std::path::PathBuf;
use tauri::{AppHandle, Manager, WebviewUrl, WebviewWindowBuilder};
use tauri_plugin_global_shortcut;
use tauri_plugin_global_shortcut::ShortcutState;
use tauri_plugin_store::StoreBuilder;
use tokio::sync::Mutex;
use tauri_plugin_global_shortcut::ShortcutState;

#[cfg(target_os = "macos")]
use tauri::ActivationPolicy;
Expand Down Expand Up @@ -83,9 +83,9 @@ fn main() {
.as_bool()
.unwrap();

// If this is the first run, show onboarding screen
// If this is the first run, show welcome screen
if first_run || !scap::has_permission() {
open_onboarding(app_handle);
open_welcome_window(app_handle);
store.insert("first_run".to_string(), false.into()).unwrap();
store.save().expect("Failed to save store")
}
Expand All @@ -109,20 +109,20 @@ fn main() {
.expect("error while running Helmer Micro");
}

fn open_onboarding(app_handle: &AppHandle) {
match app_handle.get_webview_window("onboarding") {
fn open_welcome_window(app_handle: &AppHandle) {
match app_handle.get_webview_window("welcome") {
Some(window) => {
if window.is_visible().unwrap() {
window.set_focus().unwrap();
}
}
None => create_onboarding_win(app_handle),
None => create_welcome_win(app_handle),
}
}

fn create_onboarding_win(app_handle: &AppHandle) {
let mut onboarding_win =
WebviewWindowBuilder::new(app_handle, "onboarding", WebviewUrl::App("/".into()))
fn create_welcome_win(app_handle: &AppHandle) {
let mut welcome_win =
WebviewWindowBuilder::new(app_handle, "welcome", WebviewUrl::App("/".into()))
.accept_first_mouse(true)
.inner_size(600.0, 580.0)
.title("Helmer Micro")
Expand All @@ -131,7 +131,7 @@ fn create_onboarding_win(app_handle: &AppHandle) {
.center();
#[cfg(target_os = "macos")]
{
onboarding_win = onboarding_win.title_bar_style(tauri::TitleBarStyle::Overlay);
welcome_win = welcome_win.title_bar_style(tauri::TitleBarStyle::Overlay);
}
onboarding_win.build().expect("Failed to open onboarding");
welcome_win.build().expect("Failed to open welcome window");
}
6 changes: 3 additions & 3 deletions src-tauri/src/recorder/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{sync::mpsc, thread};

use crate::{open_onboarding, AppState};
use crate::{open_welcome_window, AppState};

use tauri::{AppHandle, Manager};
use tempfile::NamedTempFile;
Expand All @@ -12,10 +12,10 @@ use henx::{VideoEncoder, VideoEncoderOptions};

#[tauri::command]
pub async fn start_recording(app_handle: AppHandle) {
// If no permissions, open onboarding screen
// If no permissions, open welcome window
if !scap::has_permission() {
eprintln!("no permission to record screen");
open_onboarding(&app_handle);
open_welcome_window(&app_handle);
return;
}

Expand Down

0 comments on commit a6cbaca

Please sign in to comment.