import 'package:flutter/cupertino.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hl_lieferservice/feature/authentication/presentation/login_page.dart';

import '../bloc/auth_bloc.dart';
import '../bloc/auth_state.dart';

class LoginEnforcer extends StatelessWidget {
  final Widget child;

  const LoginEnforcer({super.key, required this.child});

  @override
  Widget build(BuildContext context) {
    return BlocBuilder<AuthBloc, AuthState>(
      builder: (context, state) {
        if (state is Authenticated) {
          return child;
        }

        return LoginPage();
      },
    );
  }
}
