Drawer layout

This commit is contained in:
Benoit Marty 2019-05-29 10:21:02 +02:00
parent 3289cbd6e7
commit 25f6528049
6 changed files with 165 additions and 64 deletions

View File

@ -0,0 +1,29 @@
{
"data": [
{
"displayName": "benoit",
"mxid": "@benoit:matrix.org",
"message": "Hello!"
},
{
"displayName": "ganfra",
"mxid": "@ganfra:matrix.org",
"message": "How are you?"
},
{
"displayName": "Manu",
"mxid": "@manu:matrix.org",
"message": "Great weather today!"
},
{
"displayName": "Giom",
"mxid": "@giom:matrix.org",
"message": "Let's do a picnic"
},
{
"displayName": "Nad",
"mxid": "@nadonomy:matrix.org",
"message": "Yes, great idea"
}
]
}

View File

@ -0,0 +1,61 @@
/*
* 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.riotredesign.core.platform
import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.Checkable
import androidx.constraintlayout.widget.ConstraintLayout
class CheckableConstraintLayout : ConstraintLayout, Checkable {
private var mChecked = false
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
override fun isChecked(): Boolean {
return mChecked
}
override fun setChecked(b: Boolean) {
if (b != mChecked) {
mChecked = b
refreshDrawableState()
}
}
override fun toggle() {
isChecked = !mChecked
}
public override fun onCreateDrawableState(extraSpace: Int): IntArray {
val drawableState = super.onCreateDrawableState(extraSpace + 1)
if (isChecked) {
View.mergeDrawableStates(drawableState, CHECKED_STATE_SET)
}
return drawableState
}
companion object {
private val CHECKED_STATE_SET = intArrayOf(android.R.attr.state_checked)
}
}

View File

@ -25,12 +25,9 @@ import im.vector.riotredesign.R
import im.vector.riotredesign.core.extensions.observeEvent import im.vector.riotredesign.core.extensions.observeEvent
import im.vector.riotredesign.core.platform.StateView import im.vector.riotredesign.core.platform.StateView
import im.vector.riotredesign.core.platform.VectorBaseFragment import im.vector.riotredesign.core.platform.VectorBaseFragment
import im.vector.riotredesign.features.home.HomeModule
import im.vector.riotredesign.features.home.HomeNavigator import im.vector.riotredesign.features.home.HomeNavigator
import kotlinx.android.synthetic.main.fragment_group_list.* import kotlinx.android.synthetic.main.fragment_group_list.*
import org.koin.android.ext.android.inject import org.koin.android.ext.android.inject
import org.koin.android.scope.ext.android.bindScope
import org.koin.android.scope.ext.android.getOrCreateScope
class GroupListFragment : VectorBaseFragment(), GroupSummaryController.Callback { class GroupListFragment : VectorBaseFragment(), GroupSummaryController.Callback {

View File

@ -23,7 +23,7 @@ import com.airbnb.epoxy.EpoxyModelClass
import im.vector.riotredesign.R import im.vector.riotredesign.R
import im.vector.riotredesign.core.epoxy.VectorEpoxyHolder import im.vector.riotredesign.core.epoxy.VectorEpoxyHolder
import im.vector.riotredesign.core.epoxy.VectorEpoxyModel import im.vector.riotredesign.core.epoxy.VectorEpoxyModel
import im.vector.riotredesign.core.platform.CheckableFrameLayout import im.vector.riotredesign.core.platform.CheckableConstraintLayout
import im.vector.riotredesign.features.home.AvatarRenderer import im.vector.riotredesign.features.home.AvatarRenderer
@EpoxyModelClass(layout = R.layout.item_group) @EpoxyModelClass(layout = R.layout.item_group)
@ -46,7 +46,7 @@ abstract class GroupSummaryItem : VectorEpoxyModel<GroupSummaryItem.Holder>() {
class Holder : VectorEpoxyHolder() { class Holder : VectorEpoxyHolder() {
val avatarImageView by bind<ImageView>(R.id.groupAvatarImageView) val avatarImageView by bind<ImageView>(R.id.groupAvatarImageView)
val groupNameView by bind<TextView>(R.id.groupNameView) val groupNameView by bind<TextView>(R.id.groupNameView)
val rootView by bind<CheckableFrameLayout>(R.id.itemGroupLayout) val rootView by bind<CheckableConstraintLayout>(R.id.itemGroupLayout)
} }
} }

View File

@ -12,7 +12,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/colorPrimary" android:background="?attr/colorPrimary"
android:padding="16dp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
@ -21,6 +20,8 @@
android:id="@+id/homeDrawerHeaderAvatarView" android:id="@+id/homeDrawerHeaderAvatarView"
android:layout_width="64dp" android:layout_width="64dp"
android:layout_height="64dp" android:layout_height="64dp"
android:layout_marginStart="@dimen/layout_horizontal_margin"
android:layout_marginLeft="@dimen/layout_horizontal_margin"
android:layout_marginTop="24dp" android:layout_marginTop="24dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
@ -30,33 +31,41 @@
android:id="@+id/homeDrawerUsernameView" android:id="@+id/homeDrawerUsernameView"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:layout_marginTop="24dp"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textSize="15sp"
app:layout_constraintStart_toStartOf="@+id/homeDrawerHeaderAvatarView" app:layout_constraintStart_toStartOf="@+id/homeDrawerHeaderAvatarView"
app:layout_constraintTop_toBottomOf="@+id/homeDrawerHeaderAvatarView" app:layout_constraintTop_toBottomOf="@+id/homeDrawerHeaderAvatarView"
tools:text="@tools:sample/full_names" /> tools:text="@sample/matrix.json/data/displayName" />
<TextView <TextView
android:id="@+id/homeDrawerUserIdView" android:id="@+id/homeDrawerUserIdView"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="8dp" android:layout_marginBottom="17dp"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textSize="15sp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="@+id/homeDrawerUsernameView" app:layout_constraintStart_toStartOf="@+id/homeDrawerHeaderAvatarView"
app:layout_constraintTop_toBottomOf="@+id/homeDrawerUsernameView" app:layout_constraintTop_toBottomOf="@+id/homeDrawerUsernameView"
tools:text="@tools:sample/full_names" /> tools:text="@sample/matrix.json/data/mxid" />
<!-- TODO Design Picto -->
<ImageView <ImageView
android:id="@+id/homeDrawerHeaderSettingsView" android:id="@+id/homeDrawerHeaderSettingsView"
android:layout_width="32dp" android:layout_width="wrap_content"
android:layout_height="32dp" android:layout_height="wrap_content"
android:padding="6dp"
android:scaleType="fitCenter"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:paddingStart="8dp"
android:paddingLeft="8dp"
android:paddingTop="8dp"
android:paddingEnd="16dp"
android:paddingRight="16dp"
android:paddingBottom="16dp"
android:scaleType="center"
android:src="@drawable/ic_settings" android:src="@drawable/ic_settings"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/homeDrawerUsernameView" /> app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
@ -64,7 +73,7 @@
android:id="@+id/homeDrawerGroupListContainer" android:id="@+id/homeDrawerGroupListContainer"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:background="@android:color/white" android:background="#FAFAFA"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"

View File

@ -1,60 +1,65 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<im.vector.riotredesign.core.platform.CheckableConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<im.vector.riotredesign.core.platform.CheckableFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/itemGroupLayout" android:id="@+id/itemGroupLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="65dp"
android:background="@drawable/bg_group_item" android:background="@drawable/bg_group_item"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:foreground="?attr/selectableItemBackground" android:foreground="?attr/selectableItemBackground"
android:paddingStart="8dp" tools:background="#FAFAFA">
android:paddingLeft="8dp"
android:paddingEnd="16dp"
android:paddingRight="16dp">
<androidx.constraintlayout.widget.ConstraintLayout <ImageView
android:layout_width="match_parent" android:id="@+id/groupAvatarImageView"
android:layout_height="56dp" android:layout_width="42dp"
android:duplicateParentState="true"> android:layout_height="42dp"
android:layout_gravity="center"
android:layout_marginStart="@dimen/layout_horizontal_margin"
android:layout_marginLeft="@dimen/layout_horizontal_margin"
android:duplicateParentState="true"
app:layout_constraintBottom_toTopOf="@+id/groupBottomSeparator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@tools:sample/avatars" />
<ImageView <TextView
android:id="@+id/groupAvatarImageView" android:id="@+id/groupNameView"
android:layout_width="24dp" android:layout_width="0dp"
android:layout_height="24dp" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_marginStart="@dimen/layout_horizontal_margin"
android:duplicateParentState="true" android:layout_marginEnd="@dimen/layout_horizontal_margin"
app:layout_constraintBottom_toBottomOf="parent" android:ellipsize="end"
app:layout_constraintStart_toStartOf="parent" android:maxLines="1"
app:layout_constraintTop_toTopOf="parent" android:textColor="@color/dark_grey"
tools:src="@tools:sample/avatars" /> android:textSize="15sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/groupBottomSeparator"
app:layout_constraintEnd_toStartOf="@+id/groupAvatarChevron"
app:layout_constraintStart_toEndOf="@+id/groupAvatarImageView"
app:layout_constraintTop_toTopOf="parent"
tools:text="@tools:sample/lorem/random" />
<TextView <!-- TODO Design Picto -->
android:id="@+id/groupNameView" <ImageView
android:layout_width="0dp" android:id="@+id/groupAvatarChevron"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_marginLeft="32dp" android:layout_height="wrap_content"
android:ellipsize="end" android:layout_marginEnd="21dp"
android:maxLines="1" android:layout_marginRight="21dp"
app:layout_constraintBottom_toBottomOf="@+id/groupAvatarImageView" android:src="@drawable/ic_material_chevron_right_black"
app:layout_constraintEnd_toStartOf="@+id/groupAvatarChevron" app:layout_constraintBottom_toTopOf="@+id/groupBottomSeparator"
app:layout_constraintHorizontal_bias="0.0" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/groupAvatarImageView" app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="@+id/groupAvatarImageView"
tools:text="@tools:sample/lorem/random" />
<ImageView <View
android:id="@+id/groupAvatarChevron" android:id="@+id/groupBottomSeparator"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="1dp"
android:src="@drawable/ic_material_chevron_right_black" android:background="#E9EDF1"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </im.vector.riotredesign.core.platform.CheckableConstraintLayout>
</im.vector.riotredesign.core.platform.CheckableFrameLayout>