import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:krow/features/shifts/domain/blocs/complete_dialog/shift_complete_dialog_bloc.dart';
import 'package:krow/features/shifts/domain/blocs/complete_dialog/shift_complete_dialog_event.dart';
import 'package:krow/features/shifts/presentation/dialogs/complete_dialog/widgets/complete_dialog_view.dart';

//TODO(Artem: create widgets instead helper methods. Add initial break time values.Move reasons to state. Create Time slots validator.)
class ShiftCompleteDialog {
  static Future<Map<String, dynamic>?> showCustomDialog(BuildContext context,
      bool canSkip, String eventName, DateTime minLimit, int breakDurationInMinutes) async {
    return showDialog<Map<String, dynamic>>(
      barrierDismissible: canSkip,
      context: context,
      builder: (context) => BlocProvider(
        create: (_) => CompleteDialogBloc()
          ..add(
            InitializeCompleteDialog(
              minLimit: minLimit,
              breakDurationInMinutes:breakDurationInMinutes , // Default break duration
            ),
          ),
        child: CompleteDialogView(
          canSkip: canSkip,
          eventName: eventName,
        ),
      ),
    );
  }
}

class ClockOutDetails {
  final String? breakStartTime;
  final String? breakEndTime;
  final String? reason;
  final String? additionalReason;

  ClockOutDetails._(
      {this.breakStartTime,
      this.breakEndTime,
      this.reason,
      this.additionalReason});

  factory ClockOutDetails.positive(String breakStartTime, String breakEndTime) {
    return ClockOutDetails._(
      breakStartTime: breakStartTime,
      breakEndTime: breakEndTime,
    );
  }

  factory ClockOutDetails.negative(String reason, String additionalReason) {
    return ClockOutDetails._(
      reason: reason,
      additionalReason: additionalReason,
    );
  }

  factory ClockOutDetails.empty() {
    return ClockOutDetails._();
  }
}
