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

import '../../constant/colors.dart';
import '../../constant/style.dart';

class MyScafolld extends StatelessWidget {
  const MyScafolld({
    super.key,
    required this.title,
    required this.body,
    this.action,
    required this.isleading,
  });

  final String title;
  final List<Widget> body;
  final Widget? action;
  final bool isleading;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: AppColor.bg,
        appBar: AppBar(
          backgroundColor: AppColor.bg,
          elevation: 0,
          leadingWidth: 70,
          leading: isleading
              ? Center(
                  child: Container(
                    margin: const EdgeInsets.only(right: 16),
                    decoration: BoxDecoration(
                      color: AppColor.surfaceElevated,
                      borderRadius: BorderRadius.circular(12),
                      border: Border.all(color: AppColor.divider),
                    ),
                    child: IconButton(
                      onPressed: () => Get.back(),
                      icon: const Icon(
                        Icons.arrow_back_ios_new_rounded,
                        color: AppColor.textPrimary,
                        size: 18,
                      ),
                    ),
                  ),
                )
              : null,
          actions: [
            if (action != null) action!,
            const SizedBox(width: 16),
          ],
          title: Text(
            title,
            style: AppStyle.headTitle,
          ),
        ),
        body: SafeArea(child: Stack(children: body)));
  }
}
