buildToolbarTopAction method
- BuildContext context,
- 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:
- OudsTopBarActionType.text: A CupertinoButton with a text label.
- OudsTopBarActionType.back: A CupertinoButton with a back chevron icon and optional label.
- OudsTopBarActionType.icon: A CupertinoButton with a custom SVG icon.
- OudsTopBarActionType.widget: The custom widget provided in the configuration.
- OudsTopBarActionType.none: An empty SizedBox.
Throws:
- UnimplementedError if the action type is not supported for the iOS platform.
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:
return Padding(
padding: EdgeInsetsDirectional.only(start : isLeadingAction ? 16 : 0, end: isLeadingAction ? 0 : 16),
child: _CustomCupertinoButton(
contentDescription: contentDescription,
type: type,
onActionPressed: onActionPressed,
icon: icon
),
);
// CUSTOM ACTION (fully custom widget)
case OudsTopBarActionType.widget:
return widget ?? SizedBox.shrink();
default:
throw UnimplementedError('Type $type not supported for iOS');
}
}