import 'package:expansion_tile_card/expansion_tile_card.dart';
import 'package:flutter/material.dart';

import '../../../../../packages/ambito_theme/ambito_theme.dart';
import '../../measure_detail_page.dart';

class SublevelUnorderedListCard extends StatelessWidget {
  const SublevelUnorderedListCard({
    super.key,
    required this.title,
    required this.text,
  });

  final String title;
  final List<String>? text;

  @override
  Widget build(BuildContext context) {
    if (text == null) {
      return const SizedBox();
    }

    final AmbitoTheme theme = getTheme(context);

    globalKeys.putIfAbsent(title, () => GlobalKey<ExpansionTileCardState>());

    return Align(
      alignment: Alignment.topLeft,
      child: Padding(
        padding: const EdgeInsets.only(right: 20, bottom: 20),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            Text(
              title,
              style: theme.currentThemeData.textTheme.labelMedium,
            ),
            ...text!.map(
              (item) => Row(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  const Align(
                    alignment: Alignment.center,
                    child: Icon(Icons.circle, size: 4),
                  ),
                  theme.horizontalSpacerSmall,
                  Expanded(
                    child: Text(
                      item,
                      softWrap: true,
                      maxLines: 2,
                      style: theme.bodyMedium,
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
