nn-widgets 0.1.13 → 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,6 +1,6 @@
1
1
  {
2
2
  "name": "nn-widgets",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
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;AA8mDjB,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;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}`;
@@ -139,6 +162,15 @@ struct WidgetIconConfig {
139
162
  self.borderWidth = 0
140
163
  self.borderColor = nil
141
164
  }
165
+
166
+ init(url: String, size: CGFloat, radius: CGFloat, backgroundColor: String?, borderWidth: CGFloat, borderColor: String?) {
167
+ self.url = url
168
+ self.size = size
169
+ self.radius = radius
170
+ self.backgroundColor = backgroundColor
171
+ self.borderWidth = borderWidth
172
+ self.borderColor = borderColor
173
+ }
142
174
  }
143
175
 
144
176
  struct WidgetTextConfig {
@@ -386,9 +418,7 @@ struct ${w.name}: Widget {
386
418
  }`;
387
419
  }
388
420
  function generateListWidgetCode(w, deepLinkLine) {
389
- const bgColor = w.style?.backgroundColor
390
- ? `Color(hex: "${w.style.backgroundColor}")`
391
- : ".clear";
421
+ const bgColor = resolveBackgroundColor(w.style?.backgroundColor);
392
422
  const titleColor = w.style?.titleColor
393
423
  ? `Color(hex: "${w.style.titleColor}")`
394
424
  : ".primary";
@@ -598,9 +628,7 @@ function generateGridWidgetCode(w, deepLinkLine) {
598
628
  gridRows = parseInt(match[2], 10);
599
629
  }
600
630
  }
601
- const bgColor = w.style?.backgroundColor
602
- ? `Color(hex: "${w.style.backgroundColor}")`
603
- : ".clear";
631
+ const bgColor = resolveBackgroundColor(w.style?.backgroundColor);
604
632
  const titleColor = w.style?.titleColor
605
633
  ? `Color(hex: "${w.style.titleColor}")`
606
634
  : ".primary";
@@ -790,9 +818,7 @@ struct ${w.name}: Widget {
790
818
  }`;
791
819
  }
792
820
  function generateFlexGridWidgetCode(w, deepLinkLine) {
793
- const bgColor = w.style?.backgroundColor
794
- ? `Color(hex: "${w.style.backgroundColor}")`
795
- : ".clear";
821
+ const bgColor = resolveBackgroundColor(w.style?.backgroundColor);
796
822
  const titleColor = w.style?.titleColor
797
823
  ? `Color(hex: "${w.style.titleColor}")`
798
824
  : ".primary";
@@ -989,19 +1015,40 @@ struct ${w.name}FlexCell: View {
989
1015
  } else if isIconOnly {
990
1016
  // Icon only mode - centered in cell
991
1017
  if let icon = item.icon {
992
- WidgetIconView(config: icon, accentColor: defaultAccentColor)
1018
+ let scaledIcon = WidgetIconConfig(
1019
+ url: icon.url,
1020
+ size: icon.size * 1.3,
1021
+ radius: icon.radius * 1.3,
1022
+ backgroundColor: icon.backgroundColor,
1023
+ borderWidth: icon.borderWidth,
1024
+ borderColor: icon.borderColor
1025
+ )
1026
+ WidgetIconView(config: scaledIcon, accentColor: defaultAccentColor)
993
1027
  }
994
1028
  } else {
995
1029
  // Card style: icon on top, small title below
996
1030
  VStack(spacing: 4) {
997
1031
  if let icon = item.icon {
998
- WidgetIconView(config: icon, accentColor: defaultAccentColor)
1032
+ // Scale up icon for card style (1.3x larger)
1033
+ let scaledIcon = WidgetIconConfig(
1034
+ url: icon.url,
1035
+ size: icon.size * 1.3,
1036
+ radius: icon.radius * 1.3,
1037
+ backgroundColor: icon.backgroundColor,
1038
+ borderWidth: icon.borderWidth,
1039
+ borderColor: icon.borderColor
1040
+ )
1041
+ WidgetIconView(config: scaledIcon, accentColor: defaultAccentColor)
999
1042
  }
1000
1043
 
1001
1044
  Text(item.title.text)
1002
- .font(.caption2)
1003
- .fontWeight(.medium)
1004
- .foregroundColor(defaultTitleColor)
1045
+ .font(item.title.resolvedFont(default: .caption2))
1046
+ .fontWeight(item.title.resolvedWeight(default: .medium))
1047
+ .foregroundColor(
1048
+ item.title.color != nil
1049
+ ? Color(hex: item.title.color!)
1050
+ : defaultTitleColor
1051
+ )
1005
1052
  .lineLimit(2)
1006
1053
  .multilineTextAlignment(.center)
1007
1054
  .truncationMode(.tail)
@@ -1237,9 +1284,7 @@ struct ${w.name}: Widget {
1237
1284
  }`;
1238
1285
  }
1239
1286
  function generateSingleTypeWidgetCode(w, deepLinkLine) {
1240
- const bgColor = w.style?.backgroundColor
1241
- ? `Color(hex: "${w.style.backgroundColor}")`
1242
- : ".clear";
1287
+ const bgColor = resolveBackgroundColor(w.style?.backgroundColor);
1243
1288
  const titleColor = w.style?.titleColor
1244
1289
  ? `Color(hex: "${w.style.titleColor}")`
1245
1290
  : ".primary";