Skip to content

Commit cf328b3

Browse files
committed
chore(fc): update room info action menu to context menu
Signed-off-by: Brandon McAnsh <[email protected]>
1 parent 042c16e commit cf328b3

File tree

9 files changed

+156
-158
lines changed

9 files changed

+156
-158
lines changed

flipchatApp/src/main/kotlin/xyz/flipchat/app/features/chat/conversation/ConversationMessages.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import androidx.compose.ui.platform.LocalUriHandler
2727
import androidx.paging.compose.LazyPagingItems
2828
import com.getcode.manager.TopBarManager
2929
import com.getcode.navigation.core.LocalCodeNavigator
30+
import com.getcode.navigation.screens.ContextSheet
3031
import com.getcode.theme.CodeTheme
3132
import com.getcode.ui.components.chat.MessageList
3233
import com.getcode.ui.components.chat.MessageListEvent
@@ -87,7 +88,7 @@ internal fun ConversationMessages(
8788
ime?.hide()
8889
delay(500)
8990
}
90-
navigator.show(MessageActionContextSheet(event.actions))
91+
navigator.show(ContextSheet(event.actions))
9192
}
9293
}
9394

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package xyz.flipchat.app.features.chat.info
2+
3+
import androidx.compose.material.icons.Icons
4+
import androidx.compose.material.icons.automirrored.filled.Reply
5+
import androidx.compose.material.icons.automirrored.outlined.Logout
6+
import androidx.compose.material.icons.outlined.DoorFront
7+
import androidx.compose.runtime.Composable
8+
import androidx.compose.ui.graphics.painter.Painter
9+
import androidx.compose.ui.graphics.vector.rememberVectorPainter
10+
import androidx.compose.ui.res.painterResource
11+
import androidx.compose.ui.res.stringResource
12+
import com.getcode.navigation.screens.ContextSheet
13+
import com.getcode.ui.components.contextmenu.ContextMenuAction
14+
import xyz.flipchat.app.R
15+
16+
17+
sealed interface RoomControlAction : ContextMenuAction {
18+
data class CoverCharge(override val onSelect: () -> Unit) : RoomControlAction {
19+
override val isDestructive: Boolean = false
20+
override val delayUponSelection: Boolean = true
21+
override val title: String
22+
@Composable get() = stringResource(R.string.action_changeCoverCharge)
23+
override val painter: Painter
24+
@Composable get() = painterResource(R.drawable.ic_kin_white_small)
25+
}
26+
27+
data class CloseRoom(override val onSelect: () -> Unit) : RoomControlAction {
28+
override val isDestructive: Boolean = false
29+
override val delayUponSelection: Boolean = true
30+
override val title: String
31+
@Composable get() = stringResource(R.string.action_closeFlipchatTemporarily)
32+
override val painter: Painter
33+
@Composable get() = rememberVectorPainter(Icons.Outlined.DoorFront)
34+
}
35+
36+
data class OpenRoom(override val onSelect: () -> Unit) : RoomControlAction {
37+
override val isDestructive: Boolean = false
38+
override val delayUponSelection: Boolean = true
39+
override val title: String
40+
@Composable get() = stringResource(R.string.action_reopenFlipchat)
41+
override val painter: Painter
42+
@Composable get() = painterResource(R.drawable.ic_door_open)
43+
}
44+
45+
data class LeaveRoom(override val onSelect: () -> Unit) : RoomControlAction {
46+
override val isDestructive: Boolean = true
47+
override val delayUponSelection: Boolean = true
48+
override val title: String
49+
@Composable get() = stringResource(R.string.action_leaveRoom)
50+
override val painter: Painter
51+
@Composable get() = rememberVectorPainter(Icons.AutoMirrored.Outlined.Logout)
52+
}
53+
}

flipchatApp/src/main/kotlin/xyz/flipchat/app/features/chat/info/RoomInfoScreen.kt

