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

import '../core/themes/theme.dart';

class BottomSheetScaffold extends StatelessWidget {
  final Widget title, body;
  final Widget? footer;

  BottomSheetScaffold({
    required this.title,
    required this.body,
    this.footer,
  });

  @override
  Widget build(BuildContext context) {
    final EdgeInsets mqPadding = MediaQuery.of(context).padding;
    var screenSize = MediaQuery.of(context).size;
    return Container(
      constraints: BoxConstraints(maxHeight: screenSize.height - mqPadding.top),
      padding: EdgeInsets.only(bottom: mqPadding.bottom + 16, left: 16, right: 16),
      decoration: new BoxDecoration(
        color: ThemeColor.white,
        borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
      ),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Center(
            child: Container(
              width: 100,
              height: 8,
              decoration: BoxDecoration(
                color: ThemeColor.mainColor,
                borderRadius: BorderRadius.only(
                  bottomLeft: Radius.circular(8),
                  bottomRight: Radius.circular(8),
                ),
              ),
            ),
          ),
          SizedBox(height: 8.h),
          Container(
            padding: const EdgeInsets.only(bottom: 8),
            child: this.title,
          ),
          AppTheme.appColorDivider,
          Flexible(
            child: SingleChildScrollView(
              child: Column(
                mainAxisSize: MainAxisSize.min,
                children: [
                  Container(
                    padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
                    child: this.body,
                  ),
                ],
              ),
            ),
          ),
          this.footer ?? SizedBox.shrink(),
        ],
      ),
    );
  }
}
