feat: update demo

This commit is contained in:
2024-01-14 12:43:00 +08:00
parent 848ffa6d57
commit aa3de2e1a9
3 changed files with 18 additions and 9 deletions

View File

@@ -25,6 +25,8 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.unit.dp
import com.highcapable.flexiui.FlexiTheme
import com.highcapable.flexiui.component.Text
@@ -49,3 +51,15 @@ fun SecondaryText(text: String) {
style = FlexiTheme.typography.secondary
)
}
@Composable
fun HapticFeedback(
type: HapticFeedbackType = HapticFeedbackType.LongPress,
handler: () -> Unit
): () -> Unit {
val hapticFeedback = LocalHapticFeedback.current
return {
handler()
hapticFeedback.performHapticFeedback(type)
}
}

View File

@@ -44,8 +44,6 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.unit.dp
import com.highcapable.betterandroid.compose.multiplatform.backpress.BackHandler
import com.highcapable.flexiui.component.Button
@@ -61,6 +59,7 @@ import com.highcapable.flexiui.component.Text
import com.highcapable.flexiui.component.window.FlexiDialog
import com.highcapable.flexiui.demo.Delete
import com.highcapable.flexiui.demo.DeleteForever
import com.highcapable.flexiui.demo.HapticFeedback
import com.highcapable.flexiui.demo.ListAdd
import com.highcapable.flexiui.demo.PrimarySpacer
import com.highcapable.flexiui.demo.bean.SimpleListBean
@@ -155,13 +154,9 @@ fun LazyListScreen() {
@Composable
fun LazyItem(modifier: Modifier, index: Int) {
Box(modifier = modifier) {
val hapticFeedback = LocalHapticFeedback.current
var showDropdownMenu by remember { mutableStateOf(false) }
HorizontalItemBox(
onLongClick = {
showDropdownMenu = true
hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress)
},
onLongClick = HapticFeedback { showDropdownMenu = true },
title = { Text(testListData[index].title) },
subtitle = { Text(testListData[index].subtitle) },
showArrowIcon = false

View File

@@ -58,8 +58,8 @@ fun SecondaryScreen() {
AreaColumn(modifier = Modifier.fillMaxWidth()) {
Text(
"""
Now, you open a separate secondary page.
You can click the button below to back to the homepage.
Now, you open a separate secondary page.
You can click the button below to back to the homepage.
""".trimIndent(),
style = FlexiTheme.typography.primary.copy(lineHeight = 2.em)
)