mirror of
https://github.com/BetterAndroid/FlexiUI.git
synced 2025-09-07 19:14:12 +08:00
feat: update demo
This commit is contained in:
@@ -19,8 +19,9 @@
|
||||
*
|
||||
* This file is created by fankes on 2023/11/5.
|
||||
*/
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
@Composable
|
||||
fun MainView() = App()
|
||||
fun MainView() = App()
|
||||
|
||||
actual val isAndroidPlatform = true
|
@@ -31,6 +31,7 @@ import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.ReadOnlyComposable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
@@ -53,6 +54,7 @@ import com.highcapable.flexiui.component.Switch
|
||||
import com.highcapable.flexiui.component.Text
|
||||
import com.highcapable.flexiui.component.TextField
|
||||
import com.highcapable.flexiui.defaultColors
|
||||
import com.highcapable.flexiui.dynamicColors
|
||||
import com.highcapable.flexiui.greenColors
|
||||
import com.highcapable.flexiui.orangeColors
|
||||
import com.highcapable.flexiui.pinkColors
|
||||
@@ -141,7 +143,7 @@ private fun ContentView() {
|
||||
Text(text = "Choose an item following.")
|
||||
Spacer(Modifier.padding(10.dp))
|
||||
DropdownList(
|
||||
modifier = Modifier.width(150.dp),
|
||||
modifier = Modifier.width(170.dp),
|
||||
expanded = expanded,
|
||||
onExpandedChange = { expanded = it },
|
||||
text = { Text(text = curentItem) }
|
||||
@@ -169,20 +171,25 @@ private fun ThemeColorsView(themeColor: MutableState<Colors>) {
|
||||
themeColor.value = choosedColor
|
||||
Row {
|
||||
DropdownList(
|
||||
modifier = Modifier.width(150.dp),
|
||||
modifier = Modifier.width(170.dp),
|
||||
expanded = showChooser,
|
||||
onExpandedChange = { showChooser = it },
|
||||
text = { Text(text = choosedColorName) }
|
||||
) {
|
||||
ThemeColors.forEach { (name, color) ->
|
||||
DropdownMenuItem(
|
||||
onClick = {
|
||||
showChooser = false
|
||||
choosedColorName = name
|
||||
choosedColor = color
|
||||
},
|
||||
actived = choosedColorName == name
|
||||
) { Text(text = name) }
|
||||
ThemeColors.forEachIndexed { index, (name, colors) ->
|
||||
@Composable
|
||||
fun createItem(name: String, colors: Colors) =
|
||||
DropdownMenuItem(
|
||||
onClick = {
|
||||
showChooser = false
|
||||
choosedColorName = name
|
||||
choosedColor = colors
|
||||
},
|
||||
actived = choosedColorName == name
|
||||
) { Text(text = name) }
|
||||
if (isAndroidPlatform && index == 3)
|
||||
DynamicColors.forEach { (name, colors) -> createItem(name, colors) }
|
||||
else createItem(name, colors)
|
||||
}
|
||||
}
|
||||
Spacer(modifier = Modifier.padding(5.dp))
|
||||
@@ -193,6 +200,15 @@ private fun ThemeColorsView(themeColor: MutableState<Colors>) {
|
||||
}
|
||||
}
|
||||
|
||||
private val DynamicColors
|
||||
@Composable
|
||||
@ReadOnlyComposable
|
||||
get() = listOf(
|
||||
"Dynamic" to dynamicColors(),
|
||||
"Dynamic (Dark)" to dynamicColors(darkMode = true),
|
||||
"Dynamic (Black)" to dynamicColors(darkMode = true, blackDarkMode = true)
|
||||
)
|
||||
|
||||
private val ThemeColors = listOf(
|
||||
"Default" to defaultColors(),
|
||||
"Default (Dark)" to defaultColors(darkMode = true),
|
||||
@@ -218,4 +234,6 @@ private val ThemeColors = listOf(
|
||||
"Blue" to blueColors(),
|
||||
"Blue (Dark)" to blueColors(darkMode = true),
|
||||
"Blue (Black)" to blueColors(darkMode = true, blackDarkMode = true)
|
||||
)
|
||||
)
|
||||
|
||||
expect val isAndroidPlatform: Boolean
|
@@ -19,8 +19,9 @@
|
||||
*
|
||||
* This file is created by fankes on 2023/11/5.
|
||||
*/
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
@Composable
|
||||
fun MainView() = App()
|
||||
fun MainView() = App()
|
||||
|
||||
actual val isAndroidPlatform = false
|
@@ -27,4 +27,6 @@ import androidx.compose.ui.window.ComposeUIViewController
|
||||
fun createUIViewController() = ComposeUIViewController { MainView() }
|
||||
|
||||
@Composable
|
||||
fun MainView() = App()
|
||||
fun MainView() = App()
|
||||
|
||||
actual val isAndroidPlatform = false
|
Reference in New Issue
Block a user