Skip to content

Commit 7436c2e

Browse files
committed
Navigate to new empty screen
1 parent cba960f commit 7436c2e

10 files changed

+215
-1
lines changed

vector/src/main/java/im/vector/app/core/di/MavericksViewModelModule.kt

+6
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ import im.vector.app.features.roomprofile.banned.RoomBannedMemberListViewModel
8484
import im.vector.app.features.roomprofile.members.RoomMemberListViewModel
8585
import im.vector.app.features.roomprofile.notifications.RoomNotificationSettingsViewModel
8686
import im.vector.app.features.roomprofile.permissions.RoomPermissionsViewModel
87+
import im.vector.app.features.roomprofile.polls.RoomPollsViewModel
8788
import im.vector.app.features.roomprofile.settings.RoomSettingsViewModel
8889
import im.vector.app.features.roomprofile.settings.joinrule.advanced.RoomJoinRuleChooseRestrictedViewModel
8990
import im.vector.app.features.roomprofile.uploads.RoomUploadsViewModel
@@ -697,4 +698,9 @@ interface MavericksViewModelModule {
697698
@IntoMap
698699
@MavericksViewModelKey(SetLinkViewModel::class)
699700
fun setLinkViewModelFactory(factory: SetLinkViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
701+
702+
@Binds
703+
@IntoMap
704+
@MavericksViewModelKey(RoomPollsViewModel::class)
705+
fun roomPollsViewModelFactory(factory: RoomPollsViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
700706
}

vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileActivity.kt

+6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import im.vector.app.features.roomprofile.banned.RoomBannedMemberListFragment
3636
import im.vector.app.features.roomprofile.members.RoomMemberListFragment
3737
import im.vector.app.features.roomprofile.notifications.RoomNotificationSettingsFragment
3838
import im.vector.app.features.roomprofile.permissions.RoomPermissionsFragment
39+
import im.vector.app.features.roomprofile.polls.RoomPollsFragment
3940
import im.vector.app.features.roomprofile.settings.RoomSettingsFragment
4041
import im.vector.app.features.roomprofile.uploads.RoomUploadsFragment
4142
import im.vector.lib.core.utils.compat.getParcelableCompat
@@ -98,6 +99,7 @@ class RoomProfileActivity :
9899
RoomProfileSharedAction.OpenRoomSettings -> openRoomSettings()
99100
RoomProfileSharedAction.OpenRoomAliasesSettings -> openRoomAlias()
100101
RoomProfileSharedAction.OpenRoomPermissionsSettings -> openRoomPermissions()
102+
RoomProfileSharedAction.OpenRoomPolls -> openRoomPolls()
101103
RoomProfileSharedAction.OpenRoomUploads -> openRoomUploads()
102104
RoomProfileSharedAction.OpenBannedRoomMembers -> openBannedRoomMembers()
103105
RoomProfileSharedAction.OpenRoomNotificationSettings -> openRoomNotificationSettings()
@@ -126,6 +128,10 @@ class RoomProfileActivity :
126128
finish()
127129
}
128130

131+
private fun openRoomPolls() {
132+
addFragmentToBackstack(views.simpleFragmentContainer, RoomPollsFragment::class.java, roomProfileArgs)
133+
}
134+
129135
private fun openRoomUploads() {
130136
addFragmentToBackstack(views.simpleFragmentContainer, RoomUploadsFragment::class.java, roomProfileArgs)
131137
}

vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileFragment.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ class RoomProfileFragment :
270270
}
271271

272272
override fun onPollHistoryClicked() {
273-
// TODO navigate to new screen
273+
roomProfileSharedActionViewModel.post(RoomProfileSharedAction.OpenRoomPolls)
274274
}
275275

