mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-27 12:00:03 +03:00
Add title to the new two bottom sheets
This commit is contained in:
parent
589c301606
commit
056b9df65e
6 changed files with 119 additions and 2 deletions
|
@ -17,19 +17,37 @@ package im.vector.app.core.ui.bottomsheet
|
|||
|
||||
import android.view.View
|
||||
import com.airbnb.epoxy.TypedEpoxyController
|
||||
import im.vector.app.core.epoxy.dividerItem
|
||||
|
||||
/**
|
||||
* Epoxy controller for generic bottom sheet actions
|
||||
*/
|
||||
abstract class BottomSheetGenericController<State : BottomSheetGenericState, Action: BottomSheetGenericAction>
|
||||
abstract class BottomSheetGenericController<State : BottomSheetGenericState, Action : BottomSheetGenericAction>
|
||||
: TypedEpoxyController<State>() {
|
||||
|
||||
var listener: Listener<Action>? = null
|
||||
|
||||
abstract fun getTitle(): String?
|
||||
|
||||
open fun getSubTitle(): String? = null
|
||||
|
||||
abstract fun getActions(state: State): List<Action>
|
||||
|
||||
override fun buildModels(state: State?) {
|
||||
state ?: return
|
||||
// Title
|
||||
getTitle()?.let { title ->
|
||||
bottomSheetTitleItem {
|
||||
id("title")
|
||||
title(title)
|
||||
subTitle(getSubTitle())
|
||||
}
|
||||
|
||||
dividerItem {
|
||||
id("title_separator")
|
||||
}
|
||||
}
|
||||
// Actions
|
||||
getActions(state).forEach { action ->
|
||||
action.toBottomSheetItem()
|
||||
.listener(View.OnClickListener { listener?.didSelectAction(action) })
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 2020 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.core.ui.bottomsheet
|
||||
|
||||
import android.widget.TextView
|
||||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.extensions.setTextOrHide
|
||||
|
||||
/**
|
||||
* A title for bottom sheet, with an optional subtitle. It does not include the bottom separator.
|
||||
*/
|
||||
@EpoxyModelClass(layout = R.layout.item_bottom_sheet_title)
|
||||
abstract class BottomSheetTitleItem : VectorEpoxyModel<BottomSheetTitleItem.Holder>() {
|
||||
|
||||
@EpoxyAttribute
|
||||
lateinit var title: String
|
||||
|
||||
@EpoxyAttribute
|
||||
var subTitle: String? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.title.text = title
|
||||
holder.subtitle.setTextOrHide(subTitle)
|
||||
}
|
||||
|
||||
class Holder : VectorEpoxyHolder() {
|
||||
val title by bind<TextView>(R.id.itemBottomSheetTitleTitle)
|
||||
val subtitle by bind<TextView>(R.id.itemBottomSheetTitleSubtitle)
|
||||
}
|
||||
}
|
|
@ -16,15 +16,22 @@
|
|||
|
||||
package im.vector.app.features.roomprofile.settings.historyvisibility
|
||||
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.app.core.ui.bottomsheet.BottomSheetGenericController
|
||||
import im.vector.app.features.home.room.detail.timeline.format.RoomHistoryVisibilityFormatter
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomHistoryVisibility
|
||||
import javax.inject.Inject
|
||||
|
||||
class RoomHistoryVisibilityController @Inject constructor(
|
||||
private val historyVisibilityFormatter: RoomHistoryVisibilityFormatter
|
||||
private val historyVisibilityFormatter: RoomHistoryVisibilityFormatter,
|
||||
private val stringProvider: StringProvider
|
||||
) : BottomSheetGenericController<RoomHistoryVisibilityState, RoomHistoryVisibilityAction>() {
|
||||
|
||||
override fun getTitle() = stringProvider.getString(R.string.room_settings_room_read_history_rules_pref_dialog_title)
|
||||
|
||||
override fun getSubTitle() = stringProvider.getString(R.string.room_settings_room_read_history_dialog_subtitle)
|
||||
|
||||
override fun getActions(state: RoomHistoryVisibilityState): List<RoomHistoryVisibilityAction> {
|
||||
return listOf(
|
||||
RoomHistoryVisibility.WORLD_READABLE,
|
||||
|
|
|
@ -27,6 +27,8 @@ class RoomJoinRuleController @Inject constructor(
|
|||
private val stringProvider: StringProvider
|
||||
) : BottomSheetGenericController<RoomJoinRuleState, RoomJoinRuleAction>() {
|
||||
|
||||
override fun getTitle() = stringProvider.getString(R.string.room_settings_room_access_rules_pref_dialog_title)
|
||||
|
||||
override fun getActions(state: RoomJoinRuleState): List<RoomJoinRuleAction> {
|
||||
return listOf(
|
||||
RoomJoinRuleAction(
|
||||
|
|
40
vector/src/main/res/layout/item_bottom_sheet_title.xml
Normal file
40
vector/src/main/res/layout/item_bottom_sheet_title.xml
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="50dp"
|
||||
android:paddingStart="@dimen/layout_horizontal_margin"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingEnd="@dimen/layout_horizontal_margin"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/itemBottomSheetTitleTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?riotx_text_primary"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/itemBottomSheetTitleSubtitle"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="@string/room_settings_room_read_history_rules_pref_dialog_title" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/itemBottomSheetTitleSubtitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:textColor="?riotx_text_primary"
|
||||
android:textSize="15sp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/itemBottomSheetTitleTitle"
|
||||
tools:text="@string/room_settings_room_read_history_dialog_subtitle"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -1022,6 +1022,7 @@
|
|||
<string name="room_settings_room_access_rules_pref_title">Room Access</string>
|
||||
<string name="room_settings_room_read_history_rules_pref_title">Room History Readability</string>
|
||||
<string name="room_settings_room_read_history_rules_pref_dialog_title">Who can read history?</string>
|
||||
<string name="room_settings_room_read_history_dialog_subtitle">Changes to who can read history will only apply to future messages in this room. The visibility of existing history will be unchanged.</string>
|
||||
<string name="room_settings_room_access_rules_pref_dialog_title">Who can access this room?</string>
|
||||
<string name="room_settings_room_access_title">Room access</string>
|
||||
|
||||
|
|
Loading…
Reference in a new issue