import 'package:aman_kassa_flutter/redux/constants/setting_const.dart';
import 'package:meta/meta.dart';

@immutable
class SettingState {
  final String mode;
  final String tradeType;

  SettingState({this.mode, this.tradeType});

  //read hive
  factory SettingState.initial(SettingState payload) {
    return SettingState(
        mode: payload?.mode ?? SettingModeKassa,
        tradeType: payload?.tradeType ?? SettingTradeTypeGood);
  }

  //write hive
  SettingState copyWith({
    @required mode,
    @required tradeType,
  }) {
    return SettingState(
      mode: mode ?? this.mode,
      tradeType: tradeType ?? this.tradeType,
    );
  }

  static SettingState fromJson(dynamic json) {
    return json != null
        ? SettingState(
            tradeType: json['tradeType'],
            mode: json['mode'],
          )
        : null;
  }

  dynamic toJson() {
    return {"tradeType": tradeType, "mode": mode};
  }
}