276276
override fun onUploadsClicked() {

vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileSharedAction.kt

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ sealed class RoomProfileSharedAction : VectorSharedAction {
2525
object OpenRoomSettings : RoomProfileSharedAction()
2626
object OpenRoomAliasesSettings : RoomProfileSharedAction()
2727
object OpenRoomPermissionsSettings : RoomProfileSharedAction()
28+
object OpenRoomPolls : RoomProfileSharedAction()
2829
object OpenRoomUploads : RoomProfileSharedAction()
2930
object OpenRoomMembers : RoomProfileSharedAction()
3031
object OpenBannedRoomMembers : RoomProfileSharedAction()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) 2020 New Vector Ltd
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package im.vector.app.features.roomprofile.polls
18+
19+
import im.vector.app.core.platform.VectorViewModelAction
20+
21+
sealed class RoomPollsAction : VectorViewModelAction
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright (c) 2020 New Vector Ltd
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package im.vector.app.features.roomprofile.polls
18+
19+
import android.os.Bundle
20+
import android.view.LayoutInflater
21+
import android.view.View
22+
import android.view.ViewGroup
23+
import com.airbnb.mvrx.args
24+
import com.airbnb.mvrx.fragmentViewModel
25+
import com.airbnb.mvrx.withState
26+
import dagger.hilt.android.AndroidEntryPoint
27+
import im.vector.app.core.platform.VectorBaseFragment
28+
import im.vector.app.databinding.FragmentRoomPollsBinding
29+
import im.vector.app.features.roomprofile.RoomProfileArgs
30+
31+
@AndroidEntryPoint
32+
class RoomPollsFragment : VectorBaseFragment<FragmentRoomPollsBinding>() {
33+
34+
private val roomProfileArgs: RoomProfileArgs by args()
35+
36+
private val viewModel: RoomPollsViewModel by fragmentViewModel()
37+
38+
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRoomPollsBinding {
39+
return FragmentRoomPollsBinding.inflate(inflater, container, false)
40+
}
41+
42+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
43+
super.onViewCreated(view, savedInstanceState)
44+
45+
setupToolbar()
46+
setupTabs()
47+
}
48+
49+
private fun setupToolbar() {
50+
setupToolbar(views.roomPollsToolbar)
51+
.allowBack()
52+
}
53+
54+
private fun setupTabs() {
55+
// TODO
56+
}
57+
58+
override fun invalidate() = withState(viewModel) {
59+
// TODO
60+
}
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) 2020 New Vector Ltd
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package im.vector.app.features.roomprofile.polls
18+
19+
import im.vector.app.core.platform.VectorViewEvents
20+
21+
sealed class RoomPollsViewEvent : VectorViewEvents
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2020 New Vector Ltd
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package im.vector.app.features.roomprofile.polls
18+
19+
import com.airbnb.mvrx.MavericksViewModelFactory
20+
import dagger.assisted.Assisted
21+
import dagger.assisted.AssistedFactory
22+
import dagger.assisted.AssistedInject
23+
import im.vector.app.core.di.MavericksAssistedViewModelFactory
24+
import im.vector.app.core.di.hiltMavericksViewModelFactory
25+
import im.vector.app.core.platform.VectorViewModel
26+
27+
class RoomPollsViewModel @AssistedInject constructor(
28+
@Assisted initialState: RoomPollsViewState,
29+
) : VectorViewModel<RoomPollsViewState, RoomPollsAction, RoomPollsViewEvent>(initialState) {
30+
31+
@AssistedFactory
32+
interface Factory : MavericksAssistedViewModelFactory<RoomPollsViewModel, RoomPollsViewState> {
33+
override fun create(initialState: RoomPollsViewState): RoomPollsViewModel
34+
}
35+
36+
companion object : MavericksViewModelFactory<RoomPollsViewModel, RoomPollsViewState> by hiltMavericksViewModelFactory()
37+
38+
override fun handle(action: RoomPollsAction) {
39+
// do nothing for now
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2022 New Vector Ltd
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package im.vector.app.features.roomprofile.polls
18+
19+
import com.airbnb.mvrx.MavericksState
20+
import im.vector.app.features.roomprofile.RoomProfileArgs
21+
22+
data class RoomPollsViewState(
23+
val roomId: String,
24+
) : MavericksState {
25+
26+
constructor(roomProfileArgs: RoomProfileArgs) : this(roomId = roomProfileArgs.roomId)
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
android:id="@+id/coordinatorLayout"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent">
7+
8+
<com.google.android.material.appbar.AppBarLayout
9+
android:id="@+id/appBarLayout"
10+
android:layout_width="match_parent"
11+
android:layout_height="wrap_content"
12+
app:layout_constraintEnd_toEndOf="parent"
13+
app:layout_constraintStart_toStartOf="parent"
14+
app:layout_constraintTop_toTopOf="parent">
15+
16+
<com.google.android.material.appbar.MaterialToolbar
17+
android:id="@+id/roomPollsToolbar"
18+
android:layout_width="match_parent"
19+
android:layout_height="?actionBarSize"
20+
app:title="@string/room_profile_section_more_polls" />
21+
22+
</com.google.android.material.appbar.AppBarLayout>
23+
24+
<androidx.viewpager2.widget.ViewPager2
25+
android:id="@+id/roomPollsViewPager"
26+
android:layout_width="match_parent"
27+
android:layout_height="match_parent"
28+
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
29+
30+
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)