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

/// 检查小卡片
class ExamCard extends StatelessWidget {
  const ExamCard({
    super.key,
    this.title,
    required this.content,
    this.clickCard,
    this.titleText,
  });
  final String? title;
  final Widget content;
  final Widget? titleText;
  final Function? clickCard;
  @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,
              const SizedBox(
                height: 30,
              )
            ],
          ),
        ),
      ),
    );
  }

  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,
        );
  }
}
