refactor(mobile): more look and feel work
All checks were successful
Build and Push LST Docker Image / docker (push) Successful in 1m17s
All checks were successful
Build and Push LST Docker Image / docker (push) Successful in 1m17s
This commit is contained in:
38
lstMobile/src/lib/feedbackScan.ts
Normal file
38
lstMobile/src/lib/feedbackScan.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { createAudioPlayer } from "expo-audio";
|
||||
import * as Haptics from "expo-haptics";
|
||||
|
||||
export type ScanFeedback = {
|
||||
type: "good" | "bad";
|
||||
sound?: boolean;
|
||||
vibrate?: boolean;
|
||||
led?: boolean;
|
||||
};
|
||||
|
||||
const goodSound = createAudioPlayer(require("../../assets/sounds/good.wav"));
|
||||
const badSound = createAudioPlayer(require("../../assets/sounds/bad.wav"));
|
||||
|
||||
export async function scannerFeedback({
|
||||
type,
|
||||
sound = true,
|
||||
vibrate = true,
|
||||
led = true,
|
||||
}: ScanFeedback) {
|
||||
if (sound) {
|
||||
const player = type === "good" ? goodSound : badSound;
|
||||
player.seekTo(0);
|
||||
player.play();
|
||||
}
|
||||
|
||||
if (vibrate) {
|
||||
await Haptics.notificationAsync(
|
||||
type === "good"
|
||||
? Haptics.NotificationFeedbackType.Success
|
||||
: Haptics.NotificationFeedbackType.Error,
|
||||
);
|
||||
}
|
||||
|
||||
if (led) {
|
||||
// Zebra LED hook goes here
|
||||
// More below 👇
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user