How to use the @shoutem/ui.GridRow.groupByRows function in @shoutem/ui

To help you get started, we’ve selected a few @shoutem/ui examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github shoutem / extensions / shoutem.news / app / screens / GridArticlesScreen.js View on Github external
renderData(articles) {
    const { hasFeaturedItem } = this.props;

    // Group the articles into rows with 2 columns
    // If the screen has a featured article, it is the first article
    let isFeaturedArticle = hasFeaturedItem;
    const groupedArticles = GridRow.groupByRows(articles, GRID_ITEMS_PER_ROW, () => {
      if (isFeaturedArticle) {
        // The first article is featured, and it
        // should take up the entire width of the grid
        isFeaturedArticle = false;
        return GRID_ITEMS_PER_ROW;
      }
      return 1;
    });

    // Transfer the loading status from the original collection
    cloneStatus(articles, groupedArticles);

    return super.renderData(groupedArticles);
  }
}
github shoutem / extensions / shoutem.wordpress / app / screens / ArticlesGridScreen.js View on Github external
renderData(articles) {
    const { hasFeaturedItem } = this.props;
    // Group the articles into rows with 2 columns, except for the
    // first article. The first article is treated as a featured article
    let isFirstArticle = hasFeaturedItem;
    const groupedArticles = GridRow.groupByRows(articles, 2, () => {
      if (isFirstArticle) {
        isFirstArticle = false;
        return 2;
      }

      return 1;
    });

    // Transfer the loading status from the original collection
    cloneStatus(articles, groupedArticles);

    return super.renderData(groupedArticles);
  }
}
github shoutem / extensions / shoutem-rss-news / app / screens / ArticlesGridScreen.js View on Github external
renderData(articles) {
    // Group the articles into rows with 2 columns, except for the
    // first article. The first article is treated as a featured article
    let isFirstArticle = true;
    const groupedArticles = GridRow.groupByRows(articles, 2, () => {
      if (isFirstArticle) {
        isFirstArticle = false;
        return 2;
      }

      return 1;
    });

    // Transfer the loading status from the original collection
    cloneStatus(articles, groupedArticles);

    return super.renderData(groupedArticles);
  }
}
github shoutem / extensions / shoutem.rss-news / app / screens / ArticlesGridScreen.js View on Github external
renderData(articles) {
    const { hasFeaturedItem } = this.props;
    // Group the articles into rows with 2 columns, except for the
    // first article. The first article is treated as a featured article
    let isFirstArticle = hasFeaturedItem;
    const groupedArticles = GridRow.groupByRows(articles, 2, () => {
      if (isFirstArticle) {
        isFirstArticle = false;
        return 2;
      }

      return 1;
    });

    // Transfer the loading status from the original collection
    cloneStatus(articles, groupedArticles);

    return super.renderData(groupedArticles);
  }
}
github shoutem / extensions / shoutem.deals / app / components / MyDeals / FavoriteDealsList.js View on Github external
renderData(deals) {
    const { isLoading } = this.state;

    const groupedDeals = GridRow.groupByRows(deals, 2);
    cloneStatus(deals, groupedDeals);

    const loading = isBusy(groupedDeals) || !isInitialized(groupedDeals) || isLoading;

    return (
      
    );
  }
github shoutem / extensions / shoutem.ical-events / app / screens / EventsGridScreen.js View on Github external
renderData(events) {
    const { hasFeaturedItem } = this.props;
    const { shouldRenderMap } = this.state;

    if (shouldRenderMap) {
      return this.renderEventsMap(events);
    }

    let isItemFeatured = hasFeaturedItem;
    const groupedEvents = GridRow.groupByRows(events, 2, () => {
      if (isItemFeatured) {
        isItemFeatured = false;
        return 2;
      }
      return 1;
    });
    cloneStatus(events, groupedEvents);

    return super.renderData(groupedEvents);
  }
}
github shoutem / extensions / shoutem-events / app / screens / GridScreen.js View on Github external
renderData(events) {
    const { shouldRenderMap } = this.state;

    if (shouldRenderMap) {
      return this.renderEventsMap(events);
    }

    const groupedEvents = GridRow.groupByRows(events, 2, event => (event.featured ? 2 : 1));
    cloneStatus(events, groupedEvents);

    return super.renderData(groupedEvents);
  }
}
github shoutem / extensions / shoutem.navigation / app / components / IconGrid.js View on Github external
groupItemsIntoRows(items) {
    const { cols } = this.getLayoutSettings();
    return GridRow.groupByRows(items, cols);
  }
github shoutem / extensions / shoutem-rss-photos / app / screens / PhotosGrid.js View on Github external
renderData() {
    const { photos } = this.state;

    const groupedPhotos = GridRow.groupByRows(photos, NUMBER_OF_COLUMNS);
    cloneStatus(photos, groupedPhotos);

    return super.renderData(groupedPhotos);
  }
}
github shoutem / extensions / shoutem.navigation / app / components / TileGrid.js View on Github external
renderRows(page = []) {
    const groupedShortcuts = GridRow.groupByRows(page, TileGrid.ROW_COUNT);
    return groupedShortcuts.map(this.renderRow);
  }
}