feat: double click to reply (temporary)

Signed-off-by: Infi <wingit@geist.ga>
This commit is contained in:
Infi 2023-06-03 21:45:42 +02:00
parent 1b9e458640
commit cf6a506eb5
3 changed files with 42 additions and 6 deletions

View File

@ -140,7 +140,6 @@ fun Message(
onResult = { onResult = {
// do nothing // do nothing
}) })
Column { Column {
if (message.tail == false) { if (message.tail == false) {
Spacer(modifier = Modifier.height(10.dp)) Spacer(modifier = Modifier.height(10.dp))
@ -169,6 +168,9 @@ fun Message(
modifier = Modifier modifier = Modifier
.combinedClickable( .combinedClickable(
onClick = {}, onClick = {},
onDoubleClick = {
onReply()
},
onLongClick = { onLongClick = {
onMessageContextMenu() onMessageContextMenu()
} }

View File

@ -1,17 +1,43 @@
package chat.revolt.screens.chat.views.channel package chat.revolt.screens.chat.views.channel
import android.widget.Toast
import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.animation.* import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.animateDpAsState import androidx.compose.animation.core.animateDpAsState
import androidx.compose.foundation.layout.* import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInHorizontally
import androidx.compose.animation.slideOutHorizontally
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.KeyboardArrowDown import androidx.compose.material.icons.filled.KeyboardArrowDown
import androidx.compose.material3.* import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.runtime.* import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExtendedFloatingActionButton
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Text
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.material3.surfaceColorAtElevation
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
@ -47,7 +73,6 @@ import chat.revolt.sheets.ChannelInfoSheet
import chat.revolt.sheets.MessageContextSheet import chat.revolt.sheets.MessageContextSheet
import com.discord.simpleast.core.simple.SimpleMarkdownRules import com.discord.simpleast.core.simple.SimpleMarkdownRules
import com.discord.simpleast.core.simple.SimpleRenderer import com.discord.simpleast.core.simple.SimpleRenderer
import io.ktor.http.*
import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import java.io.File import java.io.File
@ -252,6 +277,14 @@ fun ChannelScreen(
}, },
canReply = true, canReply = true,
onReply = { onReply = {
if (viewModel.replies.size >= 5) {
Toast.makeText(
context,
context.getString(R.string.too_many_replies, 5),
Toast.LENGTH_SHORT
).show()
return@Message
}
viewModel.replyToMessage(message) viewModel.replyToMessage(message)
}, },
) )

View File

@ -89,6 +89,7 @@
<string name="remove_reply_alt">Remove reply</string> <string name="remove_reply_alt">Remove reply</string>
<string name="reply_mention_on">\@ on</string> <string name="reply_mention_on">\@ on</string>
<string name="reply_mention_off">\@ off</string> <string name="reply_mention_off">\@ off</string>
<string name="too_many_replies">You can only reply to %1$d messages at a time.</string>
<string name="badge_bot_alt">Bot</string> <string name="badge_bot_alt">Bot</string>
<string name="badge_masquerade_alt">From linked channel</string> <string name="badge_masquerade_alt">From linked channel</string>