buildToolbarTopAction method

Widget buildToolbarTopAction(
  1. BuildContext context,
  2. bool isLeadingAction
)

An internal method that builds the widget for this action on the iOS platform.

This method is called by OudsToolbarTop to render the appropriate Cupertino-style widget based on the action's type. It is not intended to be called directly by application code.

Supported action types:

Throws:

Implementation

Widget buildToolbarTopAction(BuildContext context, bool isLeadingAction) {
  final ModalRoute<dynamic>? currentRoute = ModalRoute.of(context);

  switch (type) {
    // TEXT ACTION
    case OudsTopBarActionType.text:
      return _CustomCupertinoButton(
        type: type,
        onActionPressed: onActionPressed,
        actionLabel: actionLabel,
        isLeadingAction: isLeadingAction,
      );
    // BACK ACTION (icon + optional label)
    case OudsTopBarActionType.back:
      return _CustomCupertinoButton(
        contentDescription: contentDescription,
        onActionPressed: onActionPressed,
        previousPageTitle: previousPageTitle,
        route: currentRoute,
        type: type,
      );
    // NO ACTION
    case OudsTopBarActionType.none:
      return SizedBox.shrink();
    // ICON ACTION
    case OudsTopBarActionType.icon:
      final customCupertinoButton = _CustomCupertinoButton(
        contentDescription: contentDescription,
        type: type,
        onActionPressed: onActionPressed,
        icon: icon,
      );
      return Padding(
        padding: EdgeInsetsDirectional.only(
          start: isLeadingAction ? 16 : 0,
          end: isLeadingAction ? 0 : 16,
        ),
        child: badge != null
            ? buildBadgeWithBorder(
                context: context,
                hasCount: badge!.hasCount,
                child: badge!.hasCount
                    ? OudsBadge.count(
                        semanticsLabel: badge?.contentDescription,
                        label: badge?.count.toString(),
                        status: Negative(),
                        size: OudsBadgeSize.medium,
                        child: customCupertinoButton,
                      )
                    : OudsBadge.standard(
                        semanticsLabel: badge?.contentDescription,
                        status: Negative(),
                        size: OudsBadgeSize.xsmall,
                        child: customCupertinoButton,
                      ),
              )
            : customCupertinoButton,
      );
    // CUSTOM ACTION (fully custom widget)
    case OudsTopBarActionType.widget:
      return widget ?? SizedBox.shrink();
    default:
      throw UnimplementedError('Type $type not supported for iOS');
  }
}