canvasframework 0.3.27 → 0.3.28

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.
@@ -31,21 +31,29 @@ class AndroidDatePickerDialog extends Component {
31
31
  height: framework.height,
32
32
  visible: false
33
33
  });
34
-
34
+
35
35
  this.selectedDate = options.selectedDate || new Date();
36
36
  this.onChange = options.onChange;
37
37
  this.currentMonth = this.selectedDate.getMonth();
38
38
  this.currentYear = this.selectedDate.getFullYear();
39
39
  this.hoveredDay = null;
40
-
40
+
41
+ // Options de personnalisation
42
+ this.headerBgColor = options.headerBgColor || '#6200EE';
43
+ this.selectedColor = options.selectedColor || '#6200EE';
44
+ this.buttonColor = options.buttonColor || '#6200EE';
45
+ this.todayColor = options.todayColor || '#6200EE';
46
+ this.textColor = options.textColor || '#000000';
47
+ this.dayNamesColor = options.dayNamesColor || '#666666';
48
+
41
49
  this.dialogWidth = Math.min(320, framework.width - 40);
42
50
  this.dialogHeight = 420;
43
51
  this.headerHeight = 100;
44
52
  this.daySize = (this.dialogWidth - 40) / 7;
45
-
53
+
46
54
  this.opacity = 0;
47
55
  this.isVisible = false;
48
-
56
+
49
57
  this.onPress = this.handlePress.bind(this);
50
58
  }
51
59
 
