Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all 16564 articles
Browse latest View live

OS pod install error. Module glog cannot be installed

$
0
0

I'am trying to upgrade "react-native" from "0.50.4" to "0.55".

When I run pod install, i receive an error

checking for a BSD-compatible install... /usr/local/bin/ginstall -c
checking whether build environment is sane... yes
checking for arm-apple-darwin-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... /usr/local/bin/gmkdir -p
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... no
checking whether make supports nested variables... no
checking for arm-apple-darwin-gcc...  -arch armv7 -isysroot 
checking whether the C compiler works... no
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
/Users/MacBook/Library/Caches/CocoaPods/Pods/Release/glog/0.3.4-1de0b/missing: Unknown `--is-lightweight' option
Try `/Users/MacBook/Library/Caches/CocoaPods/Pods/Release/glog/0.3.4-1de0b/missing --help' for more information
configure: WARNING: 'missing' script is too old or missing
configure: error: in `/Users/MacBook/Library/Caches/CocoaPods/Pods/Release/glog/0.3.4-1de0b':
configure: error: C compiler cannot create executables
See `config.log' for more details


[!] Automatically assigning platform `ios` with version `8.0` on target `quanta_react` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

I am a beginner in react-native and I can not make a pod install in my iOS project. Thank you in advance.


Xcode Launch Image Source

$
0
0

I have a very silly question, my xcode project doesn't have setting for Launch Image Source , I have already added my splash screen image to Images.xcassets -> LaunchImage , but in my project target General -> App Icon and Launch Images doesn't have setting for Launch Image Source

enter image description hereenter image description here

How can i create new react native App using npx?

$
0
0

I didn't use react-native for a few months. It looks like some things have changed meanwhile. In the official documentation they recommend to uninstall react-native-cli and to usenpx react-native init instead. I did this but ended up with an error because I didn't install that package globally. However, if I install react-native globally, it results in an error when I run the project, saying that I should remove the global package.

What is the proper way to create a react app nowadays?

Date formatting in React Native

$
0
0

I try to format a date time value according to device settings. Whatever I change on the simulator settings or in xCode scheme, I always get US format with date.toLocaleDateString()

So I tried different librairies (moment, react-native-localize, ...) but same, always get US format.

So I tried to set Locale directly with this code :

  const date = new Date(Date.UTC(2019, 11, 26, 14, 5, 0))
  const options = {
     dateStyle: 'medium',
     timeStyle: 'short',
  }
  console.log(date.toLocaleDateString('en-US', options))               // Dec 26, 2019, 3:05 PM
  console.log(date.toLocaleDateString('fr-FR', options))               // Dec 26, 2019, 3:05 PM
  console.log(new Intl.DateTimeFormat('en-US', options).format(date))  // Dec 26, 2019, 3:05 PM
  console.log(new Intl.DateTimeFormat('fr-FR', options).format(date))  // Dec 26, 2019, 3:05 PM

And I still get same results !

What can I do to display my date in other Locale than 'en-US' ?

I don't want to hardcore the format by myself ("DD/MM/YYY HH:mm"), I want to use a Locale I set or better the device's one.

Thanks for advice

Background color turns black after OnPress, when displayed on top of FlatList

$
0
0

Very strange behavior, I am using a FlatList, and on top of it there are 2 floating buttons (TouchableOpacity) (absolute position) and when they are pressed, their background color turns black. This happens only on IOS.

enter image description hereenter image description here

Code:

Render

let content = (
  <CollapsableNavList
    onListScroll={this.showOrHideFilterButtons}
    showFilterButtonsOnScroll={this.showOrHideFilterButtons}
    style={styles.list}
    isHorizontal={false}
    dataModel={this.props.isFetching ? this.props.whileFetchingDisplayedResults : this.props.dataModel}
    isFetching={false}
    onRowSelect={this._onRowSelect}
    didScrollWithOffset={this.didScrollWithOffset}
    renderRowContent={this.renderRowContent}
    keyExtractor={(item) => {
      if (this.props.isFetching) {
        return item
      }
      const property = item
      return property.propertyId
    }}
  >
    {header}
  </CollapsableNavList>
)

