diff --git a/app/src/main/java/com/desiredsoftware/socialquiz/ui/question/QuestionResultFragment.kt b/app/src/main/java/com/desiredsoftware/socialquiz/ui/question/QuestionResultFragment.kt index 98ae0eb..eb6331a 100644 --- a/app/src/main/java/com/desiredsoftware/socialquiz/ui/question/QuestionResultFragment.kt +++ b/app/src/main/java/com/desiredsoftware/socialquiz/ui/question/QuestionResultFragment.kt @@ -4,7 +4,10 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.TextView +import androidx.core.view.isVisible import androidx.fragment.app.Fragment +import androidx.navigation.fragment.navArgs import com.desiredsoftware.socialquiz.R class QuestionResultFragment : Fragment() { @@ -15,11 +18,37 @@ class QuestionResultFragment : Fragment() { private lateinit var viewModel: QuestionResultViewModel + val args: QuestionResultFragmentArgs by navArgs() + + lateinit var root : View + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { - return inflater.inflate(R.layout.fragment_question_result, container, false) + + root = inflater.inflate(R.layout.fragment_question_result, container, false) + + val buttonNextQuestion: View = root.findViewById(R.id.buttonNextQuestion) + var textviewNextQuestion: TextView = buttonNextQuestion.findViewById(R.id.textView) + textviewNextQuestion.setText(R.string.nextQuestion) + + val buttonChangeCategory: View = root.findViewById(R.id.buttonChangeCategory) + var textviewChangeCategory: TextView = buttonChangeCategory.findViewById(R.id.textView) + textviewChangeCategory.setText(R.string.changeCategory) + + + + if (args.answerIsCorrect) + { + configureCorrectAnswer() + } + else { + configureWrongAnswer() + } + + return root + } /* override fun onActivityCreated(savedInstanceState: Bundle?) { @@ -28,4 +57,18 @@ class QuestionResultFragment : Fragment() { // TODO: Use the ViewModel }*/ + fun configureWrongAnswer() { + val viewTryAgain: View = root.findViewById(R.id.buttonTryAgain) + var textviewTryAgain: TextView = viewTryAgain.findViewById(R.id.textView) + textviewTryAgain.setText(R.string.tryAgain) + } + + fun configureCorrectAnswer() { + val textViewResult : TextView = root.findViewById(R.id.textViewResult) + textViewResult.setText(R.string.congrat) + val viewTryAgain: View = root.findViewById(R.id.buttonTryAgain) + viewTryAgain.isVisible = false + } + + } \ No newline at end of file diff --git a/app/src/main/java/com/desiredsoftware/socialquiz/ui/question/QuestionShowingFragment.kt b/app/src/main/java/com/desiredsoftware/socialquiz/ui/question/QuestionShowingFragment.kt index d87c379..7e013d7 100644 --- a/app/src/main/java/com/desiredsoftware/socialquiz/ui/question/QuestionShowingFragment.kt +++ b/app/src/main/java/com/desiredsoftware/socialquiz/ui/question/QuestionShowingFragment.kt @@ -6,6 +6,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment +import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.navArgs import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.RecyclerView @@ -62,6 +63,10 @@ class QuestionShowingFragment : Fragment() { object : OnClickAnswerListener{ override fun onClicked(answerVariant: Question.Answer) { // TODO: Show QuestionResultsFragment + val answerIsCorrect : Boolean = answerVariant.isCorrect + val action = QuestionShowingFragmentDirections.actionQuestionShowingFragmentToQuestionResultFragment(answerIsCorrect) + val navController = requireParentFragment().findNavController() + navController.navigate(action) } }) diff --git a/app/src/main/res/layout/button_with_icon.xml b/app/src/main/res/layout/button_with_icon.xml index 36f3c01..0c93596 100644 --- a/app/src/main/res/layout/button_with_icon.xml +++ b/app/src/main/res/layout/button_with_icon.xml @@ -1,7 +1,7 @@ - - + android:text="Your text"> + diff --git a/app/src/main/res/layout/fragment_question_result.xml b/app/src/main/res/layout/fragment_question_result.xml index 0ed718a..f50ee7b 100644 --- a/app/src/main/res/layout/fragment_question_result.xml +++ b/app/src/main/res/layout/fragment_question_result.xml @@ -8,45 +8,68 @@ tools:context=".ui.question.QuestionResultFragment"> + app:layout_constraintTop_toBottomOf="@+id/textViewResult" /> + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_question_showing.xml b/app/src/main/res/layout/fragment_question_showing.xml index aea4466..3c93fb2 100644 --- a/app/src/main/res/layout/fragment_question_showing.xml +++ b/app/src/main/res/layout/fragment_question_showing.xml @@ -30,9 +30,10 @@ android:id="@+id/recyclerViewAnswerVariants" android:layout_width="match_parent" android:layout_height="0dp" - android:layout_marginStart="8dp" + android:layout_marginStart="50dp" + android:layout_marginEnd="50dp" android:layout_marginTop="24dp" - android:layout_marginEnd="8dp" + android:layout_marginBottom="?attr/actionBarSize" app:layout_constraintTop_toBottomOf="@id/framePlayerLayout" app:layout_constraintEnd_toEndOf="parent" diff --git a/app/src/main/res/layout/item_answer_variant.xml b/app/src/main/res/layout/item_answer_variant.xml index 85b5639..559fc63 100644 --- a/app/src/main/res/layout/item_answer_variant.xml +++ b/app/src/main/res/layout/item_answer_variant.xml @@ -8,7 +8,7 @@