import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/modules/cm_module/cm_request_utils.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/views/widgets/total_working_time_detail_bottomsheet.dart';

class WorkingTimeTile extends StatelessWidget {
  final List<TimerHistoryModel> timerList;
  final double totalWorkingTime;
  final String title;

  const WorkingTimeTile({
    Key? key,
    required this.timerList,
    required this.totalWorkingTime,
    this.title = "Total Working Time",
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 56.toScreenHeight,
      padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth),
      alignment: Alignment.centerLeft,
      decoration: BoxDecoration(
        color: AppColor.disableFieldBackground(context),
        borderRadius: BorderRadius.circular(10),
        // boxShadow: [
        //   BoxShadow(
        //     color: Colors.black.withOpacity(0.05),
        //     blurRadius: 10,
        //   )
        // ],
      ),
      child: Row(
        children: [
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisAlignment: MainAxisAlignment.center,
            mainAxisSize: MainAxisSize.min,
            children: [

              Text(
                title,
                style: Theme.of(context).textTheme.bodySmall?.copyWith(
                      color: context.isDark ? null : AppColor.neutral20,
                      fontWeight: FontWeight.w500,
                    ),
              ),
              Text(
                " ${CMRequestUtils.formatTotalWorkingHours(totalWorkingTime)}",
                style: Theme.of(context).textTheme.bodyMedium,
              ),
            ],
          ).expanded,
          8.width,
          const Icon(Icons.info_outline_rounded, color: AppColor.primary10),
        ],
      ),
    ).onPress(() async {
      await showModalBottomSheet(
        context: context,
        useSafeArea: true,
        isScrollControlled: true,
        isDismissible: true,
        backgroundColor: AppColor.bottomSheetColor(context),
        builder: (BuildContext context) => TotalWorkingTimeDetailBottomSheet(timerList: timerList).bottomSheetContainer(context),
      );
    });
  }
}