Lines changed: 20 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ import com.getcode.manager.BottomBarManager
4747
import com.getcode.navigation.NavScreenProvider
4848
import com.getcode.navigation.RoomInfoArgs
4949
import com.getcode.navigation.core.LocalCodeNavigator
50+
import com.getcode.navigation.screens.ContextSheet
5051
import com.getcode.theme.CodeTheme
5152
import com.getcode.ui.components.AppBarDefaults
5253
import com.getcode.ui.components.AppBarWithTitle
5354
import com.getcode.ui.components.chat.AvatarEndAction
5455
import com.getcode.ui.components.chat.HostableAvatar
56+
import com.getcode.ui.components.contextmenu.ContextMenuAction
5557
import com.getcode.ui.theme.ButtonState
5658
import com.getcode.ui.theme.CodeButton
5759
import com.getcode.ui.theme.CodeScaffold
@@ -98,7 +100,7 @@ class RoomInfoScreen(
98100
.filterIsInstance<ChatInfoViewModel.Event.OnChangeCover>()
99101
.map { it.roomId }
100102
.onEach {
101-
navigator.push(ScreenRegistry.get(NavScreenProvider.Room.ChangeCover(it)))
103+
navigator.push(ScreenRegistry.get(NavScreenProvider.Room.ChangeCover(it)), delay = 100)
102104
}.launchIn(this)
103105
}
104106

@@ -149,13 +151,7 @@ class RoomInfoScreen(
149151
endContent = {
150152
if (state.isMember) {
151153
AppBarDefaults.Settings {
152-
BottomBarManager.showMessage(
153-
buildBottomBarMessage(
154-
context,
155-
state,
156-
viewModel::dispatchEvent
157-
)
158-
)
154+
navigator.show(ContextSheet(buildActions(state, viewModel::dispatchEvent)))
159155
}
160156
}
161157
}
@@ -368,108 +364,36 @@ private fun RoomInfoScreenContent(
368364
}
369365
}
370366

