import 'package:flutter/material.dart';
import 'package:grocery_app/src/core/network_services/service_locator.dart';
import 'package:grocery_app/src/data/user_profile.dart';
import 'package:grocery_app/src/logic/repo/product_repo.dart';
import 'package:grocery_app/utils/constants/shared_pref_utils.dart';
import 'package:grocery_app/utils/constants/string_constant.dart';

class BottomNavProvider with ChangeNotifier {
  int _currentIndex = 0;
  PageController _pageController = PageController();

  int get currentIndex => _currentIndex;
  PageController get pageController => _pageController;

  void setIndex(int index) {
    _currentIndex = index;
    _pageController.jumpToPage(index);
    notifyListeners();
  }
  final _homeRepo = getIt<ProductRepo>();
 
  Future<bool> refreshToken(BuildContext context) async {
    var data = {"refresh_token": "${await SharedPrefUtils.getRefreshToken()}"};

    var result = await _homeRepo.refreshToken(data, context);
    return result.fold(
      (error) {
        return true;
      },
      (response) {
        return true;
      },
    );
  }
}
