Im building a react-native app and the screen so far loads an image from a uri into a BackgroundImage and there is also some text loading on top of the image, please see the attached image:
So what i want is to get this image and text downloaded to the device, merge them if you will?
Any suggestions are welcome..
Thanks
I would recommend you to use the ViewShot component from here.
Here's an example of how you would be able to integrate it with your project (keep in mind this uses the ES6 arrow function syntax):
class CaptureImage extends Component {
capturePic = () => {
this.refs.viewShot.capture().then(uri => {
console.log("Path to the image: ", uri); // do what you want with the url
})
};
render() {
return (
<View
<ViewShot ref="viewShot">
// your background image components go here (the image with the text you want to capture)
</ViewShot>
// rest of your code goes here
<Button onClick= {() => capturePic()} /> // button just for demonstration purpose
</View>
);
}
}
Hope you understood :)
I am using imagepicker https://github.com/NativeScript/nativescript-imagepicker in Nativescript to select and display an image in my app. This was very simple using Android, but I can't figure out how to do it using IOS. I have found a few examples online, but I am assuming they are out of date because they didn't work.
this.imagePicker.onSelectSingleTap().then(
(imageAsset: any) => {
if (!isAndroid) {
// What do I do here?
}
if (isAndroid) {
this.imgURL = imageAsset.android;
}
}
)
I am trying to implement the nativescript-camera-plus plugin to take an image. I am developing an IOS (for iPad) application with NativeScript + vue and am using an emulator to test.
For some reason the photoCapturedEvent event is not been triggered when the takePicture() is called. Furthermore, when { saveToGallery: true } is been passed through this method, the image is not saved to the photo gallery.
The loaded event works and runs as the component is loaded. I am unsure if the errorEvent event gets triggered.
Here is a snippet of my code (in TakePhoto.vue):
<CameraPlus ref="CameraPlus" height="600" id="camPlus"
saveToGallery="true"
showCaptureIcon="true"
showGalleryIcon="false"
showToggleIcon="false"
showFlashIcon="false"
debug="true"
enableVideo="false"
confirmVideo="false"
defaultCamera="front"
#loaded="onCameraLoaded"
#photoCapturedEvent="photoCaptured($event)"
#errorEvent="onCameraError">
</CameraPlus>
And here is the associated methods
onCameraLoaded(result) {
this.cam = result.object;
console.log("Camera loaded...");
},
onButtonCapture() {
console.log('Take Picture');
this.image = this.cam.takePicture({ saveToGallery: true });
},
photoCaptured(args){
console.log("ARGS - ", args)
},
I would also like to mention that I have registered the component in the app.js file like so: Vue.registerElement('CameraPlus', () => require('#nstudio/nativescript-camera-plus').CameraPlus);
Any help would be appreciated.
I'm trying to implement Fresco in my NS Vue app.
I have this in my main.js
Vue.registerElement('FrescoDrawee', () => require("nativescript-fresco").FrescoDrawee)
var application = require("application");
var fresco = require("nativescript-fresco");
if (application.android) {
application.onLaunch = function (intent) {
fresco.initialize();
};
}
and in home.vue
< FrescoDrawee horizontalAlignment="stretch" height="150" :imageUri="item.avatar" />
this is the error I'm getting. "SimpleDraweeView was not initialized!". I'm pretty sure the way I'm initializing it is wrong. Googling it gives me examples in TS and Angular, and none for nativescript Vue. any help would be greatly appreciated
Mostly TypeScript is again JavaScript if you eliminate the typings from code. It's just the same you will have to follow in irrespective of your flavour (Core / Angular / Vue).
if (application.android) {
application.on("launch", function () {
fresco.initialize();
});
}
Source: https://github.com/NativeScript/nativescript-fresco#how-to-use-nativescript-fresco
I'm trying to open the browser window without leaving the app when I click a URL (for both iOS and Android).
The behavior should be as follows (with airbnb app example):
Clicks in "Terms and conditions" link: links example
Open the browser in-app:
For iOS: in-app browser iOS
Same for Android.
How can I do this? Do I need to use any specified existing library?
I'm using react-native 0.37.
You can use the new InAppBrowser plugin for React Native, check the next example:
import { Linking } from 'react-native'
import InAppBrowser from 'react-native-inappbrowser-reborn';
...
async openLink() {
try {
const isAvailable = await InAppBrowser.isAvailable()
const url = 'https://www.google.com'
if (isAvailable) {
InAppBrowser.open(url, {
// iOS Properties
dismissButtonStyle: 'cancel',
preferredBarTintColor: 'gray',
preferredControlTintColor: 'white',
// Android Properties
showTitle: true,
toolbarColor: '#6200EE',
secondaryToolbarColor: 'black',
enableUrlBarHiding: true,
enableDefaultShare: true,
forceCloseOnRedirection: true,
}).then((result) => {
Alert.alert(JSON.stringify(result))
})
} else Linking.openURL(url)
} catch (error) {
Alert.alert(error.message)
}
}
...
On the other hand, you can use this plugin with deep linking, check the README of the project.
Opens Safa Module Method
On iOS SafariView 3rd party native module - https://github.com/naoufal/react-native-safari-view
On Android CustomTabs 3rd party native module - https://github.com/droibit/react-native-custom-tabs - however if the user does not have Chrome installed, it will pop open the link outside of your app in their default browser.
Alternative WebView Method
You can use a <WebView> but this is not using the real browser - http://facebook.github.io/react-native/releases/0.47/docs/webview.html#webview
import React, { Component } from 'react';
import { WebView } from 'react-native';
class MyWeb extends Component {
render() {
return (
<WebView
source={{uri: 'https://github.com/facebook/react-native'}}
style={{marginTop: 20}}
/>
);
}
}
Use React Native Custom Tabs to open in-app browser window in React native. It support both platform Android and iOS
You can use React Native In-App Browser Reborn. It works perfectly on both Android and iOS.
This library use react-native-safari-view (SafariView) on iOS and react-native-custom-tabs (ChromeView) on Android.
Use native react native linking to open a url
https://reactnative.dev/docs/linking