mirrored_repositories/lifeclass/lib/pages/content/lessons
import 'package:flutter/material.dart';
import 'package:lifeclass/classes/clsApp.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../../../classes/clsRichTextFormatter.dart';
import '../../../../classes/sql/clsSqlLesson.dart';
import 'package:lifeclass/pages/content/lessons/classes/clsLanguageSelector.dart';
import 'package:lifeclass/classes/sql/sqlHelper.dart';
import 'package:lifeclass/classes/Themes.dart';
import '../../../../models/modelDailyVerse.dart';
import '../../../../widgets/ads/BannerAds.dart';
import '../components/ParagraphCenterCenterFormatter.dart';
import '../components/ParagraphFormatter.dart';
class LessonQuestionnaire28 extends StatefulWidget {
  const LessonQuestionnaire28({super.key});
  @override
  State<LessonQuestionnaire28> createState() => _LessonQuestionnaire28State();
}

class _LessonQuestionnaire28State extends State<LessonQuestionnaire28> {
  late String colorTheme=clsApp.defaultColorThemes;
  late double fontSize=16;
  late String language = clsApp.defaultLanguage;
  clsSqlLesson? lessonData;
  modelDailyVerse? dailyVerseData;
  final int lessonID = 28;
  late String createdDt = '';
  late String content = '';
  late int maxAnswers=0;
  late int completionRate=0;
  late int _currentFontSize = 1;
  List<double> availableFontSize = [10,12,16,18,20,24,28,32];
  @override
  void initState() {
    super.initState();
    initTheme();
    loadData();
  }
  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
  }
  void initTheme() async {
    final SharedPreferences prefs = await SharedPreferences.getInstance();
    setState(() {
      colorTheme = prefs.getString('colorThemes') ?? clsApp.defaultColorThemes;
      _currentFontSize = prefs.getInt('fontSize') ?? 1;
      language = prefs.getString('language') ?? clsApp.defaultLanguage;
      fontSize = availableFontSize[_currentFontSize];
    });
  }
  void loadData() async{
    lessonData = await sqlHelper.getLessonByID(lessonID);
    dailyVerseData = await sqlHelper.getDailyVerseByID(lessonID);
    maxAnswers = lessonData!.maxAnswers;
    completionRate = lessonData!.completionRate;
    createdDt = lessonData!.createdDt;
  }
  void openDailyVerse(int dailyVerseID, String content, String title){
    Navigator.of(context).pushNamed('/DailyVerseDetails', arguments: {
      'dailyVerseID': dailyVerseID.toString(),
      'content': content,
      'title' : title
    });
  }

  @override
  Widget build(BuildContext context) {
    var brightness = MediaQuery.of(context).platformBrightness;
    bool isDarkMode = brightness == Brightness.dark;

    List<clsRichTextFormatter> question_01 = [
      clsRichTextFormatter(content: clsWeek04Lesson28.question_01(language), fontStyle: FontStyle.normal, fontWeight: FontWeight.normal, bColor: '', fontSize: fontSize, isDarkMode: isDarkMode),
     ];

    List<clsRichTextFormatter> answer_01_01 = [
      clsRichTextFormatter(content: clsWeek04Lesson28.answer_01_01(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, bColor: '', fontSize: fontSize, isDarkMode: isDarkMode),
      clsRichTextFormatter(content: clsWeek04Lesson28.answer_01_02(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, color: colorTheme, fontSize: fontSize, isDarkMode: isDarkMode),
      clsRichTextFormatter(content: clsWeek04Lesson28.answer_01_03(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, bColor: '', fontSize: fontSize, isDarkMode: isDarkMode),
    ];
    List<clsRichTextFormatter> answer_02_01 = [
      clsRichTextFormatter(content: clsWeek04Lesson28.answer_02_01(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, bColor: '', fontSize: fontSize, isDarkMode: isDarkMode),
      clsRichTextFormatter(content: clsWeek04Lesson28.answer_02_02(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, color: colorTheme, fontSize: fontSize, isDarkMode: isDarkMode),
      clsRichTextFormatter(content: clsWeek04Lesson28.answer_02_03(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, bColor: '', fontSize: fontSize, isDarkMode: isDarkMode),
      clsRichTextFormatter(content: clsWeek04Lesson28.answer_02_04(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, color: colorTheme, fontSize: fontSize, isDarkMode: isDarkMode),
    ];
    List<clsRichTextFormatter> answer_03_01 = [
      clsRichTextFormatter(content: clsWeek04Lesson28.answer_03_01(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, bColor: '', fontSize: fontSize, isDarkMode: isDarkMode),
      clsRichTextFormatter(content: clsWeek04Lesson28.answer_03_02(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, color: colorTheme, fontSize: fontSize, isDarkMode: isDarkMode),
      clsRichTextFormatter(content: clsWeek04Lesson28.answer_03_03(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, bColor: '', fontSize: fontSize, isDarkMode: isDarkMode),
      clsRichTextFormatter(content: clsWeek04Lesson28.answer_03_04(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, color: colorTheme, fontSize: fontSize, isDarkMode: isDarkMode),
      clsRichTextFormatter(content: clsWeek04Lesson28.answer_03_05(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, bColor: '', fontSize: fontSize, isDarkMode: isDarkMode),
    ];
    List<clsRichTextFormatter> answer_04_01 = [
      clsRichTextFormatter(content: clsWeek04Lesson28.answer_04_01(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, bColor: '', fontSize: fontSize, isDarkMode: isDarkMode),
      clsRichTextFormatter(content: clsWeek04Lesson28.answer_04_02(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, color: colorTheme, fontSize: fontSize, isDarkMode: isDarkMode),
      clsRichTextFormatter(content: clsWeek04Lesson28.answer_04_03(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, bColor: '', fontSize: fontSize, isDarkMode: isDarkMode),
      clsRichTextFormatter(content: clsWeek04Lesson28.answer_04_04(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, color: colorTheme, fontSize: fontSize, isDarkMode: isDarkMode),
      clsRichTextFormatter(content: clsWeek04Lesson28.answer_04_05(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, bColor: '', fontSize: fontSize, isDarkMode: isDarkMode),
    ];
    List<clsRichTextFormatter> answer_05_01 = [
      clsRichTextFormatter(content: clsWeek04Lesson28.answer_05_01(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, bColor: '', fontSize: fontSize, isDarkMode: isDarkMode),
      clsRichTextFormatter(content: clsWeek04Lesson28.answer_05_02(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, color: colorTheme, fontSize: fontSize, isDarkMode: isDarkMode),
      clsRichTextFormatter(content: clsWeek04Lesson28.answer_05_03(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, bColor: '', fontSize: fontSize, isDarkMode: isDarkMode),
      clsRichTextFormatter(content: clsWeek04Lesson28.answer_05_04(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, color: colorTheme, fontSize: fontSize, isDarkMode: isDarkMode),
      clsRichTextFormatter(content: clsWeek04Lesson28.answer_05_05(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, bColor: '', fontSize: fontSize, isDarkMode: isDarkMode),
      clsRichTextFormatter(content: clsWeek04Lesson28.answer_05_06(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, color: colorTheme, fontSize: fontSize, isDarkMode: isDarkMode),
      clsRichTextFormatter(content: clsWeek04Lesson28.answer_05_07(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, bColor: '', fontSize: fontSize, isDarkMode: isDarkMode),
    ];

    List<clsRichTextFormatter> remember_the_lesson = [
      clsRichTextFormatter(content: clsWeek04Lesson28.remember_the_lesson(language), fontStyle: FontStyle.italic, fontWeight: FontWeight.bold, bColor: '', fontSize: fontSize, isDarkMode: isDarkMode),
      clsRichTextFormatter(content: '', fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, bColor: colorTheme, fontSize: fontSize, isDarkMode: isDarkMode),
    ];
    List<clsRichTextFormatter> study_the_word = [
      clsRichTextFormatter(content: clsWeek04Lesson28.study_the_word(language), fontStyle: FontStyle.normal, fontWeight: FontWeight.normal, bColor: '', fontSize: fontSize, isDarkMode: isDarkMode),
      clsRichTextFormatter(content: '', fontStyle: FontStyle.italic, fontWeight: FontWeight.normal, bColor: colorTheme, fontSize: fontSize, isDarkMode: isDarkMode),
    ];

    return Scaffold(
      appBar: AppBar(
        title: Text(clsLanguagePreset.app_bar_label_questionnaire(language) + ' ' + lessonID.toString()),
        backgroundColor: myThemes.getColor(colorTheme),
      ),
     body: SafeArea(
        child: Column(
          children: [Expanded(
            child: RawScrollbar(
              child: SingleChildScrollView(
                child: SafeArea(
                  child: Column(
                    mainAxisSize: MainAxisSize.max,
                    mainAxisAlignment: MainAxisAlignment.start,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Center(child: Image.asset('assets/images/live_the_lessons.png')),
                      Divider(),
                      ParagraphFormatter(richTextData: question_01),

                      Row(
                        children: [
                          Expanded(flex: 6,child: ParagraphFormatter(richTextData: answer_01_01)),
                          Expanded(flex: 4,child: Image.asset('assets/images/week_4_days_28_answer_1.jpg')),
                        ],
                      ),
                      Row(
                        children: [
                          Expanded(flex: 5,child: ParagraphFormatter(richTextData: answer_02_01)),
                          Expanded(flex: 4,child: Image.asset('assets/images/week_4_days_28_answer_2.jpg')),
                          Expanded(flex: 1,child: SizedBox(width: 10,)),
                        ],
                      ),
                      Row(
                        children: [
                          Expanded(flex: 4,child: ParagraphFormatter(richTextData: answer_03_01)),
                          Expanded(flex: 4,child: Image.asset('assets/images/week_4_days_28_answer_3.jpg')),
                          Expanded(flex: 2,child: SizedBox(width: 10,)),
                        ],
                      ),
                      Row(
                        children: [
                          Expanded(flex: 5,child: ParagraphFormatter(richTextData: answer_04_01)),
                          Expanded(flex: 4,child: Image.asset('assets/images/week_4_days_28_answer_4.jpg')),
                          Expanded(flex: 1,child: SizedBox(width: 10,)),
                        ],
                      ),
                      Row(
                        children: [
                          Expanded(flex: 6,child: ParagraphFormatter(richTextData: answer_05_01)),
                          Expanded(flex: 4,child: Image.asset('assets/images/week_4_days_28_answer_5.jpg')),
                        ],
                      ),

                      Center(child: Image.asset('assets/images/remember_the_lesson.png')),
                      Divider(),
                      ParagraphCenterCenterFormatter(richTextData: remember_the_lesson, marginGap: 50),
                      Center(child: Image.asset('assets/images/study_the_word.png')),
                      Divider(),
                      ParagraphCenterCenterFormatter(richTextData: study_the_word, marginGap: 50),
                      SizedBox(width: 0, height: 30,),
                      Center(child: Padding(padding: EdgeInsets.all(10.0), child: ElevatedButton.icon(icon: Icon(Icons.open_in_new), onPressed: () {openDailyVerse(lessonID, dailyVerseData!.content.toString(), 'DAY ' + lessonID.toString());}, style: ButtonStyle(backgroundColor: MaterialStateProperty.all(myThemes.getColor(colorTheme))), label: Padding(padding: EdgeInsets.all(15), child: Text(clsLanguagePreset.button_open_daily_readings(language))),))),
                      SizedBox(width: 0, height: 100,),
                    ],
                  ),
                ),
              ),
            ),
          ),
            BannerAds()
          ],
        ),
      ),
    );
  }
}
