import 'package:flutter/material.dart';
import 'package:vitalapp/consts/styles.dart';

/// 检查小卡片
class ExamCard extends StatelessWidget {
  const ExamCard({
    super.key,
    this.title,
    required this.content,
    this.clickCard,
    this.titleText,
    this.bottomPadding = 30,
  });
  final String? title;
  final Widget content;
  final Widget? titleText;
  final Function? clickCard;
  final double bottomPadding;
  @override
  Widget build(BuildContext context) {
    return Card(
      elevation: 6,
      shape: RoundedRectangleBorder(
        borderRadius: GlobalStyles.borderRadius,
      ),
      child: Material(
        color: Colors.white,
        borderRadius: GlobalStyles.borderRadius,
        child: InkWell(
          borderRadius: GlobalStyles.borderRadius,
          onTap: clickCard != null ? () => clickCard!.call() : null,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              _buildTitle(),
              content,
              SizedBox(
                height: bottomPadding,
              )
            ],
          ),
        ),
      ),
    );
  }

  Widget _buildTitle() {
    Widget titleContent = const SizedBox();
    if (title?.isNotEmpty ?? false) {
      titleContent = Text(
        title!,
        style: const TextStyle(fontSize: 25),
      );
    }
    return titleText ??
        Container(
          padding: const EdgeInsets.only(
            top: 20,
            left: 30,
            bottom: 15,
          ),
          child: titleContent,
        );
  }
}
