feat: adding reactions
Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
parent
63e2f6e9af
commit
07e38002de
|
|
@ -39,6 +39,7 @@ import androidx.compose.ui.unit.dp
|
||||||
import chat.revolt.R
|
import chat.revolt.R
|
||||||
import chat.revolt.api.REVOLT_APP
|
import chat.revolt.api.REVOLT_APP
|
||||||
import chat.revolt.api.RevoltAPI
|
import chat.revolt.api.RevoltAPI
|
||||||
|
import chat.revolt.api.routes.channel.react
|
||||||
import chat.revolt.callbacks.UiCallbacks
|
import chat.revolt.callbacks.UiCallbacks
|
||||||
import chat.revolt.components.chat.Message
|
import chat.revolt.components.chat.Message
|
||||||
import chat.revolt.components.generic.SheetClickable
|
import chat.revolt.components.generic.SheetClickable
|
||||||
|
|
@ -69,6 +70,7 @@ fun MessageContextSheet(
|
||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
|
|
||||||
var showShareSheet by remember { mutableStateOf(false) }
|
var showShareSheet by remember { mutableStateOf(false) }
|
||||||
|
var showReactSheet by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
if (showShareSheet) {
|
if (showShareSheet) {
|
||||||
val shareSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
val shareSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
||||||
|
|
@ -234,6 +236,30 @@ fun MessageContextSheet(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (showReactSheet) {
|
||||||
|
val reactSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
||||||
|
|
||||||
|
ModalBottomSheet(
|
||||||
|
sheetState = reactSheetState,
|
||||||
|
onDismissRequest = {
|
||||||
|
showReactSheet = false
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
ReactSheet(messageId) {
|
||||||
|
if (it == null) return@ReactSheet
|
||||||
|
|
||||||
|
coroutineScope.launch {
|
||||||
|
message.channel?.let { channelId ->
|
||||||
|
react(channelId, messageId, it)
|
||||||
|
}
|
||||||
|
|
||||||
|
reactSheetState.hide()
|
||||||
|
onHideSheet()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(horizontal = 16.dp, vertical = 8.dp)
|
.padding(horizontal = 16.dp, vertical = 8.dp)
|
||||||
|
|
@ -292,15 +318,7 @@ fun MessageContextSheet(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
Toast.makeText(
|
showReactSheet = true
|
||||||
context,
|
|
||||||
context.getString(R.string.comingsoon_toast),
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
|
|
||||||
coroutineScope.launch {
|
|
||||||
onHideSheet()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.author == RevoltAPI.selfId) {
|
if (message.author == RevoltAPI.selfId) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package chat.revolt.sheets
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import chat.revolt.api.RevoltAPI
|
||||||
|
import chat.revolt.components.emoji.EmojiPicker
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ReactSheet(messageId: String, onSelect: (String?) -> Unit) {
|
||||||
|
val message = RevoltAPI.messageCache[messageId]
|
||||||
|
|
||||||
|
if (message == null) {
|
||||||
|
onSelect(null)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
EmojiPicker {
|
||||||
|
onSelect(it.removeSurrounding(":"))
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue