Add quick room category to list (WIP, not clean at all)

This commit is contained in:
ganfra 2018-10-29 20:29:09 +01:00
parent e06d95b8e3
commit 55efd226bb
29 changed files with 86 additions and 8 deletions

View File

@ -2,5 +2,5 @@ package im.vector.riotredesign.core.extensions
fun CharSequence.firstCharAsString(): String {
return this[0].toString()
return if (isNotEmpty()) this[0].toString() else ""
}

View File

@ -0,0 +1,16 @@
package im.vector.riotredesign.features.home.room.list
import android.support.annotation.DrawableRes
import im.vector.riotredesign.R
import im.vector.riotredesign.core.epoxy.KotlinModel
data class RoomCategoryItem(
val title: CharSequence,
@DrawableRes val expandDrawable: Int,
val listener: (() -> Unit)? = null
) : KotlinModel(R.layout.item_room_category) {
override fun bind() {
}
}

View File

@ -3,6 +3,7 @@ package im.vector.riotredesign.features.home.room.list
import android.content.Context
import com.airbnb.epoxy.Typed2EpoxyController
import im.vector.matrix.android.api.session.room.model.RoomSummary
import im.vector.riotredesign.R
import im.vector.riotredesign.features.home.RoomSummaryViewHelper
class RoomSummaryController(private val context: Context,
@ -10,6 +11,13 @@ class RoomSummaryController(private val context: Context,
) : Typed2EpoxyController<List<RoomSummary>, RoomSummary>() {
override fun buildModels(summaries: List<RoomSummary>?, selected: RoomSummary?) {
RoomCategoryItem(
title = "DIRECT MESSAGES",
expandDrawable = R.drawable.ic_expand_more_white
)
.id("direct_messages")
.addTo(this)
summaries?.forEach {
val roomSummaryViewHelper = RoomSummaryViewHelper(it)
RoomSummaryItem(
@ -27,4 +35,4 @@ class RoomSummaryController(private val context: Context,
fun onRoomSelected(room: RoomSummary)
}
}
}

View File

@ -16,7 +16,7 @@ data class RoomSummaryItem(
) : KotlinModel(R.layout.item_room) {
private val titleView by bind<TextView>(R.id.titleView)
private val avatarImageView by bind<ImageView>(R.id.toolbarAvatarImageView)
private val avatarImageView by bind<ImageView>(R.id.avatarImageView)
private val rootView by bind<CheckableConstraintLayout>(R.id.itemRoomLayout)
override fun bind() {

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/black" android:state_checked="true" />
<item android:color="@color/bluey_grey_two" />
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 574 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 770 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 899 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 447 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -10,7 +10,7 @@
android:minHeight="48dp">
<ImageView
android:id="@+id/toolbarAvatarImageView"
android:id="@+id/avatarImageView"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginStart="16dp"
@ -19,16 +19,17 @@
app:layout_constraintTop_toTopOf="parent"
tools:src="@tools:sample/avatars" />
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
<TextView
android:id="@+id/titleView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:duplicateParentState="true"
android:textColor="@color/color_room_title"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/toolbarAvatarImageView"
app:layout_constraintStart_toEndOf="@id/avatarImageView"
app:layout_constraintTop_toTopOf="parent"
tools:text="@tools:sample/full_names" />

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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:gravity="center_vertical"
android:minHeight="24dp"
android:padding="16dp"
tools:background="@color/pale_grey">
<TextView
android:id="@+id/roomCategoryTitleView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:gravity="center_vertical"
android:drawableLeft="@drawable/ic_expand_more_white"
android:drawableTint="@color/bluey_grey_two"
android:foregroundTint="@color/bluey_grey_two"
android:text="DIRECT MESSAGES"
android:textColor="@color/bluey_grey_two"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/roomCategoryAddButton"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/roomCategoryAddButton"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginEnd="8dp"
android:scaleType="centerInside"
android:src="@drawable/ic_add_circle_white"
android:tint="@color/bluey_grey_two"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>

View File

@ -9,5 +9,10 @@
<color name="bluey_grey">#a5a5a6</color>
<color name="slate_grey">#5f6268</color>
<color name="sky_blue">#7bb2ea</color>
<color name="bluey_grey_two">#929eb4</color>
<color name="light_blue_grey">#c1c9d6</color>
<color name="dark_grey">#2e2f32</color>
<color name="light_grey_blue">#9fa9ba</color>
<color name="cool_grey">#a5aab2</color>
<color name="pale_grey_two">#ebedf8</color>
</resources>