feat: update demo

This commit is contained in:
2024-01-18 12:15:36 +08:00
parent e092e42ec0
commit 333b2a59ba
2 changed files with 27 additions and 22 deletions

View File

@@ -34,10 +34,11 @@ enum class Locales { EN, ZH_CN }
fun locales() = Locales.entries.toTypedArray() fun locales() = Locales.entries.toTypedArray()
@Stable @Stable
fun Locales.toName() = when (this) { val Locales.displayName
Locales.EN -> "English" get() = when (this) {
Locales.ZH_CN -> "简体中文" Locales.EN -> "English"
} Locales.ZH_CN -> "简体中文"
}
val strings val strings
@Composable @Composable

View File

@@ -74,10 +74,10 @@ import com.highcapable.flexiui.demo.PROJECT_URL
import com.highcapable.flexiui.demo.Preferences import com.highcapable.flexiui.demo.Preferences
import com.highcapable.flexiui.demo.Screen import com.highcapable.flexiui.demo.Screen
import com.highcapable.flexiui.demo.Style import com.highcapable.flexiui.demo.Style
import com.highcapable.flexiui.demo.displayName
import com.highcapable.flexiui.demo.locales import com.highcapable.flexiui.demo.locales
import com.highcapable.flexiui.demo.rememberRouter import com.highcapable.flexiui.demo.rememberRouter
import com.highcapable.flexiui.demo.strings import com.highcapable.flexiui.demo.strings
import com.highcapable.flexiui.demo.toName
import com.highcapable.flexiui.displayName import com.highcapable.flexiui.displayName
import com.highcapable.flexiui.resources.FlexiIcons import com.highcapable.flexiui.resources.FlexiIcons
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@@ -120,21 +120,25 @@ fun MainScreen() {
) )
}, },
navigationBar = { navigationBar = {
NavigationBarRow( NavigationBarRow(arrangement = Arrangement.SpaceAround) {
arrangement = Arrangement.SpaceAround repeat(pageCount) { index ->
) { NavigationBarItem(
NavigationBarItem( selected = pagerState.currentPage == index,
selected = pagerState.currentPage == 0, onClick = { scope.launch { pagerState.animateScrollToPage(page = index) } },
onClick = { scope.launch { pagerState.animateScrollToPage(page = 0) } }, icon = {
icon = { Icon(FlexiIcons.Home, style = IconDefaults.style(size = 24.dp)) }, Icon(when (index) {
text = { Text(strings.home) } 0 -> FlexiIcons.Home
) else -> FlexiIcons.Component
NavigationBarItem( }, style = IconDefaults.style(size = 24.dp))
selected = pagerState.currentPage == 1, },
onClick = { scope.launch { pagerState.animateScrollToPage(page = 1) } }, text = {
icon = { Icon(FlexiIcons.Component, style = IconDefaults.style(size = 24.dp)) }, Text(when (index) {
text = { Text(strings.component) } 0 -> strings.home
) else -> strings.component
})
}
)
}
} }
} }
) { innerPadding -> ) { innerPadding ->
@@ -177,7 +181,7 @@ fun MainHomePage(modifier: Modifier) {
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),
expanded = expanded, expanded = expanded,
onExpandedChange = { expanded = it }, onExpandedChange = { expanded = it },
text = { Text(locale.toName()) }, text = { Text(locale.displayName) },
) { ) {
locales.forEach { locales.forEach {
DropdownMenuItem( DropdownMenuItem(
@@ -186,7 +190,7 @@ fun MainHomePage(modifier: Modifier) {
expanded = false expanded = false
locale = it locale = it
} }
) { Text(it.toName()) } ) { Text(it.displayName) }
} }
} }
} }