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

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

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

  final String title;
  final 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,
          children: [
            Text(
              title,
              style: theme.currentThemeData.textTheme.labelMedium,
            ),
            theme.verticalSpacerSmall,
            Text(
              text!,
              style: theme.bodyMedium,
            ),
          ],
        ),
      ),
    );
  }
}
