-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
just a few somethings, working on uninit.ui
- Loading branch information
Showing
11 changed files
with
262 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
43 changes: 43 additions & 0 deletions
43
uninit/common/src/commonMain/kotlin/uninit/common/collections/Four.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package uninit.common.collections | ||
|
||
import kotlin.jvm.JvmInline | ||
|
||
//open class Four<T, U, V, W>( | ||
// 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<T> ( internal val it: Array<T> ) : Collection<T> { | ||
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<T>): Boolean { | ||
return elements.all { contains(it) } | ||
} | ||
override fun isEmpty(): Boolean = false | ||
override fun iterator(): Iterator<T> = it.iterator() | ||
} | ||
|
||
val <T> Array<T>.four: Four<T> | ||
get() = Four(this) |
19 changes: 11 additions & 8 deletions
19
uninit/common/src/commonMain/kotlin/uninit/common/color/RGBA.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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!") | ||
} | ||
} |
137 changes: 137 additions & 0 deletions
137
uninit/ui/src/commonMain/kotlin/uninit/ui/application/ApplicationConfigurationScope.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Any>() // 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 | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
uninit/ui/src/commonMain/kotlin/uninit/ui/application/ApplicationScope.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<UIKit> { | ||
error("No UIKit provided") | ||
} | ||
val LocalApplicationTheme = compositionLocalOf<ApplicationTheme> { | ||
error("No ApplicationTheme provided") | ||
} | ||
val LocalMutableWindowTitle = compositionLocalOf<String> { | ||
"" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
) | ||
} |