Drawer layout
This commit is contained in:
parent
3289cbd6e7
commit
25f6528049
|
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 {
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -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"
|
||||||
|
|
|
@ -1,33 +1,25 @@
|
||||||
<?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
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="56dp"
|
|
||||||
android:duplicateParentState="true">
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/groupAvatarImageView"
|
android:id="@+id/groupAvatarImageView"
|
||||||
android:layout_width="24dp"
|
android:layout_width="42dp"
|
||||||
android:layout_height="24dp"
|
android:layout_height="42dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginStart="@dimen/layout_horizontal_margin"
|
||||||
|
android:layout_marginLeft="@dimen/layout_horizontal_margin"
|
||||||
android:duplicateParentState="true"
|
android:duplicateParentState="true"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toTopOf="@+id/groupBottomSeparator"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:src="@tools:sample/avatars" />
|
tools:src="@tools:sample/avatars" />
|
||||||
|
@ -36,25 +28,38 @@
|
||||||
android:id="@+id/groupNameView"
|
android:id="@+id/groupNameView"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="32dp"
|
android:layout_marginStart="@dimen/layout_horizontal_margin"
|
||||||
|
android:layout_marginEnd="@dimen/layout_horizontal_margin"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/groupAvatarImageView"
|
android:textColor="@color/dark_grey"
|
||||||
|
android:textSize="15sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/groupBottomSeparator"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/groupAvatarChevron"
|
app:layout_constraintEnd_toStartOf="@+id/groupAvatarChevron"
|
||||||
app:layout_constraintHorizontal_bias="0.0"
|
|
||||||
app:layout_constraintStart_toEndOf="@+id/groupAvatarImageView"
|
app:layout_constraintStart_toEndOf="@+id/groupAvatarImageView"
|
||||||
app:layout_constraintTop_toTopOf="@+id/groupAvatarImageView"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:text="@tools:sample/lorem/random" />
|
tools:text="@tools:sample/lorem/random" />
|
||||||
|
|
||||||
|
<!-- TODO Design Picto -->
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/groupAvatarChevron"
|
android:id="@+id/groupAvatarChevron"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="21dp"
|
||||||
|
android:layout_marginRight="21dp"
|
||||||
android:src="@drawable/ic_material_chevron_right_black"
|
android:src="@drawable/ic_material_chevron_right_black"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toTopOf="@+id/groupBottomSeparator"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
<View
|
||||||
|
android:id="@+id/groupBottomSeparator"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="#E9EDF1"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|
||||||
</im.vector.riotredesign.core.platform.CheckableFrameLayout>
|
</im.vector.riotredesign.core.platform.CheckableConstraintLayout>
|
Loading…
Reference in New Issue