getLeftView method

Widget getLeftView(
  1. BuildContext context,
  2. IconData? icon,
  3. String title,
  4. double maxHeight,
)

Implementation

Widget getLeftView(
  BuildContext context,
  IconData? icon,
  String title,
  double maxHeight,
) {
  final theme = TUITheme.of(context);

  TextStyle titleTextStyle = theme.typography.heading7.copyWith(
    color: theme.colors.onSurface,
  );

  List<Widget> leftViewItems = [];

  if (icon != null) {
    leftViewItems.add(SizedBox(
      width: 24,
      height: 24,
      child: Center(
        child: Icon(icon),
      ),
    ));

    leftViewItems.add(const SizedBox(width: 16));
  }

  Padding titleWidget = Padding(
    padding: const EdgeInsets.fromLTRB(0, 3, 0, 3),
    child: Text(
      title,
      style: titleTextStyle,
      textAlign: TextAlign.left,
      overflow: maxHeight == double.infinity ? null : TextOverflow.ellipsis,
    ),
  );

  leftViewItems.add(Expanded(child: titleWidget));
  leftViewItems.add(
    const SizedBox(
      width: 8,
      height: 0,
    ),
  );

  if (accessoryView != null) {
    leftViewItems.add(accessoryView!);
  }

  return Expanded(
    child: Row(
      children: leftViewItems,
    ),
  );
}