53 lines
1.5 KiB
Dart
53 lines
1.5 KiB
Dart
|
|
import 'package:logger/logger.dart';
|
|
import 'package:meta/meta.dart';
|
|
import 'package:redux/redux.dart';
|
|
import 'package:redux_thunk/redux_thunk.dart';
|
|
import 'package:satu/core/models/settings/printer_setting.dart';
|
|
import 'package:satu/core/redux/state/setting_state.dart';
|
|
import 'package:satu/core/utils/logger.dart';
|
|
|
|
import '../store.dart';
|
|
|
|
@immutable
|
|
class SetSettingStateAction {
|
|
const SetSettingStateAction(this.settingState);
|
|
|
|
final SettingState settingState;
|
|
}
|
|
|
|
final Logger log = getLogger('SetSettingStateAction');
|
|
|
|
|
|
ThunkAction<AppState> selectBluetoothDevice(PrinterDevice device) {
|
|
return (Store<AppState> store) async {
|
|
final PrinterSetting? setting = store.state.settingState?.printer;
|
|
if(setting != null) {
|
|
setting.device = device;
|
|
store.dispatch(SetSettingStateAction(SettingState(printer: setting)));
|
|
log.i('device with name ${device.name} added');
|
|
}
|
|
};
|
|
}
|
|
|
|
ThunkAction<AppState> setPaperSize(String size) {
|
|
return (Store<AppState> store) async {
|
|
final PrinterSetting? setting = store.state.settingState?.printer;
|
|
if(setting != null) {
|
|
setting.paperSize = size;
|
|
store.dispatch(SetSettingStateAction(SettingState(printer: setting)));
|
|
}
|
|
};
|
|
}
|
|
|
|
ThunkAction<AppState> setEncodingPrint(String encoding) {
|
|
return (Store<AppState> store) async {
|
|
final PrinterSetting? setting = store.state.settingState?.printer;
|
|
if(setting != null) {
|
|
setting.encoding = encoding;
|
|
store.dispatch(SetSettingStateAction(SettingState(printer: setting)));
|
|
}
|
|
};
|
|
}
|
|
|