Creation of header and content items

This commit is contained in:
Maxime NATUREL 2022-09-08 15:10:48 +02:00
parent c7099f53c1
commit 94d1649ec9
4 changed files with 158 additions and 0 deletions

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2022 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.settings.devices.v2.details
import android.view.View
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
@EpoxyModelClass
abstract class SessionDetailsContentItem : VectorEpoxyModel<SessionDetailsContentItem.Holder>(R.layout.item_session_details_header) {
@EpoxyAttribute
var title: String? = null
@EpoxyAttribute
var description: String? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var onLongClickListener: View.OnLongClickListener? = null
override fun bind(holder: Holder) {
super.bind(holder)
holder.sessionDetailsContentTitle.text = title
holder.sessionDetailsContentDescription.text = description
holder.view.isClickable = onLongClickListener != null
holder.view.setOnLongClickListener(onLongClickListener)
}
class Holder : VectorEpoxyHolder() {
val sessionDetailsContentTitle by bind<TextView>(R.id.sessionDetailsContentTitle)
val sessionDetailsContentDescription by bind<TextView>(R.id.sessionDetailsContentDescription)
}
}

View File

@ -0,0 +1,40 @@
/*
* Copyright (c) 2022 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.settings.devices.v2.details
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
@EpoxyModelClass
abstract class SessionDetailsHeaderItem : VectorEpoxyModel<SessionDetailsHeaderItem.Holder>(R.layout.item_session_details_header) {
@EpoxyAttribute
var title: String? = null
override fun bind(holder: Holder) {
super.bind(holder)
holder.sessionDetailsHeaderTitle.text = title
}
class Holder : VectorEpoxyHolder() {
val sessionDetailsHeaderTitle by bind<TextView>(R.id.sessionDetailsHeaderTitle)
}
}

View File

@ -0,0 +1,45 @@
<?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:paddingTop="16dp">
<TextView
android:id="@+id/sessionDetailsContentTitle"
style="@style/TextAppearance.Vector.Body.DevicesManagement"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/layout_horizontal_margin"
android:ellipsize="end"
android:lines="2"
app:layout_constraintEnd_toStartOf="@id/sessionDetailsContentDescription"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Session name" />
<TextView
android:id="@+id/sessionDetailsContentDescription"
style="@style/TextAppearance.Vector.Body"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="@dimen/layout_horizontal_margin"
android:gravity="end"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/sessionDetailsContentTitle"
app:layout_constraintTop_toTopOf="parent"
tools:text="Element Web: Firefox on macOS" />
<View
android:id="@+id/sessionDetailsContentDivider"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginTop="14dp"
android:background="@drawable/divider_horizontal"
app:layout_constraintEnd_toEndOf="@id/sessionDetailsContentDescription"
app:layout_constraintStart_toStartOf="@id/sessionDetailsContentTitle"
app:layout_constraintTop_toBottomOf="@id/sessionDetailsContentTitle" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,22 @@
<?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:paddingTop="16dp">
<TextView
android:id="@+id/sessionDetailsHeaderTitle"
style="@style/TextAppearance.Vector.Body.Medium"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/layout_horizontal_margin"
android:ellipsize="end"
android:lines="1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Session" />
</androidx.constraintlayout.widget.ConstraintLayout>