nn-widgets 0.1.14 → 0.1.15
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/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withIosWidget.d.ts","sourceRoot":"","sources":["../src/withIosWidget.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAIb,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EAEpB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"withIosWidget.d.ts","sourceRoot":"","sources":["../src/withIosWidget.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAIb,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EAEpB,MAAM,SAAS,CAAC;AAgqDjB,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,oBAAoB,CAugB5D,CAAC;AAMF,wBAAgB,eAAe,CAC7B,KAAK,EAAE,oBAAoB,EAC3B,OAAO,EAAE,MAAM,EACf,gBAAgB,EAAE,MAAM,GACvB,mBAAmB,CA2GrB;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -41,6 +41,29 @@ const path = __importStar(require("path"));
|
|
|
41
41
|
// ──────────────────────────────────────────────
|
|
42
42
|
// Swift code generation helpers
|
|
43
43
|
// ──────────────────────────────────────────────
|
|
44
|
+
// Material background types supported by SwiftUI
|
|
45
|
+
const MATERIAL_BACKGROUNDS = {
|
|
46
|
+
blur: ".regularMaterial",
|
|
47
|
+
ultraThinMaterial: ".ultraThinMaterial",
|
|
48
|
+
thinMaterial: ".thinMaterial",
|
|
49
|
+
regularMaterial: ".regularMaterial",
|
|
50
|
+
thickMaterial: ".thickMaterial",
|
|
51
|
+
ultraThickMaterial: ".ultraThickMaterial",
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Convert backgroundColor value to SwiftUI code.
|
|
55
|
+
* Supports: hex colors (#FFFFFF), material names (blur, thinMaterial, etc.)
|
|
56
|
+
*/
|
|
57
|
+
function resolveBackgroundColor(backgroundColor, defaultValue = ".clear") {
|
|
58
|
+
if (!backgroundColor)
|
|
59
|
+
return defaultValue;
|
|
60
|
+
// Check if it's a material background
|
|
61
|
+
const material = MATERIAL_BACKGROUNDS[backgroundColor];
|
|
62
|
+
if (material)
|
|
63
|
+
return material;
|
|
64
|
+
// Otherwise treat as hex color
|
|
65
|
+
return `Color(hex: "${backgroundColor}")`;
|
|
66
|
+
}
|
|
44
67
|
function generateDataProviderCode(props, bundleId) {
|
|
45
68
|
const useAppGroups = props.ios.useAppGroups;
|
|
46
69
|
const appGroupId = props.ios.appGroupIdentifier || `group.${bundleId}`;
|
|
@@ -395,9 +418,7 @@ struct ${w.name}: Widget {
|
|
|
395
418
|
}`;
|
|
396
419
|
}
|
|
397
420
|
function generateListWidgetCode(w, deepLinkLine) {
|
|
398
|
-
const bgColor = w.style?.backgroundColor
|
|
399
|
-
? `Color(hex: "${w.style.backgroundColor}")`
|
|
400
|
-
: ".clear";
|
|
421
|
+
const bgColor = resolveBackgroundColor(w.style?.backgroundColor);
|
|
401
422
|
const titleColor = w.style?.titleColor
|
|
402
423
|
? `Color(hex: "${w.style.titleColor}")`
|
|
403
424
|
: ".primary";
|
|
@@ -607,9 +628,7 @@ function generateGridWidgetCode(w, deepLinkLine) {
|
|
|
607
628
|
gridRows = parseInt(match[2], 10);
|
|
608
629
|
}
|
|
609
630
|
}
|
|
610
|
-
const bgColor = w.style?.backgroundColor
|
|
611
|
-
? `Color(hex: "${w.style.backgroundColor}")`
|
|
612
|
-
: ".clear";
|
|
631
|
+
const bgColor = resolveBackgroundColor(w.style?.backgroundColor);
|
|
613
632
|
const titleColor = w.style?.titleColor
|
|
614
633
|
? `Color(hex: "${w.style.titleColor}")`
|
|
615
634
|
: ".primary";
|
|
@@ -799,9 +818,7 @@ struct ${w.name}: Widget {
|
|
|
799
818
|
}`;
|
|
800
819
|
}
|
|
801
820
|
function generateFlexGridWidgetCode(w, deepLinkLine) {
|
|
802
|
-
const bgColor = w.style?.backgroundColor
|
|
803
|
-
? `Color(hex: "${w.style.backgroundColor}")`
|
|
804
|
-
: ".clear";
|
|
821
|
+
const bgColor = resolveBackgroundColor(w.style?.backgroundColor);
|
|
805
822
|
const titleColor = w.style?.titleColor
|
|
806
823
|
? `Color(hex: "${w.style.titleColor}")`
|
|
807
824
|
: ".primary";
|
|
@@ -1267,9 +1284,7 @@ struct ${w.name}: Widget {
|
|
|
1267
1284
|
}`;
|
|
1268
1285
|
}
|
|
1269
1286
|
function generateSingleTypeWidgetCode(w, deepLinkLine) {
|
|
1270
|
-
const bgColor = w.style?.backgroundColor
|
|
1271
|
-
? `Color(hex: "${w.style.backgroundColor}")`
|
|
1272
|
-
: ".clear";
|
|
1287
|
+
const bgColor = resolveBackgroundColor(w.style?.backgroundColor);
|
|
1273
1288
|
const titleColor = w.style?.titleColor
|
|
1274
1289
|
? `Color(hex: "${w.style.titleColor}")`
|
|
1275
1290
|
: ".primary";
|