RSS

Author Archives: sochinda

About sochinda

I really like new technology!!

Creating custom icon set

By: reactnative.guide

react-native-vector-icons supports using custom icon sets if you do not want to use the icons which come bundled with it or if you want to add your own icons. It supports Fontello and IcoMoon to create custom fonts. We used IcoMoon to convert our SVGs to a config which is readable by the library.

Setting up the framework

Install the npm module using npm or Yarn.

npm install --save react-native-vector-icons

or

yarn add react-native-vector-icons

Configuring your project to support custom icon sets.

We will use IcoMoon to support custom icons/fonts. Icomoon is a free and open source application which lets you convert a set of SVG icons to fonts. It is a front end only app and does not upload your icons anywhere, so there will be no privacy concerns!

The steps for the configuration are as follows:

  • Create a resources folder where we will keep our custom font file (.ttf).
  • Do react-native link react-native-vector-icons. This will set up the vector icons framework for you.

That’s it, you are done with the setup. Now we need to get the TTF file and place it in the resources/fonts folder that we just created.

How to generate .ttf fonts using IcoMoon:

  1. Open the IcoMoon application.
  2. Remove the current set (if there is one) and create a new empty set and give your preferred name (remember to give the same name everywhere).
  3. Drag and drop your SVG files onto the tool.
  4. Select the files which you want to export. Select all if you want to export all the icons.
  5. After the selection, click Generate Font. This will download a zip file to your system.
  6. The zip file will contain a selection.json file and a fonts folder containing a .ttf file. We only need these two files to use fonts in react-native.
     
  7. Put the font file (.ttf) in the resources/fonts folder and add the following script to the package.json:
    "rnpm": {
    
           "assets": [
               "resources/fonts"
           ]
       }
    

    This script will copy the font files to both Android and iOS folders. After this, whenever we want to update the fonts, we will do react-native link react-native-vector-icons and the fonts will be copied/updated automatically to both Android and iOS projects.

  8. Put the JSON file (selection.json) in your app and create a file called CustomIcon.js. Import the selection.json in CustomIcon.js.
    import {createIconSetFromIcoMoon} from 'react-native-vector-icons';
    import icoMoonConfig from './selection.json';
    export default createIconSetFromIcoMoon(icoMoonConfig);
    
  9. That’s it! To use a font simply import the file as a React component and pass the icon name and size (optional) or even style.
    import CustomIcon from './components/CustomIcon.js'
    
    <CustomIcon name='android' /> //To use the icon
    <CustomIcon name='android' size={25} /> // To pass size
    <CustomIcon name='android' style={styles.androidIcon} /> // To pass custom tyle
    

Changing file names of the font file

The default name of the font file is icomoon.ttf. If you want to give it a different name, go to Preferences after step 5 and change the name there before downloading. Also, make sure that if you change the font file name, give the same name to the set as well (by default it is “Untitled Set”).

It is not recommended to change the filename of .ttf font file after the setup/native linking. The filename gets written in project.pbxproj and Info.plist and the file gets copied to android/app/src/main/assets/fonts/ once you run the link command. If you wish to change the filename, you would need to take care of changing the above 2 files as well, and removing the unused icon from the android folder which might cause problems if not done properly.

How do I add/delete icons from the font file (.ttf)

You can easily change/delete the contents of the font file. The tool only needs the selection.json file, which defines the font configuration. The steps for the same are as follows:

  1. Open IcoMoon App
  2. Upload the current selection.json file.
  3. Edit/delete the icon using the tools on top. (Adding an icon is the same as step 3 mentioned above)
  4. After the editing is complete, generate a new font file by following the steps 5 and 6 mentioned above. Once you have the new font file and the new selection.json file, place them in their appropriate locations in the app and do react-native link react-native-vector-icons.

That’s how you change the icons. Pretty neat huh?

 

Copy from: https://www.reactnative.guide/12-svg-icons-using-react-native-vector-icons/12.1-creating-custom-iconset.html

View at Medium.com

 
Leave a comment

Posted by on June 20, 2019 in Mobile Development, React Native

 

SSL in DigitalOcean

Goto your server and

openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr

 

 

  1.  Generate Key and CSR file for request certificate in hosting by using command
    sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/example.com.key -out /etc/ssl/certs/example.com.crt
  2. Go to control panel which hosting provide SSL and download
  3. Now you will get 2 files are *.key and *.crt
  4. copy file domainName.key to /etc/ssl/private/
  5. copy file domainName.crt to /etc/ssl/certs/ 
  6. modify file default in sudo nano /etc/nginx/sites-available/default as bellow

server {

        listen 80 default_server;

        listen [::]:80 default_server;

        # SSL configuration

        #

        listen 443 ssl http2 default_server;

        listen [::]:443 ssl http2 default_server;

        #

        # Note: You should disable gzip for SSL traffic.

        # See: https://bugs.debian.org/773332

        #

        # Read up on ssl_ciphers to ensure a secure configuration.

        # See: https://bugs.debian.org/765782

        #

        # Self signed certs generated by the ssl-cert package

        # Don’t use them in a production server!

        #

        # include snippets/snakeoil.conf;

        root /var/www/landing-page;

        # Add index.php to the list if you are using PHP

        index index.html index.htm index.nginx-debian.html;

        server_name domain.com;

        #ssl on;

        ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;

        ssl_ciphers         “HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES”;

        ssl_certificate     /etc/ssl/certs/domain.com.crt;

        ssl_certificate_key /etc/ssl/private/domain.com.key;

        location / {

                # First attempt to serve request as file, then

                # as directory, then fall back to displaying a 404.

                try_files $uri $uri/ =404;

        }

}

 

