mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-08-15 06:56:30 +00:00
* Add BitChatBrandButton and BitChatIcon Add a dedicated brand button component and custom vector icon to the UI library. Refactor the chat header to use this component, replacing the previous modifier-based multi-click implementation. * **BitChatBrandButton**: A new Composable that encapsulates single and triple click detection logic using coroutine delays and tap counting. * **BitChatIcon**: A custom pixel-style `ImageVector` representing the brand. * **ChatHeader**: Updated to use the new brand button and included a visual separator (`/`) in the layout. * **ModifierExt.kt**: Removed the `singleOrTripleClickable` extension as its functionality is now handled internally by the brand button component. * ui: refactor text messages to two-row layout Refactor the message list items to use a two-row layout for standard text messages, while preserving the legacy compact format for system messages. * **UI Formatting**: Added `formatTextMessageSender`, `formatTextMessageMetadata`, and `formatTextMessageBody` in `ChatUIUtils.kt` to separate the rendering of sender info, timestamps/PoW, and message content. * **Layout Change**: Replaced the single-block `Text` component with a `Column` containing a `Row` (Sender + Metadata) and a message body `Text` block for standard messages. * **Interaction**: Updated `pointerInput` and `detectTapGestures` to handle nickname clicks in the header row and geohash/URL clicks within the message body row. * **Styling**: Refined `appendIOSFormattedContent` to support a `contentColor` parameter and applied specific font weights and colors (e.g., orange for self-messages) to match the platform's design language. * **System Messages**: Explicitly kept messages where `sender == "system"` on the original compact layout. * refactor(ui): extract annotated text pointer handling * fix(ui): address chat redesign review feedback * fix(ui): align PoW animation with text layout * refactor(ui): extract message interaction helpers --------- Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
45 lines
1.1 KiB
Kotlin
45 lines
1.1 KiB
Kotlin
package com.bitchat.android.ui
|
|
|
|
import com.bitchat.android.model.BitchatMessage
|
|
import java.text.SimpleDateFormat
|
|
import java.util.Date
|
|
import java.util.Locale
|
|
import org.junit.Assert.assertEquals
|
|
import org.junit.Test
|
|
|
|
class ChatUIUtilsTest {
|
|
private val timeFormatter = SimpleDateFormat("HH:mm:ss", Locale.ROOT).apply {
|
|
timeZone = java.util.TimeZone.getTimeZone("UTC")
|
|
}
|
|
|
|
@Test
|
|
fun `text message metadata separates PoW badge with one space`() {
|
|
val message = BitchatMessage(
|
|
sender = "alice",
|
|
content = "hello",
|
|
timestamp = Date(0),
|
|
powDifficulty = 12,
|
|
)
|
|
|
|
assertEquals(
|
|
"00:00:00 ⛨12b",
|
|
formatTextMessageMetadata(message, timeFormatter).text,
|
|
)
|
|
}
|
|
|
|
@Test
|
|
fun `text message metadata omits non-positive PoW difficulty`() {
|
|
val message = BitchatMessage(
|
|
sender = "alice",
|
|
content = "hello",
|
|
timestamp = Date(0),
|
|
powDifficulty = 0,
|
|
)
|
|
|
|
assertEquals(
|
|
"00:00:00",
|
|
formatTextMessageMetadata(message, timeFormatter).text,
|
|
)
|
|
}
|
|
}
|