How to better organize your React applications?

View story at


View story at



How to run API document
1. Install aglio
npm install aglio -g

2. Run API Document
aglio -i -s -p 8081

2.1. Export file
aglio -i -o api.html

Swift 3 – some snippets..

  • if let paypal = user.paypal {
    // paypal != nil
    } else {
    // paypal == nil
  • guard let paypal = user.paypal else {
    // paypal == nil
  • Handler :
    • VC 1: (CashoutContentVC)

      var loadTotalBalanceHandler: (()->())?  

      if (condition) {

                           if let callback = self.loadTotalBalanceHandler {



    • VC 2:

      let cashoutVC = storyboard.instantiateViewController(withIdentifier: “CASH OUT”) as! CashoutContentVC

              cashoutVC.loadTotalBalanceHandler = {[weak self] in

                  self?.loadTotalBalance() //things need to do when callback


      //example 2 :  pass a Double from vc1 -> vc2 

    • VC1:
      ratingScoreHandler: ((_ score: Double) -> ())?

      if (condition) {

                     if let callback = self.ratingScoreHandler {



    • VC 2:

      let ratingVC = RatingVC(nibName: “RatingVC”, bundle: nil)

      ratingVC.ratingScoreHandler = { [weak self] (score) in

                  if let strongSelf = self {

                      strongSelf.ratingScore = Int(score) //things need to do when callback



UICollectionView set num of colums

I implemented UICollectionViewDelegateFlowLayout on my UICollectionViewController and override the method responsible for determining the size of the Cell. I then took the screen width and divided it with my column requirement. For example, I wanted to have 3 columns on each screen size. So here’s what my code looks like –

– (CGSize)collectionView:(UICollectionView *)collectionView

                  layout:(UICollectionViewLayout *)collectionViewLayout

  sizeForItemAtIndexPath:(NSIndexPath *)indexPath


    CGRect screenRect = [[UIScreen mainScreen] bounds];

    CGFloat screenWidth = screenRect.size.width;

    float cellWidth = screenWidth / 3.0; //Replace the divisor with the column count requirement. Make sure to have it in float.

    CGSize size = CGSizeMake(cellWidth, cellWidth);

    return size;


Mobile trends + techniques

Demo App: (support both Android/iOS/Hybrid)

  • Will submit this app to the stores – easier for presentation, help client can install and try to use….
  • Should have a Content Team to build the content data about NashTech capabilities, activities (We will request company support us)
  • Should have Design Team to build cool UI for us (We will request company support us)


  • Build UI sample:
    • Use social network register/login (should request permission for team and for client when they visit)
    • Navigation behavior
    • Sliding menu (contain all features menu at here)
    • Setting pages
    • List view: swipe item left/right to show item menu, swipe actions
    • Popup : confirm popup, selection option popup, warning popup,….
    • Database sample: create data and save to dB then load to a list (done, should build the real content to make sense)
    • SSL & OAuth 2 authentication sample (done – should be integrate to demo app)
    • Push Notifications
    • Camera action
    • QR code action
    • Chat feature (optional)
    • API to get traveller App data  (reuse exiting source)
    • DateTime converter (reuse exiting source)
    • Animation examples (flying, transparent, scale, transittion,….)
    • Build analytics pages to show the installed user, user activities,…
    • Build questionnaire structure to show that we can build the dynamic pages,..
    • Like/share app to social network…
    • Chart samples
  • Build Bluetooth sample (should purchase some fitness devices such as Xiaomi band, Apple watch, samsung watch, Google fit.. and sync data with them
  • Material design for UI
  • Big data visualization
  • Ad Targeting (showing ads for a specific target group which selected by user)
  • Deep Linking
  • Location based service

Create QR code image from String

public Bitmap createBitmap(String str, Context context) throws WriterException {

    int wd = UiUtil.getPixelFromDp(100);
    int pinkColor = context.getResources().getColor(;
    int whiteColor = context.getResources().getColor(R.color.white);

    Map<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>(1);

    hints.put(EncodeHintType.MARGIN, 0);

    BitMatrix result;
    try {
        result = new MultiFormatWriter().encode(str,
                BarcodeFormat.QR_CODE, wd, wd, hints);
    } catch (IllegalArgumentException iae) {
        // TODO Unsupported format
        return null;

    //Change color pixel
    int w = result.getWidth();
    int h = result.getHeight();
    int[] pixels = new int[w * h];
    for (int y = 0; y < h; y++) {
        int offset = y * w;
        for (int x = 0; x < w; x++) {
            pixels[offset + x] = result.get(x, y) ? pinkColor : whiteColor;

    Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
    bitmap.setPixels(pixels, 0, wd, 0, 0, w, h);

    return bitmap;