Skip to content

Commit

Permalink
Added header to general verification result (#206)
Browse files Browse the repository at this point in the history
* Added header to general verification result

* Update
  • Loading branch information
oleksandrsarapulovgl authored Sep 8, 2021
1 parent 19f366b commit 686c544
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class VerificationResultDialogFragment :
override fun actionButton(): Button = binding.actionButton

private fun handleDecodeResult() {
binding.verificationResultHeaderView.setUp(args.standardizedVerificationResult, args.certificateModel, args.ruleValidationResultModelsContainer)
handleVerificationResult(
args.certificateModel,
args.standardizedVerificationResult.category
Expand All @@ -101,7 +102,6 @@ class VerificationResultDialogFragment :
setCertStatusUI(standardizedVerificationResultCategory)
setCertDataVisibility(standardizedVerificationResultCategory)
certificateModel?.let { it ->
binding.personFullName.text = it.getFullName()
toggleButton(it)

if (standardizedVerificationResultCategory != StandardizedVerificationResultCategory.INVALID) {
Expand Down Expand Up @@ -175,9 +175,6 @@ class VerificationResultDialogFragment :
}
}

binding.status.text = text
binding.certStatusIcon.setImageResource(imageId)
binding.verificationStatusBg.backgroundTintList = statusColor
actionButton().isVisible = true
actionButton().backgroundTintList = statusColor
actionButton().text = actionBtnText
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import android.content.Context
import android.content.res.ColorStateList
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat
import dgca.verifier.app.android.R
Expand All @@ -51,6 +52,10 @@ class DetailedVerificationResultHeaderView(context: Context, attrs: AttributeSet
) {
binding.personFullName.text = certificateModel?.getFullName() ?: ""

val isValid =
standardizedVerificationResult.category == StandardizedVerificationResultCategory.VALID
binding.information.visibility = if (isValid) View.GONE else View.VISIBLE

val (colorRes, textRes) = when (standardizedVerificationResult.category) {
StandardizedVerificationResultCategory.VALID -> Pair(R.color.green, R.string.cert_valid)
StandardizedVerificationResultCategory.INVALID -> Pair(
Expand All @@ -66,9 +71,18 @@ class DetailedVerificationResultHeaderView(context: Context, attrs: AttributeSet
binding.verificationStatusBackground.backgroundTintList =
ColorStateList.valueOf(ContextCompat.getColor(context, colorRes))

binding.detailedVerificationResultView.setUp(
standardizedVerificationResult,
ruleValidationResultModelsContainer
)
if (isValid) {
binding.detailedVerificationResultView.visibility = View.GONE
binding.certStatusIcon.visibility = View.VISIBLE
View.GONE
} else {
binding.detailedVerificationResultView.visibility = View.VISIBLE
binding.certStatusIcon.visibility = View.GONE
binding.detailedVerificationResultView.setUp(
standardizedVerificationResult,
ruleValidationResultModelsContainer
)
View.VISIBLE
}
}
}
58 changes: 5 additions & 53 deletions app/src/main/res/layout/dialog_fragment_verification_result.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,61 +29,13 @@
android:layout_marginTop="50dp"
android:minHeight="500dp">

<View
android:id="@+id/verification_status_bg"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@drawable/bottom_sheet_bg"
app:layout_constraintBottom_toBottomOf="@id/bottomStatusViewStub"
app:layout_constraintTop_toTopOf="parent"
tools:backgroundTint="@color/green" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/person_full_name"
<dgca.verifier.app.android.verification.detailed.DetailedVerificationResultHeaderView
android:id="@+id/verificationResultHeaderView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/default_margin"
android:layout_marginTop="@dimen/default_double_margin"
android:textColor="@color/white"
android:textSize="26sp"
android:typeface="normal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Gabriele \nMusterfrau" />

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/cert_status_icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginStart="@dimen/default_margin"
android:scaleType="centerInside"
app:layout_constraintBottom_toBottomOf="@id/status"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/status"
tools:src="@drawable/check" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/status"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginTop="5dp"
android:textColor="@color/white"
android:textSize="42sp"
app:layout_constraintEnd_toEndOf="@id/person_full_name"
app:layout_constraintStart_toEndOf="@+id/cert_status_icon"
app:layout_constraintTop_toBottomOf="@id/person_full_name"
tools:text="@string/cert_valid" />

<View
android:id="@+id/bottomStatusViewStub"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="@dimen/default_double_margin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/status" />
app:layout_constraintTop_toTopOf="parent" />

<View
android:id="@+id/whiteBackground"
Expand All @@ -93,7 +45,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/verification_status_bg" />
app:layout_constraintTop_toBottomOf="@id/verificationResultHeaderView" />

<androidx.core.widget.NestedScrollView
android:id="@+id/nestedScrollView"
Expand All @@ -103,7 +55,7 @@
app:layout_constraintBottom_toTopOf="@+id/bottom_container"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/verification_status_bg"
app:layout_constraintTop_toBottomOf="@+id/verificationResultHeaderView"
tools:visibility="visible">

<androidx.constraintlayout.widget.ConstraintLayout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,34 @@
android:textColor="@color/white"
android:textSize="26sp"
android:typeface="normal"
app:layout_constraintBottom_toTopOf="@id/status"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Gabriele \nMusterfrau" />

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/certStatusIcon"
android:layout_width="48dp"
android:layout_height="48dp"
android:scaleType="centerInside"
app:layout_constraintStart_toStartOf="@id/personFullName"
app:layout_constraintTop_toBottomOf="@id/personFullName"
app:layout_constraintBottom_toBottomOf="@id/status"
app:layout_constraintTop_toTopOf="@id/status"
android:src="@drawable/check" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/status"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:textColor="@color/white"
app:layout_constraintBottom_toTopOf="@id/detailedVerificationResultView"
android:textSize="42sp"
android:layout_marginBottom="@dimen/default_margin"
app:layout_constraintEnd_toEndOf="@id/personFullName"
app:layout_constraintStart_toStartOf="@id/personFullName"
app:layout_constraintStart_toEndOf="@id/certStatusIcon"
app:layout_constraintTop_toBottomOf="@id/personFullName"
tools:text="@string/cert_valid" />

Expand All @@ -79,7 +93,6 @@
android:id="@+id/detailedVerificationResultView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/default_margin"
android:layout_marginBottom="@dimen/default_half_margin"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/personFullName"
Expand Down

0 comments on commit 686c544

Please sign in to comment.