diff --git a/genesis/app/build.gradle.kts b/genesis/app/build.gradle.kts index 7a57aa1..9d5de45 100644 --- a/genesis/app/build.gradle.kts +++ b/genesis/app/build.gradle.kts @@ -60,9 +60,9 @@ kotlin { implementation(project(":uninit:common")) implementation(project(":uninit:common-compose")) + implementation(project(":uninit:ui")) implementation(project(":genesis:discord:api")) implementation(project(":genesis:discord:client")) - implementation(project(":genesis:genesisApi")) } diff --git a/uninit/common/src/commonMain/kotlin/uninit/common/Quad.kt b/uninit/common/src/commonMain/kotlin/uninit/common/Quad.kt deleted file mode 100644 index 8c014c8..0000000 --- a/uninit/common/src/commonMain/kotlin/uninit/common/Quad.kt +++ /dev/null @@ -1,10 +0,0 @@ -package uninit.common - -open class Quad( - val first: T, - val second: U, - val third: V, - val fourth: W, -) { - override fun toString(): String = "Quad($first, $second, $third, $fourth)" -} diff --git a/uninit/common/src/commonMain/kotlin/uninit/common/collections/Four.kt b/uninit/common/src/commonMain/kotlin/uninit/common/collections/Four.kt new file mode 100644 index 0000000..3b7ebda --- /dev/null +++ b/uninit/common/src/commonMain/kotlin/uninit/common/collections/Four.kt @@ -0,0 +1,43 @@ +package uninit.common.collections + +import kotlin.jvm.JvmInline + +//open class Four( +// val first: T, +// val second: U, +// val third: V, +// val fourth: W, +//) { +// override fun toString(): String = "Four($first, $second, $third, $fourth)" +//} + + +@JvmInline value class Four ( internal val it: Array ) : Collection { + override val size: Int + get() = 4 + init { + require(it.size == 4) + } + val first: T get() = it[0] + val second: T get() = it[1] + val third: T get() = it[2] + val fourth: T get() = it[3] + + override fun toString(): String = "Four($first, $second, $third, $fourth)" + operator fun component1(): T = first + operator fun component2(): T = second + operator fun component3(): T = third + operator fun component4(): T = fourth + operator fun get(index: Int): T = it[index] + override fun contains(element: T): Boolean { + return first == element || second == element || third == element || fourth == element + } + override fun containsAll(elements: Collection): Boolean { + return elements.all { contains(it) } + } + override fun isEmpty(): Boolean = false + override fun iterator(): Iterator = it.iterator() +} + +val Array.four: Four + get() = Four(this) \ No newline at end of file diff --git a/uninit/common/src/commonMain/kotlin/uninit/common/color/RGBA.kt b/uninit/common/src/commonMain/kotlin/uninit/common/color/RGBA.kt index a874a1b..efc0b74 100644 --- a/uninit/common/src/commonMain/kotlin/uninit/common/color/RGBA.kt +++ b/uninit/common/src/commonMain/kotlin/uninit/common/color/RGBA.kt @@ -1,26 +1,29 @@ package uninit.common.color -import uninit.common.Quad +import uninit.common.collections.Four +import uninit.common.collections.four class RGBA( val r: Int, val g: Int, val b: Int, val a: Int = 255, -) : Quad(r, g, b, a){ +){ init { require(r in 0..255) require(g in 0..255) require(b in 0..255) require(a in 0..255) } + override fun toString(): String = "RGBA($r, $g, $b, $a)" - fun toFloat(): Quad = Quad( - r / 255f, - g / 255f, - b / 255f, - a / 255f, - ) + fun toFloat(): Four = + arrayOf( + r / 255f, + g / 255f, + b / 255f, + a / 255f + ).four companion object { fun hex(it: String): RGBA { require(it.length in 6..9) diff --git a/uninit/ui/build.gradle.kts b/uninit/ui/build.gradle.kts index 856ebcc..c3803a5 100644 --- a/uninit/ui/build.gradle.kts +++ b/uninit/ui/build.gradle.kts @@ -51,7 +51,7 @@ kotlin { android { compileSdk = (findProperty("android.compileSdk") as String).toInt() - namespace = "uninit.common" + namespace = "uninit.ui" sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") sourceSets["main"].res.srcDirs("src/androidMain/res") diff --git a/uninit/ui/src/commonMain/kotlin/uninit/ui/UIKit.kt b/uninit/ui/src/commonMain/kotlin/uninit/ui/UIKit.kt deleted file mode 100644 index 6279e66..0000000 --- a/uninit/ui/src/commonMain/kotlin/uninit/ui/UIKit.kt +++ /dev/null @@ -1,5 +0,0 @@ -package uninit.ui - -interface UIKit { - -} \ No newline at end of file diff --git a/uninit/ui/src/commonMain/kotlin/uninit/ui/application.kt b/uninit/ui/src/commonMain/kotlin/uninit/ui/application.kt new file mode 100644 index 0000000..b164a1b --- /dev/null +++ b/uninit/ui/src/commonMain/kotlin/uninit/ui/application.kt @@ -0,0 +1,24 @@ +package uninit.ui + +import androidx.compose.runtime.Composable +import uninit.ui.application.ApplicationConfigurationScope +import uninit.ui.application.ApplicationScope + +@Composable +fun application( + config: ApplicationConfigurationScope.() -> Unit = {}, + content: @Composable ApplicationScope.() -> Unit) +{ + +} + +@Composable +@Deprecated(level = DeprecationLevel.ERROR, message = "Not intended for use") +private fun example() = application({ + applicationName = "My New Application" + useWebview = true +}) { + ui.ElevatedBox { + ui.Text("Hello, World!") + } +} \ No newline at end of file diff --git a/uninit/ui/src/commonMain/kotlin/uninit/ui/application/ApplicationConfigurationScope.kt b/uninit/ui/src/commonMain/kotlin/uninit/ui/application/ApplicationConfigurationScope.kt new file mode 100644 index 0000000..6ee3923 --- /dev/null +++ b/uninit/ui/src/commonMain/kotlin/uninit/ui/application/ApplicationConfigurationScope.kt @@ -0,0 +1,137 @@ +package uninit.ui.application + +import uninit.ui.theme.ThemeRegistry + +class ApplicationConfigurationScope { + /** + * List of modules to be loaded by Koin. + */ + var koinModules = mutableListOf() // FIXME + + /** + * Whether to download the webview modules on + * desktop platforms. Requires + */ + var useWebview = false + + /** + * The theme to use for the application. + * + * Will default to the theme with the ID that + * matches the preference [themePreferenceName] in + * the PreferencesManager. + */ + var themeId: String? = null + + /** + * The name of the preference to use for the theme ID. + + * Defaults to "currentThemeId". + */ + var themePreferenceName = "currentThemeId" + + /** + * The theme registry to use for the application. + * + * Defaults to the singleton instance of ThemeRegistry. + */ + var themeRegistry: ThemeRegistry = ThemeRegistry + + /** + * The default theme ID to use if no theme ID is set + * and no theme ID is found in the preferences. + * + * This will also set the theme ID in the preferences + * if no theme ID is set. + * + * Defaults to "Catppuccin/Mocha/Pink". + */ + var defaultThemeId: String = "Catppuccin/Mocha/Pink" + + + /** + * The UI kit to use for the application. + * + * Will default to the ui kit with the ID that + * matches the preference [uikitPreferenceName] in + * the PreferencesManager. + */ + var uikitId: String? = null + + /** + * The name of the preference to use for the UI kit ID. + * + * Defaults to "currentUIKitId". + */ + + var uikitPreferenceName = "currentUIKitId" + + /** + * The default UI kit ID to use if no UI kit ID is set + * and no UI kit ID is found in the preferences. + * + * This will also set the UI kit ID in the preferences + * if no UI kit ID is set. + * + * Defaults to "builtin/uninit". + */ + + var defaultUIKitId = "builtin/uninit" + + /** + * The name of the application. + */ + var applicationName: String? = null + + /** + * The version of the application. + */ + var applicationVersion: String? = null + + /** + * Whether the application's name is normalized + * to lowercase dash-delimited on linux when + * creating directories and files. + * + * This setting only applies to linux, and + * only effects ASCII application names + * + * Example: "My App" -> "my-app" + */ + var normalizeApplicationName = true + + /** + * Which directory to use for the application's + * cache and data storage on Windows. + * + * Use the `%APP_NAME%` placeholder to insert the + * application name into the path. + * + * Defaults to the user's Local AppData directory. + */ + var windowsDataDirectory: String? = null + + /** + * Which directory to use for the application's + * cache and data storage on macOS. + * + * Use the `%APP_NAME%` placeholder to insert the + * application name into the path. + * + * Defaults to the user's Application Support directory. + */ + var macDataDirectory: String? = null + + /** + * Which directory to use for the application's + * cache and data storage on Linux. + * + * + * Use the `%APP_NAME%` placeholder to insert the + * application name into the path. + * + * Defaults to "~/.%APP_NAME%". + */ + var linuxDataDirectory: String? = null + +} \ No newline at end of file diff --git a/uninit/ui/src/commonMain/kotlin/uninit/ui/application/ApplicationScope.kt b/uninit/ui/src/commonMain/kotlin/uninit/ui/application/ApplicationScope.kt new file mode 100644 index 0000000..af96646 --- /dev/null +++ b/uninit/ui/src/commonMain/kotlin/uninit/ui/application/ApplicationScope.kt @@ -0,0 +1,10 @@ +package uninit.ui.application + +import uninit.ui.kit.UIKit + +class ApplicationScope { + val ui: UIKit + get() = TODO() + val preferences: Any /* TODO: PreferencesManager */ + get() = TODO() +} \ No newline at end of file diff --git a/uninit/ui/src/commonMain/kotlin/uninit/ui/composites.kt b/uninit/ui/src/commonMain/kotlin/uninit/ui/composites.kt new file mode 100644 index 0000000..bc1dfef --- /dev/null +++ b/uninit/ui/src/commonMain/kotlin/uninit/ui/composites.kt @@ -0,0 +1,15 @@ +package uninit.ui + +import androidx.compose.runtime.compositionLocalOf +import uninit.ui.kit.UIKit +import uninit.ui.theme.ApplicationTheme + +val LocalUIKit = compositionLocalOf { + error("No UIKit provided") +} +val LocalApplicationTheme = compositionLocalOf { + error("No ApplicationTheme provided") +} +val LocalMutableWindowTitle = compositionLocalOf { + "" +} \ No newline at end of file diff --git a/uninit/ui/src/commonMain/kotlin/uninit/ui/kit/UIKit.kt b/uninit/ui/src/commonMain/kotlin/uninit/ui/kit/UIKit.kt new file mode 100644 index 0000000..75b5391 --- /dev/null +++ b/uninit/ui/src/commonMain/kotlin/uninit/ui/kit/UIKit.kt @@ -0,0 +1,20 @@ +package uninit.ui.kit + +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.text.TextStyle + + +interface UIKit { + @Composable + fun Text( + text: String, + style: TextStyle = TextStyle.Default, + modifier: Modifier = Modifier + ) + @Composable + fun ElevatedBox( + modifier: Modifier = Modifier, + content: @Composable () -> Unit, + ) +} \ No newline at end of file