import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:wallpaperx/res/themes/app_colors.dart';

class NestedBottomBar extends StatelessWidget implements PreferredSizeWidget {
  const NestedBottomBar(
    this.title, {
    super.key,
    this.backgroundColor,
    this.backWidget,
    this.titleStyle,
    this.onBackTap,
  });

  final Color? backgroundColor;
  final Widget? backWidget;
  final String title;
  final TextStyle? titleStyle;
  final Function()? onBackTap;

  @override
  Widget build(BuildContext context) {
    return Container(
      height: preferredSize.height,
      padding: EdgeInsets.fromLTRB(16, ScreenUtil().statusBarHeight, 16, 0).w,
      color: backgroundColor ?? seedColor,
      child: Row(
        children: [
          Expanded(
            child: Text(
              title,
              maxLines: 1,
              overflow: TextOverflow.ellipsis,
              style: titleStyle ??
                  TextStyle(
                    color: Colors.black,
                    fontSize: 20.sp,
                    fontWeight: FontWeight.w500,
                  ),
            ),
          ),
          backWidget ??
              ClipOval(
                child: Material(
                  color: Colors.transparent,
                  child: InkWell(
                    onTap: onBackTap ?? () {
                      Get.back();
                    },
                    child: Icon(Icons.close,color: Colors.white,size: 24.sp),
                  ),
                ),
              ),
        ],
      ),
    );
  }

  @override
  Size get preferredSize => Size.fromHeight(ScreenUtil().statusBarHeight + kToolbarHeight);
}
