mirrored_repositories/lifeclass/lib/pages/content/lessons

import 'package:flutter/material.dart';
import 'package:lifeclass/classes/clsRichTextFormatter.dart';
import 'package:lifeclass/classes/Themes.dart';

class ParagraphBoxFormatter extends StatelessWidget {
  final List<clsRichTextFormatter> richTextData;
  const ParagraphBoxFormatter({super.key,required this.richTextData});

  TextSpan getData(clsRichTextFormatter data){
    if(data.bColor!=''){
      return TextSpan(
          text: data.content,
          style: TextStyle(
            backgroundColor: myThemes.getLightColor(data.bColor),
            color:Colors.white,
            fontStyle: data.fontStyle,
            fontWeight: data.fontWeight,
            fontSize: data.fontSize,
          ));
    }else{
      return TextSpan(
          text: data.content,
          style: TextStyle(
            color:  data.isDarkMode ? Colors.white : Colors.black,
            fontStyle: data.fontStyle,
            fontWeight: data.fontWeight,
            fontSize: data.fontSize,
          ));
    }


  }

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.all(10.0),
      child: Container(
        decoration: BoxDecoration(color: (richTextData[0].isDarkMode?Colors.black26: Colors.grey),borderRadius: BorderRadius.circular(15)),
        child: Padding(
          padding: EdgeInsets.fromLTRB(10.0, 10, 10.0, 10.0),
          child: RichText(
              textAlign: TextAlign.justify,
              text: TextSpan(
                  children: richTextData.map((e) => getData(e)).toList()
              )),
        ),
      ),
    );
  }

}