371-
private fun buildBottomBarMessage(
372-
context: Context,
367+
private fun buildActions(
373368
state: ChatInfoViewModel.State,
374369
dispatch: (ChatInfoViewModel.Event) -> Unit,
375-
): BottomBarManager.BottomBarMessage {
376-
val actions = buildList {
370+
): List<ContextMenuAction> {
371+
return buildList {
377372
if (state.isHost) {
378373
add(
379-
BottomBarAction(
380-
text = context.getString(R.string.action_changeCoverCharge),
381-
onClick = {
382-
dispatch(ChatInfoViewModel.Event.OnChangeCover(state.roomInfo.id!!))
383-
}
384-
)
374+
RoomControlAction.CoverCharge {
375+
dispatch(ChatInfoViewModel.Event.OnChangeCover(state.roomInfo.id!!))
376+
}
385377
)
386378
if (state.isOpen) {
387379
add(
388-
BottomBarAction(
389-
text = context.getString(R.string.action_closeFlipchatTemporarily),
390-
onClick = {
391-
dispatch(ChatInfoViewModel.Event.OnOpenStateChangedRequested)
392-
}
393-
)
380+
RoomControlAction.CloseRoom {
381+
dispatch(ChatInfoViewModel.Event.OnOpenStateChangedRequested)
382+
}
394383
)
395384
} else {
396385
add(
397-
BottomBarAction(
398-
text = context.getString(R.string.action_reopenFlipchat),
399-
onClick = {
400-
dispatch(ChatInfoViewModel.Event.OnOpenStateChangedRequested)
401-
}
402-
)
386+
RoomControlAction.OpenRoom {
387+
dispatch(ChatInfoViewModel.Event.OnOpenStateChangedRequested)
388+
}
403389
)
404390
}
405391
}
406392

407393
add(
408-
BottomBarAction(
409-
text = context.getString(R.string.action_leaveRoom),
410-
onClick = {
411-
dispatch(ChatInfoViewModel.Event.LeaveRoom)
412-
}
413-
)
394+
RoomControlAction.LeaveRoom {
395+
dispatch(ChatInfoViewModel.Event.LeaveRoom)
396+
}
414397
)
415398
}
416-
417-
return BottomBarManager.BottomBarMessage(
418-
title = "",
419-
actions = actions,
420-
showCancel = true,
421-
type = BottomBarManager.BottomBarMessageType.THEMED,
422-
showScrim = true,
423-
)
424-
}
425-
426-
//@Composable
427-
//private fun Actions(
428-
// modifier: Modifier = Modifier,
429-
// state: ChatInfoViewModel.State,
430-
// dispatch: (ChatInfoViewModel.Event) -> Unit,
431-
//) {
432-
// val context = LocalContext.current
433-
// val composeScope = rememberCoroutineScope()
434-
// Column(
435-
// modifier = modifier
436-
// .fillMaxWidth()
437-
// .padding(horizontal = CodeTheme.dimens.inset)
438-
// .padding(bottom = CodeTheme.dimens.grid.x2)
439-
// .navigationBarsPadding(),
440-
// verticalArrangement = Arrangement.spacedBy(CodeTheme.dimens.inset)
441-
// ) {
442-
//
443-
//
444-
// if (state.isHost) {
445-
// CodeButton(
446-
// modifier = Modifier.fillMaxWidth(),
447-
// buttonState = ButtonState.Subtle,
448-
// text = stringResource(R.string.action_customizeRoom),
449-
// ) {
450-
// BottomBarManager.showMessage(
451-
// BottomBarManager.BottomBarMessage(
452-
// positiveText = context.getString(R.string.action_changeRoomName),
453-
// negativeText = context.getString(R.string.action_changeCoverCharge),
454-
// negativeStyle = BottomBarManager.BottomBarButtonStyle.Filled,
455-
// tertiaryText = context.getString(R.string.action_cancel),
456-
// onPositive = {
457-
// composeScope.launch {
458-
// delay(300)
459-
// dispatch(ChatInfoViewModel.Event.OnChangeName(state.roomInfo.id!!, state.roomInfo.customTitle))
460-
// }
461-
// },
462-
// onNegative = {
463-
// composeScope.launch {
464-
// delay(300)
465-
// dispatch(ChatInfoViewModel.Event.OnChangeCover(state.roomInfo.id!!))
466-
// }
467-
// },
468-
// type = BottomBarManager.BottomBarMessageType.THEMED,
469-
// showScrim = true,
470-
// )
471-
// )
472-
// }
473-
// }
474-
// }
475-
//}
399+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="960"
5+
android:viewportHeight="960">
6+
<path
7+
android:pathData="M440,520q17,0 28.5,-11.5T480,480q0,-17 -11.5,-28.5T440,440q-17,0 -28.5,11.5T400,480q0,17 11.5,28.5T440,520ZM280,840v-80l240,-40v-445q0,-15 -9,-27t-23,-14l-208,-34v-80l220,36q44,8 72,41t28,77v512l-320,54ZM120,840v-80h80v-560q0,-34 23.5,-57t56.5,-23h400q34,0 57,23t23,57v560h80v80L120,840ZM280,760h400v-560L280,200v560Z"
8+
android:fillColor="#e8eaed"/>
9+
</vector>

flipchatApp/src/main/res/values/strings.xml

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -121,29 +121,19 @@
121121
<string name="title_muteUserInRoom">Mute %1$s?</string>
122122
<string name="subtitle_muteUserInRoom">They will no longer be able send messages in this room</string>
123123
<string name="action_mute">Mute</string>
124-
<string name="action_muteUser">Mute %1$s</string>
125124

126125
<string name="title_blockUserInRoom">Block %1$s?</string>
127126
<string name="subtitle_blockUserInRoom">All messages from this user will be hidden</string>
128127
<string name="action_block">Block</string>
129128

130129
<string name="title_reportUserForMessage">Report</string>
131130
<string name="subtitle_reportUserForMessage">This message will be forwarded to Flipchat. This contact will not be notified</string>
132-
<string name="action_report">Report</string>
133131

134132
<string name="success_title_reportUser">Report Sent</string>
135133
<string name="success_description_reportUser">Your report was sent successfully</string>
136134

137135
<string name="permissions_description_push_messages">Receive push notifications when people message you.</string>
138136

139-
<string name="action_copyMessage">Copy Message</string>
140-
<string name="action_deleteMessage">Delete</string>
141-
<string name="action_blockUser">Block User</string>
142-
<string name="action_blockUserByName">Block %1$s</string>
143-
<string name="action_unblockUser">Unblock %1$s</string>
144-
<string name="action_removeUser">Remove %1$s</string>
145-
<string name="action_reportUser">Report %1$s</string>
146-
147137
<string name="title_roomCardHostedBy">Hosted by %1$s</string>
148138
<string name="title_roomCardJoinCost">Cover Charge: ⬢ %1$s</string>
149139

@@ -177,20 +167,20 @@
177167
<string name="subtitle_roomNameHint">Enter a name appropriate for all ages</string>
178168

179169
<string name="title_youHaveBeenMuted">You\'ve been muted</string>
180-
<string name="title_roomIsClosed">The host has temporarily closed this room. Only they can send messages until they reopen it</string>
181-
<string name="subtitle_roomIsOpen">Your room is currently open</string>
182-
<string name="subtitle_roomIsClosed">Your room is currently closed</string>
170+
<string name="title_roomIsClosed">The host has temporarily closed this flipchat. Only they can send messages until they reopen it</string>
171+
<string name="subtitle_roomIsOpen">Your flipchat is currently open</string>
172+
<string name="subtitle_roomIsClosed">Your flipchat is currently closed</string>
183173
<string name="action_change">Change</string>
184174
<string name="action_reopen">Reopen</string>
185175
<string name="action_close">Close</string>
186-
<string name="prompt_title_reopenRoom">Reopen Room?</string>
176+
<string name="prompt_title_reopenRoom">Reopen Flipchat?</string>
187177
<string name="prompt_description_reopenRoom">People will be able to send messages again</string>
188178
<string name="action_closeFlipchatTemporarily">Close Flipchat Temporarily</string>
189179
<string name="action_reopenFlipchat">Reopen Flipchat</string>
190-
<string name="prompt_title_closeRoom">Close Room Temporarily?</string>
191-
<string name="prompt_description_closeRoom">Only you will be able to send messages until you reopen the room</string>
180+
<string name="prompt_title_closeRoom">Close Flipchat Temporarily?</string>
181+
<string name="prompt_description_closeRoom">Only you will be able to send messages until you reopen the flipchat</string>
192182
<string name="action_closeTemporarily">Close Temporarily</string>
193-
<string name="action_reopenRoom">Reopen Room</string>
183+
<string name="action_reopenRoom">Reopen Flipchat</string>
194184

195185
<string name="subtitle_accessKeyDescription">Your Access Key is the only way to access your account. Please keep it private and safe.</string>
196186
<string name="subtitle_accessKeySnapshotWarning">Warning! This image gives access to your Flipchat account. Do not share this image with anyone else. Keep it secure and safe.</string>
@@ -208,9 +198,6 @@
208198
<string name="prompt_title_logout">Log Out?</string>
209199
<string name="prompt_description_logout">You will need to enter your Access Key to get back into this account</string>
210200

211-
<string name="action_reply">Reply</string>
212-
<string name="action_giveTip">Give Tip</string>
213-
214201
<string name="title_betaFlags">Labs</string>
215202

216203
<string name="action_notNow">Not Now</string>

0 commit comments

Comments
 (0)