Create separate view model for poll detail.
This commit is contained in:
parent
9d43846b9b
commit
429a71964d
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2023 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app.features.roomprofile.polls.detail
|
||||
|
||||
import im.vector.app.core.platform.VectorViewModelAction
|
||||
|
||||
sealed interface RoomPollDetailAction : VectorViewModelAction {
|
||||
|
||||
}
|
|
@ -24,17 +24,18 @@ import javax.inject.Inject
|
|||
|
||||
class RoomPollDetailController @Inject constructor(
|
||||
|
||||
) : TypedEpoxyController<RoomPollsViewState>() {
|
||||
) : TypedEpoxyController<RoomPollDetailViewState>() {
|
||||
|
||||
override fun buildModels(viewState: RoomPollsViewState?) {
|
||||
override fun buildModels(viewState: RoomPollDetailViewState?) {
|
||||
viewState ?: return
|
||||
val pollSummary = viewState.getSelectedPoll() ?: return
|
||||
|
||||
PollItem_()
|
||||
/*
|
||||
.eventId(pollSummary.id)
|
||||
.pollQuestion(pollSummary.title.toEpoxyCharSequence())
|
||||
.canVote(viewState.canVoteSelectedPoll())
|
||||
.optionViewStates(pollSummary.optionViewStates)
|
||||
.ended(viewState.canVoteSelectedPoll().not())
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ class RoomPollDetailFragment : VectorBaseFragment<FragmentRoomPollDetailBinding>
|
|||
|
||||
@Inject lateinit var roomPollDetailController: RoomPollDetailController
|
||||
|
||||
private val viewModel: RoomPollsViewModel by fragmentViewModel()
|
||||
private val viewModel: RoomPollDetailViewModel by fragmentViewModel()
|
||||
private val roomPollDetailArgs: RoomPollDetailArgs by args()
|
||||
|
||||
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRoomPollDetailBinding {
|
||||
|
@ -61,9 +61,9 @@ class RoomPollDetailFragment : VectorBaseFragment<FragmentRoomPollDetailBinding>
|
|||
)
|
||||
}
|
||||
|
||||
private fun setupToolbar(roomPollsType: RoomPollsType) {
|
||||
val title = if (roomPollsType == RoomPollsType.ACTIVE) getString(R.string.room_polls_active)
|
||||
else getString(R.string.room_polls_ended)
|
||||
private fun setupToolbar(isEnded: Boolean) {
|
||||
val title = if (isEnded) getString(R.string.room_polls_ended)
|
||||
else getString(R.string.room_polls_active)
|
||||
|
||||
setupToolbar(views.roomPollDetailToolbar)
|
||||
.setTitle(title)
|
||||
|
@ -71,11 +71,15 @@ class RoomPollDetailFragment : VectorBaseFragment<FragmentRoomPollDetailBinding>
|
|||
}
|
||||
|
||||
override fun invalidate() = withState(viewModel) { state ->
|
||||
setupToolbar(state.selectedRoomPollsType)
|
||||
state.pollDetail ?: return@withState
|
||||
|
||||
setupToolbar(state.pollDetail.isEnded)
|
||||
|
||||
/*
|
||||
state.getSelectedPoll()?.let { _ ->
|
||||
roomPollDetailController.setData(state)
|
||||
}
|
||||
Unit
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2023 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app.features.roomprofile.polls.detail
|
||||
|
||||
import im.vector.app.core.platform.VectorViewEvents
|
||||
|
||||
sealed class RoomPollDetailViewEvent : VectorViewEvents {
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (c) 2023 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app.features.roomprofile.polls.detail
|
||||
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedInject
|
||||
import im.vector.app.core.platform.VectorViewModel
|
||||
|
||||
class RoomPollDetailViewModel @AssistedInject constructor(
|
||||
@Assisted initialState: RoomPollDetailViewState,
|
||||
) : VectorViewModel<RoomPollDetailViewState, RoomPollDetailAction, RoomPollDetailViewEvent>(initialState) {
|
||||
|
||||
init {
|
||||
// Subscribe to the poll event and map it
|
||||
}
|
||||
|
||||
override fun handle(action: RoomPollDetailAction) {
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue