native-base#Accordion JavaScript Examples

The following examples show how to use native-base#Accordion. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DateAccordionsContainer.js    From discovery-mobile-ui with MIT License 5 votes vote down vote up
DateAccordion = ({
  date, types, fromDetailsPanel, expanded, maxRecordCount,
}) => {
  const dataArray = [{ title: date, content: types }];

  const renderHeader = (item, isExpanded) => {
    const recordCountOnDate = item.content.reduce((acc, { subTypes }) => {
      subTypes.forEach(({ recordIds }) => acc.push(...recordIds));
      return acc;
    }, []).length;

    const chevronIcon = isExpanded
      ? <Ionicons name="chevron-up" size={16} color={Colors.accordionChevronIcon} />
      : <Ionicons name="chevron-down" size={16} color={Colors.accordionChevronIcon} />;
    return (
      <View style={styles.header}>
        <View style={styles.leftSideHeader}>
          {chevronIcon}
          <BaseText style={styles.headerText}>
            {item.title}
          </BaseText>
        </View>
        <View style={styles.rightSideHeader}>
          <RecordNumberBar count={recordCountOnDate} maxCount={maxRecordCount} />
        </View>
      </View>
    );
  };

  return (
    <Accordion
      style={styles.accordion}
      dataArray={dataArray}
      expanded={expanded}
      renderHeader={renderHeader}
      renderContent={(item) => (
        <SubTypeAccordionsContainer
          data={item.content}
          fromDetailsPanel={fromDetailsPanel}
          fromDateAccordion
        />
      )}
    />
  );
}
Example #2
Source File: BaseAccordion.js    From discovery-mobile-ui with MIT License 5 votes vote down vote up
BaseAccordion = ({
  headerCount,
  resourceIds,
  activeCollectionId,
  headerLabel,
  fromDetailsPanel,
  fromDateAccordion,
  maxRecordsCount,
  fromTimeSavedAccordion,
}) => {
  const dataArray = [{ headerLabel, headerCount, resourceIds }];

  return (
    <View style={styles.accordionContainer}>
      <Accordion
        style={styles.accordion}
        dataArray={dataArray}
        expanded={[]}
        renderHeader={(item, expanded) => (
          <AccordionHeader
            item={item}
            expanded={expanded}
            fromDetailsPanel={fromDetailsPanel}
            activeCollectionId={activeCollectionId}
            fromDateAccordion={fromDateAccordion}
            maxRecordsCount={maxRecordsCount}
            fromTimeSavedAccordion={fromTimeSavedAccordion}
          />
        )}
        renderContent={(item) => (
          <ResourceCards
            item={item}
            fromDetailsPanel={fromDetailsPanel}
            activeCollectionId={activeCollectionId}
          />
        )}
      />
    </View>
  );
}