-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest-image-fixes.ts
More file actions
295 lines (263 loc) · 8.28 KB
/
test-image-fixes.ts
File metadata and controls
295 lines (263 loc) · 8.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
/**
* Test file to verify the image icon fixes
* This tests the main issues that were reported and fixed
*/
import { TabsBar } from './src/index';
// Test 1: Verify images display without color tinting
async function testImageDisplayFix() {
console.log('🧪 Testing image display fix...');
// Use a colorful test image to verify it's not being tinted
const testImage = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==';
await TabsBar.configure({
items: [
{
id: 'test-image',
title: 'Test Image',
systemIcon: 'photo',
imageIcon: {
shape: 'square',
size: 'fit',
image: testImage
}
}
],
initialId: 'test-image',
visible: true,
selectedIconColor: '#FF0000', // Red - should NOT tint the image
unselectedIconColor: '#0000FF' // Blue - should NOT tint the image
});
console.log('✅ Image should display without color tinting');
}
// Test 2: Verify smaller size and padding
async function testSizeAndPadding() {
console.log('🧪 Testing smaller size and padding...');
await TabsBar.configure({
items: [
{
id: 'size-test',
title: 'Size Test',
systemIcon: 'square',
imageIcon: {
shape: 'square',
size: 'fit', // Should have padding around the image
image: 'https://via.placeholder.com/50x50/FF5733/FFFFFF?text=SIZE'
}
}
],
initialId: 'size-test',
visible: true
});
console.log('✅ Image should be smaller (24x24) with padding');
}
// Test 3: Verify enhanced ring functionality
async function testRingFeature() {
console.log('🧪 Testing enhanced ring feature...');
await TabsBar.configure({
items: [
{
id: 'ring-test',
title: 'Ring Test',
systemIcon: 'circle',
imageIcon: {
shape: 'circle',
size: 'fit',
image: 'https://via.placeholder.com/30x30/34C759/FFFFFF?text=RING',
ring: {
enabled: true,
width: 3.0
}
}
},
{
id: 'no-ring-test',
title: 'No Ring',
systemIcon: 'square',
imageIcon: {
shape: 'square',
size: 'fit',
image: 'https://via.placeholder.com/30x30/007AFF/FFFFFF?text=NO',
// ring is optional, so we can omit it entirely if no ring is desired
}
}
],
initialId: 'ring-test',
visible: true,
selectedIconColor: '#FF3B30', // Red ring for selected tab
unselectedIconColor: '#8E8E93' // Gray ring for unselected tab
});
console.log('✅ Selected tab should show red ring, unselected should show gray ring');
console.log('✅ Rings should have transparent spacer and 2px bottom padding');
}
// Test 4: Comprehensive test with all enhanced fixes
async function testAllFixes() {
console.log('🧪 Testing all enhanced fixes together...');
await TabsBar.configure({
items: [
{
id: 'fix1',
title: 'No Tint',
systemIcon: 'photo',
imageIcon: {
shape: 'circle',
size: 'fit',
image: 'https://via.placeholder.com/40x40/FF5733/FFFFFF?text=1'
}
},
{
id: 'fix2',
title: 'With Ring',
systemIcon: 'star',
imageIcon: {
shape: 'square',
size: 'fit',
image: 'https://via.placeholder.com/40x40/007AFF/FFFFFF?text=2',
ring: {
enabled: true,
width: 2.5
}
}
},
{
id: 'fix3',
title: 'Enhanced',
systemIcon: 'heart',
// imageIcon is optional, so we can omit it entirely
}
],
initialId: 'fix1',
visible: true,
selectedIconColor: '#FF3B30',
unselectedIconColor: '#8E8E93'
});
console.log('✅ All enhanced fixes applied: no tinting, proper sizing, padding, and dual-state rings');
}
// Test 5: Test different ring widths and configurations
async function testRingVariations() {
console.log('🧪 Testing ring width variations...');
await TabsBar.configure({
items: [
{
id: 'thin-ring',
title: 'Thin',
systemIcon: 'circle',
imageIcon: {
shape: 'circle',
size: 'fit',
image: 'https://via.placeholder.com/30x30/FF5733/FFFFFF?text=1',
ring: {
enabled: true,
width: 1.0
}
}
},
{
id: 'medium-ring',
title: 'Medium',
systemIcon: 'square',
imageIcon: {
shape: 'square',
size: 'fit',
image: 'https://via.placeholder.com/30x30/007AFF/FFFFFF?text=2',
ring: {
enabled: true,
width: 2.5
}
}
},
{
id: 'thick-ring',
title: 'Thick',
systemIcon: 'star',
imageIcon: {
shape: 'circle',
size: 'fit',
image: 'https://via.placeholder.com/30x30/34C759/FFFFFF?text=3',
ring: {
enabled: true,
width: 4.0
}
}
},
{
id: 'no-ring',
title: 'None',
systemIcon: 'triangle',
imageIcon: {
shape: 'square',
size: 'fit',
image: 'https://via.placeholder.com/30x30/FF9500/FFFFFF?text=4',
// ring is optional, so we can omit it entirely
}
}
],
initialId: 'medium-ring',
visible: true,
selectedIconColor: '#FF3B30',
unselectedIconColor: '#8E8E93'
});
console.log('✅ Ring variations: 1px, 2.5px, 4px, and no ring');
console.log('✅ Each should show appropriate spacer and padding');
}
// Run all tests
export async function runImageFixTests() {
console.log('🚀 Starting enhanced image icon fix tests...\n');
try {
await testImageDisplayFix();
console.log('');
await testSizeAndPadding();
console.log('');
await testRingFeature();
console.log('');
await testAllFixes();
console.log('');
await testRingVariations();
console.log('');
console.log('🎉 All enhanced tests completed successfully!');
console.log('\nEnhanced fixes implemented:');
console.log('✅ Images now use .withRenderingMode(.alwaysOriginal) to prevent color tinting');
console.log('✅ Icon size reduced to 24x24 with 4px padding for better appearance');
console.log('✅ Enhanced ring feature with dual-state support:');
console.log(' • Selected tabs show ring in selectedIconColor');
console.log(' • Unselected tabs show ring in unselectedIconColor');
console.log(' • Transparent spacer ring between image and colored ring');
console.log(' • Additional 2px padding beneath rings');
console.log('✅ TypeScript definitions updated with ImageIconRing interface');
console.log('✅ Example files updated to demonstrate enhanced features');
} catch (error) {
console.error('❌ Test failed:', error);
}
}
// Export individual test functions
export {
testImageDisplayFix,
testSizeAndPadding,
testRingFeature,
testAllFixes,
testRingVariations
};
// Usage instructions
console.log(`
Image Icon Fixes Test Suite:
ENHANCED ISSUES FIXED:
1. 🎨 Image Display: Images were being tinted by selectedIconColor/unselectedIconColor
- Fixed by using .withRenderingMode(.alwaysOriginal)
2. 📏 Size & Padding: Images were too large and had no padding
- Reduced from 30x30 to 24x24 pixels
- Added 4px padding around images in 'fit' mode
3. 💍 Enhanced Ring Feature: Added dual-state rings around images
- Selected tabs show ring in selectedIconColor
- Unselected tabs show ring in unselectedIconColor
- Transparent spacer ring between image and colored ring (same width as ring)
- Additional 2px padding beneath rings for better visual spacing
- Configurable width (default: 2.0px)
- Can be enabled/disabled per image
USAGE:
import { runImageFixTests } from './test-image-fixes';
runImageFixTests();
Or run individual tests:
- testImageDisplayFix() - Test color tinting fix
- testSizeAndPadding() - Test size and padding improvements
- testRingFeature() - Test enhanced ring functionality
- testAllFixes() - Test all enhanced fixes together
- testRingVariations() - Test different ring widths and configurations
`);