54 lines
1.3 KiB
Dart
54 lines
1.3 KiB
Dart
import 'package:aman_kassa_flutter/redux/constants/setting_const.dart';
|
|
import 'package:meta/meta.dart';
|
|
import 'package:flutter_bluetooth_basic/src/bluetooth_device.dart';
|
|
|
|
|
|
@immutable
|
|
class SettingState {
|
|
final String mode;
|
|
final String tradeType;
|
|
final BluetoothDevice printerBT;
|
|
|
|
SettingState({this.mode, this.tradeType, this.printerBT});
|
|
|
|
//read hive
|
|
factory SettingState.initial(SettingState payload) {
|
|
return SettingState(
|
|
mode: payload?.mode ?? SettingModeKassa,
|
|
tradeType: payload?.tradeType ?? SettingTradeTypeGood,
|
|
printerBT: payload?.printerBT ?? null
|
|
);
|
|
}
|
|
|
|
//write hive
|
|
SettingState copyWith({
|
|
@required mode,
|
|
@required tradeType,
|
|
@required printerBT,
|
|
}) {
|
|
return SettingState(
|
|
mode: mode ?? this.mode,
|
|
tradeType: tradeType ?? this.tradeType,
|
|
printerBT: printerBT ?? this.printerBT
|
|
);
|
|
}
|
|
|
|
static SettingState fromJson(dynamic json) {
|
|
return json != null
|
|
? SettingState(
|
|
tradeType: json['tradeType'],
|
|
mode: json['mode'],
|
|
printerBT: json['printerBT']!=null ? BluetoothDevice.fromJson(json['printerBT']) : null
|
|
)
|
|
: null;
|
|
}
|
|
|
|
dynamic toJson() {
|
|
return {
|
|
"tradeType": tradeType,
|
|
"mode": mode,
|
|
"printerBT": printerBT !=null ? printerBT.toJson() : null
|
|
};
|
|
}
|
|
}
|