From 6e03fa5fa7a72f6758ba4ac070816d2d0b6970e7 Mon Sep 17 00:00:00 2001 From: Prajna Prayoga Date: Wed, 21 Feb 2024 13:26:29 +0700 Subject: [PATCH] fix: validation questioner risk profile --- .../risk_profile/question_view.dart | 13 +- .../risk_profile/results_view.dart | 113 ++---------------- 2 files changed, 18 insertions(+), 108 deletions(-) diff --git a/lib/features/auth/registration/view/submission_data/risk_profile/question_view.dart b/lib/features/auth/registration/view/submission_data/risk_profile/question_view.dart index 5d38aee..e301cc8 100644 --- a/lib/features/auth/registration/view/submission_data/risk_profile/question_view.dart +++ b/lib/features/auth/registration/view/submission_data/risk_profile/question_view.dart @@ -56,17 +56,24 @@ class _QuestionViewState extends State { bottomNavigationBar: SizedBox( height: 84, child: ButtonView( + disabled: provider.listScore[currentPage] == 0, name: 'Next', marginVertical: 16, + disabledBgColor: ColorPalette.slate200, + textColor: provider.listScore[currentPage] == 0 ? ColorPalette.slate500 : Colors.white, + backgroundColor: ColorPalette.primary, onPressed: () { if (currentPage > 3) { int totalScore = provider.listScore .reduce((value, element) => value + element); provider.setTypeResult(totalScore); routePush(context, - page: ResultsView( - totalScore: totalScore.toString(), - typeResult: provider.typeResult)); + page: ResultsView( + totalScore: totalScore, + typeResult: provider.typeResult + ), + routeType: RouteType.pushReplace + ); } else { setState(() { currentPage += 1; diff --git a/lib/features/auth/registration/view/submission_data/risk_profile/results_view.dart b/lib/features/auth/registration/view/submission_data/risk_profile/results_view.dart index 80d7595..1b9129b 100644 --- a/lib/features/auth/registration/view/submission_data/risk_profile/results_view.dart +++ b/lib/features/auth/registration/view/submission_data/risk_profile/results_view.dart @@ -1,14 +1,17 @@ import 'package:cims_apps/application/component/button/back_button_view.dart'; import 'package:cims_apps/application/component/button/button_view.dart'; +import 'package:cims_apps/application/component/risk_profile.dart'; import 'package:cims_apps/application/theme/color_palette.dart'; import 'package:cims_apps/core/route/route.dart'; import 'package:cims_apps/core/utils/size_config.dart'; +import 'package:cims_apps/features/auth/registration/view/submission_data/risk_profile/question_view.dart'; +import 'package:cims_apps/features/auth/registration/view/submission_data/risk_profile/risk_profile_view.dart'; import 'package:cims_apps/features/auth/registration/view/submission_data/risk_profile/risk_profile_view_model/risk_profile_view_model.dart'; import 'package:cims_apps/features/auth/registration/view/submission_data/terms_and_condition/terms_and_condition_view.dart'; import 'package:flutter/material.dart'; class ResultsView extends StatelessWidget { - final String totalScore; + final int totalScore; final RiskProfileResult typeResult; const ResultsView( {super.key, required this.typeResult, required this.totalScore}); @@ -37,115 +40,15 @@ class ResultsView extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - ClipRRect( - borderRadius: BorderRadius.circular(8), - child: Container( - decoration: BoxDecoration( - color: typeResult.color, - image: DecorationImage( - image: AssetImage(typeResult.img), - alignment: Alignment.centerRight)), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - padding: const EdgeInsets.all(24), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - typeResult.type, - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 24, - color: ColorPalette.white), - ), - const SizedBox( - height: 16, - ), - const Text( - 'Total Score :', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 16, - color: ColorPalette.white), - ), - Text( - totalScore, - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 28, - color: ColorPalette.white), - ) - ], - ), - ), - ], - ), - ), - ), - const SizedBox( - height: 24, - ), - Text(typeResult.desc, - style: const TextStyle( - color: ColorPalette.slate500, fontSize: 16)), - const SizedBox( - height: 24, - ), - const Text( - 'Suitable Product', - style: TextStyle( - color: ColorPalette.slate800, - fontWeight: FontWeight.bold, - fontSize: 16), - ), - const SizedBox( - height: 16, - ), - Wrap( - runSpacing: 16, - children: typeResult.suitableProduct.map((e) { - return Container( - padding: const EdgeInsets.all(16), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(6), - border: Border.all(color: ColorPalette.slate200), - ), - child: Row( - children: [ - Container( - padding: const EdgeInsets.all(8), - alignment: Alignment.center, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: typeResult.color.withOpacity(0.1)), - child: Image.asset(e['icon'], - width: SizeConfig.width * 0.07, - color: typeResult.color)), - const SizedBox( - width: 12, - ), - Expanded( - child: Text( - e['desc'], - style: const TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold, - color: ColorPalette.slate800), - ), - ) - ], - ), - ); - }).toList(), - ), + RiskProfile(totalScore: totalScore, rowSuitableProduct: false), const SizedBox( height: 32, ), ButtonView( name: 'Re-test', - onPressed: () {}, + onPressed: () { + routePush(context, page: QuestionView(), routeType: RouteType.pushReplace); + }, marginVertical: 0, backgroundColor: ColorPalette.white, textColor: ColorPalette.primary,