import 'package:boilerplate/core/utils/navigator_util.dart';
import 'package:boilerplate/core/utils/shared_preferences_util.dart';
import 'package:boilerplate/domain/entities/flavor/flavor_data.dart';
import 'package:boilerplate/presentation/screen/web_view/web_view_screen.dart';
import 'package:flutter/foundation.dart';

import '../di/injection_init.dart';

class AuthenticationUtil {
  static checkHasUser(VoidCallback callback) {
    final _pref = getIt.get<SharedPreferencesUtil>();
    final _flavor = getIt.get<AppFlavorData>();

    if (_pref.getInt(SharedPreferencesUtil.keyUserId) != null) {
      callback();
      // print("callBack =${callback}");
    } else {
      NavigatorUtil.pushToPage(
        WebViewScreen(
          url: _flavor.webDomain + '/login?mobile=1&lang=${_pref.getString('lang')}',
          title: 'ลงชื่อเข้าใช้',
        ),
      );
    }
  }
}
