Skip to content

Commit

Permalink
Merge pull request #144 from ronickg/main
Browse files Browse the repository at this point in the history
Various UI improvements and a bug fix.
  • Loading branch information
Rigidity authored Dec 17, 2024
2 parents 992c164 + 7f56a1a commit fb17b8b
Show file tree
Hide file tree
Showing 78 changed files with 2,371 additions and 248 deletions.
62 changes: 61 additions & 1 deletion Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ base64 = "0.22.1"
tauri = "2.1.1"
tauri-plugin-clipboard-manager = "2.0.2"
tauri-plugin-shell = "2.0.2"
tauri-plugin-os = "2.0.0"
tauri-build = "2.0.3"
tauri-plugin-safe-area-insets = { path = "./plugins/tauri-plugin-safe-area-insets" }

# Specta
specta = "2.0.0-rc.20"
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no viewport-fit=cover"
/>
<title>Sage</title>
<link rel="stylesheet" href="/src/index.css" />
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-switch": "^1.1.0",
"@radix-ui/react-tabs": "^1.1.1",
"@react-spring/web": "^9.7.5",
"@tanstack/react-table": "^8.20.5",
"@tauri-apps/api": "2.0.0-rc.4",
"@tauri-apps/plugin-clipboard-manager": "2.0.0-rc.1",
"@tauri-apps/plugin-os": "^2.0.0",
"@tauri-apps/plugin-shell": "2.0.0",
"tauri-plugin-safe-area-insets": "file:./plugins/tauri-plugin-safe-area-insets",
"@use-gesture/react": "^10.3.1",
"@walletconnect/sign-client": "^2.17.2",
"@walletconnect/types": "^2.17.2",
"bignumber.js": "^9.1.2",
Expand All @@ -42,6 +46,7 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.53.0",
"react-imask": "^7.6.1",
"react-router-dom": "^6.26.0",
"tailwind-merge": "^2.5.2",
"tailwindcss-animate": "^1.0.7",
Expand Down
17 changes: 17 additions & 0 deletions plugins/tauri-plugin-safe-area-insets/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/.vs
.DS_Store
.Thumbs.db
*.sublime*
.idea/
debug.log
package-lock.json
.vscode/settings.json
yarn.lock

/.tauri
/target
Cargo.lock
node_modules/

# dist-js
# dist
17 changes: 17 additions & 0 deletions plugins/tauri-plugin-safe-area-insets/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "tauri-plugin-safe-area-insets"
version = "0.1.0"
authors = [ "Ronald <[email protected]>" ]
description = ""
edition = "2021"
rust-version = "1.77.2"
exclude = ["/examples", "/webview-dist", "/webview-src", "/node_modules"]
links = "tauri-plugin-safe-area-insets"

[dependencies]
tauri = { version = "2.1.0" }
serde = "1.0"
thiserror = "2"

[build-dependencies]
tauri-plugin = { version = "2.0.2", features = ["build"] }
1 change: 1 addition & 0 deletions plugins/tauri-plugin-safe-area-insets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Tauri Plugin safe-area-insets
2 changes: 2 additions & 0 deletions plugins/tauri-plugin-safe-area-insets/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build
/.tauri
44 changes: 44 additions & 0 deletions plugins/tauri-plugin-safe-area-insets/android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
}

android {
namespace = "com.plugin.safeareainsets"
compileSdk = 34

defaultConfig {
minSdk = 21

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}

dependencies {

implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.appcompat:appcompat:1.6.0")
implementation("com.google.android.material:material:1.7.0")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
implementation(project(":tauri-android"))
}
21 changes: 21 additions & 0 deletions plugins/tauri-plugin-safe-area-insets/android/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions plugins/tauri-plugin-safe-area-insets/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
google()
}
resolutionStrategy {
eachPlugin {
switch (requested.id.id) {
case "com.android.library":
useVersion("8.0.2")
break
case "org.jetbrains.kotlin.android":
useVersion("1.8.20")
break
}
}
}
}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
google()

}
}

include ':tauri-android'
project(':tauri-android').projectDir = new File('./.tauri/tauri-api')
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.plugin.safeareainsets

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.plugin.safeareainsets", appContext.packageName)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.plugin.safeareainsets

import android.util.Log

class Example {
fun pong(value: String): String {
Log.i("Pong", value)
return value
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.plugin.safeareainsets

import android.app.Activity
import android.view.View
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import app.tauri.annotation.Command
import app.tauri.annotation.TauriPlugin
import app.tauri.plugin.JSObject
import app.tauri.plugin.Plugin
import app.tauri.plugin.Invoke

@TauriPlugin
class InsetPlugin(private val activity: Activity): Plugin(activity) {
private fun toDIPFromPixel(pixels: Float): Float {
val density = activity.resources.displayMetrics.density
return pixels / density
}

@Command
fun getInsets(invoke: Invoke) {
val rootView = activity.window.decorView
ViewCompat.getRootWindowInsets(rootView)?.let { windowInsets ->
val systemBars = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
val result = JSObject()
result.put("top", toDIPFromPixel(systemBars.top.toFloat()).toDouble())
result.put("bottom", toDIPFromPixel(systemBars.bottom.toFloat()).toDouble())
result.put("left", toDIPFromPixel(systemBars.left.toFloat()).toDouble())
result.put("right", toDIPFromPixel(systemBars.right.toFloat()).toDouble())
invoke.resolve(result)
} ?: invoke.reject("Failed to get window insets")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.plugin.safeareainsets

import org.junit.Test

import org.junit.Assert.*

/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
8 changes: 8 additions & 0 deletions plugins/tauri-plugin-safe-area-insets/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const COMMANDS: &[&str] = &["get_insets"];

fn main() {
tauri_plugin::Builder::new(COMMANDS)
.android_path("android")
.ios_path("ios")
.build();
}
9 changes: 9 additions & 0 deletions plugins/tauri-plugin-safe-area-insets/dist-js/index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

var core = require('@tauri-apps/api/core');

async function getInsets() {
return await core.invoke("plugin:window-insets|get_insets");
}

exports.getInsets = getInsets;
Loading

0 comments on commit fb17b8b

Please sign in to comment.