import 'package:injectable/injectable.dart';
import 'package:connectivity_plus/connectivity_plus.dart';

/// Interface pour vérifier la connectivité réseau
abstract class NetworkInfo {
  Future<bool> get isConnected;
}

/// Implémentation de NetworkInfo utilisant connectivity_plus
@LazySingleton(as: NetworkInfo)
class NetworkInfoImpl implements NetworkInfo {
  final Connectivity connectivity;

  NetworkInfoImpl(this.connectivity);

  @override
  Future<bool> get isConnected async {
    final result = await connectivity.checkConnectivity();
    return result.any((r) => r != ConnectivityResult.none);
  }
}
