import 'package:flutter/material.dart';
import 'package:niogu_app/core/constants/app_color.dart';
import 'package:niogu_app/core/constants/app_font_size.dart';
import 'package:niogu_app/core/utils/time_zone.dart';
import 'package:sizer/sizer.dart';

class CustomTimePicker extends StatelessWidget {
  final String label;
  final TimeOfDay time;
  final VoidCallback onTap;
  final bool isEnabled;
  const CustomTimePicker({
    super.key,
    required this.label,
    required this.time,
    required this.onTap,
    this.isEnabled = true,
  });

  @override
  Widget build(BuildContext context) {
    final bool isTablet = 100.w >= 600;

    final formattedTime =
        '${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')} ${TimeZone.getCurrentTimeZone()}';

    return InkWell(
      onTap: isEnabled ? onTap : null,
      child: Container(
        padding: EdgeInsets.symmetric(horizontal: 3.w, vertical: 1.8.h),
        decoration: BoxDecoration(
          color: Colors.grey[50],
          borderRadius: BorderRadius.circular(2.5.w),
          border: Border.all(color: Colors.grey.shade300),
        ),
        child: Row(
          children: [
            Icon(
              Icons.access_time,
              color: isEnabled ? AppColor.primaryColor : Colors.grey.shade600,
              size: 5.w,
            ),
            SizedBox(width: 2.w),
            Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  label,
                  style: TextStyle(
                    fontSize: isTablet
                        ? (AppFontSize.medium - 1.25).sp
                        : (AppFontSize.small - 1.25).sp,
                    color: Colors.grey[600],
                  ),
                ),
                Text(
                  formattedTime,
                  style: TextStyle(
                    color: isEnabled ? Colors.black : Colors.grey.shade600,
                    fontSize: isTablet
                        ? (AppFontSize.medium - 1.25).sp
                        : (AppFontSize.small - 1.25).sp,
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
