Author: Sandeep Mishra

  • The Latest Addition to the Laravel Eco-system

    The Latest Addition to the Laravel Eco-system

    If you’ve been a user of Laravel, you must’ve surely heard about their latest offering. Nova is an administration panel for Laravel. This sleek and beautifully designed single-page application, built on the Vue.js platform and Tailwind, is highly customizable in a true Laravel fashion.

    Nova is a composer package, which can be installed in an existing Laravel package. It does not interfere with an existing application in any way. In fact, you can install Nova in the existing Laravel applications which you have already built, without hampering the application, as well as removing the need of starting all over again, if you want to integrate resource management in your application. On the front-end, Nova is powered by Vue.js, Vue components and Tailwind.css. This makes for a powerful and flexible combination, especially with regards to customization – it is easier than ever to build custom cards, tools and fields.

    With Nova, you can forget the clumsy, unmanageable administration panels. You can configure the whole dashboard with a simple PHP class. None of your configuration is stored in the database. It is a piece of cake to add an administration panel to the existing Laravel applications without interfering with the eloquent and potent models.

    Before you begin, here is a list of requirements which you need to preload before installing Laravel Nova:

    1. Composer
    2. Laravel Framework 5.8+
    3. Laravel Mix
    4. Node.js and NPM

     Nova supports all the new versions of Google Chrome, Apple Safari and Microsoft Edge web browsers.

    Features of Nova Laravel:

    The primary feature of Nova is to be able to create, read, update and delete resources from the database. The versatility of the app helps to create an easy to use and simplistic platform to get it done.

    • Resource Management
    • Search Integration
    • Filters
    • Lens
    • Actions
    • Metrics
    • Customization

    If you’ve been a user of Laravel, you must’ve surely heard about their latest offering. Nova is an administration panel for Laravel. This sleek and beautifully designed single-page application, built on the Vue.js platform and Tailwind, is highly customizable in a true Laravel fashion.

    Nova is a composer package, which can be installed in an existing Laravel package. It does not interfere with an existing application in any way. In fact, you can install Nova in the existing Laravel applications which you have already built, without hampering the application, as well as removing the need of starting all over again, if you want to integrate resource management in your application. On the front-end, Nova is powered by Vue.js, Vue components and Tailwind.css. This makes for a powerful and flexible combination, especially with regards to customization – it is easier than ever to build custom cards, tools and fields.

    With Nova, you can forget the clumsy, unmanageable administration panels. You can configure the whole dashboard with a simple PHP class. None of your configuration is stored in the database. It is a piece of cake to add an administration panel to the existing Laravel applications without interfering with the eloquent and potent models.

    Before you begin, here is a list of requirements which you need to preload before installing Laravel Nova:

    1. Composer
    2. Laravel Framework 5.8+
    3. Laravel Mix
    4. Node.js and NPM

     Nova supports all the new versions of Google Chrome, Apple Safari and Microsoft Edge web browsers.

    Features of Nova Laravel:

    The primary feature of Nova is to be able to create, read, update and delete resources from the database. The versatility of the app helps to create an easy to use and simplistic platform to get it done.

    • Resource Management
    • Search Integration
    • Filters
    • Lens
    • Actions
    • Metrics
    • Customization
  • 5 Things You Need to Know about Blockchain Security

    5 Things You Need to Know about Blockchain Security

    The blockchain was the most talked about topic in the past few months over the internet. Certainly, being a distributed ledger technology and having different security concepts, it was the most hyped and controversial topic in the RSA Conference, San Francisco in 2018.

    Enterprises are still skeptical about adopting blockchain as the technology for business because of the security concerns. The idea of implementing blockchain in the enterprise level has been suspended somewhere in between a hype and disappointments, a buzz or realization and it varies from person to person. The result is the same – it is still not a full-fledged technology for many businesses.

    After everything, enterprises are really looking forward to taking blockchains seriously. According to a research report, almost 23% of organizations are testing blockchain before implementing it for their business actively. So, why the extensive testing is going on still when it is proven to be a smart technology? The answer is – the security techniques of the blockchain. There are myths and reality about the blockchain security you can find everywhere. Here are 5 things you should know about blockchain security before adopting it wholeheartedly –

    1. Security through the blocks and distribution

    In a blockchain, the digital blocks that contain information are connected to other blocks that are placed before and after the blocks. Therefore, hackers find it difficult to attack the data contained in the blocks as they are linked to other blocks in sequence. Blockchains are decentralized and the peers involved in the chain are continuously notified and kept in sync about the changes happen in the information. The information in the blockchain cannot be changed using a single computer, thus there is no single point of failure in the blockchains. It requires a huge amount of time, resources and computing to access all the nodes.

    2. All the blockchains are not open

    Blocks involved in blockchains are open and accessible by everyone – this statement a myth. There are two types of blockchains available – public blockchains and private blockchains and some variations of them. Public blockchains are accessible and available on the internet and the blocks get validated for transactions with the public. Private blockchains are used by known organizations or participants. Partially-private data can flow through the private blockchain and it is good for enterprises. Bitcoin is a very good example of the public blockchain. A blockchain that is used by a university is a good example of the private blockchain.

    3. Blockchain network is also secure

    Before implementing blockchain, you must analyze the security vulnerability of any system. Blockchain provides security, but any loophole in the architecture, on which blockchain has been implemented, can be a threat to it. Your infrastructure should be able to –

    • Prevent all of the users, including the administrators and the root users from using the system.
    • Data changing requests or attempts should be denied at the network level.
    • Highest standard of security for the encryption keys and transactions are needed.

    With these things in your architecture, blockchain will surely be a success in terms of security.

    4. Smart Contracts cannot provide legal protection

    Smart contracts are the rules made by the provider of the smart transactional system and it is written as a code through a software developer. Therefore, these contracts have a value between these parties or in theory precisely. The law is different and still exists in reality. If you do not refund someone’s money, the contracts or rules incorporated into the blockchain codes cannot give you legal protection anyhow, unless you have a separate legal contract prepared through proper channels. Data security vulnerabilities may leave your business endangered and smart contracts won’t be able to protect you anyway.

    5. Third Party systems are not blockchain’s “business”

    As the distributed ledger system gets adopted more and more, third-party solutions will become more and more available for this platform. The areas under the blockchain ecosystem where the third party systems can be built are –

    • Fintech services
    • Blockchain payment services and platforms
    • Smart Contract systems
    • Payment Wallets
    • Integration scopes and platforms

    The vulnerabilities in the third-party systems and potential threats through them can make the attackers break the blockchain systems. It will not be a blockchain security issue. The third party systems should be thoroughly verified and validated before integrating into a blockchain platform, as codes are written by the vendors.

    The blockchain technology is robust, secure and efficient. But security issues like orphan blocks, weakly secure and weak permissions networks, poor implementation of cryptography, weakly defined and developed smart contracts and transaction tampering through third-party systems are needed to be handled with more maturity. The highly complex blockchain technology and highly computed blockchain development, need more maturity, full-scale testing at the enterprise level and more regulations to make it the most desirable and successful system for businesses.

  • How will the blockchain transform supply chain Industry?

    Blockchain transform supply chain Industry- The world of supply chain and logistics is made of two important aspects – transparency and traceability. Blockchain creates a secure, robust and reliable business and communication channel and optimizes the existing business networks and transactions.

    The blockchain is basically a shared ledger which gets validated and updated through each of the participants.  Blockchains thus increase the equality in keeping the visibility of the activities that are performed on the platform and providing information about where an asset is. To revolutionize the supply-chain ecology, it needs a balance between blockchain’s complexity and supply-chains clarity.

    What is blockchain and how does it help the supply chain process?

    In the past decade, the process of the supply chain management system has become truly complex due to the emergence of new technologies and globalization of businesses. Today it is very difficult for buyers to know the exact cost involved for goods in the whole process of the supply chain, because of the lack of transparency of the existing system of managing supply chain process. It is very difficult to investigate a supply chain ecosystem due to some unethical practices in the system.

    The blockchain is a distributed digital ledger which provides transparency and security in the industries it is being used. In popular beliefs, Bitcoins are the major use of this powerful technology, but blockchain has potential into it. Blockchains can be used for – exchanges, agreements, contracts, tracking and transactions related to payments.

    Every blockchain transaction is recorded and the information is maintained in separate blocks each time with the timestamp. This information about the transaction has many copies which are kept throughout the distributed systems at the nodes. Therefore, blockchains provide transparency as the information is visible and accessible by all of the participants of the chain.

    Each block of a blockchain refers to the other blocks that are placed before and after them. There is no central authority for update and changing of the information. During any change, all the participant can verify and validate it and approve the change request. For each change request, a new block is created and is placed in the sequence of other blocks. Therefore, the security of the blockchains is very high. Everyone can see and access the data contained in the blocks but no one can change it alone.

    These features of blockchains make this technology a perfect choice for the supply chain management system. The transparency of the supply chain system will improve the trust of the buyers and sellers, remove any unethical practice, remove the need of any mediator in the system, provide information about the transactions, goods transportation exact status and many more. Ultimately, the business will get improved through the extremely efficient and highly scalable blockchain technology.

    What are the benefits of using blockchain in the supply chain or logistics?

    Blockchain provides the logistic companies a real-time digital ledger to keep track of the transactions and record and inform the movement of all the components and participants involved in the supply chain management system. Here are some benefits of using blockchains straight into the supply chain ecology –

    Improved visibility in procurement

    The negotiation of the procurement discounts happens based on the total volume and a total number of purchases someone have made. But for the companies, it is very difficult and costly to keep track of the procurement data due to its large volume and different way of selling the products, companies, vendors, subsidiaries and business partners through whom the business is being made.

    Blockchains provides a solution for this situation to the supply chain companies through its constantly refreshed digital ledger. The company can always visualize the total volume of the purchases regardless of the parties involved in it. Moreover, it removes the necessity of submitting the purchase data from each and every employee end of the day and costly auditors to validate the data. It saves both time and money for the company.

    Smart Contracts and Payment methods

    The gap between the digitally generated invoice and manually chosen payment methods leverages a risk of non-payment in any business, especially in supply chain management. Though it is always mentioned in the contracts that payment must be cleared within 30 days of the service availed. But, customers chose their manual payment mode and enter the amount on the system manually as well.

    Smart contracts induce the payment method and other necessities into the code of the blockchain system making it automated. Customers just have to approve the payments. This will lead to the highly reduced amount of non-payments.

    Eliminate the bad component

    In blockchains, every participant has one copy of the ledger. All the movements, activities and transactions involved in the system are part of the ledger which is refreshed continuously, including the copies. If any participant tries to tamper the data to game the system, that will tamper the data of only the copy of the ledger he has. Without the approval of other participants, it won’t affect the whole ledger. Therefore, when the other participants do not approve the changes, his copy of the ledger becomes out of sync immediately. This helps to remove the rogues from the system, which is necessary for supply chain or logistics.

    Better visibility through analytics using block data

    In supply chain management, it is necessary to have the insight of how much material is in a certain place, the order is placed for how much material, what is the actual demand and what is going to become garbage soon. This computation and information maintenance is costly for bigger companies.

    Blockchains provide the power to the companies to micromanage and get insights into everything at the ecosystem level and that too any point of time. It pays off with an accuracy of data, better insights, reduced need for maintaining costly inventory and better business decisions.

    Easy plugging into the existing system

    The main benefit of the blockchain technology is, it can be easily integrated into the existing supply management systems. Therefore, costly and time taking the process of removal of the old process and implement and adapt to the new one is not necessary.

    The supply chain ecosystem cannot be transformed overnight. But, through the hands of blockchain technology, it can improve the business and customer experience significantly. What do you think?

  • Blockchains for current business models

    Blockchains for current business models

    The Blockchains for current business models that currently exist are not traditional models, neither the most innovative ones. They are somewhere in between, the evolution from being simple to super complex, from manual to digitized and from being location-centric to become globalized. But, like the traditional business models, the decision making is process oriented and time taking for many still. Organizations have started working on new and innovative business models like data-centric and collaborative to gain new direction in business. Blockchain technology is a driver to innovate new business models, wiping out the existing ones as we know by now.

    Here are some statistical facts and insights of blockchain technology –

    blockchains-statics

    Impact on Blockchain on Business Models

    A business model is a conceptual tool that includes a set of elements and relationships between them to function according to the logic and regulations of a specific organization. The innovation and creation of a business model get driven by the effect of social, financial and technological influences. It is evident that technology firms consistently fail to stay competitive in the market when technological changes happen. The business models can be disrupted by the impact of technological discontinuation. Introduction of the smartphones is the classical example of the technological impact on business models. Nokia had to cope up with huge business losses due to non-adaptability of new business models.

    blockchain-strategic

    Blockchains, popularly known as the underlying technology of bitcoins, was popularly established in the market as an approach to the payment models where it can provide a mechanism for the trust between the buyer and the seller. Blockchains provides a digital ledger which uses cryptography and hash function to allow the users or participants to conclude on the decision of approving the transaction. The information for each transaction gathers into one single block and each block gets placed one after another to create a sequence or chain.

    The impact of the blockchain technology is more than just some updated and modified processes and adding new services or products. Blockchain has the potential to change the entire business model of an organization.

    The industry or the business model that is affected majorly till now by the blockchain technology is finance. After an introduction of bitcoins or similar virtual currencies, popularly known as cryptocurrencies like bitcoins, the model for being paid or pay someone has changed a lot. It even has opened the doors to a new business model or business aspects further. Larger payment infrastructure operators like SWIFT has taken a deep interest in the potential of blockchain technology in the payment sector. Now, even big IT enterprises also launching prototypes of blockchain based technology solutions for payments. The business is also considering testing and defining their business models keeping blockchain technology into their mind.

    Why are businesses rethinking about blockchains to be implemented?

    Even after knowing the huge impact on the complete business models of their organizations, businesses still are considering to get on the tide of the blockchain. Following are the benefits of using blockchains in a business –

    1. With the robust and efficient blockchain technology, execution and completion of projects are easier and faster. Therefore organizations are able to take up projects further.

    2. The smart contracts help to keep all the stakeholders on one page making them adhere to the rules of business as defined.

    3. The transparency and efficiency of the blockchain technology improve collaboration and effectiveness providing security in a business model.

    4. Businesses are now considering the private blockchain network to take it up to the new level by creating Blockchain as a service model.

    Blockchain Business models and projects

    The creation and innovation of a new business model is a continuous process going through extensive tests, knowledge, experience, and processes. Blockchains will not necessarily wipe out the existing models, but it will support them getting easily integrated into them. It depends on how the technology is being leveraged into the current scenario of a business and the potential of it is being used in a provided business case.

    Let’s check out the below decision tree to understand this better –

    blockchain-pool

    For making blockchain as a game-changing enzyme for the businesses, business models must be identified properly and then utilize the model into a real business is very important. The legacy businesses or organizations have to adopt the technology faster or they may face the swipe out in near future by it.

    Financing the businesses or the startups could find the new ways of developing the blockchain technology for their benefit. It may be a time when customers will use some currency like utility tokens as an alternative to traditional equity shares by purchase something. These new things will revolutionize the way businesses function. There are even opportunities to create corporate governance models to make the decision making the process a democratic one.

  • How does blockchain work: A beginner’s guide

    How does blockchain work: A beginner’s guide

    You might have heard the term Blockchain or bitcoin many times by now. Blockchain has actually come a long way from being a “term” or a buzzword to a complete technology with applications. The tale of digital currencies has swiped away the world by its feet. But, there is more to it. Blockchains has other implementations that are enhancing the businesses to another level.

    bitcoin-blockchain

    In this article, we’ll talk about blockchains, how it works and its usages.

    What is a Blockchain?

    In short, Blockchain is the underlying technology on which bitcoins work. The blockchain is a public transaction ledger, where information cannot be appended from. It is a decentralized database system for transferring and storing huge amount of data or information through a highly secure environment than a traditional data storage system.

    From the name itself, we can understand it, it consists of two things, blocks, and chains. Blocks are a chunk of data that are attached to each other through a virtual string. It uses the century-old technique of ledger. For example – imagine that I have bought a property from Mr. A today and the attorney enters the record of the entire transaction in the ledger with the timestamp. Now, I sell it to Mr. B after 8 months. It will again have a new entry in the ledger with the new timestamp but will not remove or edit the older one. Thus the record for each and every transaction about the property will remain there forever with the exact timestamp. Blockchains work in a similar way. Information updates and deletion or new creation do not disturb the older one and keeps attaching blocks of information one after another forming a chain.

    How does Blockchain work?

    Block is the chunk of information. The information contains different components along with the timestamp. Block is immutable, that means it cannot be edited when updating any component or part of the data.

    The blockchain forms on a distributed architecture. That means the data lies on different nodes or personal computers. All the parties that own the information or the one whom the information is shared with, are involved in approving any changes or updates that are needed to be done on the blocks. The updates are made after the approval of all the parties involved. Approval can come through a digital signature or any similar technology. This is why managing blockchain is costly and crowdsourced and effort of many involved.

    The blockchains can be used and updated by anyone using the internet. There is no centralized organization to secure the privacy of the information and millions of users can verify that any illegal update is being made on the information chunks but no one can change the information on it. It is quite a unique solution that provides security and transparency in a single system.

    Technically, following are the way a blockchain work –

    1. The blockchain is a type of ledger or spreadsheet where information about transactions is recorded.
    2. Each transaction creates a hash. Hash is a string of numbers of letters containing the information about the transaction. Each and every update creates a new hash.
    3. Transactions are recorded in a block in the order of their occurrence. The order is a very important thing.
    4. The nodes or the participants check the hash to verify the changes.
    5. Each transaction is approved by all the nodes and then it is entered into the block.
    6. For each approved change, a new block is created.
    7. Each block refers to the previous block and function together. Thus it creates a blockchain.

    Applications of the Blockchain

    Blockchains are used in many industries to maximize the success and profitability.

    Cryptocurrency

    Cryptocurrency is the most popular application of the blockchain technology. Cryptocurrencies like bitcoin, litecoin, ethereum. These cryptocurrencies are a  form of digital money. These allow the transfer of money from one person to another without adhering to a middleman.

    Healthcare

    Healthcare industry is a primary stage of using blockchain as a technology. However, it can provide a transparent health management system with medication monitoring and safer money transactions where NGOs can help those who cannot afford healthcare.

    Education

    Education sector can be revolutionized through the use of the blockchain technology. Universities, teachers, students, and employers can access student’s data marks, past records, criminal records (if any), the duration of training & certification. This will create a transparent system of education and employment opportunities later on. Through this system, even those extracurricular activities will be counted seriously.

    Other than these, the blockchain technology can be used in energy saving, charity or virtually anything. But, to become popular in the mainstream industries, blockchain technology needs to change its way a lot. The financial regulations of different countries, security issues can be a threat to the virtual concept. Information is accessible to all, so banking transactions or personal information of the participants are also visible to others. Therefore it can lead to security threats to any individual or the nation if not handled responsibly. But, still, there is a lot of scope and hope for this technology to revolutionize businesses

  • React Native Installation iOS and Windows : Part 1

    React Native Installation iOS and Windows : Part 1

    React Native Installation iOS and Windows : Part 1- We often need to list youtube video of a playlist and play it in Android and IOS App . Youtube easily provide data in xml by playlist id. Here I am going to explain how to parse video xml and play video using WebView component in react native.

    Page 1: React native installation process on windows and ios

    IOS:

    Dependencies for IOS

    1. XCODE from App Store https://developer.apple.com/xcode/
    2. Copy code from brew.sh and paste in terminal. Press Enter
    3. Node : brew install node
    4. Watchman: brew install watchman
    5. React Native CLI: npm install -g react-native-cli

    Finally run command to create your project.Please open terminal and run this command:

    react-native  init youtube_video
    To open Simulator. Please run this command

    1.  cd youtube_video
    2. react-native run ios

    Window:

    Installation of Dependency for Window. It is long process

    1. Installation of Java http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
    2. Installatiion of Node Js : https://nodejs.org/en/
    3. Installtion of Android Studio : https://developer.android.com/studio/index.html
    4. Then open command prompt in window , win + r, type cmd then press enter
    5. Run command npm install -g react-native-cli
    6. Then install react native in drive where you like
    7. Type E: or C: or D: where you want to install
    8. Run command react-native init youtube_video ( or which name you like )
    9. Open android studio and click on open an existing android project
    10. Please select android folder in your youtube_video folder and click ok
    11. Open message tab in android studio and if you see any update please click on link if it is there
    12. Create virtual device:  Open Tool menu on top then android > AVD Manager
    13. Click on create virtual device select which device you want to add as i select Nexus 5 click on next then click on download button of Marshmallow
    14. On popup window you will see installation start and after finish click on finish button
    15. Then in window select Marshmallow and click on next and on next window click on finish
    16. You can see you virtual device in list , In action column click on green arrow to open it
    17. Now we need to set environment of our system
    18. Search system setting in window search then select View Advance System Setting
    19. Select Advance tab
    20. Click on Environment variables button
    21. In user variable section , please click on new button
    22. Variable name :  JAVA_HOME
    23. Variable Value: Then click on browse directory and select path where android sdk folder so click on c: > Program Files > Java > jdk1.8.0 (what is folder name of java there)
    24. click on path on user variable then click edit and click on new button and enter c:\Users\Computer\AppData\Local\Android\sdk\platform-tools
    25. to check this open any directory and type this path in top path bar you will see all files and folder of sdk folder
    26. Now open command prompt and cd your project directory path run react-native run-android and you can see your project in similator now

    We are all done for window

  • Registering Component in React Native : Part 2

    Registering Component in React Native : Part 2

    Registering component process in react native, open your project folder. In root you can see index.js and App.js . In older version files name are index.ios.js and index.android.js. But it does not matter if you are coding for android you can use index.android.js and if you are coding for IOS you can use index.ios.js

    In updated installation index.ios.js and index.android.js are removed and index.js and app.js is added as root file

    So If you have index.android.js , please use this file as your root android file and as i have index.js and app.js i will use app.js as root file

    Index.js : This file use to import App component from app.js file

    App.js: this file has code which is used to display landing screen of app

    So I am going to use app.js to start our application . in app.js remove all code and write following code

    import React, { Component } from 'react';

    This code is importing React and Component from react which we will use later in our app. Use of importing Component is  to extends class of our component.

    Now we will import design element component View and text using react native so we will write second line

    import { View, Text } from 'react-native';
     

    View and Text these component help us to design our application. We can apply css to it . View work as container and text work as to write text in it

    Now we will register our component so

    class YoutubeVideo extends Component {
        render() {
            return (
                <View>
               <Text>Youtube Video</Text>
              </View>
            )
          }
    }

    Now we will export this component by adding line blow

    export default YoutubeVideo;

    So your complete code will look like this

    import React, { Component } from 'react';
    
    import { View, Text } from 'react-native';
    
    
    class YoutubeVideo extends Component {
    
        render() {
    
            return (
    
            <View>
    
            <Text>Youtube Video</Text>
    
            </View>
    
           );
    
         }
    
    }
    
    
    export default YoutubeVideo;

    In above code you can see we created a component YoutubeVideo and export it for import on another file, If you will not use export you can’t import it on another file for use

    Now we will import and register this component in index.js file

    Open index.js file

    Now change App import to YoutubeVideo

    import App from './App';

    You will see code like this

    Change to

    import YoutubeVideo from './App';


    One important thing is here as you can see code is written … from ‘./App’; . Actually we do not use .js extension when we import any component from any file . we just write file name only so App.js is written only as App

    Now we will register our component to our application

    So now you can see code below AppRegistry. AppRegistry use to register component with app . like we have main component YoutubeVideo so we will register this main component with our app. So to do this we will change last line of AppRegistry

    AppRegistry.registerComponent('youtube_video', () => App);

    You can see line like this . But we have imported our component as YoutubeVideo so we will change App to YoutubeVideo. Now our line should look like this

    AppRegistry.registerComponent('youtube_video', () => YoutubeVideo);

    youtube_video this is our project name which we created using react init command above

    Now our main component is created and registered to app

    Open simulator and click r button two times

    Now you can a your text on screen which we added in app.js file using <Text></Text>

    So your screen is ready with your component to move further

    So your complete code will look like this

  • Header Card Component in React Native : Part 3

    Card component use to create Header in react native. Now we will create a common folder for common design component . By Using props and children props we will get data in these design component.

    Create new folder src in your project folder

    Now create a new folder common in src folder

    So your folder hierarchy will be

    Youtube_video

    -src

    — common

    Adding Header file

    Now create Header.js file in common folder and open it in editor

    Please open Header.js file in editor and import React, Component, View and Text . So we will do same thing as we did before

    import  React, { Component } from 'react';
    
    import  { View, Text } from 'react-native';

    Now we will create Header component

    class Header extends Component {
        render() {
            return (
              <View>
                <Text>Header Text Here</Text>
             </View>
           );
         }
    }

    Now we will export this header. So add last line in Header.js

    export default Header;

    Now our Header component is ready to export . Now we will import this header in App.js so open App.js and write below last import line

    import  Header from './src/common/Header';

    Now call Header in View in App.js

    So we will write <Header /> just above <Text> , so now our App.js code will be like this

    class YoutubeVideo extends Component {
    
        render() {
    
            return (
    
                <View>
    
                    <Header />
    
                    <Text>Youtube Video</Text>
    
                </View>
    
           )
    
        }
    
    }
    
    export default YoutubeVideo;

    Now press two time r button and see result. You will se yout Header text above application

    we will call header text easy to change from App.js easily using props. Props carry parameter which is useful to customize component

    So add a prop in Header in App.js

    <Header HeaderText='My Youtube Play List' />

    So change line <Header /> to

    Here HeaderText is prop . you can name prop anything what you like to keep and now we will call this prop in Header.js. So replace text in Header component Text component

    <Text>Header Text Here</Text>
    change to
    <Text>{ this.props.HeaderText }</Text>

    Props we call in curly braces using this.props. So finally your header code will look like this in Header.js

    import  React, { Component } from 'react';
    
    import { View, Text } from 'react-native';
    
    
    class Header extends Component {
    
        render() {
    
            return (
    
             <View>
    
              <Text>{ this.props.HeaderText }</Text>
    
            </View>
    
           );
    
        }
    
    }
    
    
    export default Header;

    Styling Header Component

    Now before export default Header; line in Header.js file, we will create style component and we will call it in Header component. So

    const Styles = {
    
    
        HeaderStyle: {
    
            justifyContent: 'center',
    
            alignSelf: 'stretch',
    
            alignItems: 'center',
    
            paddingTop: 20,
    
            paddingBottom: 20,
    
            paddingLeft: 20,
    
            paddingRight: 20,
    
            elevation: 2,
    
            backgroundColor: '#ff0000'
    
    }
    
    };

    justifyContent place content vertically center  in a view

    alignItems place inside content center in a view

    Here all details are added if you would like to learn more https://facebook.github.io/react-native/docs/layout-props.html

    Now we will apply this style to View component. So we will call like this

    style={Styles.HeaderStyle}

    So now change in View component of Header.js. It should look like this

    <View style={Styles.HeaderStyle}>
    
    <Text>{ this.props.HeaderText }</Text>
    
    </View>

    Now we will design Text Component. So we will create another skyle in same Styles const

    Add comma after HeaderStyle curly braces and start adding new style so

    HeaderText: {
    
        fontSize: 20,
    
        color: '#FFFFFF'
    
    }
    const Styles = {
    
    
        HeaderStyle: {
    
            justifyContent: 'center',
    
            alignSelf: 'stretch',
    
            alignItems: 'center',
    
            paddingTop: 20,
    
            paddingBottom: 20,
    
            paddingLeft: 20,
    
            paddingRight: 20,
    
            elevation: 2,
    
            backgroundColor: '#ff0000'
    
    
    },
    
    HeaderText: {
    
        fontSize: 20,
    
        color:  '#FFFFFF';
    
    }
    
    
    }

    your final Styles code will be

    Now we will call this HeaderText style in Text component . So we will add like same way

    <View style={Styles.HeaderStyle}>
    
    <Text style={Styles.HeaderText}>{ this.props.HeaderText }</Text>
    
    </View>

    Now refresh simulator you will see a better look for header something like this

  • Card Design with Props and Children : Part 4

    Card Design is just like to create a boxes to hold Video Title, Video Image and Click button. By Adding some shades border by styling we will add a good design view for all listing. These are common component which we can use many places in app

    Now we will create Cards Wrapper and CardsInner so for this we will create new files

    CardWrapper.js and CardsInner.js in common folder of src folder

    Creating CardWrapper

    Open CardWrapper.js file and start importing components from react and react native

    import React, { Component } from 'react';
    import { View } from 'react-native';
    
    class CardWrapper extends Component {
      render() {
      return (
      <View>
          {this.props.children}
      </View>
      );
     }
    }

    Here i have added this.props.children this will call the component which we will add inside CardWrapper 

    For example if we import CardWrapper and call it like

    <CardWrapper>
    <View>

    <Text>Something here to write</Text>

    </View>
    </CardWrapper>

    So this.props.children will return all code inside <CardWrapper></CardWrapper>
    component as children props. I will show you its use further in below code. It will be more clear for you

    Styling Card Wrapper

    Now we will add some styling to Card Wrapper. So create WrapperStyle

    const Styles = {
        WrapperStyle: {
          borderWidth: 1,
          borderRadius: 2,
          borderColor: '#ddd',
          borderBottomWidth: 0,
          shadowColor: '#000',
          shadowRadius: 2,
          elevation: 5,
          marginLeft: 5,
          marginRight: 5,
          marginTop: 10
        }
    };

    Now we will add this style to CardWrapper component. So add this code in CardWrapper View

    <View style={Styles.WrapperStyle}>
    {this.props.children}
    </View>

    So final code will look like this

    import React, { Component } from 'react';
    import { View } from 'react-native';
    
    class CardWrapper extends Component {
     render() {
      return (
       <View style={Styles.WrapperStyle}>
        {this.props.children}
      </View>
      );
     }
    }
    const Styles = {
        WrapperStyle: {
          borderWidth: 1,
          borderRadius: 2,
          borderColor: '#ddd',
          borderBottomWidth: 0,
          shadowColor: '#000',
          shadowRadius: 2,
          elevation: 5,
          marginLeft: 5,
          marginRight: 5,
          marginTop: 10
        }
    };
    
    export default CardWrapper;

    Creating Card Inner

    Now open CardInner.js and start import component from react and react-native

    import React, { Component } from 'react';
    import { View } from 'react-native';
    
    class CardInner extends Component {
    render() {
         return (
          <View>
          {this.props.children}
          </View>
        );
    }
    }
    
    export default CardInner;

    Now add style in same way as added for Cardinner component. So now add CardStyles

    So now add CardStyles

    Now we will add Style to CardInner component View

    1. <View style={Styles.CardStyles}>
    2. {this.props.children}
    3. </View>
    import React, { Component } from 'react';
    import { View } from 'react-native';
    
    class CardInner extends Component {
      render() {
        return (
        <View style={Styles.CardStyles}>
           {this.props.children}
        </View>
        );
      }
    }
    const Styles = {
      CardStyles: {
        borderBottomWidth: 1,
        padding: 5,
        backgroundColor: '#FFF',
        justifyContent: 'flex-start',
        flexDirection: 'row',
        borderColor: '#ddd',
        position: 'relative'
      }
    };
    export default CardInner;

    If you are eager  to check how this long CardWrapper and CardInner will look. So just import both in App.js file and this line for test

    import CardWrapper from ‘./src/common/CardWrapper’;
    import CardInner from ‘./src/common/CardInner’;

    And add this test code inside view tag

    <CardWrapper>
    
             <CardInner><Text>Title</Text></CardInner>
    
             <CardInner><Text>Image</Text></CardInner>
    
             <CardInner><Text>Play Button</Text></CardInner>
    
    </CardWrapper>

    Now refresh Simulator by pressing r button two times and it will show result

    If it is working please remove recent code of import and CardWrapper and CardInner. We will use these designs later in listing

    So it was a long Code but hope you understand following things

    – How create component

    – How Import other component

    – How design a component

    So our design is ready now we will use these cards to list youtube videos. So first we will select a playlist