import 'package:flutter/material.dart';
import 'package:utils/src/size_utils.dart';

class PageLayout extends StatelessWidget{

  final String title;
  final Widget body;
  final Widget? footer;
  final bool showEdit;
  final VoidCallback? onEditChange;

  const PageLayout({
    super.key,
    required this.title,
    required this.body,
    this.footer,
    this.showEdit = false,
    this.onEditChange
  });

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: SafeArea(
        child: Column(
          children: [
            Container(
              padding: SizeUtils.getByScreen(
                small: EdgeInsets.fromLTRB(22, 20, 22, 0),
                big: EdgeInsets.fromLTRB(21, 16, 21, 0),
              ),
              child: Stack(
                children: [
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      IconButton(onPressed: () {Navigator.pop(context);},
                        icon: Icon(Icons.arrow_back,
                          color: Color(0xFF588EA5),
                          size: 32,
                        ),
                        padding: EdgeInsets.zero,
                      ),
                      if (showEdit)
                        DecoratedBox(
                          decoration: BoxDecoration(
                              color: Color(0xFF588EA5),
                              shape: BoxShape.circle
                          ),
                          child: IconButton(onPressed: onEditChange,
                              icon: Icon(Icons.edit_outlined,
                                color: Colors.white,
                                size: SizeUtils.getByScreen(small: 30, big: 28),
                              )
                          ),
                        )
                    ],
                  ),
                  SizedBox(
                    height: 50,
                    child: Center(
                      child: Text(title.toUpperCase(),
                        style: TextStyle(
                          fontSize: SizeUtils.getByScreen(small: 20, big: 19),
                          fontWeight: FontWeight.w500,
                          letterSpacing: 0,
                          color: Color(0xFF588EA5)
                        ),
                      )
                    )
                  )
                ],
              ),
            ),
            SizedBox(height: SizeUtils.getByScreen(small: 30, big: 28)),
            Expanded(child: body),
            ?footer
          ],
        )
      ),
    );
  }

}