-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add optional store scanner beep sound (#10)
Signed-off-by: Dmytro Turskyi <[email protected]>
- Loading branch information
Showing
32 changed files
with
421 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"spellright.language": [ | ||
"en" | ||
], | ||
"spellright.documentTypes": [ | ||
"markdown", | ||
"latex", | ||
"plaintext", | ||
"Log" | ||
], | ||
"spellright.parserByClass": { | ||
"Log": { | ||
"parser": "plain" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
components/core/use_cases/lib/src/use_cases/get_sound_preference_use_case.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import 'package:use_cases/use_cases.dart'; | ||
|
||
class GetSoundPreferenceUseCase implements UseCase<bool, Null> { | ||
const GetSoundPreferenceUseCase(this._settingsGateway); | ||
|
||
final SettingsGateway _settingsGateway; | ||
|
||
@override | ||
bool call([_]) => _settingsGateway.getSoundPreference(); | ||
} |
11 changes: 11 additions & 0 deletions
11
components/core/use_cases/lib/src/use_cases/save_sound_preference_use_case.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import 'package:use_cases/use_cases.dart'; | ||
|
||
class SaveSoundPreferenceUseCase implements UseCase<Future<bool>, bool> { | ||
const SaveSoundPreferenceUseCase(this._settingsGateway); | ||
|
||
final SettingsGateway _settingsGateway; | ||
|
||
@override | ||
Future<bool> call([bool isSoundOn = false]) => | ||
_settingsGateway.saveSoundPreferenceAsFuture(isSoundOn); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const String scanSoundAsset = | ||
'components/interface_adapters/assets/audio/store_scanner_beep.mp3'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 48 additions & 3 deletions
51
components/interface_adapters/lib/src/ui/modules/scan/scan_presenter.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,63 @@ | ||
import 'package:bloc/bloc.dart'; | ||
import 'package:interface_adapters/src/ui/modules/scan/scan_event.dart'; | ||
import 'package:use_cases/use_cases.dart'; | ||
|
||
part 'scan_view_model.dart'; | ||
|
||
class ScanPresenter extends Bloc<ScanEvent, ScanViewModel> { | ||
ScanPresenter() : super(const ScanningState()) { | ||
ScanPresenter( | ||
this._saveSoundPreferenceUseCase, | ||
this._getSoundPreferenceUseCase, | ||
) : super(const LoadingScanningState()) { | ||
on<LoadScannerEvent>( | ||
(_, Emitter<ScanViewModel> emit) { | ||
emit(ScanningState(_getSoundPreferenceUseCase.call())); | ||
}, | ||
); | ||
on<PopBarcodeEvent>( | ||
(PopBarcodeEvent event, Emitter<ScanViewModel> emit) => | ||
emit(ScanSuccessState(event.barcode)), | ||
(PopBarcodeEvent event, Emitter<ScanViewModel> emit) { | ||
if (event.barcode != null) { | ||
emit(ScanSuccessState(event.barcode!)); | ||
} else { | ||
emit(const CanceledScanningState()); | ||
} | ||
}, | ||
); | ||
on<NavigateBackEvent>( | ||
(_, Emitter<ScanViewModel> emit) { | ||
emit(const CanceledScanningState()); | ||
}, | ||
); | ||
|
||
on<SoundToggleEvent>(( | ||
_, | ||
Emitter<ScanViewModel> emit, | ||
) async { | ||
if (state is ScanningState) { | ||
bool isSoundOn = !(state as ScanningState).isSoundOn; | ||
bool isSaved = await _saveSoundPreferenceUseCase.call(isSoundOn); | ||
if (isSaved) { | ||
emit((state as ScanningState).copyWith(isSoundOn)); | ||
} else { | ||
emit(const LoadingScanningState()); | ||
} | ||
} | ||
}); | ||
|
||
on<DetectedBarcodeEvent>( | ||
(DetectedBarcodeEvent event, Emitter<ScanViewModel> emit) { | ||
if (state is ScanningState) { | ||
emit( | ||
DetectedBarcodeState( | ||
barcodeValue: event.barcodeValue, | ||
isSoundOn: (state as ScanningState).isSoundOn, | ||
), | ||
); | ||
} | ||
}, | ||
); | ||
} | ||
|
||
final SaveSoundPreferenceUseCase _saveSoundPreferenceUseCase; | ||
final GetSoundPreferenceUseCase _getSoundPreferenceUseCase; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.