HUBComponentModelBuilder
@protocol HUBComponentModelBuilder <HUBJSONCompatibleBuilder>
Protocol defining the public API for a builder that builds component model objects
This builder acts like a mutable model counterpart for HUBComponentModel
, with the key
difference that they are not related by inheritance.
All properties are briefly documented as part of this protocol, but for more extensive
documentation and use case examples, see the full documentation in the HUBComponentModel
protocol definition.
-
The identifier of the model that this builder is for
Declaration
Objective-C
@property (readonly, copy, nonatomic) NSString *_Nonnull modelIdentifier;
-
The index that the component would prefer to be placed at. Can be used to move components locally.
Declaration
Objective-C
@property (readwrite, copy, nonatomic, nullable) NSNumber *preferredIndex;
-
The identifier of any logical group to put the component model in within its parent.
Declaration
Objective-C
@property (readwrite, copy, nonatomic, nullable) NSString *groupIdentifier;
-
The namespace of the component that the model should be rendered using
The default value of this property is the
defaultComponentNamespace
declared by the application’s implementation ofHUBComponentFallbackHandler
. If overriden, it should match the namespace of a registeredHUBComponentFactory
, which will be asked to create a component for the model’scomponentName
.In case no
HUBComponentFactory
could be resolved for the namespace, the Hub Framework will use its fallback handler to create a fallback component using the model’scomponentCategory
.Declaration
Objective-C
@property (readwrite, copy, nonatomic) NSString *_Nonnull componentNamespace;
-
The name of the component that the model should be rendered using
The default value of this property is the
defaultComponentName
declared by the application’s implementation ofHUBComponentFallbackHandler
. It will be sent to theHUBComponentFactory
resolved forcomponentNamespace
, which will be asked to create a component for the model.Declaration
Objective-C
@property (readwrite, copy, nonatomic) NSString *_Nonnull componentName;
-
The category of the component that the model should be rendered using
The default value of this property is the
defaultComponentCategory
declared by the application’s implementation ofHUBComponentFallbackHandler
. It is sent to the fallback handler in case no component could be created for the model’scomponentNamespace
/componentName
combo - so that a fallback component may be created with similar visuals as the originally intended component.Declaration
Objective-C
@property (readwrite, copy, nonatomic) HUBComponentCategory _Nonnull componentCategory;
-
Any title that the component should render
Declaration
Objective-C
@property (readwrite, copy, nonatomic, nullable) NSString *title;
-
Any subtitle that the component should render
Declaration
Objective-C
@property (readwrite, copy, nonatomic, nullable) NSString *subtitle;
-
Any accessory title that the component should render
Declaration
Objective-C
@property (readwrite, copy, nonatomic, nullable) NSString *accessoryTitle;
-
Any longer describing text that the component should render
Declaration
Objective-C
@property (readwrite, copy, nonatomic, nullable) NSString *descriptionText;
-
A builder that can be used to construct data that describes how to render the component’s
main
imageDeclaration
Objective-C
@property (readonly, strong, nonatomic) id<HUBComponentImageDataBuilder> _Nonnull mainImageDataBuilder;
-
Any URL for the component’s
main
image. This is an alias formainImageDataBuilder.URL
.Declaration
Objective-C
@property (readwrite, copy, nonatomic, nullable) NSURL *mainImageURL;
-
Any local component
main
image. This is an alias formainImageDataBuilder.localImage
.Declaration
Objective-C
@property (readwrite, strong, nonatomic, nullable) UIImage *mainImage;
-
A builder that can be used to construct data that describes how to render the component’s background image
Declaration
Objective-C
@property (readonly, strong, nonatomic) id<HUBComponentImageDataBuilder> _Nonnull backgroundImageDataBuilder;
-
Any URL for the component’s background image. This is an alias for
backgroundImageDataBuilder.URL
.Declaration
Objective-C
@property (readwrite, copy, nonatomic, nullable) NSURL *backgroundImageURL;
-
Any local component background image. This is an alias for
backgroundImageDataBuilder.localImage
.Declaration
Objective-C
@property (readwrite, strong, nonatomic, nullable) UIImage *backgroundImage;
-
Any identifier of any icon that should be used with the component
Declaration
Objective-C
@property (readwrite, copy, nonatomic, nullable) NSString *iconIdentifier;
-
A builder that can be used to construct target data for the component
Declaration
Objective-C
@property (readonly, strong, nonatomic) id<HUBComponentTargetBuilder> _Nonnull targetBuilder;
-
Any application-specific model metadata that should be associated with the component
Declaration
Objective-C
@property (readwrite, strong, nonatomic, nullable) NSDictionary<NSString *, id> *metadata;
-
Any data that should be logged alongside interactions or impressions for the component
Declaration
Objective-C
@property (readwrite, strong, nonatomic, nullable) NSDictionary<NSString *, id> *loggingData;
-
Any custom data that the component should use
Declaration
Objective-C
@property (readwrite, strong, nonatomic, nullable) NSDictionary<NSString *, id> *customData;
-
Return whether this builder contains a builder for custom image data for a certain identifier
Declaration
Objective-C
- (BOOL)builderExistsForCustomImageDataWithIdentifier: (nonnull NSString *)identifier;
Parameters
identifier
The identifier to look for
-
Get or create a builder for data for a custom image with a certain identifier
Declaration
Objective-C
- (nonnull id<HUBComponentImageDataBuilder>) builderForCustomImageDataWithIdentifier:(nonnull NSString *)identifier;
Parameters
identifier
The identifier of the image
Return Value
If a builder already exists for the supplied identifier, then it’s returned. Otherwise a new builder is created, which can be used to build an image data model. Since this method lazily creates a builder in case one doesn’t already exist, use the
-builderExistsForImageDataWithIdentifier:
API instead if you simply wish to check for the existance of a builder. SeeHUBComponentImageDataBuilder
for more information.
-
Return all current child component model builders
Declaration
Objective-C
- (nonnull NSArray<id<HUBComponentModelBuilder>> *)allChildBuilders;
Return Value
All the existing child component model builders, in the order that they were created. Note that any
preferredIndex
set by the component model builders hasn’t been resolved at this point, so those are not taken into account. -
Return whether this builder contains a builder for a child component model builder with a certain identifier
Declaration
Objective-C
- (BOOL)builderExistsForChildWithIdentifier:(nonnull NSString *)identifier;
Parameters
identifier
The identifier to look for
-
Get or create a builder for a child component model with a certain identifier
Declaration
Objective-C
- (nonnull id<HUBComponentModelBuilder>)builderForChildWithIdentifier: (nonnull NSString *)identifier;
Parameters
identifier
The identifier that the component model should have
Return Value
If a builder already exists for the supplied identifier, then it’s returned. Otherwise a new builder is created, which can be used to build a child component model. If a new builder is created, it will have the same
componentNamespace
andcomponentName
as its parent. Since this method lazily creates a builder in case one doesn’t already exist, use the-builderExistsForChildComponentModelWithIdentifier:
API instead if you simply wish to check for the existance of a builder. -
Return child component model builders with a certain group identifier
Declaration
Objective-C
- (nullable NSArray<id<HUBComponentModelBuilder>> *) buildersForChildrenInGroupWithIdentifier:(nonnull NSString *)groupIdentifier;
Parameters
groupIdentifier
The desired group identifier
Return Value
All the existing child component model builders with the same group identifier, in the order that they were created.
-
Remove a builder for a child component model with a certain identifier
Declaration
Objective-C
- (void)removeBuilderForChildWithIdentifier:(nonnull NSString *)identifier;
Parameters
identifier
The identifier of the child component model builder to remove
-
Remove all builders for child component models contained within this builder
Declaration
Objective-C
- (void)removeAllChildBuilders;