Skip to content

Commit

Permalink
feat: display contact address as tooltip in sms thread screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Bnyro committed Oct 6, 2023
1 parent 65df6fc commit 47060b3
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions app/src/main/java/com/bnyro/contacts/ui/screens/SmsThreadScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import androidx.compose.material3.ElevatedCard
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.PlainTooltipBox
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SwipeToDismiss
import androidx.compose.material3.Text
Expand Down Expand Up @@ -63,7 +64,8 @@ fun SmsThreadScreen(
val context = LocalContext.current

val threadId = smsModel.smsList.firstOrNull { it.address == address }?.threadId
val smsList = threadId?.let { smsModel.smsGroups[threadId]?.sortedBy { it.timestamp } } ?: listOf()
val smsList =
threadId?.let { smsModel.smsGroups[threadId]?.sortedBy { it.timestamp } } ?: listOf()
val lazyListState = rememberLazyListState()
var showContactScreen by remember {
mutableStateOf(false)
Expand All @@ -77,12 +79,18 @@ fun SmsThreadScreen(
val interactionSource = remember {
MutableInteractionSource()
}
Text(
modifier = Modifier.clickable(interactionSource, null) {
if (contactData != null) showContactScreen = true
},
text = contactData?.displayName ?: address
)
PlainTooltipBox(
tooltip = { Text(address) }
) {
Text(
modifier = Modifier
.tooltipTrigger()
.clickable(interactionSource, null) {
if (contactData != null) showContactScreen = true
},
text = contactData?.displayName ?: address
)
}
},
navigationIcon = {
ClickableIcon(
Expand Down Expand Up @@ -157,7 +165,8 @@ fun SmsThreadScreen(
modifier = Modifier.align(messageAlignment),
fontSize = 14.sp,
color = MaterialTheme.colorScheme.primary,
text = DateUtils.getRelativeTimeSpanString(smsData.timestamp).toString()
text = DateUtils.getRelativeTimeSpanString(smsData.timestamp)
.toString()
)
}
}
Expand Down Expand Up @@ -211,7 +220,8 @@ fun SmsThreadScreen(
) {
if (text.isBlank()) return@ClickableIcon
if (!SmsUtil.isShortEnoughForSms(text)) {
Toast.makeText(context, R.string.message_too_long, Toast.LENGTH_SHORT).show()
Toast.makeText(context, R.string.message_too_long, Toast.LENGTH_SHORT)
.show()
return@ClickableIcon
}

Expand Down

0 comments on commit 47060b3

Please sign in to comment.