@@ -183,7 +191,7 @@ class AndroidDatePickerDialog extends Component {
183
191
  const selectedMonth = monthNames[this.selectedDate.getMonth()];
184
192
  const selectedDayNum = this.selectedDate.getDate();
185
193
 
186
- ctx.fillStyle = '#FFFFFF';
194
+ ctx.fillStyle = '#000000';
187
195
  ctx.font = 'bold 32px Roboto, sans-serif';
188
196
  ctx.textBaseline = 'middle';
189
197
  ctx.fillText(`${selectedDay}, ${selectedMonth} ${selectedDayNum}`,
@@ -263,7 +271,7 @@ class AndroidDatePickerDialog extends Component {
263
271
  }
264
272
 
265
273
  // Numéro
266
- ctx.fillStyle = isSelected ? '#FFFFFF' : '#000000';
274
+ ctx.fillStyle = isSelected ? '#FFFFFF' : '#212121';
267
275
  ctx.font = '14px Roboto, sans-serif';
268
276
  ctx.textAlign = 'center';
269
277
  ctx.textBaseline = 'middle';
@@ -35,19 +35,29 @@ class DatePicker extends Component {
35
35
  this.onChange = options.onChange;
36
36
  this.platform = framework.platform;
37
37
  this.label = options.label || 'Sélectionner une date';
38
-
39
- // Pour iOS: créer un bouton qui ouvre le picker
38
+
39
+ // Options de personnalisation
40
+ this.headerBgColor = options.headerBgColor || '#6200EE'; // Android dialog header
41
+ this.inputBgColor = options.inputBgColor || null;
42
+ this.inputTextColor = options.inputTextColor || null;
43
+ this.inputBorderColor = options.inputBorderColor || null;
44
+ this.labelColor = options.labelColor || null;
45
+ this.inputHeight = options.inputHeight || 50;
46
+ this.inputRadius = options.inputRadius || (this.platform === 'cupertino' ? 10 : 0);
47
+ this.fontSize = options.fontSize || null;
48
+ this.selectedColor = options.selectedColor || '#6200EE'; // Android selected items
49
+ this.buttonColor = options.buttonColor || '#6200EE'; // Android buttons
50
+
51
+ // Dimensions
40
52
  if (this.platform === 'cupertino') {
41
53
  this.width = options.width || framework.width - 40;
42
- this.height = 50;
43
54
  this.pickerModal = null;
44
- this.onClick = this.openPicker.bind(this);
45
55
  } else {
46
- // Pour Android: afficher directement le modal
47
56
  this.width = options.width || Math.min(320, framework.width - 40);
48
- this.height = 50;
49
- this.onClick = this.openPicker.bind(this);
50
57
  }
58
+
59
+ this.height = this.inputHeight;
60
+ this.onClick = this.openPicker.bind(this);
51
61
  }
52
62
 
53
63
  /**
@@ -69,7 +79,6 @@ class DatePicker extends Component {
69
79
 
70
80
 
71
81
  openIOSPicker() {
72
- // Créer un modal avec le picker iOS
73
82
  const modal = new Modal(this.framework, {
74
83
  title: '',
75
84
  width: this.framework.width,
@@ -78,8 +87,7 @@ class DatePicker extends Component {
78
87
  closeOnOverlayClick: true,
79
88
  bgColor: '#F9F9F9'
80
89
  });
81
-
82
- // Créer le picker de date iOS style
90
+
83
91
  const picker = new IOSDatePickerWheel(this.framework, {
84
92
  x: 0,
85
93
  y: 20,
@@ -89,22 +97,23 @@ class DatePicker extends Component {
89
97
  this.selectedDate = date;
90
98
  if (this.onChange) this.onChange(date);
91
99
  }
100
+ // Ajoutez ici d'autres options si IOSDatePickerWheel en supporte
92
101
  });
93
102
  modal.add(picker);
94
-
95
- // Bouton Valider
103
+
96
104
  const btnOK = new Button(this.framework, {
97
105
  x: (this.framework.width - 200) / 2,
98
106
  y: 230,
99
107
  width: 200,
100
108
  height: 44,
101
109
  text: 'Valider',
102
- onClick: () => {
103
- modal.hide();
104
- }
110
+ // Personnalisation du bouton si nécessaire
111
+ bgColor: this.buttonColor,
112
+ textColor: '#FFFFFF',
113
+ onClick: () => modal.hide()
105
114
  });
106
115
  modal.add(btnOK);
107
-
116
+
108
117
  this.framework.add(modal);
109
118
  modal.show();
110
119
  this.pickerModal = modal;
@@ -115,15 +124,18 @@ class DatePicker extends Component {
115
124
  * @private
116
125
  */
117
126
  openAndroidDialog() {
118
- // Créer un dialog Material Design avec calendrier
119
127
  const dialog = new AndroidDatePickerDialog(this.framework, {
120
128
  selectedDate: this.selectedDate,
121
129
  onChange: (date) => {
122
130
  this.selectedDate = date;
123
131
  if (this.onChange) this.onChange(date);
124
- }
132
+ },
133
+ // Transmettre toutes les options de couleur
134
+ headerBgColor: this.headerBgColor,
135
+ selectedColor: this.selectedColor,
136
+ buttonColor: this.buttonColor
125
137
  });
126
-
138
+
127
139
  this.framework.add(dialog);
128
140
  dialog.show();
129
141
  }
@@ -134,34 +146,39 @@ class DatePicker extends Component {
134
146
  */
135
147
  draw(ctx) {
136
148
  if (this.platform === 'cupertino') {
137
- // Dessiner un bouton iOS
149
+ // Styles Cupertino
150
+ const bgColor = this.inputBgColor || '#FFFFFF';
151
+ const textColor = this.inputTextColor || '#000000';
152
+ const labelColor = this.labelColor || '#8E8E93';
153
+ const borderColor = this.inputBorderColor || '#C7C7CC';
154
+ const fontSize = this.fontSize || 16;
155
+
138
156
  ctx.save();
139
-
157
+
140
158
  // Background
141
- ctx.fillStyle = '#FFFFFF';
142
- ctx.beginPath();
143
- this.roundRect(ctx, this.x, this.y, this.width, this.height, 10);
159
+ ctx.fillStyle = bgColor;
160
+ this.roundRect(ctx, this.x, this.y, this.width, this.height, this.inputRadius);
144
161
  ctx.fill();
145
-
146
- // Bordure
147
- ctx.strokeStyle = '#C7C7CC';
162
+
163
+ // Border
164
+ ctx.strokeStyle = borderColor;
148
165
  ctx.lineWidth = 1;
149
166
  ctx.stroke();
150
-
167
+
151
168
  // Label
152
- ctx.fillStyle = '#8E8E93';
169
+ ctx.fillStyle = labelColor;
153
170
  ctx.font = '14px -apple-system, sans-serif';
154
171
  ctx.textAlign = 'left';
155
172
  ctx.textBaseline = 'middle';
156
173
  ctx.fillText(this.label, this.x + 15, this.y + this.height / 2 - 10);
157
-
158
- // Date sélectionnée
159
- ctx.fillStyle = '#000000';
160
- ctx.font = '16px -apple-system, sans-serif';
174
+
175
+ // Selected date
176
+ ctx.fillStyle = textColor;
177
+ ctx.font = `${fontSize}px -apple-system, sans-serif`;
161
178
  ctx.fillText(this.formatDate(this.selectedDate), this.x + 15, this.y + this.height / 2 + 10);
162
-
179
+
163
180
  // Chevron
164
- ctx.strokeStyle = '#C7C7CC';
181
+ ctx.strokeStyle = borderColor;
165
182
  ctx.lineWidth = 2;
166
183
  ctx.lineCap = 'round';
167
184
  ctx.beginPath();
@@ -169,23 +186,40 @@ class DatePicker extends Component {
169
186
  ctx.lineTo(this.x + this.width - 20, this.y + this.height / 2);
170
187
  ctx.lineTo(this.x + this.width - 15, this.y + this.height / 2 - 5);
171
188
  ctx.stroke();
172
-
189
+
173
190
  ctx.restore();
174
191
  } else {
175
- // Dessiner un bouton Material
192
+ // Styles Material
193
+ const bgColor = this.inputBgColor || (this.pressed ? '#F5F5F5' : '#FFFFFF');
194
+ const textColor = this.inputTextColor || '#000000';
195
+ const labelColor = this.labelColor || '#666666';
196
+ const borderColor = this.inputBorderColor || '#E0E0E0';
197
+ const fontSize = this.fontSize || 16;
198
+ const iconColor = labelColor;
199
+
176
200
  ctx.save();
177
-
201
+
178
202
  // Background
179
- ctx.fillStyle = this.pressed ? '#F5F5F5' : '#FFFFFF';
180
- ctx.fillRect(this.x, this.y, this.width, this.height);
181
-
182
- // Bordure
183
- ctx.strokeStyle = '#E0E0E0';
203
+ ctx.fillStyle = bgColor;
204
+ if (this.inputRadius > 0) {
205
+ this.roundRect(ctx, this.x, this.y, this.width, this.height, this.inputRadius);
206
+ ctx.fill();
207
+ } else {
208
+ ctx.fillRect(this.x, this.y, this.width, this.height);
209
+ }
210
+
211
+ // Border
212
+ ctx.strokeStyle = borderColor;
184
213
  ctx.lineWidth = 1;
185
- ctx.strokeRect(this.x, this.y, this.width, this.height);
186
-
187
- // Icône calendrier
188
- ctx.strokeStyle = '#666666';
214
+ if (this.inputRadius > 0) {
215
+ this.roundRect(ctx, this.x, this.y, this.width, this.height, this.inputRadius);
216
+ ctx.stroke();
217
+ } else {
218
+ ctx.strokeRect(this.x, this.y, this.width, this.height);
219
+ }
220
+
221
+ // Calendar icon
222
+ ctx.strokeStyle = iconColor;
189
223
  ctx.lineWidth = 2;
190
224
  ctx.strokeRect(this.x + 15, this.y + 15, 20, 20);
191
225
  ctx.beginPath();
@@ -194,20 +228,20 @@ class DatePicker extends Component {
194
228
  ctx.moveTo(this.x + 32, this.y + 12);
195
229
  ctx.lineTo(this.x + 32, this.y + 18);
196
230
  ctx.stroke();
197
-
231
+
198
232
  // Label
199
- ctx.fillStyle = '#666666';
233
+ ctx.fillStyle = labelColor;
200
234
  ctx.font = '12px Roboto, sans-serif';
201
235
  ctx.textAlign = 'left';
202
236
  ctx.textBaseline = 'top';
203
237
  ctx.fillText(this.label, this.x + 45, this.y + 8);
204
-
238
+
205
239
  // Date
206
- ctx.fillStyle = '#000000';
207
- ctx.font = '16px Roboto, sans-serif';
240
+ ctx.fillStyle = textColor;
241
+ ctx.font = `${fontSize}px Roboto, sans-serif`;
208
242
  ctx.textBaseline = 'bottom';
209
243
  ctx.fillText(this.formatDate(this.selectedDate), this.x + 45, this.y + this.height - 8);
210
-
244
+
211
245
  ctx.restore();
212
246
  }
213
247
  }