import 'package:get/get.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:trans_lark/router/router.dart';

class SettingsController extends GetxController {
  var versionName = ''.obs;
  // var options = ['Feedback', 'Privacy Policy', 'User Agreement'];
  var options = ['Privacy Policy', 'User Agreement'];

  @override
  void onReady()  {
    super.onReady();
    _getVersion();
  }

  /// 获取版本号
  void _getVersion() async {
    final packageInfo = await PackageInfo.fromPlatform();
    versionName.value = 'version number ${packageInfo.version}';
  }

  void itemOnTap(int index) {
    if (index == -1) {

    } else if (index == 0) {
      Get.toNamed(GetRouter.privacy, arguments: {
        'title': options[index],
        'url': 'https://translark.bitbucket.io/privacy.html',
      });
    } else if (index == 1) {
      Get.toNamed(GetRouter.privacy, arguments: {
        'title': options[index],
        'url': 'https://translark.bitbucket.io/terms.html',
      });
    }
  }
}
