import 'package:cims_apps/application/theme/color_palette.dart';
import 'package:flutter/material.dart';

class SeeMoreLessWidget extends StatelessWidget {
  final String? textData;
  final int? type; /* type 1 - See More | 2 - See Less */
  final Function? onSeeMoreLessTap;
  final int?
  section; /* 1: About the course | 2 - Who can take up this course? | 3 - Mentors | 4 - Course Video Reviews */
  final Alignment? alignment;
  final bool hideTextMore;
  final bool hideIconMore;

  const SeeMoreLessWidget({
    super.key,
    required this.textData,
    required this.type,
    required this.onSeeMoreLessTap,
    required this.section,
    required this.alignment,
    required this.hideTextMore,
    required this.hideIconMore,
  });

  @override
  Widget build(BuildContext context) {
    return Align(
      alignment: alignment ?? Alignment.centerLeft,
      child: InkWell(
        onTap: () {
          if (onSeeMoreLessTap != null) {
            onSeeMoreLessTap!();
          }
        },
        child: Text.rich(
          softWrap: true,
          style: const TextStyle(
            color: ColorPalette.primary,
          ),
          textAlign: TextAlign.start,
          TextSpan(
            text: "",
            children: [
              if(!hideTextMore)
                TextSpan(
                  text: textData,
                  style: const TextStyle(
                      color: ColorPalette.primary,
                      decoration: TextDecoration.underline,
                  ),
                ),
              if(!hideTextMore && !hideIconMore)
                const WidgetSpan(
                  child: SizedBox(
                    width: 3.0,
                  ),
                ),
              if(!hideIconMore)
                WidgetSpan(
                  child: Icon(
                    (type == 1)
                        ? Icons.keyboard_arrow_down
                        : Icons.keyboard_arrow_up,
                    color: ColorPalette.slate300,
                    size: 28,
                  ),
                ),
            ],
          ),
        ),
      ),
    );
  }
}