commit cd027b9f9b43f4ffb2f5daf7dbcfd5e93dfc27b9 Author: shahondin1624 Date: Sat Oct 25 11:22:27 2025 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4210562 --- /dev/null +++ b/.gitignore @@ -0,0 +1,17 @@ + +*.iml +.gradle +.idea +.kotlin +.DS_Store +build +*/build +captures +.externalNativeBuild +.cxx +local.properties +xcuserdata/ +Pods/ +*.jks +*.gpg +*yarn.lock diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..6c3692b --- /dev/null +++ b/README.MD @@ -0,0 +1,29 @@ +# ShadowrunCharSheet + +### Android +To run the application on android device/emulator: + - open project in Android Studio and run imported android run configuration + +To build the application bundle: + - run `./gradlew :androidApp:assembleDebug` + - find `.apk` file in `androidApp/build/outputs/apk/debug/androidApp-debug.apk` + +### Desktop +Run the desktop application: `./gradlew :desktopApp:run` +Run the desktop **hot reload** application: `./gradlew :desktopApp:hotRun --auto` + +### iOS +To run the application on iPhone device/simulator: + - Open `iosApp/iosApp.xcproject` in Xcode and run standard configuration + - Or use [Kotlin Multiplatform Mobile plugin](https://plugins.jetbrains.com/plugin/14936-kotlin-multiplatform-mobile) for Android Studio + +### Web Distribution +Build web distribution: `./gradlew :webApp:composeCompatibilityBrowserDistribution` +Deploy a dir `webApp/build/dist/composeWebCompatibility/productionExecutable` to a web server + +### JS Browser +Run the browser application: `./gradlew :webApp:jsBrowserDevelopmentRun` + +### Wasm Browser +Run the browser application: `./gradlew :webApp:wasmJsBrowserDevelopmentRun` + diff --git a/androidApp/build.gradle.kts b/androidApp/build.gradle.kts new file mode 100644 index 0000000..c5109a9 --- /dev/null +++ b/androidApp/build.gradle.kts @@ -0,0 +1,28 @@ +plugins { + alias(libs.plugins.compose.compiler) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.android.application) +} + +android { + namespace = "org.shahondin1624" + compileSdk = 36 + + defaultConfig { + minSdk = 23 + targetSdk = 36 + + applicationId = "org.shahondin1624.androidApp" + versionCode = 1 + versionName = "1.0.0" + } +} + +kotlin { + jvmToolchain(17) +} + +dependencies { + implementation(project(":sharedUI")) + implementation(libs.androidx.activityCompose) +} diff --git a/androidApp/src/main/AndroidManifest.xml b/androidApp/src/main/AndroidManifest.xml new file mode 100644 index 0000000..5b096b8 --- /dev/null +++ b/androidApp/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/androidApp/src/main/kotlin/org/shahondin1624/AppActivity.kt b/androidApp/src/main/kotlin/org/shahondin1624/AppActivity.kt new file mode 100644 index 0000000..940471e --- /dev/null +++ b/androidApp/src/main/kotlin/org/shahondin1624/AppActivity.kt @@ -0,0 +1,33 @@ +package org.shahondin1624 + +import android.app.Activity +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.activity.enableEdgeToEdge +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.ui.platform.LocalView +import androidx.core.view.WindowInsetsControllerCompat + +class AppActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + enableEdgeToEdge() + setContent { + App(onThemeChanged = { ThemeChanged(it) }) + } + } +} + +@Composable +private fun ThemeChanged(isDark: Boolean) { + val view = LocalView.current + LaunchedEffect(isDark) { + val window = (view.context as Activity).window + WindowInsetsControllerCompat(window, window.decorView).apply { + isAppearanceLightStatusBars = isDark + isAppearanceLightNavigationBars = isDark + } + } +} diff --git a/androidApp/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/androidApp/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..345888d --- /dev/null +++ b/androidApp/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/androidApp/src/main/res/mipmap-hdpi/ic_launcher.png b/androidApp/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..fe557d6 Binary files /dev/null and b/androidApp/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/androidApp/src/main/res/mipmap-hdpi/ic_launcher_background.png b/androidApp/src/main/res/mipmap-hdpi/ic_launcher_background.png new file mode 100644 index 0000000..1b4e1e4 Binary files /dev/null and b/androidApp/src/main/res/mipmap-hdpi/ic_launcher_background.png differ diff --git a/androidApp/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/androidApp/src/main/res/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..9b602b9 Binary files /dev/null and b/androidApp/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/androidApp/src/main/res/mipmap-hdpi/ic_launcher_monochrome.png b/androidApp/src/main/res/mipmap-hdpi/ic_launcher_monochrome.png new file mode 100644 index 0000000..d849185 Binary files /dev/null and b/androidApp/src/main/res/mipmap-hdpi/ic_launcher_monochrome.png differ diff --git a/androidApp/src/main/res/mipmap-mdpi/ic_launcher.png b/androidApp/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c079af2 Binary files /dev/null and b/androidApp/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/androidApp/src/main/res/mipmap-mdpi/ic_launcher_background.png b/androidApp/src/main/res/mipmap-mdpi/ic_launcher_background.png new file mode 100644 index 0000000..fac44bd Binary files /dev/null and b/androidApp/src/main/res/mipmap-mdpi/ic_launcher_background.png differ diff --git a/androidApp/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/androidApp/src/main/res/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..6823e99 Binary files /dev/null and b/androidApp/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/androidApp/src/main/res/mipmap-mdpi/ic_launcher_monochrome.png b/androidApp/src/main/res/mipmap-mdpi/ic_launcher_monochrome.png new file mode 100644 index 0000000..5b63c84 Binary files /dev/null and b/androidApp/src/main/res/mipmap-mdpi/ic_launcher_monochrome.png differ diff --git a/androidApp/src/main/res/mipmap-xhdpi/ic_launcher.png b/androidApp/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..3ef2396 Binary files /dev/null and b/androidApp/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/androidApp/src/main/res/mipmap-xhdpi/ic_launcher_background.png b/androidApp/src/main/res/mipmap-xhdpi/ic_launcher_background.png new file mode 100644 index 0000000..efe105a Binary files /dev/null and b/androidApp/src/main/res/mipmap-xhdpi/ic_launcher_background.png differ diff --git a/androidApp/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/androidApp/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..98f4eeb Binary files /dev/null and b/androidApp/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/androidApp/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.png b/androidApp/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.png new file mode 100644 index 0000000..ee450d8 Binary files /dev/null and b/androidApp/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.png differ diff --git a/androidApp/src/main/res/mipmap-xxhdpi/ic_launcher.png b/androidApp/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..883db51 Binary files /dev/null and b/androidApp/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/androidApp/src/main/res/mipmap-xxhdpi/ic_launcher_background.png b/androidApp/src/main/res/mipmap-xxhdpi/ic_launcher_background.png new file mode 100644 index 0000000..c42d5da Binary files /dev/null and b/androidApp/src/main/res/mipmap-xxhdpi/ic_launcher_background.png differ diff --git a/androidApp/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/androidApp/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..791b760 Binary files /dev/null and b/androidApp/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/androidApp/src/main/res/mipmap-xxhdpi/ic_launcher_monochrome.png b/androidApp/src/main/res/mipmap-xxhdpi/ic_launcher_monochrome.png new file mode 100644 index 0000000..7bf2180 Binary files /dev/null and b/androidApp/src/main/res/mipmap-xxhdpi/ic_launcher_monochrome.png differ diff --git a/androidApp/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/androidApp/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..857d804 Binary files /dev/null and b/androidApp/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/androidApp/src/main/res/mipmap-xxxhdpi/ic_launcher_background.png b/androidApp/src/main/res/mipmap-xxxhdpi/ic_launcher_background.png new file mode 100644 index 0000000..f542a43 Binary files /dev/null and b/androidApp/src/main/res/mipmap-xxxhdpi/ic_launcher_background.png differ diff --git a/androidApp/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/androidApp/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..7a102af Binary files /dev/null and b/androidApp/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/androidApp/src/main/res/mipmap-xxxhdpi/ic_launcher_monochrome.png b/androidApp/src/main/res/mipmap-xxxhdpi/ic_launcher_monochrome.png new file mode 100644 index 0000000..76fbc41 Binary files /dev/null and b/androidApp/src/main/res/mipmap-xxxhdpi/ic_launcher_monochrome.png differ diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..4a6c7f8 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,12 @@ +plugins { + alias(libs.plugins.kotlin.multiplatform).apply(false) + alias(libs.plugins.compose.compiler).apply(false) + alias(libs.plugins.compose.multiplatform).apply(false) + alias(libs.plugins.kotlin.android).apply(false) + alias(libs.plugins.android.application).apply(false) + alias(libs.plugins.android.kmp.library).apply(false) + alias(libs.plugins.kotlin.jvm).apply(false) + alias(libs.plugins.compose.hot.reload).apply(false) + alias(libs.plugins.kotlinx.serialization).apply(false) + alias(libs.plugins.metro).apply(false) +} diff --git a/desktopApp/appIcons/LinuxIcon.png b/desktopApp/appIcons/LinuxIcon.png new file mode 100644 index 0000000..a2a4517 Binary files /dev/null and b/desktopApp/appIcons/LinuxIcon.png differ diff --git a/desktopApp/appIcons/MacosIcon.icns b/desktopApp/appIcons/MacosIcon.icns new file mode 100644 index 0000000..083def5 Binary files /dev/null and b/desktopApp/appIcons/MacosIcon.icns differ diff --git a/desktopApp/appIcons/WindowsIcon.ico b/desktopApp/appIcons/WindowsIcon.ico new file mode 100644 index 0000000..7e9ab75 Binary files /dev/null and b/desktopApp/appIcons/WindowsIcon.ico differ diff --git a/desktopApp/build.gradle.kts b/desktopApp/build.gradle.kts new file mode 100644 index 0000000..e107a8c --- /dev/null +++ b/desktopApp/build.gradle.kts @@ -0,0 +1,41 @@ +import org.jetbrains.compose.desktop.application.dsl.TargetFormat +import org.jetbrains.compose.reload.gradle.ComposeHotRun + +plugins { + alias(libs.plugins.compose.compiler) + alias(libs.plugins.compose.multiplatform) + alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.compose.hot.reload) +} + +dependencies { + implementation(project(":sharedUI")) + implementation(compose.ui) +} + +compose.desktop { + application { + mainClass = "MainKt" + + nativeDistributions { + targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) + packageName = "ShadowrunCharSheet" + packageVersion = "1.0.0" + + linux { + iconFile.set(project.file("appIcons/LinuxIcon.png")) + } + windows { + iconFile.set(project.file("appIcons/WindowsIcon.ico")) + } + macOS { + iconFile.set(project.file("appIcons/MacosIcon.icns")) + bundleID = "org.shahondin1624.desktopApp" + } + } + } +} + +tasks.withType().configureEach { + mainClass = "MainKt" +} diff --git a/desktopApp/src/main/kotlin/main.kt b/desktopApp/src/main/kotlin/main.kt new file mode 100644 index 0000000..62dd13e --- /dev/null +++ b/desktopApp/src/main/kotlin/main.kt @@ -0,0 +1,18 @@ +import androidx.compose.ui.unit.dp +import androidx.compose.ui.window.Window +import androidx.compose.ui.window.application +import androidx.compose.ui.window.rememberWindowState +import java.awt.Dimension +import org.shahondin1624.App + +fun main() = application { + Window( + title = "ShadowrunCharSheet", + state = rememberWindowState(width = 800.dp, height = 600.dp), + onCloseRequest = ::exitApplication, + ) { + window.minimumSize = Dimension(350, 600) + App() + } +} + diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..11db907 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,18 @@ +#Gradle +org.gradle.jvmargs=-Xmx4G +org.gradle.caching=true +org.gradle.configuration-cache=true +org.gradle.daemon=true +org.gradle.parallel=true + +#Kotlin +kotlin.code.style=official +kotlin.daemon.jvmargs=-Xmx4G +kotlin.native.binary.gc=cms +kotlin.incremental.wasm=true + +#Android +android.useAndroidX=true +android.nonTransitiveRClass=true +#Compose +org.jetbrains.compose.experimental.jscanvas.enabled=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..f95e2dc --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,61 @@ +[versions] + +kotlin = "2.2.20" +compose-multiplatform = "1.9.0" +agp = "8.12.3" +androidx-activityCompose = "1.10.1" +compose-hot-reload = "1.0.0-beta09" +kotlinx-coroutines = "1.10.2" +ktor = "3.3.0" +androidx-lifecycle = "2.9.4" +androidx-navigation = "2.9.0" +kotlinx-serialization = "1.9.0" +metro = "0.6.8" +coil = "3.3.0" +multiplatformSettings = "1.3.0" +kstore = "1.0.0" +materialKolor = "3.0.1" +materialIcons = "1.7.1" + +[libraries] + +androidx-activityCompose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" } +kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" } +kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" } +kotlinx-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-swing", version.ref = "kotlinx-coroutines" } +kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" } +ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" } +ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" } +ktor-client-serialization = { module = "io.ktor:ktor-client-serialization", version.ref = "ktor" } +ktor-serialization-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" } +ktor-client-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" } +ktor-client-darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor" } +ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" } +ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" } +ktor-client-curl = { module = "io.ktor:ktor-client-curl", version.ref = "ktor" } +ktor-client-winhttp = { module = "io.ktor:ktor-client-winhttp", version.ref = "ktor" } +androidx-lifecycle-viewmodel = { module = "org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "androidx-lifecycle" } +androidx-lifecycle-runtime = { module = "org.jetbrains.androidx.lifecycle:lifecycle-runtime-compose", version.ref = "androidx-lifecycle" } +androidx-navigation-compose = { module = "org.jetbrains.androidx.navigation:navigation-compose", version.ref = "androidx-navigation" } +kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" } +coil = { module = "io.coil-kt.coil3:coil-compose-core", version.ref = "coil" } +coil-network-ktor = { module = "io.coil-kt.coil3:coil-network-ktor3", version.ref = "coil" } +multiplatformSettings = { module = "com.russhwolf:multiplatform-settings-no-arg", version.ref = "multiplatformSettings" } +kstore = { module = "io.github.xxfast:kstore", version.ref = "kstore" } +kstore-file = { module = "io.github.xxfast:kstore-file", version.ref = "kstore" } +kstore-storage = { module = "io.github.xxfast:kstore-storage", version.ref = "kstore" } +materialKolor = { module = "com.materialkolor:material-kolor", version.ref = "materialKolor" } +materialIcons = { module = "org.jetbrains.compose.material:material-icons-extended", version.ref = "materialIcons"} + +[plugins] + +kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } +compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } +compose-multiplatform = { id = "org.jetbrains.compose", version.ref = "compose-multiplatform" } +kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +android-application = { id = "com.android.application", version.ref = "agp" } +android-kmp-library = { id = "com.android.kotlin.multiplatform.library", version.ref = "agp" } +kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +compose-hot-reload = { id = "org.jetbrains.compose.hot-reload", version.ref = "compose-hot-reload" } +kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } +metro = { id = "dev.zacsweers.metro", version.ref = "metro" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..8bdaf60 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..2e11132 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..c2beaed --- /dev/null +++ b/gradlew @@ -0,0 +1,251 @@ +#!/bin/sh + +# +# Copyright © 2015 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH="\\\"\\\"" + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t % %/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..db3a6ac --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,94 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH= + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/iosApp/iosApp.xcodeproj/project.pbxproj b/iosApp/iosApp.xcodeproj/project.pbxproj new file mode 100644 index 0000000..5b7f8e6 --- /dev/null +++ b/iosApp/iosApp.xcodeproj/project.pbxproj @@ -0,0 +1,360 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + A93A953B29CC810C00F8E227 /* iosApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A93A953A29CC810C00F8E227 /* iosApp.swift */; }; + A93A953F29CC810D00F8E227 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A93A953E29CC810D00F8E227 /* Assets.xcassets */; }; + A93A954229CC810D00F8E227 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A93A954129CC810D00F8E227 /* Preview Assets.xcassets */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + A93A953729CC810C00F8E227 /* ShadowrunCharSheet.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ShadowrunCharSheet.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + A93A953A29CC810C00F8E227 /* iosApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iosApp.swift; sourceTree = ""; }; + A93A953E29CC810D00F8E227 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + A93A954129CC810D00F8E227 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + A93A953429CC810C00F8E227 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + A93A952E29CC810C00F8E227 = { + isa = PBXGroup; + children = ( + A93A953929CC810C00F8E227 /* iosApp */, + A93A953829CC810C00F8E227 /* Products */, + C4127409AE3703430489E7BC /* Frameworks */, + ); + sourceTree = ""; + }; + A93A953829CC810C00F8E227 /* Products */ = { + isa = PBXGroup; + children = ( + A93A953729CC810C00F8E227 /* ShadowrunCharSheet.app */, + ); + name = Products; + sourceTree = ""; + }; + A93A953929CC810C00F8E227 /* iosApp */ = { + isa = PBXGroup; + children = ( + A93A953A29CC810C00F8E227 /* iosApp.swift */, + A93A953E29CC810D00F8E227 /* Assets.xcassets */, + A93A954029CC810D00F8E227 /* Preview Content */, + ); + path = iosApp; + sourceTree = ""; + }; + A93A954029CC810D00F8E227 /* Preview Content */ = { + isa = PBXGroup; + children = ( + A93A954129CC810D00F8E227 /* Preview Assets.xcassets */, + ); + path = "Preview Content"; + sourceTree = ""; + }; + C4127409AE3703430489E7BC /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + A93A953629CC810C00F8E227 /* iosApp */ = { + isa = PBXNativeTarget; + buildConfigurationList = A93A954529CC810D00F8E227 /* Build configuration list for PBXNativeTarget "iosApp" */; + buildPhases = ( + A9D80A052AAB5CDE006C8738 /* ShellScript */, + A93A953329CC810C00F8E227 /* Sources */, + A93A953429CC810C00F8E227 /* Frameworks */, + A93A953529CC810C00F8E227 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = iosApp; + productName = iosApp; + productReference = A93A953729CC810C00F8E227 /* ShadowrunCharSheet.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + A93A952F29CC810C00F8E227 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1420; + LastUpgradeCheck = 1420; + TargetAttributes = { + A93A953629CC810C00F8E227 = { + CreatedOnToolsVersion = 14.2; + }; + }; + }; + buildConfigurationList = A93A953229CC810C00F8E227 /* Build configuration list for PBXProject "iosApp" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = A93A952E29CC810C00F8E227; + productRefGroup = A93A953829CC810C00F8E227 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + A93A953629CC810C00F8E227 /* iosApp */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + A93A953529CC810C00F8E227 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A93A954229CC810D00F8E227 /* Preview Assets.xcassets in Resources */, + A93A953F29CC810D00F8E227 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + A9D80A052AAB5CDE006C8738 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "cd \"$SRCROOT/..\"\n./gradlew :sharedUI:embedAndSignAppleFrameworkForXcode\n"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + A93A953329CC810C00F8E227 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A93A953B29CC810C00F8E227 /* iosApp.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + A93A954329CC810D00F8E227 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 16.2; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + A93A954429CC810D00F8E227 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 16.2; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + A93A954629CC810D00F8E227 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\""; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = iosApp/Info.plist; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = org.shahondin1624.iosApp; + PRODUCT_NAME = "ShadowrunCharSheet"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + A93A954729CC810D00F8E227 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\""; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = iosApp/Info.plist; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = org.shahondin1624.iosApp; + PRODUCT_NAME = "ShadowrunCharSheet"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + A93A953229CC810C00F8E227 /* Build configuration list for PBXProject "iosApp" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A93A954329CC810D00F8E227 /* Debug */, + A93A954429CC810D00F8E227 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + A93A954529CC810D00F8E227 /* Build configuration list for PBXNativeTarget "iosApp" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A93A954629CC810D00F8E227 /* Debug */, + A93A954729CC810D00F8E227 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = A93A952F29CC810C00F8E227 /* Project object */; +} diff --git a/iosApp/iosApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/iosApp/iosApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/iosApp/iosApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json b/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-20@2x.png b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-20@2x.png new file mode 100644 index 0000000..41a92ea Binary files /dev/null and b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-20@2x.png differ diff --git a/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-20@2x~ipad.png b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-20@2x~ipad.png new file mode 100644 index 0000000..41a92ea Binary files /dev/null and b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-20@2x~ipad.png differ diff --git a/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-20@3x.png b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-20@3x.png new file mode 100644 index 0000000..ff64c69 Binary files /dev/null and b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-20@3x.png differ diff --git a/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-20~ipad.png b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-20~ipad.png new file mode 100644 index 0000000..5fb4c43 Binary files /dev/null and b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-20~ipad.png differ diff --git a/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-29.png b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-29.png new file mode 100644 index 0000000..c7f7f02 Binary files /dev/null and b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-29.png differ diff --git a/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-29@2x.png b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-29@2x.png new file mode 100644 index 0000000..9068381 Binary files /dev/null and b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-29@2x.png differ diff --git a/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-29@2x~ipad.png b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-29@2x~ipad.png new file mode 100644 index 0000000..9068381 Binary files /dev/null and b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-29@2x~ipad.png differ diff --git a/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-29@3x.png b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-29@3x.png new file mode 100644 index 0000000..4552252 Binary files /dev/null and b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-29@3x.png differ diff --git a/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-29~ipad.png b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-29~ipad.png new file mode 100644 index 0000000..c7f7f02 Binary files /dev/null and b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-29~ipad.png differ diff --git a/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-40@2x.png b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-40@2x.png new file mode 100644 index 0000000..ddd8c8f Binary files /dev/null and b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-40@2x.png differ diff --git a/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-40@2x~ipad.png b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-40@2x~ipad.png new file mode 100644 index 0000000..ddd8c8f Binary files /dev/null and b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-40@2x~ipad.png differ diff --git a/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-40@3x.png b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-40@3x.png new file mode 100644 index 0000000..761f821 Binary files /dev/null and b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-40@3x.png differ diff --git a/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-40~ipad.png b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-40~ipad.png new file mode 100644 index 0000000..41a92ea Binary files /dev/null and b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-40~ipad.png differ diff --git a/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-60@2x~car.png b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-60@2x~car.png new file mode 100644 index 0000000..761f821 Binary files /dev/null and b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-60@2x~car.png differ diff --git a/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-60@3x~car.png b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-60@3x~car.png new file mode 100644 index 0000000..276a950 Binary files /dev/null and b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-60@3x~car.png differ diff --git a/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-83.5@2x~ipad.png b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-83.5@2x~ipad.png new file mode 100644 index 0000000..9e23219 Binary files /dev/null and b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon-83.5@2x~ipad.png differ diff --git a/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon@2x.png b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon@2x.png new file mode 100644 index 0000000..761f821 Binary files /dev/null and b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon@2x.png differ diff --git a/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon@2x~ipad.png b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon@2x~ipad.png new file mode 100644 index 0000000..59ac0ab Binary files /dev/null and b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon@2x~ipad.png differ diff --git a/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon@3x.png b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon@3x.png new file mode 100644 index 0000000..276a950 Binary files /dev/null and b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon@3x.png differ diff --git a/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon~ios-marketing.png b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon~ios-marketing.png new file mode 100644 index 0000000..ef951ed Binary files /dev/null and b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon~ios-marketing.png differ diff --git a/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon~ipad.png b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon~ipad.png new file mode 100644 index 0000000..1923af1 Binary files /dev/null and b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/AppIcon~ipad.png differ diff --git a/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..3be3dd8 --- /dev/null +++ b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,130 @@ +{ + "images": [ + { + "filename": "AppIcon@2x.png", + "idiom": "iphone", + "scale": "2x", + "size": "60x60" + }, + { + "filename": "AppIcon@3x.png", + "idiom": "iphone", + "scale": "3x", + "size": "60x60" + }, + { + "filename": "AppIcon~ipad.png", + "idiom": "ipad", + "scale": "1x", + "size": "76x76" + }, + { + "filename": "AppIcon@2x~ipad.png", + "idiom": "ipad", + "scale": "2x", + "size": "76x76" + }, + { + "filename": "AppIcon-83.5@2x~ipad.png", + "idiom": "ipad", + "scale": "2x", + "size": "83.5x83.5" + }, + { + "filename": "AppIcon-40@2x.png", + "idiom": "iphone", + "scale": "2x", + "size": "40x40" + }, + { + "filename": "AppIcon-40@3x.png", + "idiom": "iphone", + "scale": "3x", + "size": "40x40" + }, + { + "filename": "AppIcon-40~ipad.png", + "idiom": "ipad", + "scale": "1x", + "size": "40x40" + }, + { + "filename": "AppIcon-40@2x~ipad.png", + "idiom": "ipad", + "scale": "2x", + "size": "40x40" + }, + { + "filename": "AppIcon-20@2x.png", + "idiom": "iphone", + "scale": "2x", + "size": "20x20" + }, + { + "filename": "AppIcon-20@3x.png", + "idiom": "iphone", + "scale": "3x", + "size": "20x20" + }, + { + "filename": "AppIcon-20~ipad.png", + "idiom": "ipad", + "scale": "1x", + "size": "20x20" + }, + { + "filename": "AppIcon-20@2x~ipad.png", + "idiom": "ipad", + "scale": "2x", + "size": "20x20" + }, + { + "filename": "AppIcon-29.png", + "idiom": "iphone", + "scale": "1x", + "size": "29x29" + }, + { + "filename": "AppIcon-29@2x.png", + "idiom": "iphone", + "scale": "2x", + "size": "29x29" + }, + { + "filename": "AppIcon-29@3x.png", + "idiom": "iphone", + "scale": "3x", + "size": "29x29" + }, + { + "filename": "AppIcon-29~ipad.png", + "idiom": "ipad", + "scale": "1x", + "size": "29x29" + }, + { + "filename": "AppIcon-29@2x~ipad.png", + "idiom": "ipad", + "scale": "2x", + "size": "29x29" + }, + { + "filename": "AppIcon-60@2x~car.png", + "idiom": "car", + "scale": "2x", + "size": "60x60" + }, + { + "filename": "AppIcon-60@3x~car.png", + "idiom": "car", + "scale": "3x", + "size": "60x60" + }, + { + "filename": "AppIcon~ios-marketing.png", + "idiom": "ios-marketing", + "scale": "1x", + "size": "1024x1024" + } + ] +} diff --git a/iosApp/iosApp/Assets.xcassets/Contents.json b/iosApp/iosApp/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/iosApp/iosApp/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iosApp/iosApp/Info.plist b/iosApp/iosApp/Info.plist new file mode 100644 index 0000000..11845e1 --- /dev/null +++ b/iosApp/iosApp/Info.plist @@ -0,0 +1,8 @@ + + + + + CADisableMinimumFrameDurationOnPhone + + + diff --git a/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json b/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iosApp/iosApp/iosApp.swift b/iosApp/iosApp/iosApp.swift new file mode 100644 index 0000000..0e4b303 --- /dev/null +++ b/iosApp/iosApp/iosApp.swift @@ -0,0 +1,21 @@ +import SwiftUI +import SharedUI + +@main +struct ComposeApp: App { + var body: some Scene { + WindowGroup { + ContentView().ignoresSafeArea(.all) + } + } +} + +struct ContentView: UIViewControllerRepresentable { + func makeUIViewController(context: Context) -> UIViewController { + return MainKt.MainViewController() + } + + func updateUIViewController(_ uiViewController: UIViewController, context: Context) { + // Updates will be handled by Compose + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..99f8e39 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,40 @@ +rootProject.name = "ShadowrunCharSheet" + +pluginManagement { + repositories { + google { + content { + includeGroupByRegex("com\\.android.*") + includeGroupByRegex("com\\.google.*") + includeGroupByRegex("androidx.*") + includeGroupByRegex("android.*") + } + } + gradlePluginPortal() + mavenCentral() + } +} + +dependencyResolutionManagement { + repositories { + google { + content { + includeGroupByRegex("com\\.android.*") + includeGroupByRegex("com\\.google.*") + includeGroupByRegex("androidx.*") + includeGroupByRegex("android.*") + } + } + mavenCentral() + } +} +plugins { + //https://github.com/JetBrains/compose-hot-reload?tab=readme-ov-file#set-up-automatic-provisioning-of-the-jetbrains-runtime-jbr-via-gradle + id("org.gradle.toolchains.foojay-resolver-convention").version("1.0.0") +} + +include(":sharedUI") +include(":androidApp") +include(":desktopApp") +include(":webApp") + diff --git a/sharedUI/build.gradle.kts b/sharedUI/build.gradle.kts new file mode 100644 index 0000000..99f0f3a --- /dev/null +++ b/sharedUI/build.gradle.kts @@ -0,0 +1,96 @@ +import org.jetbrains.compose.ExperimentalComposeLibrary +import org.gradle.kotlin.dsl.withType +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget + +plugins { + alias(libs.plugins.kotlin.multiplatform) + alias(libs.plugins.compose.compiler) + alias(libs.plugins.compose.multiplatform) + alias(libs.plugins.android.kmp.library) + alias(libs.plugins.compose.hot.reload) + alias(libs.plugins.kotlinx.serialization) + alias(libs.plugins.metro) +} + +kotlin { + android { + namespace = "org.shahondin1624" + compileSdk = 36 + minSdk = 23 + androidResources.enable = true + } + + jvm() + + js { browser() } + wasmJs { browser() } + + iosX64() + iosArm64() + iosSimulatorArm64() + + sourceSets { + commonMain.dependencies { + implementation(compose.runtime) + implementation(compose.ui) + implementation(compose.foundation) + implementation(compose.material3) + implementation(compose.components.resources) + implementation(compose.components.uiToolingPreview) + implementation(libs.kotlinx.coroutines.core) + implementation(libs.ktor.client.core) + implementation(libs.ktor.client.content.negotiation) + implementation(libs.ktor.client.serialization) + implementation(libs.ktor.serialization.json) + implementation(libs.ktor.client.logging) + implementation(libs.androidx.lifecycle.viewmodel) + implementation(libs.androidx.lifecycle.runtime) + implementation(libs.androidx.navigation.compose) + implementation(libs.kotlinx.serialization.json) + implementation(libs.coil) + implementation(libs.coil.network.ktor) + implementation(libs.multiplatformSettings) + implementation(libs.kstore) + implementation(libs.materialKolor) + implementation(libs.materialIcons) + } + + commonTest.dependencies { + implementation(kotlin("test")) + @OptIn(ExperimentalComposeLibrary::class) + implementation(compose.uiTest) + implementation(libs.kotlinx.coroutines.test) + } + + androidMain.dependencies { + implementation(compose.uiTooling) + implementation(libs.kotlinx.coroutines.android) + implementation(libs.ktor.client.okhttp) + implementation(libs.kstore.file) + } + + jvmMain.dependencies { + implementation(compose.desktop.currentOs) + implementation(libs.kotlinx.coroutines.swing) + implementation(libs.ktor.client.okhttp) + implementation(libs.kstore.file) + } + + webMain.dependencies { + implementation(libs.kstore.storage) + } + + iosMain.dependencies { + implementation(libs.ktor.client.darwin) + implementation(libs.kstore.file) + } + + } + + targets + .withType() + .matching { it.konanTarget.family.isAppleFamily } + .configureEach { + binaries { framework { baseName = "SharedUI" } } + } +} diff --git a/sharedUI/src/commonMain/composeResources/drawable/dice.png b/sharedUI/src/commonMain/composeResources/drawable/dice.png new file mode 100644 index 0000000..a989544 Binary files /dev/null and b/sharedUI/src/commonMain/composeResources/drawable/dice.png differ diff --git a/sharedUI/src/commonMain/composeResources/drawable/ic_cyclone.xml b/sharedUI/src/commonMain/composeResources/drawable/ic_cyclone.xml new file mode 100644 index 0000000..f1c45b5 --- /dev/null +++ b/sharedUI/src/commonMain/composeResources/drawable/ic_cyclone.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/sharedUI/src/commonMain/composeResources/drawable/ic_dark_mode.xml b/sharedUI/src/commonMain/composeResources/drawable/ic_dark_mode.xml new file mode 100644 index 0000000..0ce2444 --- /dev/null +++ b/sharedUI/src/commonMain/composeResources/drawable/ic_dark_mode.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/sharedUI/src/commonMain/composeResources/drawable/ic_light_mode.xml b/sharedUI/src/commonMain/composeResources/drawable/ic_light_mode.xml new file mode 100644 index 0000000..b7331d3 --- /dev/null +++ b/sharedUI/src/commonMain/composeResources/drawable/ic_light_mode.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/sharedUI/src/commonMain/composeResources/drawable/ic_rotate_right.xml b/sharedUI/src/commonMain/composeResources/drawable/ic_rotate_right.xml new file mode 100644 index 0000000..1810671 --- /dev/null +++ b/sharedUI/src/commonMain/composeResources/drawable/ic_rotate_right.xml @@ -0,0 +1,10 @@ + + + \ No newline at end of file diff --git a/sharedUI/src/commonMain/composeResources/font/IndieFlower-Regular.ttf b/sharedUI/src/commonMain/composeResources/font/IndieFlower-Regular.ttf new file mode 100644 index 0000000..3774ef5 Binary files /dev/null and b/sharedUI/src/commonMain/composeResources/font/IndieFlower-Regular.ttf differ diff --git a/sharedUI/src/commonMain/composeResources/values/strings.xml b/sharedUI/src/commonMain/composeResources/values/strings.xml new file mode 100644 index 0000000..b8d73e4 --- /dev/null +++ b/sharedUI/src/commonMain/composeResources/values/strings.xml @@ -0,0 +1,7 @@ + + Cyclone + Open github + Run + Stop + Theme + \ No newline at end of file diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/App.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/App.kt new file mode 100644 index 0000000..aed923b --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/App.kt @@ -0,0 +1,119 @@ +package org.shahondin1624 + +import androidx.compose.foundation.layout.* +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.DarkMode +import androidx.compose.material.icons.filled.LightMode +import androidx.compose.material.icons.filled.Menu +import androidx.compose.material.icons.filled.Person +import androidx.compose.material.icons.filled.Settings +import androidx.compose.material3.* +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.setValue +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp +import kotlinx.coroutines.launch +import org.jetbrains.compose.ui.tooling.preview.Preview +import org.shahondin1624.lib.components.charactermodel.attributespage.AttributesPage +import org.shahondin1624.model.EXAMPLE_CHARACTER +import org.shahondin1624.theme.AppTheme +import org.shahondin1624.theme.LocalThemeIsDark + +@OptIn(ExperimentalMaterial3Api::class) +@Preview +@Composable +fun App( + onThemeChanged: @Composable (isDark: Boolean) -> Unit = {} +) = AppTheme(onThemeChanged) { + val character = EXAMPLE_CHARACTER + var isDark by LocalThemeIsDark.current + val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed) + val scope = rememberCoroutineScope() + + ModalNavigationDrawer( + drawerState = drawerState, + drawerContent = { + ModalDrawerSheet { + Spacer(Modifier.height(16.dp)) + Text( + "Menu", + modifier = Modifier.padding(16.dp), + style = MaterialTheme.typography.titleLarge + ) + HorizontalDivider() + Spacer(Modifier.height(8.dp)) + + NavigationDrawerItem( + icon = { Icon(Icons.Default.Person, contentDescription = null) }, + label = { Text("Character Sheet") }, + selected = true, + onClick = { + scope.launch { drawerState.close() } + }, + modifier = Modifier.padding(horizontal = 12.dp, vertical = 4.dp) + ) + + NavigationDrawerItem( + icon = { Icon(Icons.Default.Settings, contentDescription = null) }, + label = { Text("Settings") }, + selected = false, + onClick = { + scope.launch { drawerState.close() } + // TODO: Navigate to settings + }, + modifier = Modifier.padding(horizontal = 12.dp, vertical = 4.dp) + ) + } + } + ) { + Scaffold( + modifier = Modifier.fillMaxSize(), + topBar = { + TopAppBar( + title = { Text("Shadowrun Character Sheet") }, + navigationIcon = { + IconButton(onClick = { + scope.launch { + if (drawerState.isClosed) { + drawerState.open() + } else { + drawerState.close() + } + } + }) { + Icon(Icons.Default.Menu, contentDescription = "Menu") + } + }, + actions = { + IconButton(onClick = { isDark = !isDark }) { + Icon( + imageVector = if (isDark) { + Icons.Default.LightMode + } else { + Icons.Default.DarkMode + }, + contentDescription = "Toggle ${if (isDark) "Light" else "Dark"} mode" + ) + } + } + ) + } + ) { paddingValues -> + Column( + modifier = Modifier + .fillMaxSize() + .padding(paddingValues) + .windowInsetsPadding(WindowInsets.safeDrawing) + .padding(16.dp), + horizontalAlignment = Alignment.CenterHorizontally + ) { + AttributesPage(character) + } + } + } +} diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/components/UiConstants.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/components/UiConstants.kt new file mode 100644 index 0000000..cce6708 --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/components/UiConstants.kt @@ -0,0 +1,7 @@ +package org.shahondin1624.lib.components + +import androidx.compose.ui.unit.dp + +object UiConstants { + val SMALL_PADDING = 6.dp +} \ No newline at end of file diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/components/charactermodel/Tooltip.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/components/charactermodel/Tooltip.kt new file mode 100644 index 0000000..b211142 --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/components/charactermodel/Tooltip.kt @@ -0,0 +1,2 @@ +package org.shahondin1624.lib.components.charactermodel + diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/components/charactermodel/attributespage/Attribute.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/components/charactermodel/attributespage/Attribute.kt new file mode 100644 index 0000000..a885214 --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/components/charactermodel/attributespage/Attribute.kt @@ -0,0 +1,80 @@ +package org.shahondin1624.lib.components.charactermodel.attributespage + +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.* +import androidx.compose.material3.Card +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.ColorFilter +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.dp +import org.jetbrains.compose.resources.painterResource +import org.shahondin1624.lib.components.UiConstants.SMALL_PADDING +import org.shahondin1624.lib.functions.DiceRoll +import org.shahondin1624.model.attributes.Attribute +import org.shahondin1624.theme.LocalThemeIsDark +import shadowruncharsheet.sharedui.generated.resources.Res +import shadowruncharsheet.sharedui.generated.resources.dice + +@Composable +fun Attribute( + attribute: Attribute, + onRoll: (DiceRoll) -> Unit = { + println("Result for $attribute: ${it.result}") + }, +) { + var isInDarkMode by LocalThemeIsDark.current + val textColor = if (isInDarkMode) Color.Black else Color.White + Card { + Row( + verticalAlignment = androidx.compose.ui.Alignment.CenterVertically, + horizontalArrangement = Arrangement.Start + ) { + Row(modifier = Modifier + .padding(horizontal = SMALL_PADDING) + .background(attribute.type.color, shape = androidx.compose.foundation.shape.RoundedCornerShape(4.dp)) + .clip(androidx.compose.foundation.shape.RoundedCornerShape(4.dp)), + horizontalArrangement = Arrangement.SpaceBetween) { + Text( + text = attribute.type.name, + modifier = Modifier + .width(90.dp) + .padding(start = SMALL_PADDING), + textAlign = TextAlign.Center, + color = textColor + ) + Text( + text = attribute.value.toString(), + modifier = Modifier + .padding(end = SMALL_PADDING), + textAlign = TextAlign.Center, + color = textColor + ) + } + IconButton( + onClick = { + val result = attribute.test() + onRoll(result) + }, + modifier = Modifier.padding(end = SMALL_PADDING) + ) { + Image( + painter = painterResource(Res.drawable.dice), + contentDescription = "Roll dice", + colorFilter = ColorFilter.tint( + color = MaterialTheme.colorScheme.onSurface + ), + modifier = Modifier.size(24.dp) + ) + } + } + } +} \ No newline at end of file diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/components/charactermodel/attributespage/AttributesPage.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/components/charactermodel/attributespage/AttributesPage.kt new file mode 100644 index 0000000..f7a1b4f --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/components/charactermodel/attributespage/AttributesPage.kt @@ -0,0 +1,57 @@ +package org.shahondin1624.lib.components.charactermodel.attributespage + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.ColumnScope +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.grid.GridCells +import androidx.compose.foundation.lazy.grid.GridItemSpan +import androidx.compose.foundation.lazy.grid.LazyVerticalGrid +import androidx.compose.foundation.lazy.grid.items +import androidx.compose.foundation.lazy.grid.rememberLazyGridState +import androidx.compose.material3.HorizontalDivider +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp +import org.shahondin1624.model.charactermodel.ShadowrunCharacter + +@Composable +fun ColumnScope.AttributesPage(character: ShadowrunCharacter) { + Box(modifier = Modifier.fillMaxWidth().weight(1f)) { + val gridState = rememberLazyGridState() + + LazyVerticalGrid( + columns = GridCells.Adaptive(minSize = 75.dp), + state = gridState, + modifier = Modifier.fillMaxSize().padding(16.dp), + horizontalArrangement = Arrangement.spacedBy(8.dp), + verticalArrangement = Arrangement.spacedBy(8.dp) + ) { + items( + items = character.attributes.getAllAttributes(), + span = { + GridItemSpan(2) + }) { attribute -> + Attribute(attribute) + } + + item(span = { GridItemSpan(maxLineSpan) }) { + HorizontalDivider( + modifier = Modifier.padding(vertical = 16.dp), + thickness = 2.dp + ) + } + + items( + items = character.talents.talents, + span = { + GridItemSpan(3) + } + ) { talent -> + Talent(talent, character.attributes) + } + } + } +} \ No newline at end of file diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/components/charactermodel/attributespage/Talent.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/components/charactermodel/attributespage/Talent.kt new file mode 100644 index 0000000..b80cca9 --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/components/charactermodel/attributespage/Talent.kt @@ -0,0 +1,100 @@ +package org.shahondin1624.lib.components.charactermodel.attributespage + +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Card +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.ColorFilter +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.dp +import org.jetbrains.compose.resources.painterResource +import org.shahondin1624.lib.components.UiConstants.SMALL_PADDING +import org.shahondin1624.lib.functions.DiceRoll +import org.shahondin1624.model.attributes.Attributes +import org.shahondin1624.model.talents.TalentDefinition +import org.shahondin1624.theme.LocalThemeIsDark +import shadowruncharsheet.sharedui.generated.resources.Res +import shadowruncharsheet.sharedui.generated.resources.dice + +@Composable +fun Talent( + talent: TalentDefinition, + attributes: Attributes, + onRoll: (DiceRoll) -> Unit = { + println("Result for $talent: ${it.result}") + }, +) { + var isInDarkMode by LocalThemeIsDark.current + val textColor = if (isInDarkMode) Color.Black else Color.White + Card { + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.Start + ) { + Row( + modifier = Modifier + .padding(horizontal = SMALL_PADDING) + .background( + talent.attribute.color, + shape = RoundedCornerShape(4.dp) + ) + .clip(androidx.compose.foundation.shape.RoundedCornerShape(4.dp)), + horizontalArrangement = Arrangement.SpaceBetween + ) { + Text( + text = talent.name, + modifier = Modifier + .width(150.dp) + .padding(start = SMALL_PADDING), + textAlign = TextAlign.Center, + color = textColor + ) + Text( + text = attributes.getAttributeByType(talent.attribute).value.toString(), + modifier = Modifier + .padding(end = SMALL_PADDING), + textAlign = TextAlign.Center, + color = textColor + ) + Text( + text = talent.value.toString(), + modifier = Modifier + .padding(end = SMALL_PADDING), + textAlign = TextAlign.Center, + color = textColor + ) + } + IconButton( + onClick = { + val result = talent.test(modifiers = emptyList(), attributes = attributes) + onRoll(result) + }, + modifier = Modifier.padding(end = SMALL_PADDING) + ) { + Image( + painter = painterResource(Res.drawable.dice), + contentDescription = "Roll dice", + colorFilter = ColorFilter.tint( + color = MaterialTheme.colorScheme.onSurface + ), + modifier = Modifier.size(24.dp) + ) + } + } + } +} \ No newline at end of file diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/components/settings/Settings.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/components/settings/Settings.kt new file mode 100644 index 0000000..7c747f5 --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/components/settings/Settings.kt @@ -0,0 +1,2 @@ +package org.shahondin1624.lib.components.settings + diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/functions/DataLoader.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/functions/DataLoader.kt new file mode 100644 index 0000000..a36f0b0 --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/functions/DataLoader.kt @@ -0,0 +1,28 @@ +package org.shahondin1624.lib.functions + +import kotlinx.serialization.encodeToString +import kotlinx.serialization.decodeFromString +import kotlinx.serialization.json.Json +import org.shahondin1624.model.charactermodel.ShadowrunCharacter + +/** + * Platform-agnostic serialization helpers for ShadowrunCharacter. + * + * File I/O (reading/writing from disk) should be implemented per-platform + * (androidMain, jvmMain, iosMain, webMain). Here we only convert to/from JSON strings. + */ +object DataLoader { + // Shared Json configuration used across the app + internal val json: Json = Json { + prettyPrint = true + ignoreUnknownKeys = true + // Default classDiscriminator = "type" works with our sealed TalentDefinition hierarchy + encodeDefaults = true + } + + fun serialize(character: ShadowrunCharacter): String = + json.encodeToString(character) + + fun deserialize(jsonString: String): ShadowrunCharacter = + json.decodeFromString(jsonString) +} diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/functions/Dice.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/functions/Dice.kt new file mode 100644 index 0000000..149d2f6 --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/functions/Dice.kt @@ -0,0 +1,22 @@ +package org.shahondin1624.lib.functions + +import kotlin.random.Random + +fun rollDice(sides: Int) = Random.nextInt(sides) + 1 + +fun rollXDice(sides: Int = 6, numberOfDice: Int) = (0 until numberOfDice).map { rollDice(sides) } + +fun List.countSuccesses(numberForSuccessOrHigher: Int = 5) = this.count { it >= numberForSuccessOrHigher } + +data class DiceRoll( + val numberOfDice: Int, + val numberOfSides: Int = 6, + val numberForSuccessOrHigher: Int = 5, + val result: List = listOf(), + val numberOfSuccesses: Int = -1 +) { + fun roll(numberForSuccessOrHigher: Int = 5): DiceRoll = this.copy( + result = rollXDice(sides = this.numberOfSides, numberOfDice = this.numberOfDice), + numberOfSuccesses = result.countSuccesses(numberForSuccessOrHigher) + ) +} \ No newline at end of file diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/Defaults.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/Defaults.kt new file mode 100644 index 0000000..fe74448 --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/Defaults.kt @@ -0,0 +1,43 @@ +package org.shahondin1624.model + +import org.shahondin1624.model.attributes.Attribute +import org.shahondin1624.model.attributes.AttributeType +import org.shahondin1624.model.attributes.Attributes +import org.shahondin1624.model.characterdata.CharacterData +import org.shahondin1624.model.characterdata.Metatype +import org.shahondin1624.model.charactermodel.ShadowrunCharacter +import org.shahondin1624.model.charactermodel.createDamageMonitor +import org.shahondin1624.model.talents.Talents +import org.shahondin1624.model.talents.createAllProvidedTalents + +val EXAMPLE_ATTRIBUTES = Attributes( + body = Attribute(AttributeType.Body, 3), + agility = Attribute(AttributeType.Agility, 4), + reaction = Attribute(AttributeType.Reaction, 3), + strength = Attribute(AttributeType.Strength, 2), + willpower = Attribute(AttributeType.Willpower, 3), + logic = Attribute(AttributeType.Logic, 4), + intuition = Attribute(AttributeType.Intuition, 3), + charisma = Attribute(AttributeType.Charisma, 2), + edge = 2 +) + +val EXAMPLE_CHARACTER: ShadowrunCharacter = ShadowrunCharacter( + attributes = EXAMPLE_ATTRIBUTES, + talents = Talents(createAllProvidedTalents()), + characterData = CharacterData( + concept = "Example", + nuyen = 10500, + essence = 6.0f, + name = "Max Mustermann", + metatype = Metatype.Human, + age = 27, + gender = "male", + streetCred = 0, + notoriety = 0, + publicAwareness = 0, + totalKarma = 55, + currentKarma = 20 + ), + damageMonitor = createDamageMonitor(EXAMPLE_ATTRIBUTES), +) \ No newline at end of file diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/Versionable.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/Versionable.kt new file mode 100644 index 0000000..fd8ae8f --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/Versionable.kt @@ -0,0 +1,5 @@ +package org.shahondin1624.model + +interface Versionable { + val version: String +} \ No newline at end of file diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/attributes/Attribute.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/attributes/Attribute.kt new file mode 100644 index 0000000..4828cae --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/attributes/Attribute.kt @@ -0,0 +1,13 @@ +package org.shahondin1624.model.attributes + +import kotlinx.serialization.Serializable +import org.shahondin1624.lib.functions.DiceRoll +import org.shahondin1624.model.modifier.SRModifier +import org.shahondin1624.model.modifier.accumulateModifiers + +@Serializable +data class Attribute(val type: AttributeType, val value: Int) { + fun test(modifiers: List> = emptyList()): DiceRoll { + return modifiers.accumulateModifiers(DiceRoll(numberOfDice = value)).roll() + } +} diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/attributes/AttributeType.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/attributes/AttributeType.kt new file mode 100644 index 0000000..3771571 --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/attributes/AttributeType.kt @@ -0,0 +1,18 @@ +package org.shahondin1624.model.attributes + +import androidx.compose.ui.graphics.Color +import kotlinx.serialization.Serializable +import kotlinx.serialization.Transient + +@Serializable +enum class AttributeType(@Transient val color: Color) { + Body(Color(251, 84, 43)), + Agility(Color(239, 229, 138)), + Reaction(Color(89, 170, 56)), + Strength(Color.Red), + Willpower(Color.Blue), + Logic(Color(147, 104, 31)), + Intuition(Color.Gray), + Charisma(Color(225, 172, 46)) + ; +} \ No newline at end of file diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/attributes/Attributes.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/attributes/Attributes.kt new file mode 100644 index 0000000..e300882 --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/attributes/Attributes.kt @@ -0,0 +1,124 @@ +package org.shahondin1624.model.attributes + +import kotlinx.serialization.Serializable +import kotlinx.serialization.Transient +import org.shahondin1624.model.Versionable +import org.shahondin1624.model.modifier.AttributeModifier +import org.shahondin1624.model.modifier.ModifierCache + +@Serializable +data class Attributes( + private val body: Attribute, + private val agility: Attribute, + private val reaction: Attribute, + private val strength: Attribute, + private val willpower: Attribute, + private val logic: Attribute, + private val intuition: Attribute, + private val charisma: Attribute, + val edge: Int, + @Transient + private val cache: ModifierCache = ModifierCache(), + override val version: String = "v0.1" +): Versionable { + private fun applyModifiers(modifiers: List): Attributes { + return cache.applyModifiers(modifiers, this) + } + + fun body(modifiers: List = emptyList()): Int { + return applyModifiers(modifiers).body.value + } + + fun agility(modifiers: List = emptyList()): Int { + return applyModifiers(modifiers).agility.value + } + + fun reaction(modifiers: List = emptyList()): Int { + return applyModifiers(modifiers).reaction.value + } + + fun strength(modifiers: List = emptyList()): Int { + return applyModifiers(modifiers).strength.value + } + + fun willpower(modifiers: List = emptyList()): Int { + return applyModifiers(modifiers).willpower.value + } + + fun logic(modifiers: List = emptyList()): Int { + return applyModifiers(modifiers).logic.value + } + + fun intuition(modifiers: List = emptyList()): Int { + return applyModifiers(modifiers).intuition.value + } + + fun charisma(modifiers: List = emptyList()): Int { + return applyModifiers(modifiers).charisma.value + } + + fun initiative(modifiers: List = emptyList()): Int { + return applyModifiers(modifiers).reaction.value + applyModifiers(modifiers).intuition.value + } + + fun matrixInitiative(modifiers: List = emptyList()): Int { + return applyModifiers(modifiers).logic.value + } + + fun astralInitiative(modifiers: List = emptyList()): Int { + return 0 + } + + fun composure(modifiers: List = emptyList()): Int { + return applyModifiers(modifiers).body.value + applyModifiers(modifiers).willpower.value + } + + fun judgeIntent(modifiers: List = emptyList()): Int { + return applyModifiers(modifiers).intuition.value + applyModifiers(modifiers).charisma.value + } + + fun memory(modifiers: List = emptyList()): Int { + return applyModifiers(modifiers).logic.value + applyModifiers(modifiers).willpower.value + } + + fun carry(modifiers: List = emptyList()): Int { + return applyModifiers(modifiers).strength.value * 2 + } + + fun run(modifiers: List = emptyList()): Int { + return applyModifiers(modifiers).agility.value + applyModifiers(modifiers).body.value + } + + fun physicalLimit(modifiers: List = emptyList()): Int { + return applyModifiers(modifiers).body.value + applyModifiers(modifiers).strength.value + } + + fun mentalLimit(modifiers: List = emptyList()): Int { + return applyModifiers(modifiers).willpower.value + applyModifiers(modifiers).logic.value + } + + fun socialLimit(modifiers: List = emptyList()): Int { + return applyModifiers(modifiers).charisma.value + applyModifiers(modifiers).body.value + } + + fun mageResistance(modifiers: List = emptyList()): Int { + return 0 + } + + fun getAttributeByType(type: AttributeType): Attribute { + return when (type) { + AttributeType.Body -> body + AttributeType.Agility -> agility + AttributeType.Reaction -> reaction + AttributeType.Strength -> strength + AttributeType.Willpower -> willpower + AttributeType.Logic -> logic + AttributeType.Intuition -> intuition + AttributeType.Charisma -> charisma + } + } + + fun getAllAttributes(): List { + return listOf(body, agility, reaction, strength, willpower, logic, intuition, charisma) + } +} \ No newline at end of file diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/characterdata/CharacterData.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/characterdata/CharacterData.kt new file mode 100644 index 0000000..b9d792d --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/characterdata/CharacterData.kt @@ -0,0 +1,21 @@ +package org.shahondin1624.model.characterdata + +import kotlinx.serialization.Serializable +import org.shahondin1624.model.Versionable + +@Serializable +data class CharacterData( + val concept: String, + val nuyen: Int, + val essence: Float, + val name: String, + val metatype: Metatype, + val age: Int, + val gender: String, + val streetCred: Int, + val notoriety: Int, + val publicAwareness: Int, + val totalKarma: Int, + val currentKarma: Int, + override val version: String = "v0.1" +): Versionable \ No newline at end of file diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/characterdata/Metatype.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/characterdata/Metatype.kt new file mode 100644 index 0000000..4643744 --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/characterdata/Metatype.kt @@ -0,0 +1,8 @@ +package org.shahondin1624.model.characterdata + +import kotlinx.serialization.Serializable + +@Serializable +enum class Metatype { + Human, Elf, Dwarf, Ork, Troll +} \ No newline at end of file diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/charactermodel/DamageMonitor.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/charactermodel/DamageMonitor.kt new file mode 100644 index 0000000..1fe80d1 --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/charactermodel/DamageMonitor.kt @@ -0,0 +1,88 @@ +package org.shahondin1624.model.charactermodel + +import kotlinx.serialization.Serializable +import kotlinx.serialization.Transient +import org.shahondin1624.model.Versionable +import org.shahondin1624.model.attributes.Attribute +import org.shahondin1624.model.attributes.AttributeType +import org.shahondin1624.model.attributes.Attributes +import org.shahondin1624.model.modifier.AttributeModifier +import org.shahondin1624.model.modifier.ModifierCache + +private val EMPTY_ATTRIBUTES = Attributes( + body = Attribute(AttributeType.Body, 0), + agility = Attribute(AttributeType.Agility, 0), + reaction = Attribute(AttributeType.Reaction, 0), + strength = Attribute(AttributeType.Strength, 0), + willpower = Attribute(AttributeType.Willpower, 0), + logic = Attribute(AttributeType.Logic, 0), + intuition = Attribute(AttributeType.Intuition, 0), + charisma = Attribute(AttributeType.Charisma, 0), + edge = 0 +) + +@Serializable +data class DamageMonitor( + @Transient + private var attributes: Attributes = EMPTY_ATTRIBUTES, + private val stunCurrent: Int = 0, + private val physicalCurrent: Int = 0, + private val overflowCurrent: Int = 0, + @Transient + private val cache: ModifierCache = ModifierCache(), + override val version: String = "v0.1" +): Versionable { + init { + require(stunCurrent >= 0) { "Stun damage cannot be negative" } + require(stunCurrent <= stunMax()) { "Stun damage cannot exceed maximum stun damage of ${stunMax()}" } + require(physicalCurrent >= 0) { "Physical damage cannot be negative" } + require(physicalCurrent <= physicalMax()) { "Physical damage cannot exceed maximum physical damage of ${physicalMax()}" } + require(overflowCurrent >= 0) { "Overflow damage cannot be negative" } + require(overflowCurrent <= overflowMax()) { "Overflow damage cannot exceed maximum overflow damage of ${overflowMax()}" } + } + + private fun applyModifiers(modifiers: List): Attributes { + return cache.applyModifiers(modifiers, attributes) + } + + fun stunMax(modifiers: List = emptyList()): Int { + return 7 + (applyModifiers(modifiers).willpower() / 2.0).toInt() + } + + fun stunCurrent(modifiers: List = emptyList()): Int { + return stunCurrent + } + + fun physicalMax(modifiers: List = emptyList()): Int { + return 7 + (applyModifiers(modifiers).body() / 2.0).toInt() + } + + fun physicalCurrent(modifiers: List = emptyList()): Int { + return physicalCurrent + } + + fun overflowMax(modifiers: List = emptyList()): Int { + return (applyModifiers(modifiers).body() / 2.0).toInt() + } + + fun overflowCurrent(modifiers: List = emptyList()): Int { + return overflowCurrent + } + + fun getCurrentModifiers(modifiers: List = emptyList()): List { //TODO this does add the negative modifier every time the function is invoked + val lastRow = physicalMax(modifiers) % 3 + val subtrahend = ((physicalCurrent(modifiers) - lastRow) / 3.0).toInt() + return modifiers.toMutableList().apply { + //TODO + } + } + + fun setAttributes(attributes: Attributes) { + this.attributes = attributes + } +} + +fun createDamageMonitor(attributes: Attributes): DamageMonitor { + val monitor = DamageMonitor(attributes) + return monitor.copy(stunCurrent = monitor.stunMax(), physicalCurrent = monitor.physicalMax(), overflowCurrent = monitor.overflowMax()) +} \ No newline at end of file diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/charactermodel/ShadowrunCharacter.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/charactermodel/ShadowrunCharacter.kt new file mode 100644 index 0000000..78fe788 --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/charactermodel/ShadowrunCharacter.kt @@ -0,0 +1,20 @@ +package org.shahondin1624.model.charactermodel + +import kotlinx.serialization.Serializable +import org.shahondin1624.model.Versionable +import org.shahondin1624.model.attributes.Attributes +import org.shahondin1624.model.characterdata.CharacterData +import org.shahondin1624.model.talents.Talents + +@Serializable +data class ShadowrunCharacter( + val characterData: CharacterData, + val attributes: Attributes, + val talents: Talents, + val damageMonitor: DamageMonitor, + override val version: String = "v0.1" +): Versionable { + init { + damageMonitor.setAttributes(attributes) + } +} diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/modifier/AttributeModifier.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/modifier/AttributeModifier.kt new file mode 100644 index 0000000..36b40cb --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/modifier/AttributeModifier.kt @@ -0,0 +1,5 @@ +package org.shahondin1624.model.modifier + +import org.shahondin1624.model.attributes.Attributes + +interface AttributeModifier: SRModifier \ No newline at end of file diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/modifier/ModifierCache.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/modifier/ModifierCache.kt new file mode 100644 index 0000000..79e3b39 --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/modifier/ModifierCache.kt @@ -0,0 +1,22 @@ +package org.shahondin1624.model.modifier + +import org.shahondin1624.model.attributes.Attributes + +data class ModifierCache( + private val cache: LinkedHashMap, Attributes> = linkedMapOf() +) { + fun applyModifiers(modifiers: List = emptyList(), attributes: Attributes): Attributes { + if (cache.containsKey(modifiers)) { + return cache[modifiers]!! + } + val modified = modifiers.fold(attributes) { acc, modifier -> modifier.apply(acc) } + cache[modifiers] = modified + while (cache.size > 5) { + val oldestKey = cache.keys.firstOrNull() + oldestKey?.let { + cache.remove(oldestKey) + } + } + return modified + } +} \ No newline at end of file diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/modifier/SRModifier.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/modifier/SRModifier.kt new file mode 100644 index 0000000..1899ab4 --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/modifier/SRModifier.kt @@ -0,0 +1,12 @@ +package org.shahondin1624.model.modifier + +import org.shahondin1624.lib.functions.DiceRoll + +interface SRModifier { + fun apply(value: T): T + fun getDiceRollModifier(diceRoll: DiceRoll): SRModifier +} + +fun List>.accumulateModifiers(diceRoll: DiceRoll): DiceRoll = this.fold(diceRoll) { acc, modifier -> + modifier.getDiceRollModifier(acc).apply(acc) +} \ No newline at end of file diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/modifier/TalentModifier.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/modifier/TalentModifier.kt new file mode 100644 index 0000000..db24381 --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/modifier/TalentModifier.kt @@ -0,0 +1,5 @@ +package org.shahondin1624.model.modifier + +import org.shahondin1624.model.talents.TalentDefinition + +interface TalentModifier: SRModifier \ No newline at end of file diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/talents/ProvidedTalentName.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/talents/ProvidedTalentName.kt new file mode 100644 index 0000000..3638d4a --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/talents/ProvidedTalentName.kt @@ -0,0 +1,84 @@ +package org.shahondin1624.model.talents + +import kotlinx.serialization.Serializable +import org.shahondin1624.model.attributes.AttributeType +import org.shahondin1624.model.attributes.AttributeType.* + +@Serializable +enum class ProvidedTalentName(val attribute: AttributeType) { + Aeronautics_Mechanic(Logic), + Alchemy(Logic), + Animal_Handling(Charisma), + Arcana(Intuition), + Archery(Agility), + Armorer(Logic), + Artificing(Logic), + Artisan(Agility), + Assensing(Intuition), + Astral_Combat(Willpower), + Automatics(Agility), + Automotive_Mechanic(Logic), + Banishing(Willpower), + Binding(Willpower), + Biotechnology(Logic), + Blades(Strength), + Chemistry(Logic), + Clubs(Strength), + //TODO Logic + Computer(Logic), + Sligth_of_hand(Charisma), + Counterspelling(Willpower), + Cybercombat(Logic), + Cybertechnology(Logic), + //TODO Logic + Demolitions(Intuition), + Disenchanting(Willpower), + Disguise(Intuition), + Diving(Body), + Electronic_Warfare(Logic), + Escape_Artist(Agility), + Etiquette(Charisma), + //TODO Exotics + First_Aid(Intuition), + Forgery(Logic), + Free_Fall(Agility), + Gunnery(Agility), + Gymnastics(Agility), + Hacking(Logic), + Hardware(Logic), + Heavy_Weapons(Strength), + Impersonation(Charisma), + Industrial_Mechanic(Logic), + Instruction(Charisma), + Intimidation(Charisma), + Leadership(Charisma), + Locksmith(Intuition), + Longarms(Agility), + Medicine(Logic), + Nautical_Mechanic(Logic), + Navigation(Intuition), + Negotiation(Charisma), + Palming(Agility), + Perception(Intuition), + Performance(Charisma), + Pilot_Aerospace(Reaction), + Pilot_Aircraft(Reaction), + //TODO Pilot Exotic + Pilot_Groundcraft(Reaction), + Pilot_Walker(Reaction), + Pilot_Watercraft(Reaction), + Pistols(Agility), + //TODO, Logic + Ritual_Spellcasting(Willpower), + Running(Body), + Sneaking(Agility), + Software(Logic), + Spellcasting(Willpower), + Summoning(Willpower), + Survival(Intuition), + Swimming(Body), + Throwing_Weapons(Strength), + Tracking(Intuition), + Unarmed_Combat(Strength) + ; +} \ No newline at end of file diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/talents/Talent.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/talents/Talent.kt new file mode 100644 index 0000000..71ae872 --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/talents/Talent.kt @@ -0,0 +1,37 @@ +package org.shahondin1624.model.talents + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import org.shahondin1624.lib.functions.DiceRoll +import org.shahondin1624.model.attributes.AttributeType +import org.shahondin1624.model.attributes.Attributes +import org.shahondin1624.model.modifier.SRModifier +import org.shahondin1624.model.modifier.accumulateModifiers + +@Serializable +@SerialName("Talent") +data class Talent( + override val name: String, + override val attribute: AttributeType, + override val value: Int, + override val custom: Boolean, +): TalentDefinition { + override fun test(modifiers: List>, attributes: Attributes): DiceRoll { + val attributeValue = attributes.getAttributeByType(attribute).value + val combined = value + attributeValue + return modifiers.accumulateModifiers(DiceRoll(numberOfDice = combined)).roll() + } +} + +private fun createProvidedTalent(provided: ProvidedTalentName, value: Int = 0) = Talent( + name = provided.name.replace("_", " "), + attribute = provided.attribute, + value = value, + custom = false +) + +fun createAllProvidedTalents() = ProvidedTalentName.entries.map { + createProvidedTalent(it) +} + +fun createCustomTalent(name: String, attribute: AttributeType, value: Int = 0) = Talent(name, attribute, value, true) \ No newline at end of file diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/talents/TalentDefinition.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/talents/TalentDefinition.kt new file mode 100644 index 0000000..8772d2c --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/talents/TalentDefinition.kt @@ -0,0 +1,16 @@ +package org.shahondin1624.model.talents + +import kotlinx.serialization.Serializable +import org.shahondin1624.lib.functions.DiceRoll +import org.shahondin1624.model.attributes.AttributeType +import org.shahondin1624.model.attributes.Attributes +import org.shahondin1624.model.modifier.SRModifier + +@Serializable +sealed interface TalentDefinition { + val name: String + val attribute: AttributeType + val value: Int + val custom: Boolean + fun test(modifiers: List>, attributes: Attributes): DiceRoll +} \ No newline at end of file diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/talents/Talents.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/talents/Talents.kt new file mode 100644 index 0000000..5af4b79 --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/model/talents/Talents.kt @@ -0,0 +1,10 @@ +package org.shahondin1624.model.talents + +import kotlinx.serialization.Serializable +import org.shahondin1624.model.Versionable + +@Serializable +data class Talents( + val talents: List = createAllProvidedTalents(), + override val version: String = "v0.1" +) : Versionable diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/theme/Color.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/theme/Color.kt new file mode 100644 index 0000000..4d19804 --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/theme/Color.kt @@ -0,0 +1,80 @@ +package org.shahondin1624.theme + +import androidx.compose.ui.graphics.Color + +//generated by https://materialkolor.com +//Color palette was taken here: https://coolors.co/palette/e63946-f1faee-a8dadc-457b9d-1d3557 + +internal val Seed = Color(0xFF1D3557) + +internal val PrimaryLight = Color(0xFF485F84) +internal val OnPrimaryLight = Color(0xFFFFFFFF) +internal val PrimaryContainerLight = Color(0xFFD5E3FF) +internal val OnPrimaryContainerLight = Color(0xFF30476A) +internal val SecondaryLight = Color(0xFF2B6485) +internal val OnSecondaryLight = Color(0xFFFFFFFF) +internal val SecondaryContainerLight = Color(0xFFC7E7FF) +internal val OnSecondaryContainerLight = Color(0xFF064C6B) +internal val TertiaryLight = Color(0xFF356668) +internal val OnTertiaryLight = Color(0xFFFFFFFF) +internal val TertiaryContainerLight = Color(0xFFB9ECEE) +internal val OnTertiaryContainerLight = Color(0xFF1A4E50) +internal val ErrorLight = Color(0xFFBB152C) +internal val OnErrorLight = Color(0xFFFFFFFF) +internal val ErrorContainerLight = Color(0xFFFFDAD8) +internal val OnErrorContainerLight = Color(0xFF410007) +internal val BackgroundLight = Color(0xFFF9F9F9) +internal val OnBackgroundLight = Color(0xFF1A1C1C) +internal val SurfaceLight = Color(0xFFF9F9F9) +internal val OnSurfaceLight = Color(0xFF1A1C1C) +internal val SurfaceVariantLight = Color(0xFFDCE5D9) +internal val OnSurfaceVariantLight = Color(0xFF404941) +internal val OutlineLight = Color(0xFF717970) +internal val OutlineVariantLight = Color(0xFFC0C9BE) +internal val ScrimLight = Color(0xFF000000) +internal val InverseSurfaceLight = Color(0xFF2F3131) +internal val InverseOnSurfaceLight = Color(0xFFF0F1F1) +internal val InversePrimaryLight = Color(0xFFB0C7F1) +internal val SurfaceDimLight = Color(0xFFDADADA) +internal val SurfaceBrightLight = Color(0xFFF9F9F9) +internal val SurfaceContainerLowestLight = Color(0xFFFFFFFF) +internal val SurfaceContainerLowLight = Color(0xFFF3F3F4) +internal val SurfaceContainerLight = Color(0xFFEEEEEE) +internal val SurfaceContainerHighLight = Color(0xFFE8E8E8) +internal val SurfaceContainerHighestLight = Color(0xFFE2E2E2) + +internal val PrimaryDark = Color(0xFFB0C7F1) +internal val OnPrimaryDark = Color(0xFF183153) +internal val PrimaryContainerDark = Color(0xFF30476A) +internal val OnPrimaryContainerDark = Color(0xFFD5E3FF) +internal val SecondaryDark = Color(0xFF98CDF2) +internal val OnSecondaryDark = Color(0xFF00344C) +internal val SecondaryContainerDark = Color(0xFF064C6B) +internal val OnSecondaryContainerDark = Color(0xFFC7E7FF) +internal val TertiaryDark = Color(0xFF9ECFD1) +internal val OnTertiaryDark = Color(0xFF003739) +internal val TertiaryContainerDark = Color(0xFF1A4E50) +internal val OnTertiaryContainerDark = Color(0xFFB9ECEE) +internal val ErrorDark = Color(0xFFFFB3B1) +internal val OnErrorDark = Color(0xFF680011) +internal val ErrorContainerDark = Color(0xFF92001C) +internal val OnErrorContainerDark = Color(0xFFFFDAD8) +internal val BackgroundDark = Color(0xFF121414) +internal val OnBackgroundDark = Color(0xFFE2E2E2) +internal val SurfaceDark = Color(0xFF121414) +internal val OnSurfaceDark = Color(0xFFE2E2E2) +internal val SurfaceVariantDark = Color(0xFF404941) +internal val OnSurfaceVariantDark = Color(0xFFC0C9BE) +internal val OutlineDark = Color(0xFF8A9389) +internal val OutlineVariantDark = Color(0xFF404941) +internal val ScrimDark = Color(0xFF000000) +internal val InverseSurfaceDark = Color(0xFFE2E2E2) +internal val InverseOnSurfaceDark = Color(0xFF2F3131) +internal val InversePrimaryDark = Color(0xFF485F84) +internal val SurfaceDimDark = Color(0xFF121414) +internal val SurfaceBrightDark = Color(0xFF37393A) +internal val SurfaceContainerLowestDark = Color(0xFF0C0F0F) +internal val SurfaceContainerLowDark = Color(0xFF1A1C1C) +internal val SurfaceContainerDark = Color(0xFF1E2020) +internal val SurfaceContainerHighDark = Color(0xFF282A2B) +internal val SurfaceContainerHighestDark = Color(0xFF333535) diff --git a/sharedUI/src/commonMain/kotlin/org/shahondin1624/theme/Theme.kt b/sharedUI/src/commonMain/kotlin/org/shahondin1624/theme/Theme.kt new file mode 100644 index 0000000..cd3fa71 --- /dev/null +++ b/sharedUI/src/commonMain/kotlin/org/shahondin1624/theme/Theme.kt @@ -0,0 +1,105 @@ +package org.shahondin1624.theme + +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.runtime.* + +private val LightColorScheme = lightColorScheme( + primary = PrimaryLight, + onPrimary = OnPrimaryLight, + primaryContainer = PrimaryContainerLight, + onPrimaryContainer = OnPrimaryContainerLight, + secondary = SecondaryLight, + onSecondary = OnSecondaryLight, + secondaryContainer = SecondaryContainerLight, + onSecondaryContainer = OnSecondaryContainerLight, + tertiary = TertiaryLight, + onTertiary = OnTertiaryLight, + tertiaryContainer = TertiaryContainerLight, + onTertiaryContainer = OnTertiaryContainerLight, + error = ErrorLight, + onError = OnErrorLight, + errorContainer = ErrorContainerLight, + onErrorContainer = OnErrorContainerLight, + background = BackgroundLight, + onBackground = OnBackgroundLight, + surface = SurfaceLight, + onSurface = OnSurfaceLight, + surfaceVariant = SurfaceVariantLight, + onSurfaceVariant = OnSurfaceVariantLight, + outline = OutlineLight, + outlineVariant = OutlineVariantLight, + scrim = ScrimLight, + inverseSurface = InverseSurfaceLight, + inverseOnSurface = InverseOnSurfaceLight, + inversePrimary = InversePrimaryLight, + surfaceDim = SurfaceDimLight, + surfaceBright = SurfaceBrightLight, + surfaceContainerLowest = SurfaceContainerLowestLight, + surfaceContainerLow = SurfaceContainerLowLight, + surfaceContainer = SurfaceContainerLight, + surfaceContainerHigh = SurfaceContainerHighLight, + surfaceContainerHighest = SurfaceContainerHighestLight, +) + +private val DarkColorScheme = darkColorScheme( + primary = PrimaryDark, + onPrimary = OnPrimaryDark, + primaryContainer = PrimaryContainerDark, + onPrimaryContainer = OnPrimaryContainerDark, + secondary = SecondaryDark, + onSecondary = OnSecondaryDark, + secondaryContainer = SecondaryContainerDark, + onSecondaryContainer = OnSecondaryContainerDark, + tertiary = TertiaryDark, + onTertiary = OnTertiaryDark, + tertiaryContainer = TertiaryContainerDark, + onTertiaryContainer = OnTertiaryContainerDark, + error = ErrorDark, + onError = OnErrorDark, + errorContainer = ErrorContainerDark, + onErrorContainer = OnErrorContainerDark, + background = BackgroundDark, + onBackground = OnBackgroundDark, + surface = SurfaceDark, + onSurface = OnSurfaceDark, + surfaceVariant = SurfaceVariantDark, + onSurfaceVariant = OnSurfaceVariantDark, + outline = OutlineDark, + outlineVariant = OutlineVariantDark, + scrim = ScrimDark, + inverseSurface = InverseSurfaceDark, + inverseOnSurface = InverseOnSurfaceDark, + inversePrimary = InversePrimaryDark, + surfaceDim = SurfaceDimDark, + surfaceBright = SurfaceBrightDark, + surfaceContainerLowest = SurfaceContainerLowestDark, + surfaceContainerLow = SurfaceContainerLowDark, + surfaceContainer = SurfaceContainerDark, + surfaceContainerHigh = SurfaceContainerHighDark, + surfaceContainerHighest = SurfaceContainerHighestDark, +) + +internal val LocalThemeIsDark = compositionLocalOf { mutableStateOf(true) } + +@Composable +internal fun AppTheme( + onThemeChanged: @Composable (isDark: Boolean) -> Unit, + content: @Composable () -> Unit +) { + val systemIsDark = isSystemInDarkTheme() + val isDarkState = remember(systemIsDark) { mutableStateOf(systemIsDark) } + CompositionLocalProvider( + LocalThemeIsDark provides isDarkState + ) { + val isDark by isDarkState + onThemeChanged(!isDark) + MaterialTheme( + colorScheme = if (isDark) DarkColorScheme else LightColorScheme, + content = { Surface(content = content) } + ) + } +} \ No newline at end of file diff --git a/sharedUI/src/commonTest/kotlin/org/shahondin1624/ComposeTest.kt b/sharedUI/src/commonTest/kotlin/org/shahondin1624/ComposeTest.kt new file mode 100644 index 0000000..fb43d31 --- /dev/null +++ b/sharedUI/src/commonTest/kotlin/org/shahondin1624/ComposeTest.kt @@ -0,0 +1,45 @@ +package org.shahondin1624 + +import androidx.compose.foundation.layout.Column +import androidx.compose.material3.Button +import androidx.compose.material3.Text +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.test.ExperimentalTestApi +import androidx.compose.ui.test.assertTextEquals +import androidx.compose.ui.test.onNodeWithTag +import androidx.compose.ui.test.performClick +import androidx.compose.ui.test.runComposeUiTest +import kotlin.test.Test + +@OptIn(ExperimentalTestApi::class) +class ComposeTest { + + @Test + fun simpleCheck() = runComposeUiTest { + setContent { + var txt by remember { mutableStateOf("Go") } + Column { + Text( + text = txt, + modifier = Modifier.testTag("t_text") + ) + Button( + onClick = { txt += "." }, + modifier = Modifier.testTag("t_button") + ) { + Text("click me") + } + } + } + + onNodeWithTag("t_button").apply { + repeat(3) { performClick() } + } + onNodeWithTag("t_text").assertTextEquals("Go...") + } +} \ No newline at end of file diff --git a/sharedUI/src/iosMain/kotlin/main.kt b/sharedUI/src/iosMain/kotlin/main.kt new file mode 100644 index 0000000..43a8f1a --- /dev/null +++ b/sharedUI/src/iosMain/kotlin/main.kt @@ -0,0 +1,22 @@ +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.ui.window.ComposeUIViewController +import org.shahondin1624.App +import platform.UIKit.UIApplication +import platform.UIKit.UIStatusBarStyleDarkContent +import platform.UIKit.UIStatusBarStyleLightContent +import platform.UIKit.UIViewController +import platform.UIKit.setStatusBarStyle + +fun MainViewController(): UIViewController = ComposeUIViewController { + App(onThemeChanged = { ThemeChanged(it) }) +} + +@Composable +private fun ThemeChanged(isDark: Boolean) { + LaunchedEffect(isDark) { + UIApplication.sharedApplication.setStatusBarStyle( + if (isDark) UIStatusBarStyleDarkContent else UIStatusBarStyleLightContent + ) + } +} \ No newline at end of file diff --git a/webApp/build.gradle.kts b/webApp/build.gradle.kts new file mode 100644 index 0000000..614ef21 --- /dev/null +++ b/webApp/build.gradle.kts @@ -0,0 +1,24 @@ +plugins { + alias(libs.plugins.kotlin.multiplatform) + alias(libs.plugins.compose.compiler) + alias(libs.plugins.compose.multiplatform) +} + +kotlin { + js { + browser() + binaries.executable() + } + + wasmJs { + browser() + binaries.executable() + } + + sourceSets { + commonMain.dependencies { + implementation(project(":sharedUI")) + implementation(compose.ui) + } + } +} diff --git a/webApp/src/commonMain/kotlin/main.kt b/webApp/src/commonMain/kotlin/main.kt new file mode 100644 index 0000000..d73da0a --- /dev/null +++ b/webApp/src/commonMain/kotlin/main.kt @@ -0,0 +1,6 @@ +import androidx.compose.ui.ExperimentalComposeUiApi +import androidx.compose.ui.window.ComposeViewport +import org.shahondin1624.App + +@OptIn(ExperimentalComposeUiApi::class) +fun main() = ComposeViewport { App() } diff --git a/webApp/src/commonMain/resources/android-chrome-192x192.png b/webApp/src/commonMain/resources/android-chrome-192x192.png new file mode 100644 index 0000000..f6a9027 Binary files /dev/null and b/webApp/src/commonMain/resources/android-chrome-192x192.png differ diff --git a/webApp/src/commonMain/resources/android-chrome-512x512.png b/webApp/src/commonMain/resources/android-chrome-512x512.png new file mode 100644 index 0000000..a2a4517 Binary files /dev/null and b/webApp/src/commonMain/resources/android-chrome-512x512.png differ diff --git a/webApp/src/commonMain/resources/apple-touch-icon.png b/webApp/src/commonMain/resources/apple-touch-icon.png new file mode 100644 index 0000000..0fa8190 Binary files /dev/null and b/webApp/src/commonMain/resources/apple-touch-icon.png differ diff --git a/webApp/src/commonMain/resources/favicon-16x16.png b/webApp/src/commonMain/resources/favicon-16x16.png new file mode 100644 index 0000000..79591a3 Binary files /dev/null and b/webApp/src/commonMain/resources/favicon-16x16.png differ diff --git a/webApp/src/commonMain/resources/favicon-32x32.png b/webApp/src/commonMain/resources/favicon-32x32.png new file mode 100644 index 0000000..b47df0b Binary files /dev/null and b/webApp/src/commonMain/resources/favicon-32x32.png differ diff --git a/webApp/src/commonMain/resources/favicon.ico b/webApp/src/commonMain/resources/favicon.ico new file mode 100644 index 0000000..521b5b6 Binary files /dev/null and b/webApp/src/commonMain/resources/favicon.ico differ diff --git a/webApp/src/commonMain/resources/index.html b/webApp/src/commonMain/resources/index.html new file mode 100644 index 0000000..688a9ac --- /dev/null +++ b/webApp/src/commonMain/resources/index.html @@ -0,0 +1,31 @@ + + + + + + + + + + ShadowrunCharSheet + + + + + + + + + + + + diff --git a/webApp/src/commonMain/resources/manifest.json b/webApp/src/commonMain/resources/manifest.json new file mode 100644 index 0000000..d180642 --- /dev/null +++ b/webApp/src/commonMain/resources/manifest.json @@ -0,0 +1,19 @@ +{ + "name": "ShadowrunCharSheet", + "short_name": "ShadowrunCharSheet", + "icons": [ + { + "src": "./android-chrome-192x192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "./android-chrome-512x512.png", + "sizes": "512x512", + "type": "image/png" + } + ], + "theme_color": "#ffffff", + "background_color": "#ffffff", + "display": "standalone" +} \ No newline at end of file