import 'package:flutter/material.dart';
import 'package:rasadyar_app/infrastructure/di/di.dart';
import 'package:rasadyar_chicken/chicken.dart';
import 'package:rasadyar_core/core.dart';

class CustomNavigationObserver extends NavigatorObserver {
  bool _isWorkDone = false;

  void setInjectionDone() {
    _isWorkDone = true;
  }

  @override
  void didPush(Route route, Route? previousRoute) async {
    super.didPush(route, previousRoute);
    final routeName = route.settings.name;
    if (!_isWorkDone && routeName == ChickenRoutes.init) {
      _isWorkDone = true;
      await setupInjection();
    }
  }


  @override
  void didReplace({Route? newRoute, Route? oldRoute}) {
    super.didReplace(newRoute: newRoute, oldRoute: oldRoute);

  }

  @override
  void didPop(Route route, Route? previousRoute) {
    super.didPop(route, previousRoute);

  }

  @override
  void didRemove(Route route, Route? previousRoute) {
    super.didRemove(route, previousRoute);
  }
}
