Implement new view state.

This commit is contained in:
Onuray Sahin 2023-01-31 15:01:07 +03:00 committed by Maxime NATUREL
parent ec4226b5d3
commit 9d43846b9b
4 changed files with 68 additions and 5 deletions

View file

@ -65,7 +65,6 @@ import javax.inject.Inject
@Parcelize
data class RoomProfileArgs(
val roomId: String,
val selectedPollId: String? = null,
) : Parcelable
@AndroidEntryPoint

View file

@ -0,0 +1,29 @@
/*
* 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.features.home.room.detail.timeline.item.PollOptionViewState
data class RoomPollDetail(
val eventId: String,
val question: String,
val canVote: Boolean,
val votesStatusSummary: String,
val optionViewStates: List<PollOptionViewState>,
val hasBeenEdited: Boolean,
val isEnded: Boolean,
)

View file

@ -17,10 +17,10 @@
package im.vector.app.features.roomprofile.polls.detail
import android.os.Bundle
import android.os.Parcelable
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.airbnb.mvrx.activityViewModel
import com.airbnb.mvrx.args
import com.airbnb.mvrx.fragmentViewModel
import com.airbnb.mvrx.withState
@ -29,18 +29,24 @@ import im.vector.app.R
import im.vector.app.core.extensions.configureWith
import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.databinding.FragmentRoomPollDetailBinding
import im.vector.app.features.roomprofile.RoomProfileArgs
import im.vector.app.features.roomprofile.polls.RoomPollsType
import im.vector.app.features.roomprofile.polls.RoomPollsViewModel
import kotlinx.parcelize.Parcelize
import javax.inject.Inject
@Parcelize
data class RoomPollDetailArgs(
val roomId: String,
val pollId: String,
) : Parcelable
@AndroidEntryPoint
class RoomPollDetailFragment : VectorBaseFragment<FragmentRoomPollDetailBinding>() {
@Inject lateinit var roomPollDetailController: RoomPollDetailController
private val viewModel: RoomPollsViewModel by activityViewModel()
private val roomProfileArgs: RoomProfileArgs by args()
private val viewModel: RoomPollsViewModel by fragmentViewModel()
private val roomPollDetailArgs: RoomPollDetailArgs by args()
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRoomPollDetailBinding {
return FragmentRoomPollDetailBinding.inflate(inflater, container, false)

View file

@ -0,0 +1,29 @@
/*
* 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 com.airbnb.mvrx.MavericksState
data class RoomPollDetailViewState(
val roomId: String,
val pollId: String,
val pollDetail: RoomPollDetail? = null,
) : MavericksState {
constructor(roomPollDetailArgs: RoomPollDetailArgs)
: this(roomId = roomPollDetailArgs.roomId, pollId = roomPollDetailArgs.pollId)
}