nn-widgets 0.1.14 → 0.1.16

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,6 +1,6 @@
1
1
  {
2
2
  "name": "nn-widgets",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "Expo config plugin for adding native widgets (iOS WidgetKit & Android App Widgets)",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -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;AA4oDjB,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"}
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;AA8pDjB,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";
@@ -1068,7 +1085,6 @@ struct ${w.name}EntryView: View {
1068
1085
  .foregroundColor(.secondary)
1069
1086
  }
1070
1087
  .frame(maxWidth: .infinity, maxHeight: .infinity)
1071
- .background(${bgColor})
1072
1088
  } else {
1073
1089
  GeometryReader { geometry in
1074
1090
  let availableWidth = geometry.size.width
@@ -1100,7 +1116,6 @@ struct ${w.name}EntryView: View {
1100
1116
  }
1101
1117
  }
1102
1118
  }
1103
- .background(${bgColor})
1104
1119
  }
1105
1120
  }
1106
1121
  }
@@ -1267,9 +1282,7 @@ struct ${w.name}: Widget {
1267
1282
  }`;
1268
1283
  }
1269
1284
  function generateSingleTypeWidgetCode(w, deepLinkLine) {
1270
- const bgColor = w.style?.backgroundColor
1271
- ? `Color(hex: "${w.style.backgroundColor}")`
1272
- : ".clear";
1285
+ const bgColor = resolveBackgroundColor(w.style?.backgroundColor);
1273
1286
  const titleColor = w.style?.titleColor
1274
1287
  ? `Color(hex: "${w.style.titleColor}")`
1275
1288
  : ".primary";