import 'package:aman_kassa_flutter/core/models/bluetooth_device.dart';
import 'package:aman_kassa_flutter/redux/constants/setting_const.dart';
import 'package:aman_kassa_flutter/redux/state/setting_state.dart';
import 'package:meta/meta.dart';
import 'package:redux/redux.dart';
import 'package:redux_thunk/redux_thunk.dart';
import '../store.dart';

@immutable
class SetSettingStateAction {
  final SettingState settingState;
  SetSettingStateAction(this.settingState);
}


ThunkAction<AppState> changeModeFromSetting(bool isKassa) {
  return (Store<AppState> store) async {
    store.dispatch(SetSettingStateAction(SettingState(mode: isKassa? SettingModeKassa: SettingModeCalc )));
  };
}

ThunkAction<AppState> changeTradeTypeFromSetting(String tradeType) {
  return (Store<AppState> store) async {
    store.dispatch(SetSettingStateAction(SettingState(tradeType: tradeType )));
  };
}

ThunkAction<AppState> changePinCodeFromSetting(String pinCode) {
  return (Store<AppState> store) async {
    store.dispatch(SetSettingStateAction(SettingState(pinCode: pinCode)));
  };
}

ThunkAction<AppState> changePinLockedFromSetting(bool locked) {
  return (Store<AppState> store) async {
    store.dispatch(SetSettingStateAction(SettingState(pinLocked: locked)));
  };
}

ThunkAction<AppState> changePinSkipFromSetting(bool skip) {
  return (Store<AppState> store) async {
    store.dispatch(SetSettingStateAction(SettingState(pinSkip: skip)));
  };
}

ThunkAction<AppState> selectPrinterFromSetting(BluetoothDevice device) {
  return (Store<AppState> store) async {
    store.dispatch(SetSettingStateAction(SettingState(printerBT: device )));
  };
}

ThunkAction<AppState> selectPrinterEncodingFromSetting(String encoding) {
  return (Store<AppState> store) async {
    store.dispatch(SetSettingStateAction(SettingState(printerEncoding: encoding )));
  };
}

ThunkAction<AppState> selectPrinterPaperSizeFromSetting(String paperSize) {
  return (Store<AppState> store) async {
    store.dispatch(SetSettingStateAction(SettingState(printerPaperSize: paperSize )));
  };
}