Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be713620ef | ||
|
|
8c766c3bc2 | ||
|
|
87244e5ba3 | ||
|
|
15e29a1d93 | ||
|
|
fa93528b69 | ||
|
|
eaf9d09c32 | ||
|
|
6806a86114 |
@@ -22,3 +22,4 @@ dist-ssr
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
*.jks
|
||||
@@ -0,0 +1,12 @@
|
||||
# EditorConfig is awesome: https://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = false
|
||||
insert_final_newline = false
|
||||
@@ -0,0 +1,20 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
local.properties
|
||||
key.properties
|
||||
keystore.properties
|
||||
|
||||
/.tauri
|
||||
/tauri.settings.gradle
|
||||
@@ -0,0 +1,6 @@
|
||||
/src/main/**/generated
|
||||
/src/main/jniLibs/**/*.so
|
||||
/src/main/assets/tauri.conf.json
|
||||
/tauri.build.gradle.kts
|
||||
/proguard-tauri.pro
|
||||
/tauri.properties
|
||||
@@ -1,6 +1,5 @@
|
||||
|
||||
import java.util.Properties
|
||||
import java.io.FileInputStream
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
@@ -15,12 +14,13 @@ val tauriProperties = Properties().apply {
|
||||
}
|
||||
}
|
||||
|
||||
// Load release keystore properties
|
||||
// Load signing credentials
|
||||
val keystoreProperties = Properties().apply {
|
||||
val keystoreFile = rootProject.file("keystore.properties")
|
||||
if (keystoreFile.exists()) {
|
||||
keystoreFile.inputStream().use { load(it) }
|
||||
require(keystoreFile.exists()) {
|
||||
"Missing keystore.properties"
|
||||
}
|
||||
keystoreFile.inputStream().use { load(it) }
|
||||
}
|
||||
|
||||
android {
|
||||
@@ -32,21 +32,27 @@ android {
|
||||
applicationId = "com.lucas.thomann_dsp_app"
|
||||
minSdk = 24
|
||||
targetSdk = 36
|
||||
versionCode = tauriProperties.getProperty("tauri.android.versionCode", "1").toInt()
|
||||
versionName = tauriProperties.getProperty("tauri.android.versionName", "1.0")
|
||||
versionCode = tauriProperties
|
||||
.getProperty("tauri.android.versionCode", "1").toInt()
|
||||
versionName = tauriProperties
|
||||
.getProperty("tauri.android.versionName", "1.0")
|
||||
}
|
||||
|
||||
// Release signing configuration
|
||||
signingConfigs {
|
||||
create("release") {
|
||||
val keystorePath = keystoreProperties.getProperty("storeFile")
|
||||
?: error("Missing storeFile")
|
||||
|
||||
if (keystorePath != null) {
|
||||
storeFile = file(keystorePath)
|
||||
storePassword = keystoreProperties.getProperty("password")
|
||||
keyAlias = keystoreProperties.getProperty("keyAlias")
|
||||
keyPassword = keystoreProperties.getProperty("password")
|
||||
}
|
||||
storeFile = rootProject.file(keystorePath)
|
||||
|
||||
storePassword = keystoreProperties.getProperty("storePassword")
|
||||
?: error("Missing storePassword")
|
||||
|
||||
keyAlias = keystoreProperties.getProperty("keyAlias")
|
||||
?: error("Missing keyAlias")
|
||||
|
||||
keyPassword = keystoreProperties.getProperty("keyPassword")
|
||||
?: error("Missing keyPassword")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +62,7 @@ android {
|
||||
isDebuggable = true
|
||||
isJniDebuggable = true
|
||||
isMinifyEnabled = false
|
||||
|
||||
packaging {
|
||||
jniLibs.keepDebugSymbols.add("*/arm64-v8a/*.so")
|
||||
jniLibs.keepDebugSymbols.add("*/armeabi-v7a/*.so")
|
||||
@@ -65,14 +72,14 @@ android {
|
||||
}
|
||||
|
||||
getByName("release") {
|
||||
isMinifyEnabled = true
|
||||
|
||||
isMinifyEnabled = false
|
||||
signingConfig = signingConfigs.getByName("release")
|
||||
|
||||
proguardFiles(
|
||||
*fileTree(".") { include("**/*.pro") }
|
||||
.plus(getDefaultProguardFile("proguard-android-optimize.txt"))
|
||||
.toList().toTypedArray()
|
||||
.toList()
|
||||
.toTypedArray()
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -96,6 +103,7 @@ dependencies {
|
||||
implementation("androidx.activity:activity-ktx:1.10.1")
|
||||
implementation("com.google.android.material:material:1.12.0")
|
||||
implementation("androidx.lifecycle:lifecycle-process:2.10.0")
|
||||
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
androidTestImplementation("androidx.test.ext:junit:1.1.4")
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0")
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
<application
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.thomann_dsp_app"
|
||||
android:usesCleartextTraffic="${usesCleartextTraffic}">
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.lucas.thomann_dsp_app
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.KeyEvent
|
||||
import android.webkit.JavascriptInterface
|
||||
import android.webkit.WebView
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
|
||||
class MainActivity : TauriActivity() {
|
||||
private var webView: WebView? = null
|
||||
@Volatile private var interceptVolume = false
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
enableEdgeToEdge()
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
|
||||
override fun onWebViewCreate(webView: WebView) {
|
||||
super.onWebViewCreate(webView)
|
||||
this.webView = webView
|
||||
webView.addJavascriptInterface(object {
|
||||
@JavascriptInterface
|
||||
fun setIntercept(enabled: Boolean) {
|
||||
interceptVolume = enabled
|
||||
}
|
||||
}, "VolumeBridge")
|
||||
}
|
||||
|
||||
private fun isVolumeKey(keyCode: Int) =
|
||||
keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
|
||||
|
||||
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
||||
if (interceptVolume && isVolumeKey(keyCode)) {
|
||||
val name = if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) "volumeupbutton" else "volumedownbutton"
|
||||
webView?.post {
|
||||
webView?.evaluateJavascript("document.dispatchEvent(new Event('$name'))", null)
|
||||
}
|
||||
return true // consumed, so the system volume doesn't change
|
||||
}
|
||||
return super.onKeyDown(keyCode, event)
|
||||
}
|
||||
|
||||
override fun onKeyUp(keyCode: Int, event: KeyEvent?): Boolean {
|
||||
if (interceptVolume && isVolumeKey(keyCode)) return true
|
||||
return super.onKeyUp(keyCode, event)
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
C:/Users/lsdg/OneDrive - ETS ROBERT SAS 49/Bureau/Projects/dsp-thomann-interface/src-tauri/target/armv7-linux-androideabi/release/libthomann_dsp_app_lib.so
|
||||
@@ -1 +0,0 @@
|
||||
C:/Users/lsdg/OneDrive - ETS ROBERT SAS 49/Bureau/Projects/dsp-thomann-interface/src-tauri/target/i686-linux-android/release/libthomann_dsp_app_lib.so
|
||||
@@ -1 +0,0 @@
|
||||
C:/Users/lsdg/OneDrive - ETS ROBERT SAS 49/Bureau/Projects/dsp-thomann-interface/src-tauri/target/x86_64-linux-android/release/libthomann_dsp_app_lib.so
|
||||
@@ -0,0 +1,30 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
||||
@@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World!"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
</adaptive-icon>
|
||||
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 7.8 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#00000000</color>
|
||||
<color name="ic_launcher_background">#fff</color>
|
||||
</resources>
|
||||
@@ -1,2 +1,2 @@
|
||||
#Mon Oct 26 13:42:11 CET 2026
|
||||
#Fri Oct 30 19:15:34 CET 2026
|
||||
gradle.version=8.14.3
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
password=gitgit
|
||||
keyAlias=upload
|
||||
storeFile=C:\\Users\\lsdg\\upload-keystore.jks
|
||||
storeFile=../../../thomann-release.jks
|
||||
storePassword=gitgit
|
||||
keyAlias=thomann
|
||||
keyPassword=gitgit
|
||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 9.6 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 1004 B After Width: | Height: | Size: 1000 B |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 194 KiB After Width: | Height: | Size: 194 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
@@ -6,7 +6,7 @@ import DSPPage from './pages/DspPage/DspPage';
|
||||
import AddDSPForm from './pages/AddDspPage/AddDspPage';
|
||||
import { useNotifications } from './hooks/useNotifications';
|
||||
import Notifications from './components/Notifications/Notifications';
|
||||
import CreditsPage from './pages/CreditsPage/CreditsPage';
|
||||
import SettingsPage from './pages/SettingsPage/SettingsPage';
|
||||
import HomePage from './pages/HomePage/HomePage';
|
||||
import { addDSP, createDSPInstance, restoreDSPs } from './dsp/dspApi';
|
||||
import { removeDSP } from './dsp/dspShared';
|
||||
@@ -20,7 +20,7 @@ function App() {
|
||||
const [selected, setSelected] = useState<number | null>(null);
|
||||
const [page, setPage] = useState<AppPage>('home');
|
||||
const [loaded, setLoaded] = useState(false);
|
||||
const { notifications, notify, removeNotification, hoverNotification } = useNotifications();
|
||||
const { notifications, notify, removeNotification, hoverNotification, setNotificationsDisabled } = useNotifications();
|
||||
const connectedDspCount = dsps.filter((dsp) => isConnected(dsp)).length;
|
||||
const restoreStarted = useRef(false);
|
||||
const isMobile = useIsMobile();
|
||||
@@ -96,8 +96,10 @@ function App() {
|
||||
/>
|
||||
|
||||
<main className="stage">
|
||||
{page === 'credits' ? (
|
||||
<CreditsPage />
|
||||
{page === 'settings' ? (
|
||||
<SettingsPage
|
||||
onNotificationsDisabledChange={setNotificationsDisabled}
|
||||
/>
|
||||
) : page === 'add-dsp' ? (
|
||||
<AddDSPForm
|
||||
onCancel={() => setPage('home')}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
export function SettingsIcon(props: React.SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
{...props}
|
||||
>
|
||||
<path d="M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915" />
|
||||
<circle cx="12" cy="12" r="3" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
@@ -17,6 +17,12 @@
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.choice-select.is-selected {
|
||||
outline: 2px solid var(--accent-brand);
|
||||
outline-offset: -2px;
|
||||
border-radius: 1.6cqh;
|
||||
}
|
||||
|
||||
.choice-select[data-disabled] {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { TriangleDownIcon } from '../../assets/icons/Triangle';
|
||||
import { useVolumeKeys } from '../../hooks/useVolumeKeys';
|
||||
import './ChoiceSelect.css';
|
||||
|
||||
type CommitResult = Promise<boolean | void> | boolean | void;
|
||||
@@ -299,6 +300,20 @@ function ChoiceSelect<T extends string>({
|
||||
return true;
|
||||
};
|
||||
|
||||
const { isSelected, select } = useVolumeKeys({
|
||||
rootRef,
|
||||
disabled,
|
||||
onStep: (volumeDirection) => {
|
||||
// Same mapping as the wheel: up = previous item, down = next item.
|
||||
const direction = volumeDirection === 1 ? -1 : 1;
|
||||
if (open) {
|
||||
setHighlight((h) => Math.min(options.length - 1, Math.max(0, h + direction)));
|
||||
} else if (step(direction)) {
|
||||
scheduleWheelCommit();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
useNonPassiveWheel(triggerRef, (e) => {
|
||||
e.preventDefault();
|
||||
if (disabled) return;
|
||||
@@ -347,10 +362,10 @@ function ChoiceSelect<T extends string>({
|
||||
preview(opt);
|
||||
commitLatest();
|
||||
} else {
|
||||
// Picking the already-shown value still flushes any wheel change that is waiting on its debounce.
|
||||
commitLatest();
|
||||
}
|
||||
setOpen(false);
|
||||
select();
|
||||
triggerRef.current?.focus();
|
||||
}
|
||||
|
||||
@@ -383,10 +398,11 @@ function ChoiceSelect<T extends string>({
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`choice-select ${className}`}
|
||||
className={`choice-select ${isSelected ? 'is-selected' : ''} ${className}`}
|
||||
data-disabled={disabled || undefined}
|
||||
ref={rootRef}
|
||||
style={style}
|
||||
onPointerDown={select}
|
||||
>
|
||||
<button
|
||||
id={id}
|
||||
|
||||
@@ -11,6 +11,20 @@
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.choice-stepper.is-selected {
|
||||
outline: 2px solid var(--accent-brand);
|
||||
outline-offset: -2px;
|
||||
border-radius: 1.6cqh;
|
||||
}
|
||||
|
||||
.choice-stepper.is-touch .choice-stepper__input {
|
||||
pointer-events: none; /* taps go to the root, so the whole stepper gets selected */
|
||||
caret-color: transparent;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.choice-stepper__input {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { JSX, useEffect, useRef, useState } from 'react';
|
||||
import Button from '../Button/Button';
|
||||
import { TriangleUpIcon, TriangleDownIcon } from '../../assets/icons/Triangle';
|
||||
import { useVolumeKeys } from '../../hooks/useVolumeKeys';
|
||||
import { useIsTouch } from '../../hooks/useIsTouch';
|
||||
import './ChoiceStepper.css';
|
||||
|
||||
const WHEEL_COMMIT_DELAY = 250;
|
||||
@@ -114,6 +116,8 @@ function StepperCore<T>({
|
||||
const [text, setText] = useState(formatLabel(value));
|
||||
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
const isMobile = useIsTouch();
|
||||
|
||||
// Latest-value refs, safe to read from async code and timers.
|
||||
const valueRef = useRef(value);
|
||||
@@ -245,6 +249,15 @@ function StepperCore<T>({
|
||||
}, WHEEL_COMMIT_DELAY);
|
||||
}
|
||||
|
||||
const rootRef = useRef<HTMLDivElement>(null);
|
||||
const { isSelected, select, deselect } = useVolumeKeys({
|
||||
rootRef,
|
||||
disabled,
|
||||
onStep: (direction) => {
|
||||
if (step(direction) !== null) scheduleWheelCommit();
|
||||
},
|
||||
});
|
||||
|
||||
useNonPassiveWheel(inputRef, (e) => {
|
||||
if (disabled) return;
|
||||
e.preventDefault();
|
||||
@@ -330,13 +343,20 @@ function StepperCore<T>({
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={`choice-stepper ${className ?? ''}`} data-disabled={disabled || undefined}>
|
||||
<div
|
||||
ref={rootRef}
|
||||
className={`choice-stepper ${isMobile ? 'is-touch' : ''} ${isSelected ? 'is-selected' : ''} ${className ?? ''}`}
|
||||
data-disabled={disabled || undefined}
|
||||
onPointerDown={select}
|
||||
>
|
||||
<input
|
||||
ref={inputRef}
|
||||
id={id}
|
||||
className="choice-stepper__input"
|
||||
value={text}
|
||||
disabled={disabled}
|
||||
readOnly={isMobile}
|
||||
onFocus={deselect}
|
||||
onChange={(e) => {
|
||||
typing.current = true;
|
||||
setText(e.target.value);
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
.notifications {
|
||||
position: fixed;
|
||||
right: var(--space-5);
|
||||
top: var(--space-5);
|
||||
top: calc(var(--topbar-h) + var(--space-3));
|
||||
z-index: 9999;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-3);
|
||||
|
||||
width: 320px;
|
||||
width: min(320px, calc(100vw - 2 * var(--space-5)));
|
||||
pointer-events: none;
|
||||
|
||||
animation: notification-in var(--dur-slow) var(--ease-out); /* no "forwards" */
|
||||
touch-action: pan-y;
|
||||
}
|
||||
|
||||
.notification {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-3);
|
||||
|
||||
@@ -25,14 +22,34 @@
|
||||
border-radius: var(--radius-md);
|
||||
|
||||
font-size: 14px;
|
||||
line-height: 1.45;
|
||||
|
||||
box-shadow: var(--shadow-md);
|
||||
|
||||
animation: notification-in var(--dur-slow) var(--ease-out) forwards;
|
||||
/* no "forwards": it would keep overriding the inline drag transform */
|
||||
animation: notification-in var(--dur-slow) var(--ease-out);
|
||||
|
||||
pointer-events: auto;
|
||||
min-width: 0;
|
||||
|
||||
/* swipe behavior */
|
||||
touch-action: pan-y; /* browser keeps vertical scroll, we handle horizontal */
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
cursor: grab;
|
||||
will-change: transform, opacity;
|
||||
}
|
||||
|
||||
.notification--dragging {
|
||||
cursor: grabbing;
|
||||
}
|
||||
|
||||
/* once the user touches it, the inline style fully controls transform/opacity */
|
||||
.notification--touched:not(.notification-out) {
|
||||
animation: none;
|
||||
}
|
||||
|
||||
/* must stay "forwards" so it holds its end state until removal */
|
||||
.notification-out {
|
||||
animation: notification-out var(--dur-slow) var(--ease-in) forwards;
|
||||
}
|
||||
@@ -76,9 +93,10 @@
|
||||
|
||||
.notification-message {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
min-width: 0;
|
||||
white-space: normal;
|
||||
overflow-wrap: anywhere;
|
||||
word-break: normal;
|
||||
}
|
||||
|
||||
@keyframes notification-in {
|
||||
@@ -105,13 +123,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* After a swipe-dismiss, the inline transition takes over (no restart from translateX(0)) */
|
||||
.notification--swiped {
|
||||
animation: none;
|
||||
}
|
||||
|
||||
@media (pointer: coarse) {
|
||||
/* Undo the global 44px min-height on the small × button */
|
||||
.notification-close {
|
||||
min-height: 0;
|
||||
}
|
||||
@@ -119,11 +131,30 @@
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.notifications {
|
||||
top: calc(var(--topbar-h, 0px) + var(--space-2));
|
||||
left: max(var(--space-3), var(--safe-left, 0px));
|
||||
right: max(var(--space-3), var(--safe-right, 0px));
|
||||
top: calc(var(--topbar-h) + var(--space-2));
|
||||
left: max(var(--space-3), var(--safe-left));
|
||||
right: max(var(--space-3), var(--safe-right));
|
||||
width: auto;
|
||||
max-width: 420px;
|
||||
margin-inline: auto;
|
||||
}
|
||||
|
||||
.notification {
|
||||
padding: var(--space-3);
|
||||
font-size: 14px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.notification-message {
|
||||
white-space: normal;
|
||||
overflow: visible;
|
||||
text-overflow: unset;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.notification {
|
||||
animation-duration: 1ms;
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,11 @@ type Props = {
|
||||
onHover: (id: number, hovering: boolean) => void;
|
||||
};
|
||||
|
||||
const DRAG_START_PX = 8; // movement before it counts as a swipe
|
||||
const DISMISS_RATIO = 0.35; // fraction of the width to drag before it dismisses
|
||||
const DISMISS_MS = 160;
|
||||
const DRAG_START_PX = 6; // movement before it counts as a swipe
|
||||
const DISMISS_RATIO = 0.35; // fraction of width to drag before it dismisses
|
||||
const FLICK_VELOCITY = 0.5; // px/ms, a fast flick dismisses even below the threshold
|
||||
const DISMISS_MS = 180;
|
||||
const SNAP_MS = 220;
|
||||
|
||||
function NotificationItem({
|
||||
n,
|
||||
@@ -23,25 +25,34 @@ function NotificationItem({
|
||||
}) {
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
const startX = useRef<number | null>(null);
|
||||
const dxRef = useRef(0);
|
||||
const locked = useRef(false);
|
||||
const last = useRef({ x: 0, t: 0, v: 0 }); // for velocity
|
||||
|
||||
const [dx, setDx] = useState(0);
|
||||
const [dragging, setDragging] = useState(false);
|
||||
const [swiped, setSwiped] = useState(false);
|
||||
const [interacted, setInteracted] = useState(false); // disables the entry animation after first touch
|
||||
|
||||
function updateDx(v: number) {
|
||||
dxRef.current = v;
|
||||
setDx(v);
|
||||
}
|
||||
|
||||
function reset() {
|
||||
const wasLocked = locked.current;
|
||||
startX.current = null;
|
||||
locked.current = false;
|
||||
setDragging(false);
|
||||
setDx(0);
|
||||
updateDx(0); // transition handles the snap-back
|
||||
if (wasLocked) onHover(n.id, false);
|
||||
}
|
||||
|
||||
function onPointerDown(e: React.PointerEvent<HTMLDivElement>) {
|
||||
if (swiped || n.removing) return;
|
||||
if ((e.target as HTMLElement).closest('button')) return; // let the × button work
|
||||
if ((e.target as HTMLElement).closest('button')) return;
|
||||
startX.current = e.clientX;
|
||||
last.current = { x: e.clientX, t: performance.now(), v: 0 };
|
||||
locked.current = false;
|
||||
}
|
||||
|
||||
@@ -53,13 +64,25 @@ function NotificationItem({
|
||||
if (Math.abs(delta) < DRAG_START_PX) return;
|
||||
locked.current = true;
|
||||
e.currentTarget.setPointerCapture(e.pointerId);
|
||||
setInteracted(true);
|
||||
setDragging(true);
|
||||
onHover(n.id, true); // pause the auto-dismiss timer
|
||||
onHover(n.id, true); // pause auto-dismiss timer
|
||||
}
|
||||
setDx(delta);
|
||||
|
||||
// velocity (smoothed)
|
||||
const now = performance.now();
|
||||
const dt = now - last.current.t;
|
||||
if (dt > 0) {
|
||||
const instant = (e.clientX - last.current.x) / dt;
|
||||
last.current.v = last.current.v * 0.6 + instant * 0.4;
|
||||
}
|
||||
last.current.x = e.clientX;
|
||||
last.current.t = now;
|
||||
|
||||
updateDx(delta);
|
||||
}
|
||||
|
||||
function onPointerUp(e: React.PointerEvent<HTMLDivElement>) {
|
||||
function finish(e: React.PointerEvent<HTMLDivElement>) {
|
||||
if (startX.current === null) return;
|
||||
|
||||
if (!locked.current) {
|
||||
@@ -68,13 +91,18 @@ function NotificationItem({
|
||||
}
|
||||
|
||||
const width = ref.current?.offsetWidth ?? 300;
|
||||
if (Math.abs(dx) > width * DISMISS_RATIO) {
|
||||
const dir = dx > 0 ? 1 : -1;
|
||||
const dist = dxRef.current;
|
||||
const v = last.current.v;
|
||||
const flicked = Math.abs(v) > FLICK_VELOCITY && Math.sign(v) === Math.sign(dist);
|
||||
const farEnough = Math.abs(dist) > width * DISMISS_RATIO;
|
||||
|
||||
if (flicked || farEnough) {
|
||||
const dir = dist > 0 ? 1 : -1;
|
||||
startX.current = null;
|
||||
locked.current = false;
|
||||
setSwiped(true);
|
||||
setDragging(false);
|
||||
setDx(dir * width * 1.2);
|
||||
updateDx(dir * width * 1.1);
|
||||
window.setTimeout(() => onRemove(n.id), DISMISS_MS);
|
||||
} else {
|
||||
reset();
|
||||
@@ -85,14 +113,17 @@ function NotificationItem({
|
||||
}
|
||||
}
|
||||
|
||||
const touched = dx !== 0 || swiped;
|
||||
const style: React.CSSProperties | undefined = touched
|
||||
const width = ref.current?.offsetWidth ?? 300;
|
||||
const progress = Math.min(1, Math.abs(dx) / (width * 0.8));
|
||||
|
||||
const style: React.CSSProperties | undefined = interacted
|
||||
? {
|
||||
transform: `translateX(${dx}px)`,
|
||||
opacity: swiped ? 0 : Math.max(0.3, 1 - Math.abs(dx) / 300),
|
||||
opacity: swiped ? 0 : 1 - progress * 0.9,
|
||||
transition: dragging
|
||||
? 'none'
|
||||
: `transform ${DISMISS_MS}ms ease-out, opacity ${DISMISS_MS}ms ease-out`,
|
||||
: `transform ${swiped ? DISMISS_MS : SNAP_MS}ms cubic-bezier(0.22, 1, 0.36, 1),
|
||||
opacity ${swiped ? DISMISS_MS : SNAP_MS}ms ease-out`,
|
||||
}
|
||||
: undefined;
|
||||
|
||||
@@ -103,7 +134,8 @@ function NotificationItem({
|
||||
'notification',
|
||||
n.type,
|
||||
n.removing && !swiped ? 'notification-out' : '',
|
||||
swiped ? 'notification--swiped' : '',
|
||||
interacted ? 'notification--touched' : '',
|
||||
dragging ? 'notification--dragging' : '',
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ')}
|
||||
@@ -112,7 +144,7 @@ function NotificationItem({
|
||||
onMouseLeave={() => onHover(n.id, false)}
|
||||
onPointerDown={onPointerDown}
|
||||
onPointerMove={onPointerMove}
|
||||
onPointerUp={onPointerUp}
|
||||
onPointerUp={finish}
|
||||
onPointerCancel={reset}
|
||||
>
|
||||
<span className="notification-message" title={n.message}>
|
||||
|
||||
@@ -88,25 +88,22 @@
|
||||
aspect-ratio: 1;
|
||||
}
|
||||
|
||||
.crown-action {
|
||||
height: 70%;
|
||||
aspect-ratio: 1;
|
||||
border-radius: 50%;
|
||||
color: #facc15;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.crown-action:hover {
|
||||
color: #fde047;
|
||||
}
|
||||
|
||||
.icon-crown,
|
||||
.icon-settings,
|
||||
.icon-tab-add,
|
||||
.icon-tab-add-empty {
|
||||
aspect-ratio: 1/1;
|
||||
height: 80%;
|
||||
}
|
||||
|
||||
.settings-action {
|
||||
height: 70%;
|
||||
width: auto;
|
||||
aspect-ratio: 1 / 1;
|
||||
border-radius: 50%;
|
||||
color: var(--text-muted);
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.tab-add-empty {
|
||||
height: 70%;
|
||||
border-radius: var(--radius-pill);
|
||||
@@ -364,7 +361,7 @@
|
||||
|
||||
/* Buttons at least ~40px wide */
|
||||
.tab-add,
|
||||
.crown-action {
|
||||
.settings-action {
|
||||
height: 40px;
|
||||
width: 40px;
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@ import { useEffect, useRef } from 'react';
|
||||
import { DSP, AppPage, isConnected } from '../../types';
|
||||
import AnimatedLogo from '../../assets/icons/AnimatedLogo';
|
||||
import { PlusIcon } from '../../assets/icons/PlusIcon';
|
||||
import { CrownIcon } from '../../assets/icons/CrownIcon';
|
||||
import Led from '../Led/Led';
|
||||
import { CloseIcon } from '../../assets/icons/CloseIcon';
|
||||
|
||||
import './Topbar.css';
|
||||
import { SettingsIcon } from '../../assets/icons/SettingsIcon';
|
||||
|
||||
function getStep(count: number) {
|
||||
if (count <= 4) return 4;
|
||||
@@ -224,15 +224,15 @@ function TopBar({
|
||||
)}
|
||||
|
||||
<button
|
||||
className="crown-action tab-action"
|
||||
title="Credits & Support"
|
||||
aria-label="Credits & Support"
|
||||
className="settings-action tab-action"
|
||||
title="Settings"
|
||||
aria-label="Settings"
|
||||
onClick={() => {
|
||||
setPage('credits');
|
||||
setPage('settings');
|
||||
setSelect(null);
|
||||
}}
|
||||
>
|
||||
<CrownIcon className="icon-crown" />
|
||||
<SettingsIcon className="icon-settings" />
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -14,6 +14,12 @@
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
|
||||
.gauge-viewport.is-selected {
|
||||
outline: 0.4cqh solid var(--accent-brand);
|
||||
outline-offset: -0.4cqh;
|
||||
border-radius: 1.6cqh;
|
||||
}
|
||||
|
||||
.gauge-track {
|
||||
position: relative;
|
||||
flex: 1 1 auto;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { useVolumeKeys } from '../../hooks/useVolumeKeys';
|
||||
import './VerticalSlider.css';
|
||||
|
||||
type StepFn = (value: number) => number;
|
||||
@@ -192,8 +193,9 @@ export default function VerticalSlider({
|
||||
const sliderRef = useRef<HTMLDivElement>(null);
|
||||
const trackRef = useRef<HTMLDivElement>(null);
|
||||
const thumbRef = useRef<HTMLDivElement>(null);
|
||||
const rootRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
// --- shared interaction state (all three input methods use these) ------
|
||||
// --- shared interaction state (all input methods use these) ------------
|
||||
|
||||
/** Latest value shown locally. Source of truth for "where is the thumb right now". */
|
||||
const latestValue = useRef(value);
|
||||
@@ -259,7 +261,8 @@ export default function VerticalSlider({
|
||||
}
|
||||
|
||||
/**
|
||||
* Single serialized commit pipeline shared by drag, keyboard, wheel and text entry.
|
||||
* Single serialized commit pipeline shared by drag, keyboard, wheel,
|
||||
* volume buttons and text entry.
|
||||
*
|
||||
* - Only one onChange is ever in flight.
|
||||
* - While one is in flight, newer values just overwrite `pendingCommit`
|
||||
@@ -409,6 +412,7 @@ export default function VerticalSlider({
|
||||
onInputRef.current?.(next);
|
||||
}
|
||||
|
||||
/** Returns the value one step up (+1) or down (-1) from `base`. */
|
||||
/** Returns the value one step up (+1) or down (-1) from `base`. */
|
||||
function nudge(base: number, direction: 1 | -1) {
|
||||
if (listValues) {
|
||||
@@ -416,9 +420,35 @@ export default function VerticalSlider({
|
||||
const nextIdx = Math.min(listValues.length - 1, Math.max(0, idx + direction));
|
||||
return listValues[nextIdx];
|
||||
}
|
||||
return normalizeValue(base + direction * step(base));
|
||||
|
||||
// Use the step size of the region we're moving INTO. Without this, moving
|
||||
// down from a threshold (e.g. -20) uses the fine step, then gets snapped
|
||||
// back by the coarse grid of the lower region and never leaves.
|
||||
const probe = direction === 1 ? base : base - 1e-9;
|
||||
const s = step(Math.min(max, Math.max(min, probe)));
|
||||
|
||||
return normalizeValue(base + direction * s);
|
||||
}
|
||||
|
||||
/** Moves one step and commits after a short idle delay (shared by wheel and volume buttons). */
|
||||
function nudgeAndCommitDebounced(direction: 1 | -1) {
|
||||
updateValue(nudge(latestValue.current, direction));
|
||||
|
||||
if (wheelTimeout.current) clearTimeout(wheelTimeout.current);
|
||||
wheelTimeout.current = setTimeout(() => {
|
||||
wheelTimeout.current = null;
|
||||
commitLatestIfChanged();
|
||||
}, WHEEL_COMMIT_DELAY_MS);
|
||||
}
|
||||
|
||||
// --- hardware volume buttons (mobile only, via the shared hook) --------
|
||||
|
||||
const { isSelected, select, deselect } = useVolumeKeys({
|
||||
rootRef,
|
||||
disabled,
|
||||
onStep: nudgeAndCommitDebounced, // volume up = increase, down = decrease
|
||||
});
|
||||
|
||||
// --- keyboard ----------------------------------------------------------
|
||||
|
||||
function handleKeyDown(e: React.KeyboardEvent<HTMLDivElement>) {
|
||||
@@ -462,14 +492,7 @@ export default function VerticalSlider({
|
||||
|
||||
// deltaY < 0 means scrolling up/away from the user — treat that as
|
||||
// increasing the value, matching the vertical slider's "up = more".
|
||||
const direction: 1 | -1 = e.deltaY < 0 ? 1 : -1;
|
||||
updateValue(nudge(latestValue.current, direction));
|
||||
|
||||
if (wheelTimeout.current) clearTimeout(wheelTimeout.current);
|
||||
wheelTimeout.current = setTimeout(() => {
|
||||
wheelTimeout.current = null;
|
||||
commitLatestIfChanged();
|
||||
}, WHEEL_COMMIT_DELAY_MS);
|
||||
nudgeAndCommitDebounced(e.deltaY < 0 ? 1 : -1);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
@@ -579,7 +602,10 @@ export default function VerticalSlider({
|
||||
|
||||
return (
|
||||
<div
|
||||
className={['gauge-viewport', disabled && 'is-disabled', className].filter(Boolean).join(' ')}
|
||||
ref={rootRef}
|
||||
className={['gauge-viewport', disabled && 'is-disabled', isSelected && 'is-selected', className]
|
||||
.filter(Boolean)
|
||||
.join(' ')}
|
||||
style={style}
|
||||
>
|
||||
<div
|
||||
@@ -603,10 +629,14 @@ export default function VerticalSlider({
|
||||
aria-valuemax={max}
|
||||
aria-valuenow={displayValue}
|
||||
tabIndex={disabled ? -1 : 0}
|
||||
onFocus={select}
|
||||
onKeyDown={handleKeyDown}
|
||||
onKeyUp={handleKeyUp}
|
||||
onBlur={handleSliderBlur}
|
||||
onPointerDown={startDrag}
|
||||
onPointerDown={(e) => {
|
||||
select();
|
||||
startDrag(e);
|
||||
}}
|
||||
onPointerMove={handlePointerMove}
|
||||
onPointerUp={endDrag}
|
||||
onPointerCancel={endDrag}
|
||||
@@ -632,7 +662,10 @@ export default function VerticalSlider({
|
||||
disabled={disabled}
|
||||
value={editingText ?? formattedValue}
|
||||
style={{ width: '100%' }}
|
||||
onFocus={() => setEditingText(displayValue.toFixed(decimals))} // plain number while editing
|
||||
onFocus={() => {
|
||||
deselect(); // volume keys shouldn't move the slider while typing
|
||||
setEditingText(displayValue.toFixed(decimals)); // plain number while editing
|
||||
}}
|
||||
onChange={(e) => setEditingText(e.target.value)}
|
||||
onBlur={commitEditing}
|
||||
onKeyDown={(e) => {
|
||||
|
||||
@@ -46,6 +46,7 @@ export async function restoreDSPs(
|
||||
});
|
||||
return restored;
|
||||
}
|
||||
|
||||
export async function addDSP(
|
||||
setDsps: SetDsps,
|
||||
setSelected: React.Dispatch<React.SetStateAction<number | null>>,
|
||||
|
||||
@@ -118,7 +118,7 @@ export async function create(params: {
|
||||
ip: params.ip,
|
||||
port: params.port,
|
||||
deviceId: params.deviceId,
|
||||
mode: params.demo ? DSPMode.Demo: DSPMode.Normal,
|
||||
mode: params.demo,
|
||||
isConnecting: false,
|
||||
pollingPaused: true,
|
||||
state: snapshot.state,
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
const QUERY = '(pointer: coarse)';
|
||||
|
||||
/** True when the primary input is a finger, regardless of screen width or orientation. */
|
||||
export function useIsTouch() {
|
||||
const [isTouch, setIsTouch] = useState(() => window.matchMedia(QUERY).matches);
|
||||
|
||||
useEffect(() => {
|
||||
const mq = window.matchMedia(QUERY);
|
||||
const handler = (e: MediaQueryListEvent) => setIsTouch(e.matches);
|
||||
mq.addEventListener('change', handler);
|
||||
return () => mq.removeEventListener('change', handler);
|
||||
}, []);
|
||||
|
||||
return isTouch;
|
||||
}
|
||||
@@ -1,53 +1,151 @@
|
||||
import { useState, useCallback, useRef } from 'react';
|
||||
|
||||
import { useState, useCallback, useRef, useEffect } from 'react';
|
||||
import { NotificationType, Notification } from '../types';
|
||||
import { loadSettings } from '../pages/SettingsPage/settingsStore';
|
||||
|
||||
type PendingNotification = {
|
||||
message: string;
|
||||
type: NotificationType;
|
||||
dspName?: string;
|
||||
};
|
||||
|
||||
export function useNotifications() {
|
||||
const [notifications, setNotifications] = useState<Notification[]>([]);
|
||||
const hovered = useRef<Set<number>>(new Set());
|
||||
const nextId = useRef(0); // monotonically increasing counter
|
||||
|
||||
const notify = useCallback(
|
||||
(message: string, type: NotificationType = 'error', dspName?: string) => {
|
||||
const hovered = useRef<Set<number>>(new Set());
|
||||
const nextId = useRef(0);
|
||||
|
||||
// null means settings haven't loaded yet
|
||||
const disabled = useRef<boolean | null>(null);
|
||||
const overridden = useRef(false);
|
||||
|
||||
const pending = useRef<PendingNotification[]>([]);
|
||||
|
||||
const addNotification = useCallback(
|
||||
({ message, type, dspName }: PendingNotification) => {
|
||||
const id = nextId.current++;
|
||||
|
||||
const fullMessage = dspName ? `${dspName}: ${message}` : message;
|
||||
|
||||
setNotifications((prev) => [...prev, { id, message: fullMessage, type }]);
|
||||
setNotifications((prev) => [
|
||||
...prev,
|
||||
{ id, message: fullMessage, type },
|
||||
]);
|
||||
|
||||
const removeLater = () => {
|
||||
if (hovered.current.has(id)) {
|
||||
setTimeout(removeLater, 1000);
|
||||
return;
|
||||
}
|
||||
|
||||
setNotifications((prev) => prev.filter((n) => n.id !== id));
|
||||
};
|
||||
|
||||
setTimeout(removeLater, 5000);
|
||||
},
|
||||
[]
|
||||
[],
|
||||
);
|
||||
|
||||
// Load notification preference on startup
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
|
||||
async function initialize() {
|
||||
try {
|
||||
const settings = await loadSettings();
|
||||
|
||||
if (cancelled) return;
|
||||
|
||||
// Don't overwrite a setting changed while loading
|
||||
if (!overridden.current) {
|
||||
disabled.current = settings.disableNotifications;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load notification settings:', error);
|
||||
|
||||
if (!cancelled && !overridden.current) {
|
||||
disabled.current = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (cancelled) return;
|
||||
|
||||
// Process notifications queued during initialization
|
||||
const queued = pending.current.splice(0);
|
||||
|
||||
if (!disabled.current) {
|
||||
queued.forEach(addNotification);
|
||||
}
|
||||
}
|
||||
|
||||
initialize();
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [addNotification]);
|
||||
|
||||
// Called by SettingsPage when the checkbox changes
|
||||
const setNotificationsDisabled = useCallback((value: boolean) => {
|
||||
overridden.current = true;
|
||||
disabled.current = value;
|
||||
|
||||
if (value) {
|
||||
setNotifications([]);
|
||||
hovered.current.clear();
|
||||
pending.current = [];
|
||||
}
|
||||
}, []);
|
||||
|
||||
const notify = useCallback(
|
||||
(
|
||||
message: string,
|
||||
type: NotificationType = 'error',
|
||||
dspName?: string,
|
||||
) => {
|
||||
const notification = { message, type, dspName };
|
||||
|
||||
// Wait until the preference has loaded
|
||||
if (disabled.current === null) {
|
||||
pending.current.push(notification);
|
||||
return;
|
||||
}
|
||||
|
||||
if (disabled.current) return;
|
||||
|
||||
addNotification(notification);
|
||||
},
|
||||
[addNotification],
|
||||
);
|
||||
|
||||
const removeNotification = useCallback((id: number) => {
|
||||
hovered.current.delete(id); // prevent leaking stale hover state
|
||||
setNotifications((prev) => prev.map((n) => (n.id === id ? { ...n, removing: true } : n)));
|
||||
hovered.current.delete(id);
|
||||
|
||||
setNotifications((prev) =>
|
||||
prev.map((n) => (n.id === id ? { ...n, removing: true } : n)),
|
||||
);
|
||||
|
||||
setTimeout(() => {
|
||||
setNotifications((prev) => prev.filter((n) => n.id !== id));
|
||||
}, 250);
|
||||
}, []);
|
||||
|
||||
const hoverNotification = useCallback((id: number, hovering: boolean) => {
|
||||
if (hovering) {
|
||||
hovered.current.add(id);
|
||||
} else {
|
||||
hovered.current.delete(id);
|
||||
}
|
||||
}, []);
|
||||
const hoverNotification = useCallback(
|
||||
(id: number, hovering: boolean) => {
|
||||
if (hovering) {
|
||||
hovered.current.add(id);
|
||||
} else {
|
||||
hovered.current.delete(id);
|
||||
}
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
return {
|
||||
notifications,
|
||||
notify,
|
||||
removeNotification,
|
||||
hoverNotification,
|
||||
setNotificationsDisabled,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
import { useEffect, useId, useRef, useState } from 'react';
|
||||
import { useIsTouch } from './useIsTouch';
|
||||
|
||||
/** The control that currently owns the hardware volume buttons. */
|
||||
let activeId: string | null = null;
|
||||
|
||||
function setNativeIntercept(on: boolean) {
|
||||
(window as any).VolumeBridge?.setIntercept(on);
|
||||
}
|
||||
|
||||
type Options = {
|
||||
rootRef: React.RefObject<HTMLElement | null>;
|
||||
/** +1 = volume up, -1 = volume down. Always sees fresh state. */
|
||||
onStep: (direction: 1 | -1) => void;
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
export function useVolumeKeys({ rootRef, onStep, disabled }: Options) {
|
||||
const isMobile = useIsTouch();
|
||||
const id = useId();
|
||||
const [selected, setSelected] = useState(false);
|
||||
|
||||
const onStepRef = useRef(onStep);
|
||||
onStepRef.current = onStep;
|
||||
|
||||
function select() {
|
||||
if (!isMobile || disabled) return;
|
||||
activeId = id;
|
||||
setNativeIntercept(true);
|
||||
setSelected(true);
|
||||
}
|
||||
|
||||
function deselect() {
|
||||
setSelected(false);
|
||||
if (activeId === id) {
|
||||
activeId = null;
|
||||
setNativeIntercept(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Release on unmount
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (activeId === id) {
|
||||
activeId = null;
|
||||
setNativeIntercept(false);
|
||||
}
|
||||
};
|
||||
}, [id]);
|
||||
|
||||
// Release when disabled
|
||||
useEffect(() => {
|
||||
if (disabled) deselect();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [disabled]);
|
||||
|
||||
// Release when tapping outside
|
||||
useEffect(() => {
|
||||
if (!isMobile) return;
|
||||
const onDown = (e: PointerEvent) => {
|
||||
if (rootRef.current?.contains(e.target as Node)) return;
|
||||
setSelected(false);
|
||||
if (activeId === id) {
|
||||
activeId = null;
|
||||
setNativeIntercept(false);
|
||||
}
|
||||
};
|
||||
document.addEventListener('pointerdown', onDown, true);
|
||||
return () => document.removeEventListener('pointerdown', onDown, true);
|
||||
}, [isMobile, id, rootRef]);
|
||||
|
||||
// Volume events from the native bridge
|
||||
useEffect(() => {
|
||||
if (!isMobile || disabled) return;
|
||||
|
||||
const onUp = () => {
|
||||
if (activeId === id) onStepRef.current(1);
|
||||
};
|
||||
const onDown = () => {
|
||||
if (activeId === id) onStepRef.current(-1);
|
||||
};
|
||||
|
||||
document.addEventListener('volumeupbutton', onUp);
|
||||
document.addEventListener('volumedownbutton', onDown);
|
||||
return () => {
|
||||
document.removeEventListener('volumeupbutton', onUp);
|
||||
document.removeEventListener('volumedownbutton', onDown);
|
||||
};
|
||||
}, [isMobile, disabled, id]);
|
||||
|
||||
return { isSelected: isMobile && selected, select, deselect };
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
|
||||
.credits-page {
|
||||
width: 100%;
|
||||
max-width: 520px;
|
||||
margin: auto;
|
||||
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
|
||||
.credits-page__header {
|
||||
margin-bottom: var(--space-5);
|
||||
}
|
||||
|
||||
.credits-page__title {
|
||||
margin: 0;
|
||||
font-size: var(--font-2xl);
|
||||
font-weight: var(--font-weight-semibold);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.credits-page__subtitle {
|
||||
margin: var(--space-2) 0 0;
|
||||
font-size: var(--font-sm);
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.credits-page__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: var(--space-2);
|
||||
}
|
||||
|
||||
.credits-page input,
|
||||
.credits-page select,
|
||||
.credits-page textarea {
|
||||
user-select: text;
|
||||
-webkit-user-select: text;
|
||||
}
|
||||
|
||||
/* ---------- Phone ---------- */
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.credits-page {
|
||||
max-width: 480px;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- Landscape phone: compact card ---------- */
|
||||
|
||||
@media (max-height: 500px) and (orientation: landscape) {
|
||||
.credits-page {
|
||||
max-width: 440px;
|
||||
}
|
||||
|
||||
.credits-page__header {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.credits-page__title {
|
||||
font-size: var(--font-lg);
|
||||
}
|
||||
|
||||
.credits-page__subtitle {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.credits-page .specs {
|
||||
gap: 6px;
|
||||
margin-bottom: 8px;
|
||||
padding: 8px 12px;
|
||||
}
|
||||
|
||||
.credits-page .spec {
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.credits-page .spec dt,
|
||||
.credits-page .spec dd {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.credits-page__actions {
|
||||
margin-top: 4px;
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
import Card from '../../components/Card/Card';
|
||||
import Button from '../../components/Button/Button';
|
||||
|
||||
import './CreditsPage.css';
|
||||
|
||||
function CreditsPage() {
|
||||
return (
|
||||
<Card className="credits-page">
|
||||
<div className="credits-page__header">
|
||||
<h1 className="credits-page__title">Credits</h1>
|
||||
<p className="credits-page__subtitle">
|
||||
Thanks to the people, projects, and communities that made this application possible.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<dl className="specs">
|
||||
<div className="spec">
|
||||
<dt>Developer</dt>
|
||||
<dd>Lucas</dd>
|
||||
</div>
|
||||
|
||||
<div className="spec">
|
||||
<dt>Framework</dt>
|
||||
<dd>React + TypeScript</dd>
|
||||
</div>
|
||||
|
||||
<div className="spec">
|
||||
<dt>Desktop Runtime</dt>
|
||||
<dd>Tauri</dd>
|
||||
</div>
|
||||
|
||||
<div className="spec">
|
||||
<dt>Special Thanks</dt>
|
||||
<dd></dd>
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
<div className="credits-page__actions">
|
||||
<Button variant="primary">Support the Project</Button>
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
export default CreditsPage;
|
||||
@@ -0,0 +1,218 @@
|
||||
|
||||
.settings-page {
|
||||
width: 100%;
|
||||
max-width: 520px;
|
||||
margin: auto;
|
||||
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
|
||||
/* ---------- Header ---------- */
|
||||
|
||||
.settings-page__header {
|
||||
margin-bottom: var(--space-5);
|
||||
}
|
||||
|
||||
.settings-page__title {
|
||||
margin: 0;
|
||||
font-size: var(--font-2xl);
|
||||
font-weight: var(--font-weight-semibold);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.settings-page__hint {
|
||||
margin: var(--space-2) 0 0;
|
||||
font-size: var(--font-sm);
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
/* ---------- Sections ---------- */
|
||||
|
||||
.settings-page__section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.settings-page__section-title {
|
||||
margin: 0;
|
||||
font-size: var(--font-sm);
|
||||
font-weight: var(--font-weight-semibold);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.settings-page__divider {
|
||||
height: 1px;
|
||||
background: var(--border-hairline);
|
||||
margin: var(--space-5) 0;
|
||||
}
|
||||
|
||||
/* ---------- Checkbox ---------- */
|
||||
|
||||
.settings-page__checkbox-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
min-height: 36px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.settings-page__checkbox-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
min-width: 0;
|
||||
|
||||
font-size: var(--font-sm);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.settings-page__description {
|
||||
font-size: var(--font-xs);
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.settings-page__checkbox-label input[type='checkbox'] {
|
||||
appearance: none;
|
||||
-webkit-appearance: none;
|
||||
box-sizing: border-box;
|
||||
|
||||
flex: 0 0 auto;
|
||||
display: block;
|
||||
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
aspect-ratio: 1 / 1;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
|
||||
background: var(--bg-panel);
|
||||
border: var(--border-width) solid var(--border-hairline);
|
||||
border-radius: var(--radius-sm);
|
||||
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
|
||||
transition:
|
||||
border-color var(--dur-base) var(--ease-standard),
|
||||
background var(--dur-base) var(--ease-standard);
|
||||
}
|
||||
|
||||
.settings-page__checkbox-label input[type='checkbox']:checked {
|
||||
background: var(--accent-brand);
|
||||
border-color: var(--accent-brand);
|
||||
}
|
||||
|
||||
.settings-page__checkbox-label input[type='checkbox']:checked::after {
|
||||
content: '';
|
||||
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
|
||||
width: 5px;
|
||||
height: 9px;
|
||||
|
||||
border: solid var(--bg-panel);
|
||||
border-width: 0 2px 2px 0;
|
||||
|
||||
transform: translate(-50%, -60%) rotate(45deg);
|
||||
}
|
||||
|
||||
.settings-page__checkbox-label input[type='checkbox']:focus-visible {
|
||||
outline: 2px solid var(--accent-brand);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
/* ---------- Credits ---------- */
|
||||
|
||||
.settings-page__credits {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-3);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.settings-page__credit {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-3);
|
||||
|
||||
font-size: var(--font-sm);
|
||||
}
|
||||
|
||||
.settings-page__credit dt {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.settings-page__credit dd {
|
||||
margin: 0;
|
||||
color: var(--text-primary);
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* ---------- Text selection ---------- */
|
||||
|
||||
.settings-page input {
|
||||
user-select: text;
|
||||
-webkit-user-select: text;
|
||||
}
|
||||
|
||||
/* ---------- Phone / touch ---------- */
|
||||
|
||||
@media (pointer: coarse) {
|
||||
.settings-page__checkbox-label {
|
||||
min-height: 44px;
|
||||
}
|
||||
|
||||
.settings-page__checkbox-label input[type='checkbox'] {
|
||||
min-height: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.settings-page {
|
||||
width: 100%;
|
||||
max-width: 520px;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- Landscape phone ---------- */
|
||||
|
||||
@media (max-height: 500px) and (orientation: landscape) {
|
||||
.settings-page {
|
||||
max-width: 440px;
|
||||
}
|
||||
|
||||
.settings-page__header {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.settings-page__title {
|
||||
font-size: var(--font-lg);
|
||||
}
|
||||
|
||||
.settings-page__hint {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.settings-page__section {
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.settings-page__divider {
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.settings-page__credits {
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.settings-page__credit,
|
||||
.settings-page__checkbox-content {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
import Card from '../../components/Card/Card';
|
||||
import {
|
||||
AppSettings,
|
||||
DEFAULT_SETTINGS,
|
||||
loadSettings,
|
||||
saveSettings,
|
||||
} from './settingsStore';
|
||||
|
||||
import './SettingsPage.css';
|
||||
|
||||
function SettingsPage({
|
||||
onNotificationsDisabledChange,
|
||||
}: {
|
||||
onNotificationsDisabledChange: (disabled: boolean) => void;
|
||||
}) {
|
||||
const [settings, setSettings] = useState<AppSettings>(DEFAULT_SETTINGS);
|
||||
const [loaded, setLoaded] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
|
||||
async function initialize() {
|
||||
try {
|
||||
const saved = await loadSettings();
|
||||
|
||||
if (!cancelled) {
|
||||
setSettings(saved);
|
||||
onNotificationsDisabledChange(saved.disableNotifications);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load settings:', error);
|
||||
} finally {
|
||||
if (!cancelled) {
|
||||
setLoaded(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
initialize();
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, []);
|
||||
|
||||
async function updateSetting<K extends keyof AppSettings>(
|
||||
key: K,
|
||||
value: AppSettings[K],
|
||||
) {
|
||||
const updated = {
|
||||
...settings,
|
||||
[key]: value,
|
||||
};
|
||||
|
||||
setSettings(updated);
|
||||
|
||||
try {
|
||||
await saveSettings(updated);
|
||||
} catch (error) {
|
||||
console.error('Failed to save settings:', error);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Card className="settings-page">
|
||||
<div className="settings-page__header">
|
||||
<h1 className="settings-page__title">Settings</h1>
|
||||
<p className="settings-page__hint">
|
||||
Customize how the application behaves.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* General */}
|
||||
<div className="settings-page__section">
|
||||
<h2 className="settings-page__section-title">General</h2>
|
||||
|
||||
<label
|
||||
htmlFor="disable-notifications"
|
||||
className="settings-page__checkbox-label"
|
||||
>
|
||||
<input
|
||||
id="disable-notifications"
|
||||
type="checkbox"
|
||||
checked={settings.disableNotifications}
|
||||
disabled={!loaded}
|
||||
onChange={(e) => {
|
||||
const value = e.target.checked;
|
||||
|
||||
onNotificationsDisabledChange(value);
|
||||
updateSetting('disableNotifications', value);
|
||||
}}
|
||||
/>
|
||||
|
||||
<div className="settings-page__checkbox-content">
|
||||
<span>Disable notifications</span>
|
||||
<span className="settings-page__description">
|
||||
Prevent the application from displaying notifications.
|
||||
</span>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div className="settings-page__divider" />
|
||||
|
||||
{/* About */}
|
||||
<div className="settings-page__section">
|
||||
<h2 className="settings-page__section-title">About</h2>
|
||||
|
||||
<dl className="settings-page__credits">
|
||||
<div className="settings-page__credit">
|
||||
<dt>Developer</dt>
|
||||
<dd>Lucas</dd>
|
||||
</div>
|
||||
|
||||
<div className="settings-page__credit">
|
||||
<dt>Framework</dt>
|
||||
<dd>React + TypeScript</dd>
|
||||
</div>
|
||||
|
||||
<div className="settings-page__credit">
|
||||
<dt>Desktop Runtime</dt>
|
||||
<dd>Tauri</dd>
|
||||
</div>
|
||||
|
||||
<div className="settings-page__credit">
|
||||
<dt>Special Thanks</dt>
|
||||
<dd>Open-source community</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
export default SettingsPage;
|
||||
@@ -0,0 +1,36 @@
|
||||
|
||||
import { load, Store } from '@tauri-apps/plugin-store';
|
||||
|
||||
export type AppSettings = {
|
||||
disableNotifications: boolean;
|
||||
};
|
||||
|
||||
export const DEFAULT_SETTINGS: AppSettings = {
|
||||
disableNotifications: false,
|
||||
};
|
||||
|
||||
const STORE_FILE = 'settings.json';
|
||||
const STORE_KEY = 'settings';
|
||||
|
||||
let storePromise: Promise<Store> | null = null;
|
||||
|
||||
const getStore = () =>
|
||||
(storePromise ??= load(STORE_FILE, { autoSave: false }));
|
||||
|
||||
export async function loadSettings(): Promise<AppSettings> {
|
||||
const store = await getStore();
|
||||
|
||||
return {
|
||||
...DEFAULT_SETTINGS,
|
||||
...(await store.get<Partial<AppSettings>>(STORE_KEY)),
|
||||
};
|
||||
}
|
||||
|
||||
export async function saveSettings(
|
||||
settings: AppSettings,
|
||||
): Promise<void> {
|
||||
const store = await getStore();
|
||||
|
||||
await store.set(STORE_KEY, settings);
|
||||
await store.save();
|
||||
}
|
||||
@@ -14,7 +14,7 @@ export type Notification = {
|
||||
removing?: boolean;
|
||||
};
|
||||
|
||||
export type AppPage = 'home' | 'add-dsp' | 'view-dsp' | 'credits';
|
||||
export type AppPage = 'home' | 'add-dsp' | 'view-dsp' | 'settings';
|
||||
|
||||
type DSPDefaultParameters = {
|
||||
ip: string;
|
||||
|
||||