import 'package:fis_ui/base_define/page.dart';
import 'package:fis_ui/index.dart';
import 'package:flutter/material.dart';

class FCustomCard extends StatelessWidget implements FPage {
  final String title;
  final FWidget? line2;
  final FWidget? line3;
  final FWidget? line4;
  final FWidget? operateButtons;
  final void Function()? onTap;

  @override
  String get pageName => "FCustomCard";

  FCustomCard({
    required this.title,
    this.line2,
    this.line3,
    this.line4,
    this.operateButtons,
    this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return FGestureDetector(
      onTap: onTap,
      businessParent: this,
      name: 'FCustomCard Tap',
      child: FContainer(
        margin: EdgeInsets.symmetric(vertical: 10),
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(8),
          boxShadow: [
            BoxShadow(
              color: Colors.grey.withOpacity(0.5),
              spreadRadius: 1,
              blurRadius: 6,
              offset: Offset(0, 3),
            ),
          ],
        ),
        padding: EdgeInsets.symmetric(horizontal: 15, vertical: 10),
        child: FColumn(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            FText(
              title,
              style: TextStyle(
                fontSize: 18,
                fontWeight: FontWeight.bold,
              ),
            ),
            if (line2 != null) ...[
              _columnSpacing(),
              line2!,
              _columnSpacing(),
            ],
            if (line3 != null) ...[
              line3!,
              _columnSpacing(),
            ],
            if (line4 != null) ...[
              line4!,
              _columnSpacing(),
            ],
            if (operateButtons != null) ...[
              FDivider(
                height: 1,
                color: Colors.grey[300],
              ),
              _columnSpacing(),
              operateButtons!,
            ],
          ],
        ),
      ),
    );
  }

  FWidget _columnSpacing() {
    return const FSizedBox(height: 5);
  }
}
