diff --git a/app/src/main/java/com/example/quickmax/ResponseFragment.kt b/app/src/main/java/com/example/quickmax/ResponseFragment.kt index 73cb74c..7c92bb7 100644 --- a/app/src/main/java/com/example/quickmax/ResponseFragment.kt +++ b/app/src/main/java/com/example/quickmax/ResponseFragment.kt @@ -1,14 +1,15 @@ package com.example.quickmax +import android.graphics.Color +import android.graphics.PorterDuff import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.widget.ImageButton import android.widget.TextView -import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment +import com.google.android.material.button.MaterialButton class ResponseFragment: Fragment() { @@ -24,15 +25,25 @@ class ResponseFragment: Fragment() { val view = inflater.inflate(R.layout.fragment_response, container, false) val correct = arguments!!.getBoolean("correct") return if (correct) - view(view, ContextCompat.getColor(activity!!, R.color.colorAccent), R.string.response_correct) + view(view, color(R.color.colorAccent), R.string.response_correct, color(R.color.transparent_dark_black)) else - view(view, ContextCompat.getColor(activity!!, R.color.colorPrimary), R.string.response_wrong) + view(view, color(R.color.colorPrimary), R.string.response_wrong, Color.WHITE) } - private fun view(view: View, color: Int, responseId: Int): View { - view.findViewById<TextView>(R.id.tv_response).text = resources.getString(responseId) - view.findViewById<ConstraintLayout>(R.id.response_layout).setBackgroundColor(color) - view.findViewById<ImageButton>(R.id.btn_next).setOnClickListener { (activity as TaskActivity).reload() } + private fun view(view: View, color: Int, responseId: Int, textColor: Int): View { + view.findViewById<TextView>(R.id.tv_response).apply { + text = resources.getString(responseId) + setTextColor(color) + } + + view.findViewById<MaterialButton>(R.id.btn_next).apply { + background.setColorFilter(color, PorterDuff.Mode.MULTIPLY) + setTextColor(textColor) + setOnClickListener { (activity as TaskActivity).reload() } } return view } + + private fun color(colorId: Int): Int { + return ContextCompat.getColor(activity!!, colorId) + } } \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_response.xml b/app/src/main/res/layout/fragment_response.xml index 8cb05b9..91c28f0 100644 --- a/app/src/main/res/layout/fragment_response.xml +++ b/app/src/main/res/layout/fragment_response.xml @@ -3,18 +3,22 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/response_layout" android:layout_width="match_parent" - android:layout_height="54dp" + android:layout_height="wrap_content" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"> - <ImageButton + <com.google.android.material.button.MaterialButton android:id="@+id/btn_next" - style="@style/ButtonNext" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:layout_marginEnd="8dp" + android:layout_marginBottom="8dp" + android:text="@string/btn_next" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintTop_toTopOf="parent" - app:srcCompat="@drawable/ic_double_arrow_small" /> + app:layout_constraintTop_toTopOf="parent" /> <TextView android:id="@+id/tv_response" diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 6e4792f..3da50b3 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -4,5 +4,6 @@ <color name="colorPrimaryDark">#12005e</color> <color name="colorAccent">#4dd0e1</color> <color name="transparent_black">#97000000</color> + <color name="transparent_dark_black">#BB000000</color> <color name="transparent_red">#97FF0000</color> </resources>