Comments (9)
Update: I was looking at it in the wrong way, you were correct. If I use card.content = some element it works. Thanks a lot for the help! 👍
from nativescript-cardview.
I've never tried to do that @zee-me but it should be possible.
Likely something along the following lines:
var CardView = require('nativescript-cardview').CardView;
var Color = require('color').Color;
var card = new CardView();
console.log(card);
card.height = 300;
card.width = 500;
card.radius = 8; /// same for iOS and Android
if (card.android) {
card.elevation = 10;
} else if (card.ios) {
card.shadowOffsetWidth = 10;
card.shadowColor = new Color('#3489db').ios;
}
from nativescript-cardview.
Thank you very much for the update! It works now.
from nativescript-cardview.
@bradmartin
How can I import CardView using TypeScript?
What I always got is:
Cannot find module "nativescript-cardview".
What I am trying to do is:
import { CardView } from 'nativescript-cardview';
Tried to add the plugin through
npm install nativescript-cardview
and
tns plugin add nativescript-cardview
Is there anything I am missing?
from nativescript-cardview.
Ahhh looks like when I worked on this months ago I never created any definition files for the plugin. That's likely why. You can get around the TS errors because your import line looks correct.
from nativescript-cardview.
TS defs added. Reinstall the package and you should get the intellisense support.
from nativescript-cardview.
How do you add components to the new CardView dynamically? The method card.addChild() doesn't work. Can you help me out with this?
var stk = page.getViewById('tempStack'); var card = new cardView(); card.margin = 10; card.radius = 5; card.height = 100; card.width = 100; card.elevation = 40; var grid = new gridModule.GridLayout(); var lab1 = new labelModule.Label(); lab1.text = message.body; grid.addChild(lab1); card.addChild(grid); stk.addChild(card);
from nativescript-cardview.
I've not tried but CardView extends content-view which is a layout like StackLayout
. Hopefully that makes sense and helps a little.
from nativescript-cardview.
It does make sense, and that is what I expected and addChild() should work by analogy of content-view. But when I try to call card.addChild(some element), it throws an error:
TypeError: card.addChild is not a function File: "/data/data/org.nativescript.webauth/files/app/landingpage.js, line: 39, column: 17 StackTrace: Frame: function:'', file:'/data/data/org.nativescript.webauth/files/app/landingpage.js', line: 39, column: 18 Frame: function:'org.nativescript.plugins.firebase.FirebasePlugin.setOnNotificationReceivedCallback.org.nativescript.plugins.firebase.FirebasePluginListener.success', file:'/data/data/org.nativescript.webauth/files/app/tns_modules/nativescript-plugin-firebase/firebase.js', line: 252, column: 15 at com.tns.Runtime.callJSMethodNative(Native Method) at com.tns.Runtime.access$200(Runtime.java:25) at com.tns.Runtime$3.run(Runtime.java:882) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
from nativescript-cardview.
Related Issues (20)
- Card not working in Tabview in Nativescript-vue HOT 1
- minimum android sdk version HOT 2
- How to get rid of whitespaces ios
- Cardview radius working differently for big screen resolutions HOT 1
- Cannot read property 'obtainStyledAttributes' of undefined HOT 1
- Feat: Add new android shadow color properties HOT 2
- No Shadow/Elevation Android API 28
- Tap event stops working after orientation change or navigation HOT 1
- How to import CardView in a module HOT 1
- How to get height of CardView element?
- CardView shadow multiplying issue on Android HOT 11
- Not able to migrate app to nativescript 6 which supports only webPack work flow. HOT 3
- Radius is not working on iOS HOT 4
- Nativescript Vue instructions are wrong HOT 1
- Support for tns-core-modules > 6.2
- iOS Issue: No border box and show wrongly applied HOT 3
- App crashes after update HOT 2
- Release/document 2.0.1
- Disable Object is Cardview HOT 1
- Pressed item look HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nativescript-cardview.