@ozdao/prometheus-framework 0.2.235 → 0.2.236

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ozdao/prometheus-framework",
3
- "version": "0.2.235",
3
+ "version": "0.2.236",
4
4
  "description": "Web3 Framework focused on user experience and ease of development.",
5
5
  "author": "OZ DAO <hello@ozdao.dev>",
6
6
  "license": "GPL-3.0-or-later",
@@ -4,8 +4,14 @@
4
4
  Check Tickets
5
5
  </Button>
6
6
  <div v-if="isScanning" class="barcode-scanner-modal">
7
- <!-- Add any UI elements for the scanner here -->
7
+ <div class="square"></div>
8
+ <div class="zoom-ratio-wrapper" v-if="minZoomRatio !== undefined && maxZoomRatio !== undefined">
9
+ <input type="range" :min="minZoomRatio" :max="maxZoomRatio" @input="setZoomRatio" />
10
+ </div>
8
11
  <Button @click="stopScan" class="stop-scan-button">Stop Scan</Button>
12
+ <Button v-if="isTorchAvailable" @click="toggleTorch" class="torch-button">
13
+ Toggle Torch
14
+ </Button>
9
15
  </div>
10
16
  </div>
11
17
  </template>
@@ -19,21 +25,24 @@ import * as tickets from '@pf/src/modules/events/store/tickets'
19
25
  const emits = defineEmits(['qrcodecheck'])
20
26
  const error = ref('')
21
27
  const isScanning = ref(false)
28
+ const isTorchAvailable = ref(false)
29
+ const minZoomRatio = ref(undefined)
30
+ const maxZoomRatio = ref(undefined)
22
31
 
23
32
  onMounted(async () => {
24
33
  const { supported } = await BarcodeScanner.isSupported()
25
34
  if (!supported) {
26
35
  error.value = 'Barcode scanning is not supported on this device'
27
36
  }
37
+ const { available } = await BarcodeScanner.isTorchAvailable()
38
+ isTorchAvailable.value = available
28
39
  })
29
40
 
30
41
  onUnmounted(async () => {
31
- await BarcodeScanner.removeAllListeners()
42
+ await stopScan()
32
43
  })
33
44
 
34
45
  async function startScan() {
35
- document.querySelector('body')?.classList.add('barcode-scanner-active');
36
-
37
46
  try {
38
47
  const { camera } = await BarcodeScanner.checkPermissions()
39
48
  if (camera !== 'granted') {
@@ -44,6 +53,7 @@ async function startScan() {
44
53
  }
45
54
 
46
55
  document.querySelector('body')?.classList.add('barcode-scanner-active')
56
+ document.querySelector('html')?.classList.add('barcode-scanner-active-html')
47
57
  isScanning.value = true
48
58
 
49
59
  await BarcodeScanner.addListener('barcodeScanned', async (result) => {
@@ -51,6 +61,11 @@ async function startScan() {
51
61
  })
52
62
 
53
63
  await BarcodeScanner.startScan()
64
+
65
+ const { zoomRatio: min } = await BarcodeScanner.getMinZoomRatio()
66
+ const { zoomRatio: max } = await BarcodeScanner.getMaxZoomRatio()
67
+ minZoomRatio.value = min
68
+ maxZoomRatio.value = max
54
69
  } catch (e) {
55
70
  error.value = e.message
56
71
  alert(`Error: ${error.value}`)
@@ -59,7 +74,8 @@ async function startScan() {
59
74
 
60
75
  async function stopScan() {
61
76
  try {
62
- document.querySelector('body')?.classList.remove('barcode-scanner-active');
77
+ document.querySelector('body')?.classList.remove('barcode-scanner-active')
78
+ document.querySelector('html')?.classList.remove('barcode-scanner-active-html')
63
79
  isScanning.value = false
64
80
  await BarcodeScanner.stopScan()
65
81
  await BarcodeScanner.removeAllListeners()
@@ -83,16 +99,56 @@ async function processBarcode(barcode) {
83
99
  await stopScan()
84
100
  }
85
101
  }
102
+
103
+ async function setZoomRatio(event) {
104
+ const zoomRatio = parseFloat(event.target.value)
105
+ await BarcodeScanner.setZoomRatio({ zoomRatio })
106
+ }
107
+
108
+ async function toggleTorch() {
109
+ await BarcodeScanner.toggleTorch()
110
+ }
86
111
  </script>
87
112
 
88
- <style>
113
+ <style scoped>
114
+ .barcode-scanner-modal {
115
+ position: fixed;
116
+ top: 0;
117
+ left: 0;
118
+ width: 100%;
119
+ height: 100%;
120
+ background-color: rgba(0, 0, 0, 0.8);
121
+ display: flex;
122
+ flex-direction: column;
123
+ justify-content: center;
124
+ align-items: center;
125
+ }
126
+
127
+ .square {
128
+ width: 200px;
129
+ height: 200px;
130
+ border: 2px solid white;
131
+ border-radius: 10px;
132
+ }
133
+
134
+ .zoom-ratio-wrapper {
135
+ width: 80%;
136
+ margin-top: 20px;
137
+ }
138
+
139
+ .stop-scan-button,
140
+ .torch-button {
141
+ margin-top: 20px;
142
+ }
143
+
144
+ /* Existing styles */
89
145
  body.barcode-scanner-active {
90
- visibility: hidden;
91
146
  --background: transparent;
92
147
  --ion-background-color: transparent;
93
148
  }
94
- .barcode-scanner-modal {
95
- visibility: visible;
149
+
150
+ html.barcode-scanner-active-html {
151
+ background: transparent !important;
96
152
  }
97
153
 
98
154
  @media (prefers-color-scheme: dark) {
@@ -101,4 +157,4 @@ body.barcode-scanner-active {
101
157
  --ion-background-color: transparent;
102
158
  }
103
159
  }
104
- </style>
160
+ </style>