Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 37 additions & 5 deletions app/src/main/java/com/bitchat/android/ui/ChatScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ import androidx.compose.ui.zIndex
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.bitchat.android.model.BitchatMessage
import com.bitchat.android.ui.media.FullScreenImageViewer
import com.giphy.sdk.ui.views.GiphyDialogFragment
import com.giphy.sdk.ui.themes.GPHTheme
import com.giphy.sdk.ui.GPHContentType
import com.giphy.sdk.ui.GPHSettings
import com.giphy.sdk.core.models.Media
import androidx.appcompat.app.AppCompatActivity

/**
* Main ChatScreen - REFACTORED to use component-based architecture
Expand All @@ -39,6 +45,7 @@ import com.bitchat.android.ui.media.FullScreenImageViewer
*/
@Composable
fun ChatScreen(viewModel: ChatViewModel) {
val context = androidx.compose.ui.platform.LocalContext.current
val colorScheme = MaterialTheme.colorScheme
val messages by viewModel.messages.collectAsStateWithLifecycle()
val connectedPeers by viewModel.connectedPeers.collectAsStateWithLifecycle()
Expand Down Expand Up @@ -101,11 +108,8 @@ fun ChatScreen(viewModel: ChatViewModel) {
}
}

// Determine whether to show media buttons (only hide in geohash location chats)
val showMediaButtons = when {
currentChannel != null -> true
else -> selectedLocationChannel !is com.bitchat.android.geohash.ChannelID.Location
}
// Determine whether to show media buttons (enabled for all channels)
val showMediaButtons = true
Comment thread
a1denvalu3 marked this conversation as resolved.

// Use WindowInsets to handle keyboard properly
Box(
Expand Down Expand Up @@ -213,6 +217,32 @@ fun ChatScreen(viewModel: ChatViewModel) {
onSendFileNote = { peer, onionOrChannel, path ->
viewModel.sendFileNote(peer, onionOrChannel, path)
},
onGifClick = {
val activity = context as? AppCompatActivity
if (activity != null) {
val settings = GPHSettings(
theme = if (colorScheme.background == Color.Black) GPHTheme.Dark else GPHTheme.Light,
mediaTypeConfig = arrayOf(GPHContentType.gif, GPHContentType.sticker)
)
val picker = GiphyDialogFragment.newInstance(settings)
picker.gifSelectionListener = object : GiphyDialogFragment.GifSelectionListener {
override fun onGifSelected(media: Media, searchTerm: String?, selectedContentType: GPHContentType) {
val url = media.images.fixedHeight?.gifUrl
if (url != null) {
viewModel.sendMessage(url)
// Force scroll to bottom on next frame
forceScrollToBottom = !forceScrollToBottom
}
picker.dismiss()
}
override fun onDismissed(selectedContentType: GPHContentType) {
// no-op
}
override fun didSearchTerm(term: String) {}
}
picker.show(activity.supportFragmentManager, "giphy_picker")
}
},

showCommandSuggestions = showCommandSuggestions,
commandSuggestions = commandSuggestions,
Expand Down Expand Up @@ -354,6 +384,7 @@ fun ChatInputSection(
onSendVoiceNote: (String?, String?, String) -> Unit,
onSendImageNote: (String?, String?, String) -> Unit,
onSendFileNote: (String?, String?, String) -> Unit,
onGifClick: () -> Unit,
showCommandSuggestions: Boolean,
commandSuggestions: List<CommandSuggestion>,
showMentionSuggestions: Boolean,
Expand Down Expand Up @@ -397,6 +428,7 @@ fun ChatInputSection(
onSendVoiceNote = onSendVoiceNote,
onSendImageNote = onSendImageNote,
onSendFileNote = onSendFileNote,
onGifClick = onGifClick,
selectedPrivatePeer = selectedPrivatePeer,
currentChannel = currentChannel,
nickname = nickname,
Expand Down
Loading