return (
  <View style={[styles.container, styles.relative]}>
    <View style={styles.filterBtnBlock}>
      <AdditionalSearchParamsButton

        title='Map'
        iconName='map'
        onPress={this.onMapPress}
      />
    </View>
    {content}
  </View>
)


export default class AdditionalSearchParamsButton extends Component {
  // Prop type warnings
  static propTypes = {
    iconName: PropTypes.string.isRequired,
    title: PropTypes.string.isRequired,
    onPress: PropTypes.func.isRequired
  }

  render () {
    const { iconName, title, onPress } = this.props
    return (
      <View>
        <TouchableHighlight onPress={onPress} underlayColor={Colors.clear}>
          <View style={styles.innerContainer}>
            <McIcon
              name={iconName}
              style={styles.additionalPropsIcon}
          />
            <Text style={styles.additionalPropsText}>{title}</Text>
          </View>
        </TouchableHighlight>
      </View>
    )
  }
}

export default StyleSheet.create({
  container: {
    height: 50,
    width: 150,
    alignItems: 'center',
    justifyContent: 'center'
  },
  innerContainer: {
    height: 36,
    width: 126,
    flexDirection: 'row',
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: Colors.snow,
    borderRadius: 18,
    elevation: 2,
    shadowOffset: {width: 0, height: 2},
    shadowColor: 'black',
    shadowOpacity: 0.3,
    marginBottom: 5,
  },
  additionalPropsBtn: {
    height: 36,
    flexDirection: 'row',
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: Colors.snow
  },
  additionalPropsText: {
    ...Fonts.style.bigTitle,
    color: Colors.blue,
    paddingLeft: 10
  },
  additionalPropsIcon: {
    fontSize: 22,
    color: Colors.blue
  }
})

What I've tried:

-Setting underlays color to clear, with no success.

-Adding different layers under, no success.

-This only happens when displayed on a list, happens with ListView too.

react-native-fbsdk not returning email

$
0
0

I have integrated the react-native-fbsdk library and getting user profile info such as name, middle name etc except email

