mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-18 20:29:10 +03:00
Make the title set at the creation of the screen
This commit is contained in:
parent
f855a36022
commit
eaa9cc740e
4 changed files with 8 additions and 8 deletions
|
@ -47,11 +47,12 @@ class RoomPollDetailActivity : VectorBaseActivity<ActivitySimpleBinding>() {
|
|||
}
|
||||
|
||||
companion object {
|
||||
fun newIntent(context: Context, pollId: String, roomId: String): Intent {
|
||||
fun newIntent(context: Context, pollId: String, roomId: String, isEnded: Boolean): Intent {
|
||||
return Intent(context, RoomPollDetailActivity::class.java).apply {
|
||||
val args = RoomPollDetailArgs(
|
||||
pollId = pollId,
|
||||
roomId = roomId,
|
||||
isEnded = isEnded,
|
||||
)
|
||||
putExtra(Mavericks.KEY_ARG, args)
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import javax.inject.Inject
|
|||
data class RoomPollDetailArgs(
|
||||
val pollId: String,
|
||||
val roomId: String,
|
||||
val isEnded: Boolean,
|
||||
) : Parcelable
|
||||
|
||||
@AndroidEntryPoint
|
||||
|
@ -55,7 +56,7 @@ class RoomPollDetailFragment :
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
setupToolbar()
|
||||
setupToolbar(isEnded = roomPollDetailArgs.isEnded)
|
||||
setupDetailView()
|
||||
// TODO add link to go to timeline message + create a ViewNavigator
|
||||
}
|
||||
|
@ -74,11 +75,10 @@ class RoomPollDetailFragment :
|
|||
)
|
||||
}
|
||||
|
||||
private fun setupToolbar(isEnded: Boolean? = null) {
|
||||
private fun setupToolbar(isEnded: Boolean) {
|
||||
val title = when (isEnded) {
|
||||
true -> getString(R.string.room_polls_ended)
|
||||
false -> getString(R.string.room_polls_active)
|
||||
else -> ""
|
||||
}
|
||||
|
||||
setupToolbar(views.roomPollDetailToolbar)
|
||||
|
@ -87,9 +87,6 @@ class RoomPollDetailFragment :
|
|||
}
|
||||
|
||||
override fun invalidate() = withState(viewModel) { state ->
|
||||
state.pollDetail ?: return@withState
|
||||
// TODO should we update the title when the poll status changes?
|
||||
setupToolbar(state.pollDetail.isEnded)
|
||||
roomPollDetailController.setData(state)
|
||||
}
|
||||
|
||||
|
|
|
@ -132,6 +132,7 @@ abstract class RoomPollsListFragment :
|
|||
context = requireContext(),
|
||||
pollId = pollId,
|
||||
roomId = it.roomId,
|
||||
isEnded = getRoomPollsType() == RoomPollsType.ENDED,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -23,12 +23,13 @@ import javax.inject.Inject
|
|||
// TODO add unit tests
|
||||
class RoomPollsListNavigator @Inject constructor() {
|
||||
|
||||
fun goToPollDetails(context: Context, pollId: String, roomId: String) {
|
||||
fun goToPollDetails(context: Context, pollId: String, roomId: String, isEnded: Boolean) {
|
||||
context.startActivity(
|
||||
RoomPollDetailActivity.newIntent(
|
||||
context = context,
|
||||
pollId = pollId,
|
||||
roomId = roomId,
|
||||
isEnded = isEnded,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue