Skip to content

Commit 42ec7b9

Browse files
committed
chore(fc): room name change tweaks
Signed-off-by: Brandon McAnsh <[email protected]>
1 parent 6ad6b28 commit 42ec7b9

File tree

6 files changed

+31
-31
lines changed

6 files changed

+31
-31
lines changed

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ import com.getcode.ui.components.chat.MessageListPointerResult
3333
import com.getcode.ui.components.chat.utils.ChatItem
3434
import com.getcode.ui.components.chat.utils.HandleMessageChanges
3535
import com.getcode.ui.components.text.markup.Markup
36+
import com.getcode.ui.utils.animateScrollToItemWithFullVisibility
3637
import com.getcode.ui.utils.keyboardAsState
38+
import com.getcode.ui.utils.scrollToItemWithFullVisibility
3739
import kotlinx.coroutines.delay
3840
import kotlinx.coroutines.launch
3941
import xyz.flipchat.app.R
@@ -118,18 +120,30 @@ internal fun ConversationMessages(
118120
is MessageListEvent.ViewOriginalMessage -> {
119121
composeScope.launch {
120122
val itemIndex = messages.itemSnapshotList
123+
.filterIsInstance<ChatItem.Message>()
124+
.indexOfFirst { it.chatMessageId == event.originalMessageId }
125+
126+
val currentItemIndex = messages.itemSnapshotList
121127
.filterIsInstance<ChatItem.Message>()
122128
.indexOfFirst { it.chatMessageId == event.messageId }
129+
130+
println("target item is @ $itemIndex")
123131
if (itemIndex >= 0) {
124-
val currentIndex = lazyListState.firstVisibleItemIndex
125-
val distance = abs(itemIndex - currentIndex)
132+
val distance = abs(itemIndex - currentItemIndex)
126133

134+
println("distance from current ($currentItemIndex) is $distance")
127135
if (distance <= 100) {
128-
lazyListState.animateScrollToItem(itemIndex)
136+
// Animate smoothly if within 100 items
137+
lazyListState.animateScrollToItemWithFullVisibility(
138+
to = itemIndex,
139+
from = currentItemIndex
140+
)
129141
} else {
130-
lazyListState.scrollToItem(itemIndex)
142+
// Jump directly if too far
143+
lazyListState.scrollToItemWithFullVisibility(
144+
index = itemIndex,
145+
)
131146
}
132-
133147
}
134148
}
135149
}

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class RoomInfoScreen(private val info: RoomInfoArgs) : Screen, Parcelable {
7979
viewModel.eventFlow
8080
.filterIsInstance<ChatInfoViewModel.Event.OnChangeName>()
8181
.onEach {
82-
navigator.show(ScreenRegistry.get(NavScreenProvider.Room.ChangeName(it.id, it.title)))
82+
navigator.push(ScreenRegistry.get(NavScreenProvider.Room.ChangeName(it.id, it.title)))
8383
}.launchIn(this)
8484
}
8585

@@ -180,15 +180,9 @@ private fun Actions(
180180
buttonState = ButtonState.Filled,
181181
text = stringResource(R.string.action_customize),
182182
) {
183-
val roomNameText = if (state.roomInfo.customTitle.isNotEmpty()) {
184-
context.getString(R.string.action_editRoomName)
185-
} else {
186-
context.getString(R.string.action_addRoomName)
187-
}
188-
189183
BottomBarManager.showMessage(
190184
BottomBarManager.BottomBarMessage(
191-
positiveText = roomNameText,
185+
positiveText = context.getString(R.string.action_changeRoomName),
192186
negativeText = context.getString(R.string.action_changeCoverCharge),
193187
negativeStyle = BottomBarManager.BottomBarButtonStyle.Filled,
194188
tertiaryText = context.getString(R.string.action_cancel),

flipchatApp/src/main/kotlin/xyz/flipchat/app/features/chat/name/RoomNameScreen.kt

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,33 +65,24 @@ data class RoomNameScreen(val roomId: ID, val customTitle: String) : Screen, Par
6565
val navigator = LocalCodeNavigator.current
6666
val keyboardIsVisible by keyboardAsState()
6767
val keyboard = LocalSoftwareKeyboardController.current
68-
val composeScope = rememberCoroutineScope()
6968

7069

7170
BackHandler {
7271
if (keyboardIsVisible) {
7372
keyboard?.hide()
7473
} else {
75-
navigator.hide()
74+
navigator.pop()
7675
}
7776
}
7877

7978
Column(
8079
modifier = Modifier
81-
.fillMaxWidth()
82-
.fillMaxHeight(CodeTheme.dimens.modalHeightRatio)
80+
.fillMaxSize()
8381
) {
8482
AppBarWithTitle(
85-
endContent = {
86-
AppBarDefaults.Close {
87-
composeScope.launch {
88-
if (keyboardIsVisible) {
89-
keyboard?.hide()
90-
}
91-
navigator.hide()
92-
}
93-
}
94-
}
83+
backButton = true,
84+
title = stringResource(R.string.action_changeRoomName),
85+
onBackIconClicked = { navigator.pop() },
9586
)
9687

9788
val viewModel = getViewModel<RoomNameScreenViewModel>()
@@ -110,7 +101,7 @@ data class RoomNameScreen(val roomId: ID, val customTitle: String) : Screen, Par
110101
.filterIsInstance<RoomNameScreenViewModel.Event.OnSuccess>()
111102
.onEach {
112103
delay(2.seconds)
113-
navigator.hide()
104+
navigator.pop()
114105
}
115106
.launchIn(this)
116107
}

flipchatApp/src/main/kotlin/xyz/flipchat/app/ui/room/RoomCard.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ fun RoomCard(
148148
) { textSize = it },
149149
text = roomInfo.title,
150150
style = CodeTheme.typography.displaySmall
151-
.copy(fontSize = textSize,)
151+
.copy(fontSize = textSize, lineHeight = 24.sp)
152152
.withDropShadow(),
153153
color = Color.White,
154-
maxLines = 1
154+
maxLines = 3
155155
)
156156
}
157157
Spacer(Modifier.requiredHeight(geometry.titleBottomPadding))

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@
194194
<string name="action_changeCoverCharge">Change Cover Charge</string>
195195
<string name="action_addRoomName">Add Room Name</string>
196196
<string name="action_editRoomName">Edit Room Name</string>
197+
<string name="action_changeRoomName">Change Room Name</string>
197198
<string name="action_customize">Customize</string>
198199
<string name="action_leaveRoom">Leave Room</string>
199200

ui/components/src/main/kotlin/com/getcode/ui/utils/TextStyle.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import androidx.compose.ui.text.TextStyle
88
fun TextStyle.withDropShadow(
99
color: Color = Color.Black.copy(alpha = 0.5f),
1010
offset: Offset = Offset(4f, 4f),
11-
blurRadius: Float = 8f,
11+
blurRadius: Float = 4f,
1212
): TextStyle = copy(
1313
shadow = Shadow(
1414
color = color,

0 commit comments

Comments
 (0)