mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-26 19:36:08 +03:00
Replacing ViewEvent by a ViewState property
This commit is contained in:
parent
221cb24de8
commit
82391aa281
4 changed files with 11 additions and 12 deletions
|
@ -84,6 +84,4 @@ sealed class RoomDetailViewEvents : VectorViewEvents {
|
||||||
data class StartChatEffect(val type: ChatEffect) : RoomDetailViewEvents()
|
data class StartChatEffect(val type: ChatEffect) : RoomDetailViewEvents()
|
||||||
object StopChatEffects : RoomDetailViewEvents()
|
object StopChatEffects : RoomDetailViewEvents()
|
||||||
object RoomReplacementStarted : RoomDetailViewEvents()
|
object RoomReplacementStarted : RoomDetailViewEvents()
|
||||||
|
|
||||||
data class ChangeLocationIndicator(val isVisible: Boolean) : RoomDetailViewEvents()
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,8 @@ data class RoomDetailViewState(
|
||||||
val switchToParentSpace: Boolean = false,
|
val switchToParentSpace: Boolean = false,
|
||||||
val rootThreadEventId: String? = null,
|
val rootThreadEventId: String? = null,
|
||||||
val threadNotificationBadgeState: ThreadNotificationBadgeState = ThreadNotificationBadgeState(),
|
val threadNotificationBadgeState: ThreadNotificationBadgeState = ThreadNotificationBadgeState(),
|
||||||
val typingUsers: List<SenderInfo>? = null
|
val typingUsers: List<SenderInfo>? = null,
|
||||||
|
val isSharingLiveLocation: Boolean = false,
|
||||||
) : MavericksState {
|
) : MavericksState {
|
||||||
|
|
||||||
constructor(args: TimelineArgs) : this(
|
constructor(args: TimelineArgs) : this(
|
||||||
|
|
|
@ -498,7 +498,6 @@ class TimelineFragment @Inject constructor(
|
||||||
RoomDetailViewEvents.StopChatEffects -> handleStopChatEffects()
|
RoomDetailViewEvents.StopChatEffects -> handleStopChatEffects()
|
||||||
is RoomDetailViewEvents.DisplayAndAcceptCall -> acceptIncomingCall(it)
|
is RoomDetailViewEvents.DisplayAndAcceptCall -> acceptIncomingCall(it)
|
||||||
RoomDetailViewEvents.RoomReplacementStarted -> handleRoomReplacement()
|
RoomDetailViewEvents.RoomReplacementStarted -> handleRoomReplacement()
|
||||||
is RoomDetailViewEvents.ChangeLocationIndicator -> handleChangeLocationIndicator(it)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -663,10 +662,6 @@ class TimelineFragment @Inject constructor(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleChangeLocationIndicator(event: RoomDetailViewEvents.ChangeLocationIndicator) {
|
|
||||||
views.locationLiveStatusIndicator.isVisible = event.isVisible
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun displayErrorMessage(error: RoomDetailViewEvents.Failure) {
|
private fun displayErrorMessage(error: RoomDetailViewEvents.Failure) {
|
||||||
if (error.showInDialog) displayErrorDialog(error.throwable) else showErrorInSnackbar(error.throwable)
|
if (error.showInDialog) displayErrorDialog(error.throwable) else showErrorInSnackbar(error.throwable)
|
||||||
}
|
}
|
||||||
|
@ -1686,6 +1681,11 @@ class TimelineFragment @Inject constructor(
|
||||||
} else if (mainState.asyncInviter.complete) {
|
} else if (mainState.asyncInviter.complete) {
|
||||||
vectorBaseActivity.finish()
|
vectorBaseActivity.finish()
|
||||||
}
|
}
|
||||||
|
updateLiveLocationIndicator(mainState.isSharingLiveLocation)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateLiveLocationIndicator(isSharingLiveLocation: Boolean) {
|
||||||
|
views.locationLiveStatusIndicator.isVisible = isSharingLiveLocation
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun FragmentTimelineBinding.hideComposerViews() {
|
private fun FragmentTimelineBinding.hideComposerViews() {
|
||||||
|
@ -1706,7 +1706,7 @@ class TimelineFragment @Inject constructor(
|
||||||
|
|
||||||
private fun renderToolbar(roomSummary: RoomSummary?) {
|
private fun renderToolbar(roomSummary: RoomSummary?) {
|
||||||
when {
|
when {
|
||||||
isLocalRoom() -> {
|
isLocalRoom() -> {
|
||||||
views.includeRoomToolbar.roomToolbarContentView.isVisible = false
|
views.includeRoomToolbar.roomToolbarContentView.isVisible = false
|
||||||
views.includeThreadToolbar.roomToolbarThreadConstraintLayout.isVisible = false
|
views.includeThreadToolbar.roomToolbarThreadConstraintLayout.isVisible = false
|
||||||
setupToolbar(views.roomToolbar)
|
setupToolbar(views.roomToolbar)
|
||||||
|
@ -1724,7 +1724,7 @@ class TimelineFragment @Inject constructor(
|
||||||
}
|
}
|
||||||
views.includeThreadToolbar.roomToolbarThreadTitleTextView.text = resources.getText(R.string.thread_timeline_title)
|
views.includeThreadToolbar.roomToolbarThreadTitleTextView.text = resources.getText(R.string.thread_timeline_title)
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
views.includeRoomToolbar.roomToolbarContentView.isVisible = true
|
views.includeRoomToolbar.roomToolbarContentView.isVisible = true
|
||||||
views.includeThreadToolbar.roomToolbarThreadConstraintLayout.isVisible = false
|
views.includeThreadToolbar.roomToolbarThreadConstraintLayout.isVisible = false
|
||||||
if (roomSummary == null) {
|
if (roomSummary == null) {
|
||||||
|
|
|
@ -1295,11 +1295,11 @@ class TimelineViewModel @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onLocationServiceRunning() {
|
override fun onLocationServiceRunning() {
|
||||||
_viewEvents.post(RoomDetailViewEvents.ChangeLocationIndicator(isVisible = true))
|
setState { copy(isSharingLiveLocation = true) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onLocationServiceStopped() {
|
override fun onLocationServiceStopped() {
|
||||||
_viewEvents.post(RoomDetailViewEvents.ChangeLocationIndicator(isVisible = false))
|
setState { copy(isSharingLiveLocation = false) }
|
||||||
// Bind again in case user decides to share live location without leaving the room
|
// Bind again in case user decides to share live location without leaving the room
|
||||||
locationSharingServiceConnection.bind(this)
|
locationSharingServiceConnection.bind(this)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue