import 'package:flutter/material.dart';
import 'package:fotodocumentation/utils/di_container.dart';
import 'package:fotodocumentation/utils/jwt_token_storage.dart';

abstract class LoginCredentials extends ChangeNotifier {
  String get fullname;
  bool get isLoggedIn;

  void setLoggedIn(bool loggedIn);
  void logout();
}

class LoginCredentialsImpl extends LoginCredentials {
  JwtTokenStorage get jwtTokenStorage => DiContainer.get();

  bool loggedIn = false;

  @override
  bool get isLoggedIn => loggedIn;
  @override
  String get fullname => "";

  @override
  void setLoggedIn(bool loggedIn) {
    this.loggedIn = loggedIn;
  }

  @override
  void logout() {
    loggedIn = false;

    jwtTokenStorage.clearTokens;
    notifyListeners();
  }
}
