|
|
|
|
@ -1,4 +1,7 @@
|
|
|
|
|
import 'dart:developer';
|
|
|
|
|
|
|
|
|
|
import 'package:appinio_swiper/appinio_swiper.dart';
|
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:lottie/lottie.dart';
|
|
|
|
|
@ -6,10 +9,13 @@ import 'package:mohem_flutter_app/app_state/app_state.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/classes/decorations_helper.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/classes/lottie_consts.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/models/disclosure/disclosure_question_model.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/ui/disclosure/disclosure_provider.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
class DisclosureQuestionCard extends StatelessWidget {
|
|
|
|
|
@ -21,18 +27,25 @@ class DisclosureQuestionCard extends StatelessWidget {
|
|
|
|
|
return CupertinoPageScaffold(
|
|
|
|
|
child: provider.cardContentList.isEmpty
|
|
|
|
|
? Lottie.asset(MyLottieConsts.hourGlassLottie, height: 250).paddingOnly(top: 50)
|
|
|
|
|
: SizedBox(
|
|
|
|
|
height: MediaQuery.of(context).size.height * .45,
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
child: AppinioSwiper(
|
|
|
|
|
duration: const Duration(milliseconds: 400),
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
isDisabled: true,
|
|
|
|
|
controller: provider.swiperController,
|
|
|
|
|
unswipe: (int index, AppinioSwiperDirection direction) {},
|
|
|
|
|
onSwipe: (int index, AppinioSwiperDirection direction) {},
|
|
|
|
|
cards: provider.cardContentList,
|
|
|
|
|
),
|
|
|
|
|
: Consumer<DisclosureProvider>(
|
|
|
|
|
builder: (BuildContext context, DisclosureProvider provider, Widget? child) {
|
|
|
|
|
return Container(
|
|
|
|
|
constraints: BoxConstraints(minHeight: MediaQuery.of(context).size.height * .43),
|
|
|
|
|
height: (provider.currentQuestionSelectionStatus == DisclosureQuestionsOptionStatus.correct && provider.currentQuestionNumber != provider.disclosureDetailsModel.totalQuestions!)
|
|
|
|
|
? MediaQuery.of(context).size.height * .6
|
|
|
|
|
: MediaQuery.of(context).size.height * .43,
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
child: AppinioSwiper(
|
|
|
|
|
duration: const Duration(milliseconds: 400),
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
isDisabled: true,
|
|
|
|
|
controller: provider.swiperController,
|
|
|
|
|
unswipe: (int index, AppinioSwiperDirection direction) {},
|
|
|
|
|
onSwipe: (int index, AppinioSwiperDirection direction) {},
|
|
|
|
|
cards: provider.cardContentList,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
@ -59,36 +72,39 @@ class DisclosureCardContent extends StatelessWidget {
|
|
|
|
|
),
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.only(
|
|
|
|
|
topLeft: Radius.circular(10),
|
|
|
|
|
topRight: Radius.circular(10),
|
|
|
|
|
Flexible(
|
|
|
|
|
child: Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.only(
|
|
|
|
|
topLeft: Radius.circular(10),
|
|
|
|
|
topRight: Radius.circular(10),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: Center(
|
|
|
|
|
constraints: BoxConstraints(minHeight: MediaQuery.of(context).size.height * .23),
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 13, vertical: 15),
|
|
|
|
|
child: Text(
|
|
|
|
|
displayLocalizedContent(
|
|
|
|
|
isPhoneLangArabic: AppState().isArabic(context),
|
|
|
|
|
selectedLanguage: (provider.disclosureDetailsModel.selectedLanguage) ?? 0,
|
|
|
|
|
englishContent: provider.currentQuestion.titleEn ?? "",
|
|
|
|
|
arabicContent: provider.currentQuestion.titleAr ?? "",
|
|
|
|
|
),
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
color: MyColors.darkTextColor,
|
|
|
|
|
fontSize: 15,
|
|
|
|
|
height: 21 / 14,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
padding: const EdgeInsets.only(left: 15, right: 15, top: 15),
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: Text(
|
|
|
|
|
displayLocalizedContent(
|
|
|
|
|
isPhoneLangArabic: AppState().isArabic(context),
|
|
|
|
|
selectedLanguage: (provider.disclosureDetailsModel.selectedLanguage) ?? 0,
|
|
|
|
|
englishContent: provider.currentQuestion.titleEn ?? "",
|
|
|
|
|
arabicContent: provider.currentQuestion.titleAr ?? "",
|
|
|
|
|
),
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
color: MyColors.darkTextColor,
|
|
|
|
|
fontSize: 15,
|
|
|
|
|
height: 21 / 14,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
24.height,
|
|
|
|
|
const DisclosureAnswerContent(),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
@ -103,25 +119,52 @@ class DisclosureAnswerContent extends StatelessWidget {
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
DisclosureProvider provider = context.watch<DisclosureProvider>();
|
|
|
|
|
return Container(
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 13),
|
|
|
|
|
padding: const EdgeInsets.only(bottom: 20, left: 8, right: 8),
|
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
|
color: MyColors.kWhiteColor,
|
|
|
|
|
borderRadius: BorderRadius.only(
|
|
|
|
|
bottomLeft: Radius.circular(10),
|
|
|
|
|
bottomRight: Radius.circular(10),
|
|
|
|
|
),
|
|
|
|
|
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(10), bottomRight: Radius.circular(10)),
|
|
|
|
|
),
|
|
|
|
|
child: provider.currentQuestion.questionOptions != null
|
|
|
|
|
? Row(
|
|
|
|
|
children: List<Widget>.generate(
|
|
|
|
|
provider.currentQuestion.questionOptions!.length,
|
|
|
|
|
(int index) => Expanded(
|
|
|
|
|
child: DisclosureAnswerTileForText(
|
|
|
|
|
index: index,
|
|
|
|
|
onAnswerTapped: () => provider.updateCurrentQuestionOptionStatus(status: DisclosureQuestionsOptionStatus.selected, selectedOptIndex: index, correctOptionIndex: -1), //
|
|
|
|
|
).paddingAll(8),
|
|
|
|
|
? Column(
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
children: List<Widget>.generate(
|
|
|
|
|
provider.currentQuestion.questionOptions!.length,
|
|
|
|
|
(int index) => Expanded(
|
|
|
|
|
child: DisclosureAnswerTileForText(
|
|
|
|
|
index: index,
|
|
|
|
|
onAnswerTapped: () => provider.updateCurrentQuestionOptionStatus(status: DisclosureQuestionsOptionStatus.selected, selectedOptIndex: index, correctOptionIndex: -1), //
|
|
|
|
|
).paddingAll(8),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
if (provider.currentQuestionSelectionStatus == DisclosureQuestionsOptionStatus.correct && provider.currentQuestionNumber != provider.disclosureDetailsModel.totalQuestions!) ...[
|
|
|
|
|
15.height,
|
|
|
|
|
Text(
|
|
|
|
|
displayLocalizedContent(
|
|
|
|
|
isPhoneLangArabic: AppState().isArabic(context),
|
|
|
|
|
selectedLanguage: (provider.disclosureDetailsModel.selectedLanguage) ?? 0,
|
|
|
|
|
englishContent: provider.currentQuestion.descEn ?? "",
|
|
|
|
|
arabicContent: provider.currentQuestion.descAr ?? "",
|
|
|
|
|
),
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
color: MyColors.darkTextColor,
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
height: 21 / 14,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
).paddingOnly(left: 8, right: 8),
|
|
|
|
|
8.height,
|
|
|
|
|
DynamicTextFieldWidget(
|
|
|
|
|
LocaleKeys.pleaseWriteHere.tr(),
|
|
|
|
|
provider.currentAdditionalText,
|
|
|
|
|
lines: 3,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
provider.updateCurrentAdditionalText(value);
|
|
|
|
|
},
|
|
|
|
|
).paddingOnly(left: 8, right: 8),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: const SizedBox(),
|
|
|
|
|
);
|
|
|
|
|
|