diff --git a/app/src/main/kotlin/top/yukonga/hq_icon/MainActivity.kt b/app/src/main/kotlin/top/yukonga/hq_icon/MainActivity.kt index f6a2000..4c9ad70 100644 --- a/app/src/main/kotlin/top/yukonga/hq_icon/MainActivity.kt +++ b/app/src/main/kotlin/top/yukonga/hq_icon/MainActivity.kt @@ -40,7 +40,9 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.hapticfeedback.HapticFeedbackType import androidx.compose.ui.input.nestedscroll.nestedScroll +import androidx.compose.ui.platform.LocalHapticFeedback import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.Preview @@ -154,9 +156,12 @@ private fun FloatActionButton( cornerState: MutableState ) { val coroutineScope = rememberCoroutineScope() + val hapticFeedback = LocalHapticFeedback.current + ExtendedFloatingActionButton( modifier = Modifier.offset(y = fabOffsetHeight), onClick = { + hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress) coroutineScope.launch { if (term.value != "") { val results = Search().search(term.value, country.value, platform.value, limit.value) @@ -177,7 +182,6 @@ private fun FloatActionButton( modifier = Modifier.height(20.dp), imageVector = Icons.Filled.Check, contentDescription = null - ) Spacer( modifier = Modifier.width(8.dp) diff --git a/app/src/main/kotlin/top/yukonga/hq_icon/ui/components/AboutDialog.kt b/app/src/main/kotlin/top/yukonga/hq_icon/ui/components/AboutDialog.kt index 00503e9..c4005ce 100644 --- a/app/src/main/kotlin/top/yukonga/hq_icon/ui/components/AboutDialog.kt +++ b/app/src/main/kotlin/top/yukonga/hq_icon/ui/components/AboutDialog.kt @@ -29,6 +29,8 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.ColorFilter import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.hapticfeedback.HapticFeedbackType.Companion.LongPress +import androidx.compose.ui.platform.LocalHapticFeedback import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.vectorResource @@ -40,14 +42,18 @@ import androidx.compose.ui.unit.dp import top.yukonga.hq_icon.BuildConfig import top.yukonga.hq_icon.R - @OptIn(ExperimentalMaterial3Api::class) @Composable fun AboutDialog() { var showDialog by remember { mutableStateOf(false) } val uriHandler = LocalUriHandler.current + val hapticFeedback = LocalHapticFeedback.current + IconButton( - onClick = { showDialog = true }) { + onClick = { + showDialog = true + hapticFeedback.performHapticFeedback(LongPress) + }) { Icon( imageVector = Icons.Outlined.ImageSearch, contentDescription = null, @@ -111,7 +117,10 @@ fun AboutDialog() { text = "GitHub", spanStyle = SpanStyle(textDecoration = TextDecoration.Underline) ), - onClick = { uriHandler.openUri("https://github.com/YuKongA/HQ-ICON_Compose") }, + onClick = { + uriHandler.openUri("https://github.com/YuKongA/HQ-ICON_Compose") + hapticFeedback.performHapticFeedback(LongPress) + }, style = MaterialTheme.typography.bodyMedium + SpanStyle(color = MaterialTheme.colorScheme.primary) ) } @@ -125,7 +134,10 @@ fun AboutDialog() { text = "Telegram", spanStyle = SpanStyle(textDecoration = TextDecoration.Underline) ), - onClick = { uriHandler.openUri("https://t.me/YuKongA13579") }, + onClick = { + uriHandler.openUri("https://t.me/YuKongA13579") + hapticFeedback.performHapticFeedback(LongPress) + }, style = MaterialTheme.typography.bodyMedium + SpanStyle(color = MaterialTheme.colorScheme.primary) ) } diff --git a/app/src/main/kotlin/top/yukonga/hq_icon/ui/components/ResultsView.kt b/app/src/main/kotlin/top/yukonga/hq_icon/ui/components/ResultsView.kt index 2e51ed2..e464ef4 100644 --- a/app/src/main/kotlin/top/yukonga/hq_icon/ui/components/ResultsView.kt +++ b/app/src/main/kotlin/top/yukonga/hq_icon/ui/components/ResultsView.kt @@ -29,7 +29,9 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.ImageBitmap import androidx.compose.ui.graphics.asImageBitmap +import androidx.compose.ui.hapticfeedback.HapticFeedbackType import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalHapticFeedback import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontWeight @@ -53,6 +55,10 @@ fun ResultsView(results: List, corner: String, resolution: Stri @Composable fun ResultItemView(result: Response.Result, corner: String, resolution: String) { val isVisible = remember { mutableStateOf(false) } + val coroutineScope = rememberCoroutineScope() + val context = LocalContext.current + val hapticFeedback = LocalHapticFeedback.current + AnimatedVisibility( visible = isVisible.value, enter = fadeIn() + expandVertically(), @@ -93,12 +99,11 @@ fun ResultItemView(result: Response.Result, corner: String, resolution: String) style = MaterialTheme.typography.labelSmall ) } - val coroutineScope = rememberCoroutineScope() - val context = LocalContext.current Text( modifier = Modifier .padding(start = 16.dp) .clickable { + hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress) coroutineScope.launch { Download().downloadImage( context, @@ -127,6 +132,7 @@ fun ResultItemView(result: Response.Result, corner: String, resolution: String) @Composable fun MessageText(text: String, style: TextStyle) { val scrollState = rememberScrollState() + Text( text = text, style = style, diff --git a/app/src/main/kotlin/top/yukonga/hq_icon/ui/components/SecondCardView.kt b/app/src/main/kotlin/top/yukonga/hq_icon/ui/components/SecondCardView.kt index a10319e..25aaa1b 100644 --- a/app/src/main/kotlin/top/yukonga/hq_icon/ui/components/SecondCardView.kt +++ b/app/src/main/kotlin/top/yukonga/hq_icon/ui/components/SecondCardView.kt @@ -18,6 +18,8 @@ import androidx.compose.runtime.MutableState import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier +import androidx.compose.ui.hapticfeedback.HapticFeedbackType.Companion.LongPress +import androidx.compose.ui.platform.LocalHapticFeedback import androidx.compose.ui.res.stringResource import androidx.compose.ui.semantics.Role import androidx.compose.ui.unit.dp @@ -81,6 +83,7 @@ fun PlatformView( platformCode: MutableState ) { val platform = Data().platformNames + val hapticFeedback = LocalHapticFeedback.current Column( modifier = Modifier.padding(horizontal = 16.dp, vertical = 14.dp), @@ -101,6 +104,7 @@ fun PlatformView( selected = (text == selectedOption), onClick = { onOptionSelected(text) + hapticFeedback.performHapticFeedback(LongPress) platformCode.value = Data().platformCode(text) }, role = Role.RadioButton @@ -126,6 +130,7 @@ fun CornerView( cornerStateCode: MutableState ) { val cornerState = Data().cornerStateNames + val hapticFeedback = LocalHapticFeedback.current Column( modifier = Modifier.padding(horizontal = 16.dp, vertical = 14.dp), @@ -147,6 +152,7 @@ fun CornerView( selected = (text == selectedOption), onClick = { onOptionSelected(text) + hapticFeedback.performHapticFeedback(LongPress) cornerStateCode.value = Data().cornerStateCode(text) }, role = Role.RadioButton @@ -172,6 +178,7 @@ fun ResolutionView( resolutionCode: MutableState ) { val resolution = Data().resolutionNames + val hapticFeedback = LocalHapticFeedback.current Column( modifier = Modifier.padding(horizontal = 16.dp, vertical = 14.dp), @@ -193,6 +200,7 @@ fun ResolutionView( selected = (text == selectedOption), onClick = { onOptionSelected(text) + hapticFeedback.performHapticFeedback(LongPress) resolutionCode.value = Data().resolutionCode(text) Preferences().perfSet("resolution", resolutionCode.value) }, diff --git a/app/src/main/kotlin/top/yukonga/hq_icon/ui/components/TextFieldWithDropdown.kt b/app/src/main/kotlin/top/yukonga/hq_icon/ui/components/TextFieldWithDropdown.kt index faacbf2..afe23b1 100644 --- a/app/src/main/kotlin/top/yukonga/hq_icon/ui/components/TextFieldWithDropdown.kt +++ b/app/src/main/kotlin/top/yukonga/hq_icon/ui/components/TextFieldWithDropdown.kt @@ -1,5 +1,6 @@ package top.yukonga.hq_icon.ui.components +import androidx.compose.foundation.background import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.shape.RoundedCornerShape @@ -18,10 +19,12 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.hapticfeedback.HapticFeedbackType +import androidx.compose.ui.platform.LocalHapticFeedback import androidx.compose.ui.unit.dp - @OptIn(ExperimentalMaterial3Api::class) @Composable fun TextFieldWithDropdown( @@ -30,11 +33,15 @@ fun TextFieldWithDropdown( label: String, leadingIcon: ImageVector ) { + val hapticFeedback = LocalHapticFeedback.current var isDropdownExpanded by remember { mutableStateOf(false) } ExposedDropdownMenuBox( expanded = isDropdownExpanded, - onExpandedChange = { isDropdownExpanded = it }, + onExpandedChange = { + isDropdownExpanded = it + hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress) + }, ) { OutlinedTextField( value = text.value, @@ -42,30 +49,27 @@ fun TextFieldWithDropdown( label = { Text(label) }, readOnly = true, singleLine = true, - modifier = Modifier - .fillMaxWidth() - .menuAnchor(), + modifier = Modifier.menuAnchor().fillMaxWidth(), shape = RoundedCornerShape(10.dp), trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(isDropdownExpanded) }, leadingIcon = { Icon(imageVector = leadingIcon, null) }, ) DropdownMenu( - modifier = Modifier - .exposedDropdownSize() - .heightIn(max = 250.dp), + modifier = Modifier.exposedDropdownSize().heightIn(max = 250.dp), expanded = isDropdownExpanded, onDismissRequest = { isDropdownExpanded = false }, ) { items.forEach { item -> - DropdownMenuItem( + DropdownMenuItem(modifier = Modifier.background(Color.Transparent), text = { Text(item) }, contentPadding = ExposedDropdownMenuDefaults.ItemContentPadding, onClick = { text.value = item isDropdownExpanded = false + hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress) } ) } } } -} +} \ No newline at end of file