import 'package:checker/base/base_screen.dart';
import 'package:checker/base/settings_base_state.dart';
import 'package:checker/db.dart';
import 'package:flutter/material.dart';
import 'package:checker/strings.dart';

class CurrenciesScreen extends BaseScreen {

  CurrenciesScreen(helper, app) : super(helper, app);

  @override State createState() => new _CurrenciesState(helper, app);
}

class _CurrenciesState extends SettingsBaseState<CurrenciesScreen> {

  List<int> currencies = const [643, 840, 980, 978, 398];

  _CurrenciesState(SqliteHelper helper, String app) : super(helper, app);


  @override
  List<String> getOptions() {

    String ruble = StringsLocalization.nominativeRuble();
    String dollar = StringsLocalization.nominativeDollar();
    String hryvna = StringsLocalization.nominativeHryvna();
    String euro = StringsLocalization.nominativeEuro();
    String tenge = StringsLocalization.nominativeTenge();

    return [ruble, dollar, hryvna, euro, tenge];
  }

  @override
  void getSelectedValue() {
    helper.getCurrency().then((currency) {
      setState(() {
        selectedItem = currencies.indexOf(currency);
      });
    });
  }

  @override
  String getTitle() {
    return StringsLocalization.settings();
  }

  @override
  saveOption() async {
    await helper.saveCurrency(currencies[selectedItem]);
  }
}