canvasframework 0.5.16 → 0.5.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvasframework.js +2 -0
- package/dist/canvasframework.js.LICENSE.txt +1 -0
- package/package.json +18 -17
- package/components/Accordion.js +0 -265
- package/components/AndroidDatePickerDialog.js +0 -406
- package/components/AppBar.js +0 -398
- package/components/AudioPlayer.js +0 -611
- package/components/Avatar.js +0 -202
- package/components/Banner.js +0 -342
- package/components/BottomNavigationBar.js +0 -433
- package/components/BottomSheet.js +0 -234
- package/components/Button.js +0 -360
- package/components/Camera.js +0 -644
- package/components/Card.js +0 -193
- package/components/Chart.js +0 -700
- package/components/Checkbox.js +0 -166
- package/components/Chip.js +0 -212
- package/components/CircularProgress.js +0 -327
- package/components/ContextMenu.js +0 -116
- package/components/DatePicker.js +0 -298
- package/components/Dialog.js +0 -337
- package/components/Divider.js +0 -125
- package/components/Drawer.js +0 -276
- package/components/FAB.js +0 -270
- package/components/FileUpload.js +0 -315
- package/components/FloatedCamera.js +0 -644
- package/components/IOSDatePickerWheel.js +0 -430
- package/components/ImageCarousel.js +0 -219
- package/components/ImageComponent.js +0 -223
- package/components/Input.js +0 -831
- package/components/InputDatalist.js +0 -723
- package/components/InputTags.js +0 -624
- package/components/List.js +0 -95
- package/components/ListItem.js +0 -269
- package/components/Modal.js +0 -364
- package/components/MorphingFAB.js +0 -428
- package/components/MultiSelectDialog.js +0 -206
- package/components/NumberInput.js +0 -271
- package/components/PasswordInput.js +0 -462
- package/components/ProgressBar.js +0 -88
- package/components/QRCodeReader.js +0 -539
- package/components/RadioButton.js +0 -151
- package/components/SearchInput.js +0 -315
- package/components/SegmentedControl.js +0 -357
- package/components/Select.js +0 -199
- package/components/SelectDialog.js +0 -255
- package/components/Slider.js +0 -113
- package/components/SliverAppBar.js +0 -139
- package/components/Snackbar.js +0 -243
- package/components/SpeedDialFAB.js +0 -397
- package/components/Stepper.js +0 -281
- package/components/SwipeableListItem.js +0 -327
- package/components/Switch.js +0 -147
- package/components/Table.js +0 -492
- package/components/Tabs.js +0 -423
- package/components/Text.js +0 -141
- package/components/TextField.js +0 -151
- package/components/TimePicker.js +0 -934
- package/components/Toast.js +0 -236
- package/components/TreeView.js +0 -420
- package/components/Video.js +0 -397
- package/components/View.js +0 -140
- package/components/VirtualList.js +0 -120
- package/core/CanvasFramework.js +0 -3034
- package/core/Component.js +0 -243
- package/core/ThemeManager.js +0 -358
- package/core/UIBuilder.js +0 -267
- package/core/WebGLCanvasAdapter.js +0 -782
- package/features/Column.js +0 -43
- package/features/Grid.js +0 -47
- package/features/LayoutComponent.js +0 -43
- package/features/OpenStreetMap.js +0 -310
- package/features/Positioned.js +0 -33
- package/features/PullToRefresh.js +0 -328
- package/features/Row.js +0 -40
- package/features/SignaturePad.js +0 -257
- package/features/Skeleton.js +0 -193
- package/features/Stack.js +0 -21
- package/index.js +0 -119
- package/manager/AccessibilityManager.js +0 -107
- package/manager/ErrorHandler.js +0 -59
- package/manager/FeatureFlags.js +0 -60
- package/manager/MemoryManager.js +0 -107
- package/manager/PerformanceMonitor.js +0 -84
- package/manager/SecurityManager.js +0 -54
- package/utils/AnimationEngine.js +0 -734
- package/utils/CryptoManager.js +0 -303
- package/utils/DataStore.js +0 -403
- package/utils/DevTools.js +0 -1618
- package/utils/DevToolsConsole.js +0 -201
- package/utils/EventBus.js +0 -407
- package/utils/FetchClient.js +0 -74
- package/utils/FirebaseAuth.js +0 -653
- package/utils/FirebaseCore.js +0 -246
- package/utils/FirebaseFirestore.js +0 -581
- package/utils/FirebaseFunctions.js +0 -97
- package/utils/FirebaseRealtimeDB.js +0 -498
- package/utils/FirebaseStorage.js +0 -612
- package/utils/FormValidator.js +0 -355
- package/utils/GeoLocationService.js +0 -62
- package/utils/I18n.js +0 -207
- package/utils/IndexedDBManager.js +0 -273
- package/utils/InspectionOverlay.js +0 -308
- package/utils/NotificationManager.js +0 -60
- package/utils/OfflineSyncManager.js +0 -342
- package/utils/PayPalPayment.js +0 -678
- package/utils/QueryBuilder.js +0 -478
- package/utils/SafeArea.js +0 -64
- package/utils/SecureStorage.js +0 -289
- package/utils/StateManager.js +0 -207
- package/utils/StripePayment.js +0 -552
- package/utils/WebSocketClient.js +0 -66
package/components/TimePicker.js
DELETED
|
@@ -1,934 +0,0 @@
|
|
|
1
|
-
// TimePicker.js - Corrigé avec scroll iOS fonctionnel + Android Material
|
|
2
|
-
|
|
3
|
-
import Component from '../core/Component.js';
|
|
4
|
-
import Modal from '../components/Modal.js';
|
|
5
|
-
import Button from '../components/Button.js';
|
|
6
|
-
|
|
7
|
-
class TimePicker extends Component {
|
|
8
|
-
constructor(framework, options = {}) {
|
|
9
|
-
super(framework, options);
|
|
10
|
-
|
|
11
|
-
this.selectedTime = options.selectedTime || new Date();
|
|
12
|
-
this.selectedTime.setSeconds(0, 0);
|
|
13
|
-
|
|
14
|
-
this.minTime = options.minTime || null;
|
|
15
|
-
this.maxTime = options.maxTime || null;
|
|
16
|
-
this.onChange = options.onChange;
|
|
17
|
-
this.label = options.label || 'Sélectionner une heure';
|
|
18
|
-
this.platform = framework.platform;
|
|
19
|
-
|
|
20
|
-
// Options de style personnalisables - AJOUTEZ CECI
|
|
21
|
-
this.headerBgColor = options.headerBgColor || '#6200EE'; // Nouvelle option
|
|
22
|
-
this.inputBgColor = options.inputBgColor || null;
|
|
23
|
-
this.inputTextColor = options.inputTextColor || null;
|
|
24
|
-
this.inputBorderColor = options.inputBorderColor || null;
|
|
25
|
-
this.labelColor = options.labelColor || null;
|
|
26
|
-
this.inputHeight = options.inputHeight || 56;
|
|
27
|
-
this.inputRadius = options.inputRadius || (this.platform === 'cupertino' ? 10 : 0);
|
|
28
|
-
this.fontSize = options.fontSize || null;
|
|
29
|
-
|
|
30
|
-
this.width = options.width || Math.min(320, framework.width - 40);
|
|
31
|
-
this.height = this.inputHeight;
|
|
32
|
-
|
|
33
|
-
this.onPress = (x, y) => {
|
|
34
|
-
if (this.isPointInside(x, y)) {
|
|
35
|
-
this.openPicker();
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
return false;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
openPicker() {
|
|
43
|
-
if (this.platform === 'cupertino') {
|
|
44
|
-
this.openCupertinoTimePicker();
|
|
45
|
-
} else {
|
|
46
|
-
this.openMaterialTimePicker();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
openCupertinoTimePicker() {
|
|
51
|
-
const modal = new Modal(this.framework, {
|
|
52
|
-
title: '',
|
|
53
|
-
width: this.framework.width,
|
|
54
|
-
height: 340,
|
|
55
|
-
showCloseButton: false,
|
|
56
|
-
closeOnOverlayClick: true,
|
|
57
|
-
bgColor: '#F9F9F9'
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
const picker = new CupertinoTimeWheel(this.framework, {
|
|
61
|
-
x: 20,
|
|
62
|
-
y: 20,
|
|
63
|
-
width: this.framework.width - 40,
|
|
64
|
-
selectedTime: new Date(this.selectedTime),
|
|
65
|
-
onChange: (time) => {
|
|
66
|
-
this.selectedTime = time;
|
|
67
|
-
if (this.onChange) this.onChange(time);
|
|
68
|
-
},
|
|
69
|
-
minTime: this.minTime,
|
|
70
|
-
maxTime: this.maxTime
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
modal.add(picker);
|
|
74
|
-
|
|
75
|
-
const btnOK = new Button(this.framework, {
|
|
76
|
-
x: (this.framework.width - 200) / 2,
|
|
77
|
-
y: 250,
|
|
78
|
-
width: 200,
|
|
79
|
-
height: 44,
|
|
80
|
-
text: 'Valider',
|
|
81
|
-
onClick: () => modal.hide()
|
|
82
|
-
});
|
|
83
|
-
modal.add(btnOK);
|
|
84
|
-
|
|
85
|
-
this.framework.add(modal);
|
|
86
|
-
modal.show();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
openMaterialTimePicker() {
|
|
90
|
-
const dialog = new MaterialTimePickerDialog(this.framework, {
|
|
91
|
-
selectedTime: new Date(this.selectedTime),
|
|
92
|
-
onChange: (time) => {
|
|
93
|
-
this.selectedTime = time;
|
|
94
|
-
if (this.onChange) this.onChange(time);
|
|
95
|
-
},
|
|
96
|
-
minTime: this.minTime,
|
|
97
|
-
maxTime: this.maxTime,
|
|
98
|
-
// Transmettre les options de style
|
|
99
|
-
headerBgColor: this.headerBgColor // Ajoutez cette ligne
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
this.framework.add(dialog);
|
|
103
|
-
dialog.show();
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
draw(ctx) {
|
|
107
|
-
ctx.save();
|
|
108
|
-
|
|
109
|
-
const timeStr = this.formatTime(this.selectedTime);
|
|
110
|
-
|
|
111
|
-
// Couleurs par défaut selon la plateforme
|
|
112
|
-
let bgColor, textColor, labelColor, borderColor, fontSize;
|
|
113
|
-
|
|
114
|
-
if (this.platform === 'cupertino') {
|
|
115
|
-
// Style Cupertino par défaut
|
|
116
|
-
bgColor = this.inputBgColor || '#FFFFFF';
|
|
117
|
-
textColor = this.inputTextColor || '#000000';
|
|
118
|
-
labelColor = this.labelColor || '#8E8E93';
|
|
119
|
-
borderColor = this.inputBorderColor || '#C7C7CC';
|
|
120
|
-
fontSize = this.fontSize || 17;
|
|
121
|
-
|
|
122
|
-
// Dessiner l'arrière-plan
|
|
123
|
-
ctx.fillStyle = bgColor;
|
|
124
|
-
this.roundRect(ctx, this.x, this.y, this.width, this.height, this.inputRadius);
|
|
125
|
-
ctx.fill();
|
|
126
|
-
|
|
127
|
-
// Bordure
|
|
128
|
-
ctx.strokeStyle = borderColor;
|
|
129
|
-
ctx.lineWidth = 1;
|
|
130
|
-
ctx.stroke();
|
|
131
|
-
|
|
132
|
-
// Label
|
|
133
|
-
ctx.fillStyle = labelColor;
|
|
134
|
-
ctx.font = '14px -apple-system, sans-serif';
|
|
135
|
-
ctx.textAlign = 'left';
|
|
136
|
-
ctx.textBaseline = 'middle';
|
|
137
|
-
ctx.fillText(this.label, this.x + 16, this.y + 18);
|
|
138
|
-
|
|
139
|
-
// Valeur (heure)
|
|
140
|
-
ctx.fillStyle = textColor;
|
|
141
|
-
ctx.font = `${fontSize}px -apple-system, sans-serif`;
|
|
142
|
-
ctx.fillText(timeStr, this.x + 16, this.y + this.height - 18);
|
|
143
|
-
|
|
144
|
-
// Chevron (flèche)
|
|
145
|
-
ctx.strokeStyle = '#C7C7CC';
|
|
146
|
-
ctx.lineWidth = 2;
|
|
147
|
-
ctx.beginPath();
|
|
148
|
-
ctx.moveTo(this.x + this.width - 28, this.y + this.height/2 - 6);
|
|
149
|
-
ctx.lineTo(this.x + this.width - 22, this.y + this.height/2);
|
|
150
|
-
ctx.lineTo(this.x + this.width - 16, this.y + this.height/2 - 6);
|
|
151
|
-
ctx.stroke();
|
|
152
|
-
} else {
|
|
153
|
-
// Style Material par défaut
|
|
154
|
-
bgColor = this.inputBgColor || (this.pressed ? '#EEEEEE' : '#FFFFFF');
|
|
155
|
-
textColor = this.inputTextColor || '#000000';
|
|
156
|
-
labelColor = this.labelColor || '#757575';
|
|
157
|
-
borderColor = this.inputBorderColor || '#E0E0E0';
|
|
158
|
-
fontSize = this.fontSize || 16;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
// Arrière-plan
|
|
162
|
-
ctx.fillStyle = bgColor;
|
|
163
|
-
if (this.inputRadius > 0) {
|
|
164
|
-
this.roundRect(ctx, this.x, this.y, this.width, this.height, this.inputRadius);
|
|
165
|
-
ctx.fill();
|
|
166
|
-
} else {
|
|
167
|
-
ctx.fillRect(this.x, this.y, this.width, this.height);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Bordure
|
|
171
|
-
ctx.strokeStyle = borderColor;
|
|
172
|
-
ctx.lineWidth = 1;
|
|
173
|
-
if (this.inputRadius > 0) {
|
|
174
|
-
this.roundRect(ctx, this.x, this.y, this.width, this.height, this.inputRadius);
|
|
175
|
-
ctx.stroke();
|
|
176
|
-
} else {
|
|
177
|
-
ctx.strokeRect(this.x, this.y, this.width, this.height);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// Icône d'horloge
|
|
181
|
-
const cx = this.x + 16 + 12;
|
|
182
|
-
const cy = this.y + this.height/2;
|
|
183
|
-
ctx.strokeStyle = labelColor;
|
|
184
|
-
ctx.lineWidth = 2;
|
|
185
|
-
ctx.beginPath();
|
|
186
|
-
ctx.arc(cx, cy, 11, 0, Math.PI * 2);
|
|
187
|
-
ctx.moveTo(cx, cy - 8);
|
|
188
|
-
ctx.lineTo(cx, cy);
|
|
189
|
-
ctx.lineTo(cx + 7, cy);
|
|
190
|
-
ctx.stroke();
|
|
191
|
-
|
|
192
|
-
// Label
|
|
193
|
-
ctx.fillStyle = labelColor;
|
|
194
|
-
ctx.font = '14px Roboto, sans-serif';
|
|
195
|
-
ctx.textAlign = 'left';
|
|
196
|
-
ctx.fillText(this.label, this.x + 48, this.y + 18);
|
|
197
|
-
|
|
198
|
-
// Valeur (heure)
|
|
199
|
-
ctx.fillStyle = textColor;
|
|
200
|
-
ctx.font = `${fontSize}px Roboto, sans-serif`;
|
|
201
|
-
ctx.fillText(timeStr, this.x + 48, this.y + this.height - 10);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
ctx.restore();
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
formatTime(date) {
|
|
208
|
-
const h = date.getHours().toString().padStart(2, '0');
|
|
209
|
-
const m = date.getMinutes().toString().padStart(2, '0');
|
|
210
|
-
return `${h}:${m}`;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
roundRect(ctx, x, y, w, h, r) {
|
|
214
|
-
ctx.beginPath();
|
|
215
|
-
ctx.moveTo(x + r, y);
|
|
216
|
-
ctx.lineTo(x + w - r, y);
|
|
217
|
-
ctx.quadraticCurveTo(x + w, y, x + w, y + r);
|
|
218
|
-
ctx.lineTo(x + w, y + h - r);
|
|
219
|
-
ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
|
|
220
|
-
ctx.lineTo(x + r, y + h);
|
|
221
|
-
ctx.quadraticCurveTo(x, y + h, x, y + h - r);
|
|
222
|
-
ctx.lineTo(x, y + r);
|
|
223
|
-
ctx.quadraticCurveTo(x, y, x + r, y);
|
|
224
|
-
ctx.closePath();
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
isPointInside(x, y) {
|
|
228
|
-
return x >= this.x && x <= this.x + this.width &&
|
|
229
|
-
y >= this.y && y <= this.y + this.height;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// ════════════════════════════════════════════════════════════
|
|
234
|
-
// iOS Cupertino Time Wheel - Inspiré de IOSDatePickerWheel
|
|
235
|
-
// ════════════════════════════════════════════════════════════
|
|
236
|
-
class CupertinoTimeWheel extends Component {
|
|
237
|
-
constructor(framework, options) {
|
|
238
|
-
super(framework, options);
|
|
239
|
-
|
|
240
|
-
this.selectedTime = options.selectedTime || new Date();
|
|
241
|
-
this.onChange = options.onChange;
|
|
242
|
-
|
|
243
|
-
this.hourWheel = this.selectedTime.getHours();
|
|
244
|
-
this.minuteWheel = this.selectedTime.getMinutes();
|
|
245
|
-
|
|
246
|
-
this.minTime = options.minTime;
|
|
247
|
-
this.maxTime = options.maxTime;
|
|
248
|
-
|
|
249
|
-
this.wheelHeight = 216;
|
|
250
|
-
this.itemHeight = 44;
|
|
251
|
-
|
|
252
|
-
// État de drag
|
|
253
|
-
this.dragging = false;
|
|
254
|
-
this.dragStartY = 0;
|
|
255
|
-
this.dragWheel = null; // 0 = heures, 1 = minutes
|
|
256
|
-
this.lastY = 0;
|
|
257
|
-
|
|
258
|
-
this._setupEventHandlers();
|
|
259
|
-
|
|
260
|
-
if (!options.width) {
|
|
261
|
-
this.width = framework.width - 40;
|
|
262
|
-
}
|
|
263
|
-
if (!options.height) {
|
|
264
|
-
this.height = this.wheelHeight;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
_setupEventHandlers() {
|
|
269
|
-
// Press handler - identique à IOSDatePickerWheel
|
|
270
|
-
this.onPress = (x, y) => {
|
|
271
|
-
const inside = (x >= this.x && x <= this.x + this.width &&
|
|
272
|
-
y >= this.y && y <= this.y + this.wheelHeight);
|
|
273
|
-
|
|
274
|
-
if (!inside) return false;
|
|
275
|
-
|
|
276
|
-
this.dragging = true;
|
|
277
|
-
this.dragStartY = y;
|
|
278
|
-
this.lastY = y;
|
|
279
|
-
|
|
280
|
-
// Déterminer la roue (heures ou minutes)
|
|
281
|
-
const wheelWidth = this.width / 2;
|
|
282
|
-
this.dragWheel = x < this.x + wheelWidth ? 0 : 1;
|
|
283
|
-
|
|
284
|
-
// Prendre le contrôle
|
|
285
|
-
this.framework.activeComponent = this;
|
|
286
|
-
|
|
287
|
-
// Ajouter listener global
|
|
288
|
-
this._addGlobalMoveListener();
|
|
289
|
-
|
|
290
|
-
this._requestRedraw();
|
|
291
|
-
|
|
292
|
-
return true;
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
// Release handler
|
|
296
|
-
this.onRelease = (x, y) => {
|
|
297
|
-
if (this.dragging) {
|
|
298
|
-
this.dragging = false;
|
|
299
|
-
this.dragWheel = null;
|
|
300
|
-
|
|
301
|
-
this._removeGlobalMoveListener();
|
|
302
|
-
|
|
303
|
-
if (this.framework.activeComponent === this) {
|
|
304
|
-
this.framework.activeComponent = null;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
this._requestRedraw();
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
this.onMove = (x, y) => {
|
|
312
|
-
// Laissé vide, on utilise l'écouteur global
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
_addGlobalMoveListener() {
|
|
317
|
-
const canvas = this.framework.canvas;
|
|
318
|
-
|
|
319
|
-
this._savedMouseMove = canvas.onmousemove;
|
|
320
|
-
this._savedTouchMove = canvas.ontouchmove;
|
|
321
|
-
|
|
322
|
-
canvas.onmousemove = (e) => {
|
|
323
|
-
if (this.dragging) {
|
|
324
|
-
e.preventDefault();
|
|
325
|
-
e.stopPropagation();
|
|
326
|
-
|
|
327
|
-
const rect = canvas.getBoundingClientRect();
|
|
328
|
-
const x = e.clientX - rect.left;
|
|
329
|
-
const y = e.clientY - rect.top;
|
|
330
|
-
|
|
331
|
-
this._handleGlobalMove(x, y);
|
|
332
|
-
return false;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
if (this._savedMouseMove) {
|
|
336
|
-
return this._savedMouseMove(e);
|
|
337
|
-
}
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
canvas.ontouchmove = (e) => {
|
|
341
|
-
if (this.dragging && e.touches.length > 0) {
|
|
342
|
-
e.preventDefault();
|
|
343
|
-
e.stopPropagation();
|
|
344
|
-
|
|
345
|
-
const touch = e.touches[0];
|
|
346
|
-
const rect = canvas.getBoundingClientRect();
|
|
347
|
-
const x = touch.clientX - rect.left;
|
|
348
|
-
const y = touch.clientY - rect.top;
|
|
349
|
-
|
|
350
|
-
this._handleGlobalMove(x, y);
|
|
351
|
-
return false;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
if (this._savedTouchMove) {
|
|
355
|
-
return this._savedTouchMove(e);
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
_removeGlobalMoveListener() {
|
|
361
|
-
const canvas = this.framework.canvas;
|
|
362
|
-
|
|
363
|
-
if (this._savedMouseMove) {
|
|
364
|
-
canvas.onmousemove = this._savedMouseMove;
|
|
365
|
-
this._savedMouseMove = null;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
if (this._savedTouchMove) {
|
|
369
|
-
canvas.ontouchmove = this._savedTouchMove;
|
|
370
|
-
this._savedTouchMove = null;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
_handleGlobalMove(x, y) {
|
|
375
|
-
if (!this.dragging) return;
|
|
376
|
-
|
|
377
|
-
const deltaY = y - this.lastY;
|
|
378
|
-
this.lastY = y;
|
|
379
|
-
|
|
380
|
-
if (Math.abs(deltaY) > 0.5) {
|
|
381
|
-
const direction = deltaY > 0 ? 1 : -1;
|
|
382
|
-
|
|
383
|
-
if (this.dragWheel === 0) {
|
|
384
|
-
// Heures - avec bouclage
|
|
385
|
-
let newHour = this.hourWheel - direction;
|
|
386
|
-
if (newHour < 0) newHour = 23;
|
|
387
|
-
if (newHour > 23) newHour = 0;
|
|
388
|
-
this.hourWheel = newHour;
|
|
389
|
-
} else if (this.dragWheel === 1) {
|
|
390
|
-
// Minutes - avec bouclage
|
|
391
|
-
let newMinute = this.minuteWheel - direction;
|
|
392
|
-
if (newMinute < 0) newMinute = 59;
|
|
393
|
-
if (newMinute > 59) newMinute = 0;
|
|
394
|
-
this.minuteWheel = newMinute;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
this._updateSelectedTime();
|
|
398
|
-
this._requestRedraw();
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
_updateSelectedTime() {
|
|
403
|
-
const newTime = new Date();
|
|
404
|
-
newTime.setHours(this.hourWheel, this.minuteWheel, 0, 0);
|
|
405
|
-
|
|
406
|
-
// Vérifier les limites min/max
|
|
407
|
-
if (this.minTime && newTime < this.minTime) {
|
|
408
|
-
this.hourWheel = this.minTime.getHours();
|
|
409
|
-
this.minuteWheel = this.minTime.getMinutes();
|
|
410
|
-
newTime.setHours(this.hourWheel, this.minuteWheel, 0, 0);
|
|
411
|
-
}
|
|
412
|
-
if (this.maxTime && newTime > this.maxTime) {
|
|
413
|
-
this.hourWheel = this.maxTime.getHours();
|
|
414
|
-
this.minuteWheel = this.maxTime.getMinutes();
|
|
415
|
-
newTime.setHours(this.hourWheel, this.minuteWheel, 0, 0);
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
if (newTime.getTime() !== this.selectedTime.getTime()) {
|
|
419
|
-
this.selectedTime = newTime;
|
|
420
|
-
if (this.onChange) {
|
|
421
|
-
this.onChange(this.selectedTime);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
_requestRedraw() {
|
|
427
|
-
if (this.framework.markComponentDirty) {
|
|
428
|
-
this.framework.markComponentDirty(this);
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
draw(ctx) {
|
|
433
|
-
ctx.save();
|
|
434
|
-
|
|
435
|
-
const wheelWidth = this.width / 2;
|
|
436
|
-
|
|
437
|
-
// Fond
|
|
438
|
-
ctx.fillStyle = '#F9F9F9';
|
|
439
|
-
ctx.fillRect(this.x, this.y, this.width, this.wheelHeight);
|
|
440
|
-
|
|
441
|
-
// Bande de sélection
|
|
442
|
-
const selectionY = this.y + this.wheelHeight / 2 - this.itemHeight / 2;
|
|
443
|
-
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
|
444
|
-
ctx.fillRect(this.x, selectionY, this.width, this.itemHeight);
|
|
445
|
-
|
|
446
|
-
// Lignes de séparation
|
|
447
|
-
ctx.strokeStyle = '#C7C7CC';
|
|
448
|
-
ctx.lineWidth = 0.5;
|
|
449
|
-
ctx.beginPath();
|
|
450
|
-
ctx.moveTo(this.x, selectionY);
|
|
451
|
-
ctx.lineTo(this.x + this.width, selectionY);
|
|
452
|
-
ctx.moveTo(this.x, selectionY + this.itemHeight);
|
|
453
|
-
ctx.lineTo(this.x + this.width, selectionY + this.itemHeight);
|
|
454
|
-
ctx.stroke();
|
|
455
|
-
|
|
456
|
-
// Divider vertical
|
|
457
|
-
ctx.beginPath();
|
|
458
|
-
ctx.moveTo(this.x + wheelWidth, this.y);
|
|
459
|
-
ctx.lineTo(this.x + wheelWidth, this.y + this.wheelHeight);
|
|
460
|
-
ctx.stroke();
|
|
461
|
-
|
|
462
|
-
// Heures (0-23)
|
|
463
|
-
const hours = Array.from({length: 24}, (_, i) => i.toString().padStart(2, '0'));
|
|
464
|
-
this._drawWheel(ctx, this.x, hours, this.hourWheel, 0, 23);
|
|
465
|
-
|
|
466
|
-
// Minutes (0-59)
|
|
467
|
-
const minutes = Array.from({length: 60}, (_, i) => i.toString().padStart(2, '0'));
|
|
468
|
-
this._drawWheel(ctx, this.x + wheelWidth, minutes, this.minuteWheel, 0, 59);
|
|
469
|
-
|
|
470
|
-
ctx.restore();
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
_drawWheel(ctx, x, items, selectedIndex, minIndex = 0, maxIndex = items.length - 1) {
|
|
474
|
-
const wheelWidth = this.width / 2;
|
|
475
|
-
const centerY = this.y + this.wheelHeight / 2;
|
|
476
|
-
|
|
477
|
-
ctx.save();
|
|
478
|
-
ctx.beginPath();
|
|
479
|
-
ctx.rect(x, this.y, wheelWidth, this.wheelHeight);
|
|
480
|
-
ctx.clip();
|
|
481
|
-
|
|
482
|
-
for (let i = -2; i <= 2; i++) {
|
|
483
|
-
const index = selectedIndex + i;
|
|
484
|
-
if (index >= minIndex && index <= maxIndex) {
|
|
485
|
-
const itemY = centerY + i * this.itemHeight;
|
|
486
|
-
const distance = Math.abs(itemY - centerY);
|
|
487
|
-
const scale = 1 - (distance / this.wheelHeight);
|
|
488
|
-
const opacity = Math.max(0.3, scale);
|
|
489
|
-
|
|
490
|
-
ctx.fillStyle = `rgba(0, 0, 0, ${opacity})`;
|
|
491
|
-
ctx.font = `${i === 0 ? 'bold ' : ''}${18 + scale * 2}px -apple-system, sans-serif`;
|
|
492
|
-
ctx.textAlign = 'center';
|
|
493
|
-
ctx.textBaseline = 'middle';
|
|
494
|
-
ctx.fillText(items[index], x + wheelWidth / 2, itemY);
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
ctx.restore();
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
isPointInside(x, y) {
|
|
502
|
-
return x >= this.x && x <= this.x + this.width &&
|
|
503
|
-
y >= this.y && y <= this.y + this.wheelHeight;
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
_unmount() {
|
|
507
|
-
this._removeGlobalMoveListener();
|
|
508
|
-
super._unmount();
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
// ════════════════════════════════════════════════════════════
|
|
513
|
-
// Android Material Time Picker - Style horloge analogique
|
|
514
|
-
// FIX: Problème de clics résolu + Amélioration visibilité
|
|
515
|
-
// ════════════════════════════════════════════════════════════
|
|
516
|
-
class MaterialTimePickerDialog extends Component {
|
|
517
|
-
constructor(framework, options) {
|
|
518
|
-
super(framework, {
|
|
519
|
-
x: 0,
|
|
520
|
-
y: 0,
|
|
521
|
-
width: framework.width,
|
|
522
|
-
height: framework.height,
|
|
523
|
-
visible: false,
|
|
524
|
-
captureEvents: true
|
|
525
|
-
});
|
|
526
|
-
|
|
527
|
-
this.selectedTime = options.selectedTime || new Date();
|
|
528
|
-
this.hour = this.selectedTime.getHours() % 12 || 12;
|
|
529
|
-
this.minute = this.selectedTime.getMinutes();
|
|
530
|
-
this.isPM = this.selectedTime.getHours() >= 12;
|
|
531
|
-
|
|
532
|
-
this.onChange = options.onChange;
|
|
533
|
-
this.opacity = 0;
|
|
534
|
-
this.isVisible = false;
|
|
535
|
-
|
|
536
|
-
// Options de style Material
|
|
537
|
-
this.headerBgColor = options.headerBgColor || '#6200EE';
|
|
538
|
-
this.clockBgColor = options.clockBgColor || '#F8F8F8';
|
|
539
|
-
this.selectedColor = options.selectedColor || '#6200EE';
|
|
540
|
-
this.clockHandColor = options.clockHandColor || '#6200EE';
|
|
541
|
-
this.buttonColor = options.buttonColor || '#6200EE';
|
|
542
|
-
this.selectedTextColor = options.selectedTextColor || '#FFFFFF';
|
|
543
|
-
this.unselectedTextColor = options.unselectedTextColor || '#424242';
|
|
544
|
-
|
|
545
|
-
this.dialogWidth = Math.min(340, framework.width - 48);
|
|
546
|
-
this.dialogHeight = 520;
|
|
547
|
-
|
|
548
|
-
this.mode = 'hours';
|
|
549
|
-
this.dragging = false;
|
|
550
|
-
|
|
551
|
-
this._setupEventHandlers();
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
_setupEventHandlers() {
|
|
555
|
-
// S'assurer que le composant intercepte les événements
|
|
556
|
-
this.onPress = (x, y) => this.handlePress(x, y);
|
|
557
|
-
this.onMove = (x, y) => this.handleMove(x, y);
|
|
558
|
-
this.onRelease = (x, y) => this.handleRelease(x, y);
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
show() {
|
|
562
|
-
this.isVisible = true;
|
|
563
|
-
this.visible = true;
|
|
564
|
-
this.opacity = 0;
|
|
565
|
-
|
|
566
|
-
// FIX: Forcer un redraw complet
|
|
567
|
-
if (this.framework.requestRedraw) {
|
|
568
|
-
this.framework.requestRedraw();
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
const fade = () => {
|
|
572
|
-
this.opacity += 0.1;
|
|
573
|
-
if (this.opacity < 1) {
|
|
574
|
-
requestAnimationFrame(fade);
|
|
575
|
-
}
|
|
576
|
-
if (this.framework.requestRedraw) {
|
|
577
|
-
this.framework.requestRedraw();
|
|
578
|
-
}
|
|
579
|
-
};
|
|
580
|
-
fade();
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
hide() {
|
|
584
|
-
const fade = () => {
|
|
585
|
-
this.opacity -= 0.1;
|
|
586
|
-
if (this.opacity > 0) {
|
|
587
|
-
requestAnimationFrame(fade);
|
|
588
|
-
if (this.framework.requestRedraw) {
|
|
589
|
-
this.framework.requestRedraw();
|
|
590
|
-
}
|
|
591
|
-
} else {
|
|
592
|
-
this.isVisible = false;
|
|
593
|
-
this.visible = false;
|
|
594
|
-
this.framework.remove(this);
|
|
595
|
-
}
|
|
596
|
-
};
|
|
597
|
-
fade();
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
// Renommer les handlers pour éviter les conflits
|
|
601
|
-
handlePress(x, y) {
|
|
602
|
-
if (!this.isVisible || this.opacity <= 0) return false;
|
|
603
|
-
|
|
604
|
-
const dx = (this.framework.width - this.dialogWidth) / 2;
|
|
605
|
-
const dy = (this.framework.height - this.dialogHeight) / 2;
|
|
606
|
-
|
|
607
|
-
// Click on time display to switch mode
|
|
608
|
-
const timeY = dy + 50;
|
|
609
|
-
if (y > dy + 20 && y < dy + 80 && x > dx + 40 && x < dx + this.dialogWidth - 60) {
|
|
610
|
-
if (x < dx + this.dialogWidth/2) {
|
|
611
|
-
this.mode = 'hours';
|
|
612
|
-
this._requestRedraw();
|
|
613
|
-
return true;
|
|
614
|
-
} else {
|
|
615
|
-
this.mode = 'minutes';
|
|
616
|
-
this._requestRedraw();
|
|
617
|
-
return true;
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
// AM/PM toggle
|
|
622
|
-
const pmY = dy + 30;
|
|
623
|
-
if (x > dx + this.dialogWidth - 60 && x < dx + this.dialogWidth - 20) {
|
|
624
|
-
if (y > pmY - 10 && y < pmY + 10) {
|
|
625
|
-
this.isPM = false;
|
|
626
|
-
this._updateTime();
|
|
627
|
-
return true;
|
|
628
|
-
}
|
|
629
|
-
if (y > pmY + 15 && y < pmY + 35) {
|
|
630
|
-
this.isPM = true;
|
|
631
|
-
this._updateTime();
|
|
632
|
-
return true;
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
// Clock interaction - check if click is on clock area
|
|
637
|
-
const clockCenterX = dx + this.dialogWidth / 2;
|
|
638
|
-
const clockCenterY = dy + 280;
|
|
639
|
-
const clockRadius = 120;
|
|
640
|
-
|
|
641
|
-
const distX = x - clockCenterX;
|
|
642
|
-
const distY = y - clockCenterY;
|
|
643
|
-
const dist = Math.sqrt(distX * distX + distY * distY);
|
|
644
|
-
|
|
645
|
-
// Accept clicks within and slightly outside the clock
|
|
646
|
-
if (dist < clockRadius + 20) {
|
|
647
|
-
this._handleClockClick(x, y, clockCenterX, clockCenterY);
|
|
648
|
-
this.dragging = true;
|
|
649
|
-
return true;
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
// Buttons
|
|
653
|
-
const btnY = dy + this.dialogHeight - 40;
|
|
654
|
-
if (Math.abs(y - btnY) < 20) {
|
|
655
|
-
if (x > dx + this.dialogWidth - 200 && x < dx + this.dialogWidth - 100) {
|
|
656
|
-
this.hide();
|
|
657
|
-
return true;
|
|
658
|
-
}
|
|
659
|
-
if (x > dx + this.dialogWidth - 80) {
|
|
660
|
-
this._updateTime();
|
|
661
|
-
this.hide();
|
|
662
|
-
return true;
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
// Click outside - close dialog
|
|
667
|
-
if (x < dx || x > dx + this.dialogWidth || y < dy || y > dy + this.dialogHeight) {
|
|
668
|
-
this.hide();
|
|
669
|
-
return true;
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
return true;
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
handleMove(x, y) {
|
|
676
|
-
if (!this.dragging || !this.isVisible) return false;
|
|
677
|
-
|
|
678
|
-
const dx = (this.framework.width - this.dialogWidth) / 2;
|
|
679
|
-
const dy = (this.framework.height - this.dialogHeight) / 2;
|
|
680
|
-
const clockCenterX = dx + this.dialogWidth / 2;
|
|
681
|
-
const clockCenterY = dy + 280;
|
|
682
|
-
|
|
683
|
-
this._handleClockClick(x, y, clockCenterX, clockCenterY);
|
|
684
|
-
return true;
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
handleRelease(x, y) {
|
|
688
|
-
if (this.dragging) {
|
|
689
|
-
this.dragging = false;
|
|
690
|
-
// Auto switch to minutes after selecting hour
|
|
691
|
-
if (this.mode === 'hours') {
|
|
692
|
-
this.mode = 'minutes';
|
|
693
|
-
this._requestRedraw();
|
|
694
|
-
}
|
|
695
|
-
return true;
|
|
696
|
-
}
|
|
697
|
-
return false;
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
_handleClockClick(x, y, cx, cy) {
|
|
701
|
-
// Calculate angle from center
|
|
702
|
-
let angle = Math.atan2(y - cy, x - cx);
|
|
703
|
-
|
|
704
|
-
// Convert to 12-hour format (0 at top, clockwise)
|
|
705
|
-
// atan2 gives 0 at right (3 o'clock), we want 0 at top (12 o'clock)
|
|
706
|
-
angle = angle + Math.PI / 2;
|
|
707
|
-
if (angle < 0) angle += Math.PI * 2;
|
|
708
|
-
|
|
709
|
-
if (this.mode === 'hours') {
|
|
710
|
-
// Calculate hour (1-12)
|
|
711
|
-
let value = Math.round(angle / (Math.PI * 2 / 12));
|
|
712
|
-
if (value === 0) value = 12;
|
|
713
|
-
if (value > 12) value = value % 12;
|
|
714
|
-
this.hour = value;
|
|
715
|
-
} else {
|
|
716
|
-
// Calculate minutes (0-59, in steps of 5)
|
|
717
|
-
let value = Math.round(angle / (Math.PI * 2 / 12)) * 5;
|
|
718
|
-
if (value >= 60) value = 0;
|
|
719
|
-
this.minute = value;
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
this._updateTime();
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
_updateTime() {
|
|
726
|
-
let hour24 = this.hour;
|
|
727
|
-
if (this.isPM && hour24 !== 12) hour24 += 12;
|
|
728
|
-
if (!this.isPM && hour24 === 12) hour24 = 0;
|
|
729
|
-
|
|
730
|
-
this.selectedTime.setHours(hour24, this.minute, 0, 0);
|
|
731
|
-
if (this.onChange) this.onChange(this.selectedTime);
|
|
732
|
-
this._requestRedraw();
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
_requestRedraw() {
|
|
736
|
-
if (this.framework.requestRedraw) {
|
|
737
|
-
this.framework.requestRedraw();
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
draw(ctx) {
|
|
742
|
-
if (!this.isVisible || this.opacity <= 0) return;
|
|
743
|
-
|
|
744
|
-
ctx.save();
|
|
745
|
-
ctx.globalAlpha = this.opacity;
|
|
746
|
-
|
|
747
|
-
// Overlay
|
|
748
|
-
ctx.fillStyle = 'rgba(0,0,0,0.5)';
|
|
749
|
-
ctx.fillRect(0, 0, this.framework.width, this.framework.height);
|
|
750
|
-
|
|
751
|
-
const dx = (this.framework.width - this.dialogWidth) / 2;
|
|
752
|
-
const dy = (this.framework.height - this.dialogHeight) / 2;
|
|
753
|
-
|
|
754
|
-
// Card shadow
|
|
755
|
-
ctx.shadowColor = 'rgba(0,0,0,0.3)';
|
|
756
|
-
ctx.shadowBlur = 16;
|
|
757
|
-
ctx.shadowOffsetY = 8;
|
|
758
|
-
|
|
759
|
-
ctx.fillStyle = '#FFFFFF';
|
|
760
|
-
this.roundRect(ctx, dx, dy, this.dialogWidth, this.dialogHeight, 8);
|
|
761
|
-
ctx.fill();
|
|
762
|
-
|
|
763
|
-
ctx.shadowBlur = 0;
|
|
764
|
-
ctx.shadowOffsetY = 0;
|
|
765
|
-
|
|
766
|
-
// Header
|
|
767
|
-
ctx.fillStyle = this.headerBgColor;
|
|
768
|
-
this.roundRect(ctx, dx, dy, this.dialogWidth, 100, 8);
|
|
769
|
-
ctx.fill();
|
|
770
|
-
|
|
771
|
-
// Time display avec mode actif
|
|
772
|
-
ctx.textAlign = 'center';
|
|
773
|
-
ctx.textBaseline = 'middle';
|
|
774
|
-
|
|
775
|
-
const timeY = dy + 50;
|
|
776
|
-
|
|
777
|
-
// Heures
|
|
778
|
-
ctx.fillStyle = this.mode === 'hours' ? '#FFFFFF' : 'rgba(255,255,255,0.6)';
|
|
779
|
-
ctx.font = 'bold 48px Roboto,sans-serif';
|
|
780
|
-
ctx.fillText(this.hour.toString().padStart(2, '0'), dx + this.dialogWidth/2 - 40, timeY);
|
|
781
|
-
|
|
782
|
-
// Deux points
|
|
783
|
-
ctx.fillStyle = '#FFFFFF';
|
|
784
|
-
ctx.fillText(':', dx + this.dialogWidth/2, timeY);
|
|
785
|
-
|
|
786
|
-
// Minutes
|
|
787
|
-
ctx.fillStyle = this.mode === 'minutes' ? '#FFFFFF' : 'rgba(255,255,255,0.6)';
|
|
788
|
-
ctx.fillText(this.minute.toString().padStart(2, '0'), dx + this.dialogWidth/2 + 40, timeY);
|
|
789
|
-
|
|
790
|
-
// AM/PM
|
|
791
|
-
const pmY = dy + 30;
|
|
792
|
-
ctx.font = 'bold 14px Roboto,sans-serif';
|
|
793
|
-
ctx.fillStyle = this.isPM ? 'rgba(255,255,255,0.6)' : '#FFFFFF';
|
|
794
|
-
ctx.fillText('AM', dx + this.dialogWidth - 40, pmY);
|
|
795
|
-
ctx.fillStyle = this.isPM ? '#FFFFFF' : 'rgba(255,255,255,0.6)';
|
|
796
|
-
ctx.fillText('PM', dx + this.dialogWidth - 40, pmY + 25);
|
|
797
|
-
|
|
798
|
-
// Clock face
|
|
799
|
-
const clockCenterX = dx + this.dialogWidth / 2;
|
|
800
|
-
const clockCenterY = dy + 280;
|
|
801
|
-
const clockRadius = 120;
|
|
802
|
-
|
|
803
|
-
// Clock circle - FIX: Changé en gris plus clair pour contraste
|
|
804
|
-
ctx.fillStyle = '#F8F8F8';
|
|
805
|
-
ctx.beginPath();
|
|
806
|
-
ctx.arc(clockCenterX, clockCenterY, clockRadius, 0, Math.PI * 2);
|
|
807
|
-
ctx.fill();
|
|
808
|
-
|
|
809
|
-
// Draw numbers
|
|
810
|
-
if (this.mode === 'hours') {
|
|
811
|
-
this._drawClockNumbers(ctx, clockCenterX, clockCenterY, clockRadius, 12, this.hour);
|
|
812
|
-
} else {
|
|
813
|
-
this._drawClockMinutes(ctx, clockCenterX, clockCenterY, clockRadius, this.minute);
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
// Clock hand
|
|
817
|
-
this._drawClockHand(ctx, clockCenterX, clockCenterY, clockRadius);
|
|
818
|
-
|
|
819
|
-
// Actions buttons
|
|
820
|
-
const btnY = dy + this.dialogHeight - 40;
|
|
821
|
-
ctx.fillStyle = '#6200EE';
|
|
822
|
-
ctx.font = 'bold 14px Roboto,sans-serif';
|
|
823
|
-
ctx.textAlign = 'right';
|
|
824
|
-
ctx.fillText('ANNULER', dx + this.dialogWidth - 140, btnY);
|
|
825
|
-
ctx.fillText('OK', dx + this.dialogWidth - 30, btnY);
|
|
826
|
-
|
|
827
|
-
ctx.restore();
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
_drawClockNumbers(ctx, cx, cy, radius, count, selected) {
|
|
831
|
-
for (let i = 1; i <= count; i++) {
|
|
832
|
-
const angle = (i - 3) * (Math.PI * 2 / count);
|
|
833
|
-
const x = cx + Math.cos(angle) * (radius - 30);
|
|
834
|
-
const y = cy + Math.sin(angle) * (radius - 30);
|
|
835
|
-
|
|
836
|
-
const isSelected = i === selected;
|
|
837
|
-
|
|
838
|
-
if (isSelected) {
|
|
839
|
-
// Numéro sélectionné : fond violet, texte blanc
|
|
840
|
-
ctx.fillStyle = '#6200EE';
|
|
841
|
-
ctx.beginPath();
|
|
842
|
-
ctx.arc(x, y, 20, 0, Math.PI * 2);
|
|
843
|
-
ctx.fill();
|
|
844
|
-
ctx.fillStyle = '#FFFFFF';
|
|
845
|
-
} else {
|
|
846
|
-
// Numéros non sélectionnés : texte gris foncé pour contraste
|
|
847
|
-
ctx.fillStyle = '#424242';
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
ctx.font = 'bold 16px Roboto,sans-serif';
|
|
851
|
-
ctx.textAlign = 'center';
|
|
852
|
-
ctx.textBaseline = 'middle';
|
|
853
|
-
ctx.fillText(i.toString(), x, y);
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
_drawClockMinutes(ctx, cx, cy, radius, selected) {
|
|
858
|
-
// Afficher les minutes par pas de 5
|
|
859
|
-
for (let i = 0; i < 60; i += 5) {
|
|
860
|
-
const angle = (i / 5 - 3) * (Math.PI * 2 / 12);
|
|
861
|
-
const x = cx + Math.cos(angle) * (radius - 30);
|
|
862
|
-
const y = cy + Math.sin(angle) * (radius - 30);
|
|
863
|
-
|
|
864
|
-
const isSelected = i === selected;
|
|
865
|
-
|
|
866
|
-
if (isSelected) {
|
|
867
|
-
// Minute sélectionnée : fond violet, texte blanc
|
|
868
|
-
ctx.fillStyle = '#6200EE';
|
|
869
|
-
ctx.beginPath();
|
|
870
|
-
ctx.arc(x, y, 20, 0, Math.PI * 2);
|
|
871
|
-
ctx.fill();
|
|
872
|
-
ctx.fillStyle = '#FFFFFF';
|
|
873
|
-
} else {
|
|
874
|
-
// Minutes non sélectionnées : texte gris foncé
|
|
875
|
-
ctx.fillStyle = '#424242';
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
ctx.font = 'bold 16px Roboto,sans-serif';
|
|
879
|
-
ctx.textAlign = 'center';
|
|
880
|
-
ctx.textBaseline = 'middle';
|
|
881
|
-
ctx.fillText(i.toString().padStart(2, '0'), x, y);
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
_drawClockHand(ctx, cx, cy, radius) {
|
|
886
|
-
const value = this.mode === 'hours' ? this.hour : this.minute / 5;
|
|
887
|
-
const total = this.mode === 'hours' ? 12 : 12;
|
|
888
|
-
const angle = (value - 3) * (Math.PI * 2 / total);
|
|
889
|
-
|
|
890
|
-
const handLength = radius - 50;
|
|
891
|
-
const x = cx + Math.cos(angle) * handLength;
|
|
892
|
-
const y = cy + Math.sin(angle) * handLength;
|
|
893
|
-
|
|
894
|
-
// Line
|
|
895
|
-
ctx.strokeStyle = '#6200EE';
|
|
896
|
-
ctx.lineWidth = 2;
|
|
897
|
-
ctx.beginPath();
|
|
898
|
-
ctx.moveTo(cx, cy);
|
|
899
|
-
ctx.lineTo(x, y);
|
|
900
|
-
ctx.stroke();
|
|
901
|
-
|
|
902
|
-
// Center dot
|
|
903
|
-
ctx.fillStyle = '#6200EE';
|
|
904
|
-
ctx.beginPath();
|
|
905
|
-
ctx.arc(cx, cy, 6, 0, Math.PI * 2);
|
|
906
|
-
ctx.fill();
|
|
907
|
-
|
|
908
|
-
// End dot
|
|
909
|
-
ctx.beginPath();
|
|
910
|
-
ctx.arc(x, y, 4, 0, Math.PI * 2);
|
|
911
|
-
ctx.fill();
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
// IMPORTANT: S'assurer que le composant est clickable
|
|
915
|
-
isPointInside(x, y) {
|
|
916
|
-
return this.isVisible && this.opacity > 0;
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
roundRect(ctx, x, y, w, h, r) {
|
|
920
|
-
ctx.beginPath();
|
|
921
|
-
ctx.moveTo(x+r,y);
|
|
922
|
-
ctx.lineTo(x+w-r,y);
|
|
923
|
-
ctx.quadraticCurveTo(x+w,y,x+w,y+r);
|
|
924
|
-
ctx.lineTo(x+w,y+h-r);
|
|
925
|
-
ctx.quadraticCurveTo(x+w,y+h,x+w-r,y+h);
|
|
926
|
-
ctx.lineTo(x+r,y+h);
|
|
927
|
-
ctx.quadraticCurveTo(x,y+h,x,y+h-r);
|
|
928
|
-
ctx.lineTo(x,y+r);
|
|
929
|
-
ctx.quadraticCurveTo(x,y,x+r,y);
|
|
930
|
-
ctx.closePath();
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
export default TimePicker;
|