import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:tanami_app/features/otpVerification/presentation/bloc/otp_bloc.dart';
import 'package:tanami_app/features/otpVerification/presentation/pages/otp_layout.dart';

import '../../../../core/styles/app_color.dart';
import '../bloc/otp_event.dart';
import '../bloc/timer/timer_bloc.dart';
import '../bloc/timer/timer_event.dart';

class OtpScreen extends StatelessWidget {
  final String fromScreen;
  const OtpScreen({
    super.key,
    required this.fromScreen,
  });

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: AppColor.plainWhite,
      resizeToAvoidBottomInset: true,
      body: MultiBlocProvider(
        providers: [
          BlocProvider(
            // Create an instance of the OnboardingBloc
            create: (context) => OtpBloc()..add(StartListeningForOtp()),
          ),
          BlocProvider(
            create: (context) =>
                TimerBloc()..add(StartTimer()), // Start the timer here
          ),
        ],
        child: OtpLayout(fromScreen: fromScreen),
      ),
    );
  }
}
