/** * Copyright (c) 2019 Paul Armstrong */ import * as Theme from '../../theme'; import DeltaCell from './DeltaCell'; import GroupCell from './GroupCell'; import React from 'react'; import { StyleSheet } from 'react-native'; import TotalCell from './TotalCell'; import { Tr } from './../Table'; import { CellType, GroupCell as GCell, GroupRow as GRow, TotalCell as TCell, TotalDeltaCell as TDCell, } from '@build-tracker/comparator'; interface Props { isActive: boolean; onDisable: (artifactNames: Array) => void; onEnable: (artifactNames: Array) => void; onFocus: (artifactName: Array) => void; onHover: (artifactNames: Array) => void; row: GRow; sizeKey: string; } export const GroupRow = (props: Props): React.ReactElement => { const { isActive, onDisable, onEnable, onFocus, onHover, row, sizeKey } = props; const mapGroupCell = (cell: GCell | TCell | TDCell, i: number): React.ReactElement | void => { switch (cell.type) { case CellType.GROUP: { return ( ); } case CellType.TOTAL: return ; case CellType.TOTAL_DELTA: return ; } }; const { artifactNames } = row[0]; const handleMouseEnter = React.useCallback(() => { onHover(isActive ? artifactNames : []); }, [artifactNames, isActive, onHover]); // @ts-ignore const rows = row.map(mapGroupCell); return ( {rows} ); }; const styles = StyleSheet.create({ row: { backgroundColor: Theme.Color.Gray05, transitionProperty: 'background-color', transitionDuration: '0.1s', }, cell: { borderColor: Theme.Color.Gray20, }, }); export default React.memo(GroupRow);