Finalises home and add bottom sheet buttons

This commit is contained in:
ericdecanini 2022-08-03 22:49:21 +02:00
parent 5d183654b1
commit b4ed380caf
8 changed files with 95 additions and 6 deletions

View File

@ -0,0 +1,69 @@
/*
* Copyright 2019 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.grouplist
import android.content.res.ColorStateList
import android.widget.ImageView
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.core.graphics.ColorUtils
import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyModelClass
import im.vector.app.R
import im.vector.app.core.epoxy.ClickListener
import im.vector.app.core.epoxy.VectorEpoxyHolder
import im.vector.app.core.epoxy.VectorEpoxyModel
import im.vector.app.core.epoxy.onClick
import im.vector.app.core.platform.CheckableConstraintLayout
import im.vector.app.features.home.room.list.UnreadCounterBadgeView
import im.vector.app.features.themes.ThemeUtils
@EpoxyModelClass
abstract class NewHomeSpaceSummaryItem : VectorEpoxyModel<NewHomeSpaceSummaryItem.Holder>(R.layout.item_new_space) {
@EpoxyAttribute var text: String = ""
@EpoxyAttribute var selected: Boolean = false
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var listener: ClickListener? = null
@EpoxyAttribute var countState: UnreadCounterBadgeView.State = UnreadCounterBadgeView.State(0, false)
@EpoxyAttribute var showSeparator: Boolean = false
override fun getViewType() = R.id.space_item_home
override fun bind(holder: Holder) {
super.bind(holder)
holder.root.onClick(listener)
holder.name.text = holder.view.context.getString(R.string.all_chats)
holder.root.isChecked = selected
holder.root.context.resources
holder.avatar.background = ContextCompat.getDrawable(holder.view.context, R.drawable.new_space_home_background)
holder.avatar.backgroundTintList = ColorStateList.valueOf(
ColorUtils.setAlphaComponent(ThemeUtils.getColor(holder.view.context, R.attr.vctr_content_tertiary), (255 * 0.3).toInt()))
holder.avatar.setImageResource(R.drawable.ic_space_home)
holder.avatar.imageTintList = ColorStateList.valueOf(ThemeUtils.getColor(holder.view.context, R.attr.vctr_content_primary))
holder.avatar.scaleType = ImageView.ScaleType.CENTER_INSIDE
holder.unreadCounter.render(countState)
}
class Holder : VectorEpoxyHolder() {
val root by bind<CheckableConstraintLayout>(R.id.root)
val avatar by bind<ImageView>(R.id.avatar)
val name by bind<TextView>(R.id.name)
val unreadCounter by bind<UnreadCounterBadgeView>(R.id.unread_counter)
}
}

View File

@ -16,6 +16,8 @@
package im.vector.app.features.spaces
import android.content.res.ColorStateList
import android.widget.ImageView
import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyModelClass
import im.vector.app.R
@ -23,6 +25,7 @@ import im.vector.app.core.epoxy.ClickListener
import im.vector.app.core.epoxy.VectorEpoxyHolder
import im.vector.app.core.epoxy.VectorEpoxyModel
import im.vector.app.core.epoxy.onClick
import im.vector.app.features.themes.ThemeUtils
@EpoxyModelClass
abstract class NewSpaceAddItem : VectorEpoxyModel<NewSpaceAddItem.Holder>(R.layout.item_new_space_add) {
@ -32,7 +35,11 @@ abstract class NewSpaceAddItem : VectorEpoxyModel<NewSpaceAddItem.Holder>(R.layo
override fun bind(holder: Holder) {
super.bind(holder)
holder.view.onClick(listener)
holder.plus.imageTintList = ColorStateList.valueOf(ThemeUtils.getColor(holder.view.context, R.attr.vctr_content_primary))
}
class Holder : VectorEpoxyHolder()
class Holder : VectorEpoxyHolder() {
val plus by bind<ImageView>(R.id.plus)
}
}

View File

@ -20,6 +20,7 @@ import com.airbnb.epoxy.EpoxyController
import im.vector.app.R
import im.vector.app.core.resources.StringProvider
import im.vector.app.features.grouplist.homeSpaceSummaryItem
import im.vector.app.features.grouplist.newHomeSpaceSummaryItem
import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.home.room.list.UnreadCounterBadgeView
import org.matrix.android.sdk.api.extensions.orFalse
@ -65,7 +66,7 @@ class NewSpaceSummaryController @Inject constructor(
id("space_list_header")
}
homeSpaceSummaryItem {
newHomeSpaceSummaryItem {
id("space_home")
text(this@NewSpaceSummaryController.stringProvider.getString(R.string.all_chats))
selected(selectedSpace == null)

View File

@ -143,7 +143,7 @@ class SpaceListFragment @Inject constructor(
}
if (vectorFeatures.isNewAppLayoutEnabled()) {
newSpaceController.update(state).also { onUpdate?.invoke() }
newSpaceController.update(state)
} else {
spaceController.update(state)
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size android:width="40dp" android:height="40dp"/>
<solid android:color="?android:colorBackground" />
<corners android:radius="8dp" />
</shape>

View File

@ -10,4 +10,4 @@
<corners android:radius="8dp" />
</shape>
</shape>

View File

@ -20,7 +20,7 @@
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/groupAvatarImageView"
android:id="@+id/plus"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_gravity="center"
@ -48,7 +48,7 @@
android:textColor="?vctr_message_text_color"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/groupAvatarImageView"
app:layout_constraintStart_toEndOf="@id/plus"
app:layout_constraintTop_toTopOf="parent" />
</im.vector.app.core.platform.CheckableConstraintLayout>

View File

@ -4,6 +4,7 @@
style="@style/TextAppearance.Vector.Body.Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_space_item"
android:orientation="vertical"
android:padding="16dp"
android:text="@string/all_chats"