i have tried readPermissions={["email,"public_profile","friends"]}

Then too not getting email

Any help would be appreciated.

Thanks in advance

Issue with Rotating Image while Saving in React Native

$
0
0

Actual Behaviour :

I am supposed to implement signature pad in landscape-right mode along with a timestamp of signature drawn. Then take a screenshot of the view, and save it in document directory (iOS) or external directory (android) in portrait mode by rotating it. I was successful in implementing signature screen in landscape-right mode using tranform: [{rotate: '90deg"}] css property, and react-native-signature-capture, save the captured screenshot of signature along with the timestamp of signature drawn in local directory using react-native-view-shot cnd convert it into base64 format using react-native-fs. But the saved screenshot is not in portrait mode and i'm trying to rotate the image while saving it in document directory (iOS) or external directory (android) without using any modules. I also tried rotating the image while saving it using canvas context API but could not find way to access canvas in react-native to rotate image while saving it as canvas is HTML DOM related.

Expected Behaviour :

I'm supposed to save the signature drawn along with timestamp in document directory (iOS) or external directory (android) in portrait mode as shown in below screenshot. Can someone help me please. Thanks in advance.

Additional Resources :

Code :

render() {
  return (
    <View
    style={{
      flex: 1,
      flexDirection: 'row',
      overflow: "hidden",
    }}>
    <StatusBar hidden={true} />
    <View
      style={{
        flex: 0.8,
        flexDirection: 'row-reverse',
        marginVertical: width / 18,
        overflow: "hidden",
      }}>
      <ViewShot
        ref="viewShot"
        style={[styles.viewShot, { transform: [{ rotate: this.state.bool && '90deg' }] }]}>
        {/* options={{ width: height, height: width }}> */}
        <SignatureCapture
          style={styles.signature}
          ref={sign => (this.signComponent = sign)}
          onSaveEvent={this._onSaveEvent}
          onDragEvent={this._onDragEvent}
          saveImageFileInExtStorage={true}
          showNativeButtons={false}
          showTitleLabel={false}
          showBorder={false}
          viewMode={'portrait'}
          square={true}
          backgroundColor={"white"}
          maxSize={800}
          rotateClockwise={!!true}
        />
        <View
          ref="timeRef"
          style={{
            width: width / 10,
            height: width / 3,
            justifyContent: 'flex-end',
            flexDirection: 'row-reverse',
          }}>
          <View
            style={{
              width: width / 1.8,
              height: width / 1.8,
              transform: [{ rotate: '-90deg' }],
              overflow: "hidden",
              paddingLeft: width / 18,
              paddingTop: width / 25
            }}>
            <Text style={styles.time}>{this.state.data}</Text>
          </View>
        </View>
      </ViewShot>
      <Image
        ref="imageRef"
        source={{ uri: this.state.imageUri }}
        style={{ transform: [{ rotate: '90deg' }] }}
      />
    </View>
    <View
      style={{
        flex: 0.2,
        alignItems: 'center',
        justifyContent: 'space-around',
        flexDirection: 'column',
        overflow: "hidden",
        backgroundColor: Colors.white,
      }}>
      <View
        style={{
          backgroundColor: Colors.darkGreen,
          width: width / 2,
          justifyContent: 'center',
          alignItems: 'center',
          paddingRight: width / 25,
          paddingVertical: width / 37.5,
          transform: [{ rotate: '-90deg' }],
          overflow: "hidden",
        }}>
        <TouchableOpacity
          hitSlop={{ top: 30, left: 50, right: 50, bottom: 30 }}
          onPress={() => {
            this.saveSign();
          }}>
          <Text style={{ fontSize: width / 18, color: Colors.white }}>Submit </Text>
        </TouchableOpacity>
      </View>
      <View
        style={{
          backgroundColor: '#5476ab',
          width: width / 2,
          justifyContent: 'center',
          alignItems: 'center',
          paddingVertical: width / 37.5,
          transform: [{ rotate: '-90deg' }],
          overflow: "hidden",
        }}>
        <TouchableOpacity
          hitSlop={{ top: 30, left: 50, right: 50, bottom: 30 }}
          onPress={() => {
            this.resetSign();
          }}>
          <Text style={{ fontSize: width / 18, color: Colors.white }}>Clear</Text>
        </TouchableOpacity>
      </View>
      <View
        style={{
          backgroundColor: '#73c5de',
          width: width / 2,
          justifyContent: 'center',
          alignItems: 'center',
          paddingVertical: 10,
          transform: [{ rotate: '-90deg' }],
        }}>
        <TouchableOpacity
          hitSlop={{ top: 30, left: 50, right: 50, bottom: 30 }}
          onPress={() => {
            this.onCancel();
          }}>
          <Text style={{ fontSize: width / 18, color: Colors.white }}>Cancel</Text>
        </TouchableOpacity>
      </View>
    </View>
  </View>

); }

_onSaveEvent(result) {

this.setState({ signature: result.pathName, 
                markResult: result.encoded });

}

_onDragEvent() {

this.setState({ dragged: true });

}

saveSign() {

if (this.state.dragged === true) {
  this.setState({ bool: true });
  this.refs.viewShot.capture().then(uri => {
    this.setState({ imageUri: uri });
    console.log("uri123", uri);
     RNFS.readFile(this.state.imageUri, 
      'base64').then(image => {
      console.log("image123", image);
      this.setState({ sign: image }, () => {
        this.ChangeOrientation();
      });
    });
   });
  } else {
  Alert.alert('NALG', 'Please sign the signature 
  pad to submit');
  }

ChangeOrientation() {

this.props.getSignature(this.state.sign);
this.props.setModalVisible(!this.props.modalVisible);

}

Screenshot of Actual Behaviour :

enter image description here

Screenshot of Expected Behaviour :

enter image description here

Environment:

react-native : 0.61.1

react-native-view-shot : ^3.0.2

react-native-signature-capture : ^0.4.10

react-native-fs : ^2.16.2

react native app crashes ios on drag down screen to move back

$
0
0

in debug mode the app runs perfectly fine and smoothly from VS code. but in the release mode generated from Xcode the app crashes on dragging header top to move to back screen.

i have even imported import 'react-native-gesture-handler' in root index.js

Note: Every packages are updated to latest version.


Firebase/Crashlytics Dashboard not showing any test crashes for android

$
0
0

I can't understand why it's not showing into Firebase Crashlytics Dashboard ,when i'm trying to link this packages manually i'm getting the error about the duplication. Else i trying to change dependencies for it but i have still have this issue.But in iOS it works good and show me non-fatal errors.

On Android when i am creating custom errors for testing into Firebase Crashlytics dashboard doesn't show me any types of crashes (look the pic. below)

enter image description here

Here i am paste the "maven{url 'https://maven.fabric.io/public'}" into buildscript > repositories Else i'm past the needed classpath 'io.fabric.tools:gradle:1.28.1' into buildscript > dependencies block

My code integration was so  android/build.gradle 
buildscript {
    repositories {
        google()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {        
        classpath("com.android.tools.build:gradle:3.4.2")
        classpath 'com.google.gms:google-services:4.3.3'
        classpath 'io.fabric.tools:gradle:1.28.1'
    }
}            
allprojects {
    repositories {
        google()
    }
}

Here i'm paste the apply plugin: 'io.fabric' and implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'

android/app/build.gradle
apply plugin: "com.android.application"
apply plugin: "io.fabric"

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"
    implementation 'com.google.firebase:firebase-analytics:17.2.1'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
}
apply plugin: 'com.google.gms.google-services'

Into package.json i have installed last version of packages

package.json

{
    "dependencies": {
        "@react-native-firebase/app": "^6.2.0",
        "@react-native-firebase/crashlytics": "^6.2.0"
    }
}

NOTE : I don't link manually (as i understood i don't need to do it because it is doing automatically "react-native auto-linking")

Here is my 'index.js' file

import React, { Component } from 'react';
import crashlytics from '@react-native-firebase/crashlytics';

class App extends Component {
    componentDidMount(){
        // Here is my custom errors
        // But it's now showing in dashboard
        // But in iOS it works good
        crashlytics().recordError(new Error('For test'));
        crashlytics().log('For test');
    }
    render () {
       return (
           <View>
              <Text>Test</Text>
           </View>
       )
    }
}

export default App;

What is the meaning of 'No bundle URL present' in react-native?

$
0
0

When I run a react-native project, I get a error no bundle URL present , but I don't know what mistakes I do, I was very confused.

enter image description here

Xcode doesnt include files to build on iOS 13.3

$
0
0

I just update my iPhone to iOS 13.3 and now im unable to build a simple react native app, i tried to download the newest xcode version (Xcode 11.3 beta) wich supposed to include the files but it doesnt.

macOS Mojave 10.14.6

componentDidMount not retrieving asyncStorage data

$
0
0

I have an app with a playlist of videos. As each video plays, I get the index of the video, save it in state, and save it in AsyncStorage. Yet, when I reload the app, I get the current index of the now playing video instead of the indexes saved before reload. This is on ios simulator. This is my code:

import React, {Component} from 'react';
import {StyleSheet, View, SafeAreaView, Button} from 'react-native';
import YouTube from 'react-native-youtube';
import {withNavigationFocus} from 'react-navigation';
import AsyncStorage from '@react-native-community/async-storage';
import APIKEY from '../Keys/ApiKey';

let videoIdsList = [
  '_Czxy3nya8Y',
  '8V0HETilr4I',
  'tHa260XXH6U',
  'J3iSEq5Apfg',
  'iCc5l8iWUZs',
  'p8UR4dODogI',
  'HoL1csZPYsk',

];

class MemeRadar extends Component {
  state = {
    play: false,
    loop: false,
    videosPlayed: [],
    arrayUponMount: [],
    resetAsyncStorage: false,
  };

  _youTubeRef = React.createRef();

  async componentDidMount() {
    this.setState({
      videoIds: videoIdsList,
      play: false,
    });
    try {
      const value = await AsyncStorage.getItem('@PlayList');
      if (value !== null) {
        console.log(JSON.parse(value));
        this.setState(
          {
            videosPlayed: [JSON.parse(value)],
          },
          () => {
            console.log(JSON.parse(value));
          },
        );
      }
    } catch (error) {
      console.log(error);
    }
  }

  async componentDidUpdate(prevProps, prevState) {
    if (prevProps.isFocused !== this.props.isFocused) {
      this.setState({
        play: this.state.play === false ? true : false,
      });
    }

    try {
      if (this._youTubeRef.current._isReady) {
        await this._youTubeRef.current
          .getVideosIndex()
          .then(index => {
            this.state.videosPlayed.includes(index) || null
              ? null
              : this.setState(
                  {
                    videosPlayed: [...this.state.videosPlayed, index],
                  },
                  () => {
                    console.log(this.state.videosPlayed);
                    console.log('saving');
                    AsyncStorage.setItem(
                      '@PlayList',
                      JSON.stringify(...this.state.videosPlayed),
                    );
                    console.log('saved');
                  },
                );
          })
          .catch(err => console.log(err));
      }
    } catch (error) {
      console.log(error);
    }


  }```

I read this was an issue that others face that is being looked at, yet, is there a way around this?
thanks!

How to tell users about new updates?

$
0
0

I have a React Native app with firebase for backend,

And now I'm in the last part to release it, But I have a question, after releasing my app I will add some updates or something and I want to ensure every user updates, so should I implement a modal that appears after adding some updates to my app and publishing it to stores

So I just thought if I made a boolean item if I add updates just change it to True and in my code if that true modal appeared else hidden it!

So that's a nice way to go with it?

Or can firebase help me in this case to tells any new things I do "I don't send to them push notifications if u want to tell me that"

React Native Xcode Apple Mach-O Linker (ld) Error Group - _RCT.. problem

$
0
0

When I try to get build via xcode in my application with react native, I get error like below. I have tried many solutions via xcode, but I can't find out why the problem occurred. Can you help me with this?

linker command failed with exit code 1 (use -v to see invocation)

Xcode Version: 11.3 (11C29) React Native Version : 0.61.5

React native ios app crash when remove from background and try to open it

$
0
0

I have created React native iOS application. Everything is working fine in my application I have handle push notification also. For this I used this code. It manage my application foreground , background both states. But when I remove my application from the background and try to open it. It is crashing after splash screen. Even I remove this push notification code but still I am not able to open my application it is crashing always.

async createNotificationListenersIos() {

    console.log("createNotificationListenersIOs ");

    /* Triggered when a particular notification has been received in foreground */
   const channel = new firebase.notifications.Android.Channel('test-channel', 'Test Channel', firebase.notifications.Android.Importance.Max)
   .setDescription('My apps test channel');

 // Create the channel
 firebase.notifications().android.createChannel(channel);
 this.notificationListener = firebase.notifications().onNotification((notification) => {

  console.log(" notification is === 81 ", notification);

   notification
     .android.setChannelId('test-channel')
     .android.setSmallIcon('ic_launcher');
   firebase.notifications()
     .displayNotification(notification);

     this.checkForData(notification);

 });

 /*
 * If your app is in background, you can listen for when a notification is clicked / tapped / opened as follows: */

 this.notificationOpenedListener = firebase.notifications().onNotificationOpened((notificationOpen) => {
   console.log(" notification is === 99 =======", notificationOpen.notification);
   this.checkForData(notificationOpen.notification);
 });

 /*
 * If your app is closed, you can check if it was opened by a notification being clicked / tapped / opened as follows:
*/
/*
firebase.notifications().getInitialNotification()
      .then((notificationOpen: NotificationOpen) => {
        if (notificationOpen) {

            console.log(" 45 ===== ", notificationOpen);
          // App was opened by a notification
          // Get the action triggered by the notification being opened
          const action = notificationOpen.action;
          // Get information about the notification that was opened
          const notification: Notification = notificationOpen.notification;  

          if (notification) {

            // console.log("+================= notificationOpen ", notification, "===========");
             // App was opened by a notification
             // Get the action triggered by the notification being opened
            // const action = notificationOpen.action;
             // Get information about the notification that was opened

             console.log("^^^^^^^^^^^^^^^^^^",notification._notification);
            this.checkForData(notification._notification)
         }
        }
      });  
      */
}

  checkForData (notification){
    if (notification._data) {

        if(notification._data.type){
            if ( notification._data.type.toUpperCase() !== wordConstants.CONST_ADMIN) {
              return;
            }
          }

          console.log("69 ^^^^^^^^^^^^^^^^^^",notification._data.status);

        let notificationStatus = notification._data.status;
        console.log(" notification status ====", notificationStatus.toUpperCase());

        if(notificationStatus.toUpperCase() === wordConstants.CONST_APPROVE){

            this.props.navigation.navigate('LoginProgress', { status: wordConstants.CONST_CONFIRM, userData: {} });
        }else{
            this.props.navigation.navigate('LoginProgress', { status: wordConstants.CONST_FAILED, userData: {} });
        }
    } else {

    }
  }

Can anyone help me.
Thanks 

React-native icon inline with text

$
0
0

Hi I want achieve the following style:

enter image description here

But with the following code i get a the icon in separate column and the text in another

<View style={{flex:1, flexDirection:'row'}}>
  <Icon height={10} width={10} />
  <Text>It is a long established fact that a reader will be distracted by the readable 
    content of a page when looking at its layout. The point of using Lorem Ipsum is that it 
    has a more-or-less normal distribution of letters, as opposed to using 'Content here, 
    content here'</Text>
</View>

enter image description here

please ignore the different icons. Any solution to this problem?

Thread 1: signal SIGABRT error running on Xcode 11.2.1

$
0
0

The project(react-native) was running fine on Xcode 10.2, and to test it on iOS 13, I tried opening the project with Xcode 11.2.1 and the app crashes at startup and the error from the Xcode 11.2.1 console is below:

Assertion failure in -[UIApplication _createStatusBarWithRequestedStyle:orientation:hidden:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3900.12.16/UIApplication.m:5316
2019-12-10 14:26:37.206842+0530 workish[73259:574909] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'App called -statusBar or -statusBarWindow on UIApplication: this code must be changed as there's no longer a status bar or status bar window. Use the statusBarManager object on the window scene instead.'
*** First throw call stack:

onpress stops working when loading new items react-native Android

$
0
0

the following code works fine on iOS, but on android after loading the orders array and rendering it, the onpress event stops working, at first I thought it was a problem with firebase but then I did it locally and I get the same issue.

import React from 'react';
import {
ActivityIndicator,
Alert,
Button, 
Dimensions,
Image,
StatusBar,
StyleSheet,
ScrollView,
Text,
TouchableOpacity,
View,
Platform,
RefreshControl,
YellowBox } from 'react-native';

import { Ionicons as Icon } from '@expo/vector-icons';  
import { Card, DefaultTheme } from 'react-native-paper';
import NavigationService from '../../Navigation/navigationService';
import _ from 'lodash';
YellowBox.ignoreWarnings(['Setting a timer']);
const _console = _.clone(console);
console.warn = message => {
  if (message.indexOf('Setting a timer') <= -1) {
    _console.warn(message);
  }
};
import Firebase from '../../connection/to-firebase';

const LOGO_URL = 'https://i.imgur.com/BbYaucd.png';
const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get('window');
const styles = StyleSheet.create({
    container: {
        paddingTop: StatusBar.currentHeight,
        width: SCREEN_WIDTH,
        height: SCREEN_HEIGHT / 2,
        backgroundColor: "#317AFA",
    },
    innerContainer: {width:SCREEN_WIDTH, alignItems: 'center', justifyContent: 'center' },
    header: {position:'absolute', padding: 15, paddingTop: Platform.OS === 'ios' ? 13 : 7, marginTop:SCREEN_HEIGHT*0.05,zIndex:99 },
    scrollView: {
        position:'absolute',
                    top:SCREEN_HEIGHT*0.35,
                    marginHorizontal: 20,
                    width: SCREEN_WIDTH*0.90,
                    height: SCREEN_HEIGHT,
                    zIndex:9999
      },
      textHeader:{
        marginTop:10,
        color: 'white',
        fontWeight: 'bold',
        fontSize: 40,
      }
});
const theme = {
    colors: {
        ...DefaultTheme.colors,
        primary: '#3498db',
        accent: '#f1c40f',
      }
}

export default class DefaultScreen extends React.Component {

    constructor (props) {
        super(props)
        console.ignoredYellowBox = [
            'Setting a timer'
        ];
        this.state = {
          orders: [],
          refreshing: false,
          timePassed: false
        }
     }

     _onRefresh = () => {
        this.setState({refreshing: true});

        this.getOrders().then(() => {
          this.setState({refreshing: false});
        });

        //setTimeout(()=>{this.setState({refreshing: false})},1000)

      }

    async getOrders(){
        //let result = await Firebase.extractOrder();

        let result =  [
            {
             "Note": "",
             "coords":  {
               "finalLatitude": 14.100751767597542,
               "finalLongitude": -87.18541710839844,
               "initialLatitude": 14.061113522979957,
               "initialLongitude": -87.21807641015624
             },
             "createdAt":  {
               "nanoseconds": 686000000,
               "seconds": 1576188983
             },
             "destinataryName": "Eliana Martínez",
             "destinataryPhone": "97412032",
             "idSubcategory": "1",
             "idUsuario": 1,
             "isTakenBySomeone": false,
             "orderID": "rQAt5IEI687AkoI8rShh",
             "products": [
               {
                 "id": 93634,
                 "observation": "",
                 "price": "56.00",
                 "quantity": 1
               },
                {
                 "id": 29909,
                 "observation": "",
                 "price": "131.00",
                 "quantity": 97
               }
             ],
             "status": "Pending",
             "telephone": 23456987,
             "transportType": "Motocicleta"
           }
         ]

        this.setState({ orders:  result});
    }


    componentDidMount(){
        //this.getOrders();
    }

    renderOrders = (orders) =>{
    return orders.map((a,b)=>{
        return [
          <MainOrders key={a.orderID} dName= {a.orderID} note ={a.Note} transType={a.transportType} orderDetails={a}
                        navigation={this.props.navigation}
          />
        ]
      })
    }

    render() {

    setTimeout(()=>{this.setState({timePassed: true})}, 1000);
    if (!this.state.timePassed){

        return (
            <View style={styles.container}>

                    <StatusBar barStyle="dark-content" />
                    <View style={styles.header}>
                        <TouchableOpacity
                            onPress={() => {
                                this.props.navigation.openDrawer();
                            }}
                            style = {{marginTop:'10%'}}
                        >
                            <Icon name="md-menu" size={35} color={'#fff'}/>
                        </TouchableOpacity>
                        <Text style={styles.textHeader}>Home</Text>
                    </View>
                    <View style={styles.innerContainer}>
                    <ScrollView style={styles.scrollView}
                                refreshControl={ <RefreshControl refreshing={this.state.refreshing} onRefresh={this._onRefresh}/>} 
                    >
                        <Card theme={theme}>
                           <Card.Title title="Order List" subtitle=""  />
                           <Card.Content>
                           <ActivityIndicator size="small" color="#317AFA" />
                           </Card.Content>
                           <Card.Actions>
                          <Button title="View Order" style={{zIndex:9999, elevation:15}} onPress={()=>{
                             Alert.alert('Hello World')
                            }}>View Order</Button>
                        </Card.Actions>
                         </Card>
                    </ScrollView>
                    </View>
                </View>
        );
    }
    else{

        const {orders,navigation} = this.state;
    DefaultScreen.navigationOptions = {
                                         title: ''
                                          }

        return (
            <View style={styles.container}>

                    <StatusBar barStyle="dark-content" />
                    <View style={styles.header}>
                        <TouchableOpacity
                            onPress={() => {
                                this.props.navigation.openDrawer();
                            }}
                            style = {{marginTop:'10%'}}
                        >
                            <Icon name="md-menu" size={35} color={'#fff'}/>
                        </TouchableOpacity>
                        <Text style={styles.textHeader}>Home</Text>
                    </View>
                    <View style={styles.innerContainer}>
                    <ScrollView style={styles.scrollView}
                                refreshControl={ <RefreshControl refreshing={this.state.refreshing} onRefresh={this._onRefresh}/>} 

                    >
                        <Card theme={theme}

                        >
                           <Card.Title title="Order List" subtitle=""  />
                           <Card.Content>
                           {
                               orders.map((a,b)=>{
                                return [
                                  <MainOrders key={a.orderID} dName= {a.orderID} note ={a.Note} transType={a.transportType} orderDetails={a}
                                                navigation={this.props.navigation}
                                  />
                                ]
                              })
                           }
                           </Card.Content>
                           <Card.Actions>
                          <Button title="Press me" style={{zIndex:9999}} onPress={()=>{
                             Alert.alert('Hello World')
                            }}> Press me</Button>
                        </Card.Actions>
                         </Card>
                    </ScrollView>
                    </View>
                </View>
        );
        }
    }
}

class MainOrders extends React.Component {
    constructor() {
        super();
      }
    render() {
      return (
        <View style={{marginTop:2,marginBottom:2}}>
          <Card theme={theme}>
                      <Card.Title title={this.props.dName} subtitle={this.props.note}  />
                      <Card.Content>
                      <Text>{this.props.transType}</Text>
                      </Card.Content>
                      <Card.Actions>
                          <Button title="view order" style={{zIndex:9999}} onPress={()=>{
                             this.props.navigation.navigate('orderDetails',{orderDetails: this.props.orderDetails})
                          }}> view order</Button>
                        </Card.Actions>
            </Card>      
        </View>
      );
    }
  }

I tried changing the execution orders, setting timeout and when I manually filled out the order array was that I realized that the problem is at that point, but I can't see what I'm doing wrong.

"react-native": "0.59.8"

Thanks.

AppLock feature on React-Native application

$
0
0

I'm quite new to React-Native development and trying to implement AppLock feature in my application for both Android and IOS but not sure how to implement it. It would be great if anyone can help me on this

dynamic google-service.json after apk is generated

$
0
0

I have an app that sync data with my API. I want this app have a dynamic "google-service.json", I want to pass the google-service.json after the app.APK is ready and the app is installed on the device through my API. Is possible ? I did a generic "google-service.json" that change the values when I send data from my API to the installed app on the device but the Firebase connection is not working. Any ideas ?

Viewing all 16564 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>