Thursday, 20 December 2018

React native - Checkboxes and date pickers for IoS

This article will look at checkboxes and date pickers for IoS apps in React Native. For checkboxes, we use the built-in Switch control. For Date pickers we use the built-in DatePickerIOS control.
This is the basic JS / JSX to get you started! Note the use of a basic state variable to keep track of the chosenDate. The onDateChange callback uses an arrow inline function to update the state variable. We also set the minimum and maximum datetime allowed and some othern nice props of the control! App.js

import React from 'react';
import { StyleSheet, Text, View, DatePickerIOS, Switch } from 'react-native';

export default class App extends React.Component {

  constructor(props){
    super(props);
    this.state = { chosenDate : new Date(), isDatePickerVisible: false };

    this.setDate = this.setDate.bind(this);
  }

  setDate(newDate){
    this.setState({chosenDate: newDate })
  }


  render() {
    return (
      <View style={styles.container}>
 
        <Switch onValueChange={(val) => this.setState({ isDatePickerVisible : val })} value={this.state.isDatePickerVisible} ios_backgroundColor={"aliceblue"} trackColor={true} />
        <Text style={{ display: this.state.isDatePickerVisible ? "none" : "flex"}}>Choose datetime..</Text>
          
        <View style={{ display: this.state.isDatePickerVisible ? "flex" : "none" }}>
         <DatePickerIOS locale="no" mode={"datetime"} minuteInterval={10} minimumDate={new Date(2018,11,1)} maximumDate={new Date(2018,11,31)}
          style={{ borderWidth: 1, borderColor: 'gray'}} onDateChange={this.setDate} date={this.state.chosenDate} />
         <Text>{this.state.chosenDate.toLocaleDateString() + " " + this.state.chosenDate.toLocaleTimeString()}</Text>
        </View>
  
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
  },
});






Share this article on LinkedIn.

31 comments:

  1. In this present era of digitalization, a mobile application is one of the primary necessities for today’s modern-age businesses to stand-out in the industry, including even the top Indian app developers of the market are swapping towards mobile applications rather than the ordinary websites. The applications developed through cross-platform are apparently becoming more prevalent in the market, and React Native is one of the most preferred cross-platform development solutions by the developers as it allows them to preserves native platform compatibilities through react development.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. This blog is important for every react native developer to implement check boxes in react native application development

    ReplyDelete
  4. Are you looking for React Native Development Service or want to grow your existing team of experts to create multi-platform User Interfaces for both iOS & Android? React-Native is the most preferred JavaScript framework for building cross-platform application development. To Hire React Native Developer who will deliver the most value to your app development team, you should be prepared to recognize whether they maintain the needed skills, both professional and interpersonal.

    Hire Full Stack Developer to get an excellent one-stop software solution for your Web or Mobile App Development. Get a Free Quote For Your Reliable Front-end or Back-end Solutions.

    ReplyDelete
  5. Best Web Design Company in Lebanon delivers stunning and functional websites that resonate with the people interacting with them. They will discover the tiered content support levels by following the process and including it in the website design. Their motive is the global growth in the web development domain by rendering effective services and solutions.

    ReplyDelete
  6. Check out the top reasons why businesses should hire a React Development Agency to build their web or mobile application. Zazz is a premier ReactJS Development Company. For more information please visit the website.

    ReplyDelete
  7. The On-Demand Laundry Business is one of the services that are booming currently and is the perfect solution to the time strapped urban households
    Laundry App Development company

    ReplyDelete
  8. Thank you for sharing massive information about React native app development.
    react native development company in india


    ReplyDelete
  9. Hire flutter app developer, coder, programmer, architect, engineer mentor, from the best flutter development company

    ReplyDelete
  10. Great article. Also, if you are looking for some b2b database providers in India, market imperials is an ideal choice. We provide error free and fresh database that can help your business in generating high quality and genuine leads.

    ReplyDelete
  11. The Java language is a toolkit, like a screwdriver. It provides a lot of functionality that a programmer can use to make software, but it doesn’t provide all the functionality. To build Java games, you require a developer who is well-acquainted with its libraries and can create robust games. Eiliana provides the perfect solution by acting as a mediator between you and professional Java game developers.

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. This is a fantastic post that I came across because of the offer. It is exactly what I anticipated to see, and I am confident that you will continue to share such fascinating content in the future.

    software development company in chennai
    Top mobile app development companies in Chennai
    app developers in chennai

    ReplyDelete
  14. Our Intelligent Video Analytics Solutions use artificial intelligence and machine learning to identify and remove particles in the video, identify each object using a professional Deep Convolutional Neural network, and classify each object for innovative surveillance analysis, such as search and filtration notifying, and aggregation of data and visualization.

    ReplyDelete
  15. Thank you for giving such an interesting article on React Native chatbox. It should be very helpful. I also recommended Moon Technolabs as they also provide Custom Website and app development services. Keep sharing.

    ReplyDelete
  16. Great Job!
    React Native has been gaining significant momentum in recent years due to its versatility and efficiency in app development. Its ability to create cross-platform apps for both Android and iOS has made it a top choice for businesses seeking to reach a wider audience.

    Hire React Native Developers USA
    Hire Dedicated Mobile App Developers
    Hire iOS App Developers USA

    ReplyDelete
  17. Overall, the code demonstrates a clear implementation of checkboxes and date pickers in React JS Native for iOS. The usage of state management and event handling is appropriate, and the code structure is well-maintained.

    ReplyDelete
  18. Thanks for sharing this informative article on React native - Checkboxes and date pickers for IoS. If you want to React native app development company for your project. Please visit us.

    ReplyDelete
  19. Thank you for sharing an information article on one of the most popular cross-platform mobile app development framework React Native. For Custom mobile app development solution React native work on both platform like Custom Android app development and custom iOS app development. Thank you again! Keep sharing!

    ReplyDelete
  20. Amazing article related to react js development
    . Hire our best react js developers to experience better services.

    ReplyDelete
  21. Great post! React developer engineers play a crucial role in leveraging the innovative technology of React to propel corporate success. Their knowledge guarantees the development of scalable, dynamic, and interactive user interfaces that improve the user experience as a whole. These experts create reliable and effective solutions by using React's component-based architecture. This helps companies stay flexible, adapt quickly, and produce high-caliber web applications—all of which help them gain an advantage in the cutthroat digital market. hire react.js development team

    ReplyDelete