server {

       listen         80;

       server_name    http://www.domain.com;

       return         301 https://$server_name$request_uri;

}

 

Referenced: https://websiteforstudents.com/setup-nginx-http-server-self-signed-ssl-tls-certificates-on-ubuntu-16-04-lts-servers/

https://www.xolphin.com/support/Nginx/Nginx_-_Redirect_HTTP_to_HTTPS

 
Leave a comment

Posted by on May 7, 2019 in Nginx

 

How to Fix App “is damaged and can’t be opened. You should move it to the Trash” Error on Mac

By: clcbio.com

Mac OS Sierra 10.12.x

The premise is the same as shown for Mac OS 10.9.2 through 10.11.x except that the steps to enable the “Anywhere” option are different.

If you view your security settings under System Preferences | Security & Privacy, you will see there is no Anywhere option.

To enable the “Anywhere” option, run the following command in a terminal:

sudo spctl --master-disable

If you go back to System Preferences | Security & Privacy, you will see the Anywhere option enabled. Unlock the edit option by clicking on the padlock icon at the bottom of the window to change to Anywhere option.

At this point, you should be able to install the software.

This security setting affects your whole system. To reinstate the earlier security policy, run the following after the software is installed:

sudo spctl --master-enable

and then check your security settings are as you expect.

Copy from: https://secure.clcbio.com/helpspot/index.php?pg=kb.page&id=323

 
Leave a comment

Posted by on April 19, 2019 in Mac

 

Compile-time Error: control may reach end of non-void function with Xcode 10.2

Copy from: https://github.com/realm/realm-js/issues/2305

 

temp solution :

add default: return "null"; between line 52 and 53,

template<>
inline const char *jsc::Value::typeof(JSContextRef ctx, const JSValueRef &value) {
    switch (JSValueGetType(ctx, value)) {
        case kJSTypeNull: return "null";
        case kJSTypeNumber: return "number";
        case kJSTypeObject: return "object";
        case kJSTypeString: return "string";
        case kJSTypeBoolean: return "boolean";
        case kJSTypeUndefined: return "undefined";
        default: return "null";
    }
    
}

this working for me, waiting for the official solution

 
Leave a comment

Posted by on April 11, 2019 in iOS, Mobile Development, React Native

 

Config SSH with Siteground

For Windows

https://www.siteground.com/tutorials/ssh/putty/

For MacOS

https://www.siteground.com/kb/how_to_enable_ssh_for_vps_on_mac_os/

 
Leave a comment

Posted by on February 8, 2019 in Control Version, SSH

 

Android – Launcher Icon Size

By:

 

683

I would create separate images for each one:

LDPI should be 36 x 36.

MDPI should be 48 x 48.

TVDPI should be 64 x 64.

HDPI should be 72 x 72.

XHDPI should be 96 x 96.

XXHDPI should be 144 x 144.

XXXHDPI should be 192 x 192.

Then just put each of them in the separate stalks of the drawable folder.

You are also required to give a large version of your icon when uploading your app onto the Google Play Store and this should be WEB 512 x 512. This is so large so that Google can rescale it to any size in order to advertise your app throughout the Google Play Store and not add pixelation to your logo.

Basically, all of the other icons should be in proportion to the ‘baseline’ icon, MDPI at 48 x 48.

LDPI is MDPI x 0.75.

TVDPI is MDPI x 1.33.

HDPI is MDPI x 1.5.

XHDPI is MDPI x 2.

XXHDPI is MDPI x 3.

XXXHDPI is MDPI x 4.

This is all explained on the Iconography page of the Android Developers website:http://developer.android.com/design/style/iconography.html

copy from: https://stackoverflow.com/questions/12768128/android-launcher-icon-size

 
Leave a comment

Posted by on February 2, 2019 in Android, Mobile Development

 

Change package name for Android in React Native

By:Cherniv

Then manually switched the old and new package ids:

In: android/app/src/main/java/MY/APP/NEW_ID/MainActivity.java:

package MY.APP.NEW_ID;

In android/app/src/main/java/MY/APP/NEW_ID/MainApplication.java:

package MY.APP.NEW_ID;

In android/app/src/main/AndroidManifest.xml:

package="MY.APP.NEW_ID"

And in android/app/build.gradle:

applicationId "MY.APP.NEW_ID"

(Optional) In android/app/BUCK:

android_build_config(
  package="MY.APP.NEW_ID"
)
android_resource(
  package="MY.APP.NEW_ID"
)

Gradle’ cleaning in the end (in /android folder):

./gradlew clean

 

Copy from: https://stackoverflow.com/questions/37389905/change-package-name-for-android-in-react-native

 
Leave a comment

Posted by on January 25, 2019 in Mobile Development, React Native