|
|
|
|
import 'package:appinio_swiper/appinio_swiper.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:lottie/lottie.dart';
|
|
|
|
|
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/string_extensions.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/models/disclosure/disclosure_question_model.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/ui/disclosure/disclosure_provider.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
class DisclosureQuestionCard extends StatelessWidget {
|
|
|
|
|
const DisclosureQuestionCard({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
DisclosureProvider provider = context.read<DisclosureProvider>();
|
|
|
|
|
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,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class DisclosureCardContent extends StatelessWidget {
|
|
|
|
|
const DisclosureCardContent({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
DisclosureProvider provider = context.watch<DisclosureProvider>();
|
|
|
|
|
return Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
|
color: CupertinoColors.white,
|
|
|
|
|
boxShadow: <BoxShadow>[
|
|
|
|
|
BoxShadow(
|
|
|
|
|
color: CupertinoColors.systemGrey.withOpacity(0.2),
|
|
|
|
|
spreadRadius: 3,
|
|
|
|
|
blurRadius: 7,
|
|
|
|
|
offset: const Offset(0, 3),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
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),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: Center(
|
|
|
|
|
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,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const DisclosureAnswerContent(),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class DisclosureAnswerContent extends StatelessWidget {
|
|
|
|
|
const DisclosureAnswerContent({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
DisclosureProvider provider = context.watch<DisclosureProvider>();
|
|
|
|
|
return Container(
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 13),
|
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
|
color: MyColors.kWhiteColor,
|
|
|
|
|
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),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: const SizedBox(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class DisclosureAnswerTileForText extends StatelessWidget {
|
|
|
|
|
final int index;
|
|
|
|
|
final Function() onAnswerTapped;
|
|
|
|
|
|
|
|
|
|
const DisclosureAnswerTileForText({Key? key, required this.index, required this.onAnswerTapped}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
Color getAnswerTextColor(DisclosureQuestionsOptionStatus status) {
|
|
|
|
|
switch (status) {
|
|
|
|
|
case DisclosureQuestionsOptionStatus.correct:
|
|
|
|
|
return MyColors.white;
|
|
|
|
|
case DisclosureQuestionsOptionStatus.wrong:
|
|
|
|
|
return MyColors.white;
|
|
|
|
|
case DisclosureQuestionsOptionStatus.selected:
|
|
|
|
|
return MyColors.white;
|
|
|
|
|
case DisclosureQuestionsOptionStatus.unSelected:
|
|
|
|
|
return MyColors.darkTextColor;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
DisclosureProvider provider = context.watch<DisclosureProvider>();
|
|
|
|
|
return InkWell(
|
|
|
|
|
onTap: () => onAnswerTapped(),
|
|
|
|
|
child: Container(
|
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
|
decoration: MyDecorations.getAnswersContainerColorForDisclosure(
|
|
|
|
|
provider.currentQuestion.questionOptions![index].optionStatus!,
|
|
|
|
|
isLastQuestion: provider.currentQuestionNumber == provider.disclosureDetailsModel.totalQuestions!,
|
|
|
|
|
isAgreeSelected: provider.selectedOptionIndex == 0,
|
|
|
|
|
),
|
|
|
|
|
child: Center(
|
|
|
|
|
child: displayLocalizedContent(
|
|
|
|
|
isPhoneLangArabic: AppState().isArabic(context),
|
|
|
|
|
selectedLanguage: (provider.disclosureDetailsModel.selectedLanguage) ?? 0,
|
|
|
|
|
englishContent: provider.currentQuestion.questionOptions![index].titleEn ?? "",
|
|
|
|
|
arabicContent: provider.currentQuestion.questionOptions![index].titleAr ?? "",
|
|
|
|
|
).toText16(color: getAnswerTextColor(provider.currentQuestion.questionOptions![index].optionStatus!)).paddingOnly(top: 13, bottom: 13),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|