import 'package:chat/routes/app_routes.dart';
import 'package:chat/routes/auth_routes.dart';
import 'package:chat/services/auth_service.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class EnsureAuthMiddleware extends GetMiddleware {
  @override
  int? get priority => -1;

  @override
  RouteSettings? redirect(String? route) {
    if (!AuthService.to.isUserLogin) {
      return const RouteSettings(name: AuthRoutes.index);
    }
    return null;
  }
}

class EnsureNotAuthMiddleware extends GetMiddleware {
  @override
  int? get priority => -1;

  @override
  RouteSettings? redirect(String? route) {
    if (AuthService.to.isUserLogin) {
      return const RouteSettings(name: AppRoutes.home);
    }
    return null;
  }
}
