@nativescript-community/ui-card 1.0.1 → 1.0.3

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.0.3](https://github.com/nativescript-community/ui-native-components/compare/v1.0.2...v1.0.3) (2026-10-22)
7
+
8
+ **Note:** Version bump only for package @nativescript-community/ui-card
9
+
10
+ ## [1.0.2](https://github.com/nativescript-community/ui-native-components/compare/v1.0.1...v1.0.2) (2026-10-20)
11
+
12
+ **Note:** Version bump only for package @nativescript-community/ui-card
13
+
6
14
  ## [1.0.1](https://github.com/nativescript-community/ui-native-components/compare/v1.0.0...v1.0.1) (2026-10-19)
7
15
 
8
16
  ### Bug Fixes
@@ -1,16 +1,22 @@
1
1
  import { Background, Color, backgroundColorProperty, backgroundInternalProperty } from '@nativescript/core';
2
+ import { elevationProperty, shapeProperty } from '@nativescript-community/ui-core';
2
3
  import { CardBase, CardVariant, variantProperty } from './index-common';
3
4
  export * from './index-common';
4
5
  /**
5
6
  * Android: MaterialCardView, with the elevated, filled and outlined Material 3 looks.
6
7
  */
7
8
  export declare class Card extends CardBase {
9
+ [shapeProperty.setNative]: (shape: any) => void;
10
+ [elevationProperty.setNative]: (value: any) => void;
8
11
  [variantProperty.setNative]: (value: CardVariant) => void;
9
12
  [backgroundColorProperty.setNative]: (value: Color) => void;
10
13
  [backgroundInternalProperty.setNative]: (value: Background) => void;
11
14
  nativeViewProtected: com.google.android.material.card.MaterialCardView;
12
15
  private mUserColor;
13
16
  private mUserBackground;
17
+ private mUserElevation;
18
+ private mShape;
19
+ private mDefaultAppearanceModel;
14
20
  createNativeView(): com.google.android.material.card.MaterialCardView;
15
21
  initNativeView(): void;
16
22
  /**
package/index.android.js CHANGED
@@ -1,11 +1,10 @@
1
- import { Color, Utils, backgroundColorProperty, backgroundInternalProperty } from '@nativescript/core';
1
+ import { Color, Length, Utils, backgroundColorProperty, backgroundInternalProperty } from '@nativescript/core';
2
+ import { elevationProperty, shapeProperty, themer } from '@nativescript-community/ui-core';
2
3
  import { CardBase, variantProperty } from './index-common';
3
4
  export * from './index-common';
4
- // R is blacklisted from the native metadata of some apps: read the attribute ids with reflection
5
- function getAttr(rClass, field) {
6
- return +java.lang.Class.forName(rClass + '$attr')
7
- .getDeclaredField(field)
8
- .get(null);
5
+ // the R classes are blacklisted from the native metadata and stripped by R8 in some apps: look the ids up by name
6
+ function getAttr(name) {
7
+ return Utils.android.resources.getId(':attr/' + name);
9
8
  }
10
9
  function themeColor(context, attr, fallback) {
11
10
  const value = new android.util.TypedValue();
@@ -37,17 +36,17 @@ export class Card extends CardBase {
37
36
  const dp = (value) => Utils.layout.toDevicePixels(value);
38
37
  let color;
39
38
  let strokeWidth = 0;
40
- let strokeColor = themeColor(context, getAttr('com.google.android.material.R', 'colorOutlineVariant'), android.graphics.Color.LTGRAY);
39
+ let strokeColor = themeColor(context, getAttr('colorOutlineVariant'), android.graphics.Color.LTGRAY);
41
40
  let elevation = 0;
42
41
  if (variant === 'filled') {
43
- color = themeColor(context, getAttr('com.google.android.material.R', 'colorSurfaceContainerHighest'), android.graphics.Color.LTGRAY);
42
+ color = themeColor(context, getAttr('colorSurfaceContainerHighest'), android.graphics.Color.LTGRAY);
44
43
  }
45
44
  else if (variant === 'outlined') {
46
- color = themeColor(context, getAttr('com.google.android.material.R', 'colorSurface'), android.graphics.Color.WHITE);
45
+ color = themeColor(context, getAttr('colorSurface'), android.graphics.Color.WHITE);
47
46
  strokeWidth = dp(1);
48
47
  }
49
48
  else {
50
- color = themeColor(context, getAttr('com.google.android.material.R', 'colorSurfaceContainerLow'), android.graphics.Color.WHITE);
49
+ color = themeColor(context, getAttr('colorSurfaceContainerLow'), android.graphics.Color.WHITE);
51
50
  elevation = dp(1);
52
51
  }
53
52
  const user = this.mUserBackground;
@@ -61,8 +60,29 @@ export class Card extends CardBase {
61
60
  card.setCardBackgroundColor(color);
62
61
  card.setStrokeWidth(strokeWidth);
63
62
  card.setStrokeColor(strokeColor);
64
- card.setCardElevation(elevation);
65
- card.setRadius(user?.borderTopLeftRadius ? dp(user.borderTopLeftRadius) : dp(12));
63
+ // the elevation of the style (elevation: 0 for a flat card) wins over the one of the variant
64
+ card.setCardElevation(this.mUserElevation ?? elevation);
65
+ // the radius would replace the shape
66
+ if (!this.mShape) {
67
+ card.setRadius(user?.borderTopLeftRadius ? dp(user.borderTopLeftRadius) : dp(12));
68
+ }
69
+ }
70
+ [shapeProperty.setNative](shape) {
71
+ this.mShape = shape;
72
+ const card = this.nativeViewProtected;
73
+ if (!shape) {
74
+ if (this.mDefaultAppearanceModel) {
75
+ card.setShapeAppearanceModel(this.mDefaultAppearanceModel);
76
+ }
77
+ }
78
+ else {
79
+ this.mDefaultAppearanceModel ?? (this.mDefaultAppearanceModel = card.getShapeAppearanceModel());
80
+ card.setShapeAppearanceModel(themer.getShape(shape));
81
+ }
82
+ }
83
+ [elevationProperty.setNative](value) {
84
+ this.mUserElevation = value === undefined || value === null ? undefined : Length.toDevicePixels(typeof value === 'string' ? Length.parse(value) : value, 0);
85
+ this.updateLook();
66
86
  }
67
87
  [variantProperty.setNative](value) {
68
88
  this.updateLook();
@@ -1 +1 @@
1
- {"version":3,"file":"index.android.js","sourceRoot":"","sources":["../../src/ui-card/index.android.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,EAAE,KAAK,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AACnH,OAAO,EAAE,QAAQ,EAAe,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACxE,cAAc,gBAAgB,CAAC;AAE/B,iGAAiG;AACjG,SAAS,OAAO,CAAC,MAAc,EAAE,KAAa;IAC1C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG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AAC,UAAU,EAAE,CAAC;IACtB,CAAC;IAED,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,KAAkB;QAC1C,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;IACD,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC,KAAY;QAC5C,IAAI,CAAC,UAAU,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,KAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC1F,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;IACD,wGAAwG;IACxG,CAAC,0BAA0B,CAAC,SAAS,CAAC,CAAC,KAAiB;QACpD,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;QAC7B,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;CACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript-community/ui-card",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Card for grouping content: Material 3 MaterialCardView on Android, a grouped rounded surface on iOS (no glass: the HIG keeps Liquid Glass for controls).",
5
5
  "main": "./index",
6
6
  "sideEffects": false,
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "readmeFilename": "README.md",
46
46
  "dependencies": {
47
- "@nativescript-community/ui-core": "^1.0.1"
47
+ "@nativescript-community/ui-core": "^1.0.3"
48
48
  },
49
- "gitHead": "6a7607e3cb227ab29fa533776e85b2717a800c8e"
49
+ "gitHead": "0931c3c4d0e3855bd8af09b3cd2b604bb730e99e"
50
50
  }