import 'package:get/get.dart';
import 'package:nomo/app/components/protocol_overlay.dart';
import 'package:package_info_plus/package_info_plus.dart';

import '../../../components/country_restricted_overlay.dart';

class SplashController extends GetxController {
  final _showLoading = false.obs;

  bool get showLoading => _showLoading.value;
  set showLoading(bool value) => _showLoading.value = value;

  final _hasLogin = false.obs;

  bool get hasLogin => _hasLogin.value;
  set hasLogin(bool value) => _hasLogin.value = value;

  final _versionName = ''.obs;

  String get versionName => _versionName.value;
  set versionName(String value) => _versionName.value = value;

  @override
  void onInit() {
    super.onInit();
    getVersionInfo();
    Future.delayed(const Duration(seconds: 2), () {
      // Get.offAllNamed(Routes.HOME);
      // Get.to(
      //   () => CountryRestrictedOverlay(type: RestrictedType.network),
      //   transition: Transition.fadeIn,
      // );

      Get.to(() => const ProtocolOverlay(), transition: Transition.fadeIn);
    });
  }

  void getVersionInfo() async {
    // versionCode =
    //     await PackageInfo.fromPlatform().then((value) => value.buildNumber);
    versionName = await PackageInfo.fromPlatform().then(
      (value) => value.version,
    );
  }
}
