Skip to content

Commit

Permalink
Add missing files home notification files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Swordfish90 committed Jul 29, 2023
1 parent a2f8267 commit e070950
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.swordfish.lemuroid.app.mobile.feature.home

import android.view.View
import android.widget.Button
import android.widget.TextView
import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyHolder
import com.airbnb.epoxy.EpoxyModelClass
import com.airbnb.epoxy.EpoxyModelWithHolder
import com.swordfish.lemuroid.R

@EpoxyModelClass(layout = R.layout.layout_home_notification)
abstract class EpoxyHomeNotification : EpoxyModelWithHolder<EpoxyHomeNotification.Holder>() {

@EpoxyAttribute
var title: Int? = null

@EpoxyAttribute
var message: Int? = null

@EpoxyAttribute
var action: Int? = null

@EpoxyAttribute
var actionEnabled: Boolean? = null

@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var onClick: (() -> Unit)? = null

override fun bind(holder: Holder) {
title?.let { holder.titleView?.setText(it) }
message?.let { holder.messageView?.setText(it) }
action?.let { holder.buttonView?.setText(it) }
actionEnabled?.let { holder.buttonView?.isEnabled = it }

holder.buttonView?.setOnClickListener { onClick?.invoke() }
}

override fun unbind(holder: Holder) {
super.unbind(holder)
holder.buttonView?.setOnClickListener(null)
}

class Holder : EpoxyHolder() {
var itemView: View? = null
var messageView: TextView? = null
var titleView: TextView? = null
var buttonView: Button? = null

override fun bindView(itemView: View) {
this.itemView = itemView
this.messageView = itemView.findViewById(R.id.message)
this.titleView = itemView.findViewById(R.id.title)
this.buttonView = itemView.findViewById(R.id.action)
}
}
}
44 changes: 44 additions & 0 deletions lemuroid-app/src/main/res/layout/layout_home_notification.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>

<com.google.android.material.card.MaterialCardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp">

<androidx.appcompat.widget.LinearLayoutCompat
android:layout_margin="@dimen/grid_unit_2x"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:orientation="vertical">

<com.google.android.material.textview.MaterialTextView
android:id="@+id/title"
android:textAppearance="?attr/textAppearanceHeadline6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/message"
android:textAppearance="?attr/textAppearanceCaption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_marginTop="@dimen/grid_unit_2x" />

<com.google.android.material.button.MaterialButton
android:id="@+id/action"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginTop="@dimen/grid_unit_2x" />

</androidx.appcompat.widget.LinearLayoutCompat>

</com.google.android.material.card.MaterialCardView>

0 comments on commit e070950

Please sign in to comment.