parent
c8ee95bd80
commit
41e7532ef1
@ -0,0 +1,71 @@ |
||||
package net.pokeranalytics.android.ui.view |
||||
|
||||
import android.content.Context |
||||
import android.util.AttributeSet |
||||
import android.view.LayoutInflater |
||||
import android.widget.FrameLayout |
||||
import androidx.constraintlayout.widget.ConstraintLayout |
||||
import kotlinx.android.synthetic.main.row_transaction_view.view.* |
||||
import net.pokeranalytics.android.R |
||||
import net.pokeranalytics.android.calculus.ComputedStat |
||||
import net.pokeranalytics.android.calculus.Stat |
||||
import net.pokeranalytics.android.model.realm.Transaction |
||||
import net.pokeranalytics.android.util.extensions.getDayNumber |
||||
import net.pokeranalytics.android.util.extensions.getShortDayName |
||||
|
||||
/** |
||||
* Display a transaction row |
||||
*/ |
||||
class TransactionRowView : FrameLayout { |
||||
|
||||
private lateinit var rowTransaction: ConstraintLayout |
||||
|
||||
/** |
||||
* Constructors |
||||
*/ |
||||
constructor(context: Context) : super(context) { |
||||
init() |
||||
} |
||||
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) { |
||||
init() |
||||
} |
||||
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { |
||||
init() |
||||
} |
||||
|
||||
/** |
||||
* Init |
||||
*/ |
||||
private fun init() { |
||||
val layoutInflater = LayoutInflater.from(context) |
||||
rowTransaction = layoutInflater.inflate(R.layout.row_transaction_view, this, false) as ConstraintLayout |
||||
val layoutParams = FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT) |
||||
addView(rowTransaction, layoutParams) |
||||
} |
||||
|
||||
/** |
||||
* Set the session data to the view |
||||
*/ |
||||
fun setData(transaction: Transaction) { |
||||
|
||||
// Date |
||||
rowTransaction.transactionDateDay.text = transaction.date.getShortDayName() |
||||
rowTransaction.transactionDateNumber.text = transaction.date.getDayNumber() |
||||
|
||||
// Title / Game type |
||||
var title = transaction.type?.name ?: "" + " " + transaction.comment |
||||
var subtitle = transaction.bankroll?.name |
||||
|
||||
rowTransaction.transactionTitle.text = title |
||||
rowTransaction.transactionSubtitle.text = subtitle |
||||
|
||||
// Amount |
||||
val formattedStat = ComputedStat(Stat.NETRESULT, transaction.amount).format(context) |
||||
rowTransaction.transactionAmount.setTextColor(formattedStat.getColor(context)) |
||||
rowTransaction.transactionAmount.text = formattedStat.text |
||||
|
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,108 @@ |
||||
<?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="56dp" |
||||
android:background="?selectableItemBackground"> |
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView |
||||
android:id="@+id/transactionDateDay" |
||||
style="@style/PokerAnalyticsTheme.TextView.SessionRow.Date" |
||||
android:layout_width="32dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="8dp" |
||||
android:gravity="center" |
||||
android:textAllCaps="true" |
||||
app:fontFamily="@font/roboto_mono_medium" |
||||
app:layout_constraintBottom_toTopOf="@+id/transactionDateNumber" |
||||
app:layout_constraintStart_toStartOf="@+id/guidelineStart" |
||||
app:layout_constraintTop_toTopOf="parent" |
||||
app:layout_constraintVertical_chainStyle="packed" |
||||
tools:text="THU" /> |
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView |
||||
android:id="@+id/transactionDateNumber" |
||||
style="@style/PokerAnalyticsTheme.TextView.SessionRow.DateNumber" |
||||
android:layout_width="32dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginBottom="8dp" |
||||
android:gravity="center" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toEndOf="@+id/transactionDateDay" |
||||
app:layout_constraintHorizontal_bias="0.5" |
||||
app:layout_constraintStart_toStartOf="@+id/transactionDateDay" |
||||
app:layout_constraintTop_toBottomOf="@+id/transactionDateDay" |
||||
tools:text="21" /> |
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView |
||||
android:id="@+id/transactionTitle" |
||||
style="@style/PokerAnalyticsTheme.TextView.SessionRow.Title" |
||||
android:layout_width="0dp" |
||||
android:layout_height="24dp" |
||||
android:layout_marginStart="8dp" |
||||
android:layout_marginEnd="8dp" |
||||
app:layout_constraintBottom_toTopOf="@+id/transactionSubtitle" |
||||
app:layout_constraintEnd_toStartOf="@+id/transactionAmount" |
||||
app:layout_constraintHorizontal_bias="0.5" |
||||
app:layout_constraintStart_toEndOf="@+id/transactionDateDay" |
||||
app:layout_constraintTop_toTopOf="parent" |
||||
app:layout_constraintVertical_chainStyle="packed" |
||||
tools:text="Deposit: Live" /> |
||||
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView |
||||
android:id="@+id/transactionSubtitle" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginEnd="8dp" |
||||
android:layout_marginBottom="2dp" |
||||
android:ellipsize="end" |
||||
android:fontFamily="@font/roboto" |
||||
android:maxLines="1" |
||||
android:textColor="@color/kaki_lighter" |
||||
android:textSize="12sp" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toStartOf="@+id/transactionAmount" |
||||
app:layout_constraintStart_toStartOf="@+id/transactionTitle" |
||||
app:layout_constraintTop_toBottomOf="@+id/transactionTitle" |
||||
tools:text="Live" |
||||
tools:visibility="visible" /> |
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView |
||||
android:id="@+id/transactionAmount" |
||||
style="@style/PokerAnalyticsTheme.TextView.SessionRow.Result" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginEnd="8dp" |
||||
app:layout_constraintBottom_toBottomOf="@+id/transactionSubtitle" |
||||
app:layout_constraintEnd_toStartOf="@+id/nextArrow" |
||||
app:layout_constraintTop_toTopOf="@+id/transactionTitle" |
||||
tools:text="$ 1000" /> |
||||
|
||||
<ImageView |
||||
android:id="@+id/nextArrow" |
||||
android:layout_width="24dp" |
||||
android:layout_height="24dp" |
||||
android:src="@drawable/ic_arrow_right" |
||||
android:tint="@color/gray_light" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toEndOf="@+id/guidelineEnd" |
||||
app:layout_constraintTop_toTopOf="parent" /> |
||||
|
||||
<androidx.constraintlayout.widget.Guideline |
||||
android:id="@+id/guidelineStart" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="vertical" |
||||
app:layout_constraintGuide_begin="16dp" /> |
||||
|
||||
<androidx.constraintlayout.widget.Guideline |
||||
android:id="@+id/guidelineEnd" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="vertical" |
||||
app:layout_constraintGuide_end="8dp" /> |
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout> |
||||
Loading…
Reference in new issue