GuidesComponentsTile

Tile.TaskIcon

Healthcare measurement type icons with SVG rendering and theme integration

  • Stable unknown
  • Release candidate since 1.16.1-rc.3
  • Development since 1.16.1-dev.2111+9796905

Displays healthcare measurement type icons using SVG graphics with theme integration and support for various medical device types.

Quick Example

import React from "react";
import { Tile, useAppTheme } from "@ovok/native";
import { MeasurementTypeKey } from "@ovok/core/next";

export const TaskIconExample = () => {
  const theme = useAppTheme();

  return (
    <Tile>
      <Tile.StartSection
        isCompleted={false}
        left={() => (
          <Tile.TaskIcon
            measurementTypeKey={MeasurementTypeKey.bloodPressure}
            size={24}
            color={theme.colors.primary}
            testID="blood-pressure-icon"
          />
        )}
      />
    </Tile>
  );
};

Props

Every prop, with its type and description, is listed in the @ovok/native/tile API reference.

Component Behavior

The TaskIcon component:

  1. Icon Selection: Uses measurementTypeKey to select the appropriate SVG icon
  2. Color Application: Applies the specified color (or theme primary) to the SVG fill
  3. Size Control: Sets both width and height to the same value for square icons
  4. Fallback: Returns null if no icon is found for the measurement type
  5. Memoization: Uses React.useMemo to optimize SVG generation

Localization

This component does not use localization directly as it displays visual icons. However, it's often used alongside localized text:

import { useTranslation } from "react-i18next";

export const LocalizedIconExample = () => {
  const { t } = useTranslation();

  return (
    <Tile>
      <Tile.StartSection
        isCompleted={false}
        left={() => (
          <Tile.TaskIcon
            measurementTypeKey={MeasurementTypeKey.bloodPressure}
          />
        )}
      />
      <Tile.Title>{t("tile.bloodPressure.label")}</Tile.Title>
    </Tile>
  );
};

Styling

Theme Colors Used

  • theme.colors.primary - Default icon fill color when no custom color is provided

Technical Implementation

The component uses:

  • react-native-svg: For SVG rendering
  • Memoization: Performance optimization for icon generation
  • Dynamic SVG: Icons are generated as SVG strings with dynamic color injection

Last updated on

On this page