// Author: fengshengxiong
// Date: 2024/5/11
// Description: 标题栏

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:hello_wallpaper/generated/assets.dart';
import 'package:hello_wallpaper/res/themes/app_sizes.dart';

class TitleBarWidget extends StatelessWidget {
  const TitleBarWidget(
    this.title, {
    super.key,
    this.showSettingsBtn = true,
    this.settingsOnTap,
  });

  final String title;
  final bool? showSettingsBtn;
  final Function()? settingsOnTap;

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
      child: SizedBox(
        height: titleBarHeight,
        child: Row(
          children: [
            SizedBox(width: 20.w),
            Expanded(
              child: Text(
                title,
                style: TextStyle(
                  color: Colors.white,
                  fontSize: 32.sp,
                  fontWeight: FontWeight.w600,
                ),
              ),
            ),
            if (showSettingsBtn!) ...[
              ClipOval(
                child: Material(
                  color: Colors.transparent,
                  child: InkWell(
                    onTap: settingsOnTap,
                    child: Padding(
                      padding: const EdgeInsets.all(10).w,
                      child: Image.asset(
                        Assets.imagesIcSettings,
                        width: 20.w,
                        height: 20.w,
                      ),
                    ),
                  ),
                ),
              ),
              SizedBox(width: 10.w),
            ],
          ],
        ),
      ),
    );
  }
}
