Room name and topic fields added to form.

This commit is contained in:
onurays 2020-06-09 11:11:17 +03:00 committed by Benoit Marty
parent c23819bfcf
commit 05e848244e
6 changed files with 44 additions and 2 deletions

View file

@ -9,6 +9,7 @@ Improvements 🙌:
- "Add Matrix app" menu is now always visible (#1495) - "Add Matrix app" menu is now always visible (#1495)
- Handle `/op`, `/deop`, and `/nick` commands (#12) - Handle `/op`, `/deop`, and `/nick` commands (#12)
- Prioritising Recovery key over Recovery passphrase (#1463) - Prioritising Recovery key over Recovery passphrase (#1463)
- Room Settings: Name, Topic, Photo, Aliases, History Visibility (#1455)
Bugfix 🐛: Bugfix 🐛:
- Fix dark theme issue on login screen (#1097) - Fix dark theme issue on login screen (#1097)

View file

@ -22,6 +22,7 @@ import im.vector.riotx.core.epoxy.profiles.buildProfileAction
import im.vector.riotx.core.epoxy.profiles.buildProfileSection import im.vector.riotx.core.epoxy.profiles.buildProfileSection
import im.vector.riotx.core.resources.ColorProvider import im.vector.riotx.core.resources.ColorProvider
import im.vector.riotx.core.resources.StringProvider import im.vector.riotx.core.resources.StringProvider
import im.vector.riotx.features.form.formEditTextItem
import javax.inject.Inject import javax.inject.Inject
// TODO Add other feature here (waiting for design) // TODO Add other feature here (waiting for design)
@ -32,6 +33,8 @@ class RoomSettingsController @Inject constructor(
interface Callback { interface Callback {
fun onEnableEncryptionClicked() fun onEnableEncryptionClicked()
fun onNameChanged(name: String)
fun onTopicChanged(topic: String)
} }
private val dividerColor = colorProvider.getColorFromAttribute(R.attr.vctr_list_divider_color) private val dividerColor = colorProvider.getColorFromAttribute(R.attr.vctr_list_divider_color)
@ -68,5 +71,27 @@ class RoomSettingsController @Inject constructor(
action = { callback?.onEnableEncryptionClicked() } action = { callback?.onEnableEncryptionClicked() }
) )
} }
formEditTextItem {
id("name")
/*enabled(enableFormElement)*/
value(roomSummary.displayName)
hint(stringProvider.getString(R.string.room_settings_name_hint))
onTextChange { text ->
callback?.onNameChanged(text)
}
}
formEditTextItem {
id("topic")
/*enabled(enableFormElement)*/
value(roomSummary.topic)
hint(stringProvider.getString(R.string.room_settings_topic_hint))
onTextChange { text ->
callback?.onTopicChanged(text)
}
}
} }
} }

View file

@ -82,6 +82,14 @@ class RoomSettingsFragment @Inject constructor(
.show() .show()
} }
override fun onNameChanged(name: String) {
viewModel.handle(RoomSettingsAction.SetRoomName(name))
}
override fun onTopicChanged(topic: String) {
viewModel.handle(RoomSettingsAction.SetRoomTopic(topic))
}
private fun renderRoomSummary(state: RoomSettingsViewState) { private fun renderRoomSummary(state: RoomSettingsViewState) {
waiting_view.isVisible = state.isLoading waiting_view.isVisible = state.isLoading

View file

@ -62,6 +62,8 @@ class RoomSettingsViewModel @AssistedInject constructor(@Assisted initialState:
override fun handle(action: RoomSettingsAction) { override fun handle(action: RoomSettingsAction) {
when (action) { when (action) {
is RoomSettingsAction.EnableEncryption -> handleEnableEncryption() is RoomSettingsAction.EnableEncryption -> handleEnableEncryption()
is RoomSettingsAction.SetRoomName -> setState { copy(newName = action.newName) }
is RoomSettingsAction.SetRoomTopic -> setState { copy(newTopic = action.newTopic) }
} }
} }

View file

@ -25,7 +25,9 @@ import im.vector.riotx.features.roomprofile.RoomProfileArgs
data class RoomSettingsViewState( data class RoomSettingsViewState(
val roomId: String, val roomId: String,
val roomSummary: Async<RoomSummary> = Uninitialized, val roomSummary: Async<RoomSummary> = Uninitialized,
val isLoading: Boolean = false val isLoading: Boolean = false,
val newName: String? = null,
val newTopic: String? = null
) : MvRxState { ) : MvRxState {
constructor(args: RoomProfileArgs) : this(roomId = args.roomId) constructor(args: RoomProfileArgs) : this(roomId = args.roomId)

View file

@ -2496,4 +2496,8 @@ Not all features in Riot are implemented in RiotX yet. Main missing (and coming
<string name="save_your_security_key_title">Save your Security Key</string> <string name="save_your_security_key_title">Save your Security Key</string>
<string name="save_your_security_key_notice">Store your Security Key somewhere safe, like a password manager or a safe.</string> <string name="save_your_security_key_notice">Store your Security Key somewhere safe, like a password manager or a safe.</string>
<!-- Room Settings -->
<string name="room_settings_name_hint">Room Name</string>
<string name="room_settings_topic_hint">Topic</string>
</resources> </resources>