diff --git a/ios/RNNScrollEdgeAppearanceOptions.h b/ios/RNNScrollEdgeAppearanceOptions.h index ff820ed159..8f0f020a03 100644 --- a/ios/RNNScrollEdgeAppearanceOptions.h +++ b/ios/RNNScrollEdgeAppearanceOptions.h @@ -1,9 +1,11 @@ #import "RNNComponentOptions.h" #import "RNNOptions.h" #import "RNNScrollEdgeAppearanceBackgroundOptions.h" +#import "RNNTitleOptions.h" @interface RNNScrollEdgeAppearanceOptions : RNNOptions +@property(nonatomic, strong) RNNTitleOptions *title; @property(nonatomic, strong) RNNScrollEdgeAppearanceBackgroundOptions *background; @property(nonatomic, strong) Bool *active; @property(nonatomic, strong) Bool *noBorder; diff --git a/ios/RNNScrollEdgeAppearanceOptions.mm b/ios/RNNScrollEdgeAppearanceOptions.mm index 7cdabe68d4..528124b405 100644 --- a/ios/RNNScrollEdgeAppearanceOptions.mm +++ b/ios/RNNScrollEdgeAppearanceOptions.mm @@ -9,12 +9,14 @@ - (instancetype)initWithDict:(NSDictionary *)dict { self.active = [BoolParser parse:dict key:@"active"]; self.noBorder = [BoolParser parse:dict key:@"noBorder"]; self.borderColor = [ColorParser parse:dict key:@"borderColor"]; + self.title = [[RNNTitleOptions alloc] initWithDict:dict[@"title"]]; return self; } - (void)mergeOptions:(RNNScrollEdgeAppearanceOptions *)options { [self.background mergeOptions:options.background]; + [self.title mergeOptions:options.title]; if (options.active.hasValue) self.active = options.active; diff --git a/ios/TopBarAppearancePresenter.mm b/ios/TopBarAppearancePresenter.mm index e914b761fe..8084862ac1 100644 --- a/ios/TopBarAppearancePresenter.mm +++ b/ios/TopBarAppearancePresenter.mm @@ -19,8 +19,13 @@ - (void)applyOptions:(RNNTopBarOptions *)options { [self setBackgroundColor:[options.background.color withDefault:nil]]; [self setScrollEdgeAppearanceColor:[options.scrollEdgeAppearance.background.color withDefault:nil]]; + [self setTitleAttributes:options.title]; [self setLargeTitleAttributes:options.largeTitle]; + if (options.scrollEdgeAppearance.title && [options.scrollEdgeAppearance.title hasValue]) { + [self setScrollEdgeTitleAttributes:options.scrollEdgeAppearance.title]; + } + [self setBorderColor:[options.borderColor withDefault:nil]]; [self showBorder:![options.noBorder withDefault:NO]]; [self setBackButtonOptions:options.backButton]; @@ -158,6 +163,29 @@ - (void)setTitleAttributes:(RNNTitleOptions *)titleOptions { self.getScrollEdgeAppearance.titleTextAttributes = titleTextAttributes; } +- (void)setScrollEdgeTitleAttributes:(RNNTitleOptions *)titleOptions { + NSString *fontFamily = [titleOptions.fontFamily withDefault:nil]; + NSString *fontWeight = [titleOptions.fontWeight withDefault:nil]; + NSNumber *fontSize = [titleOptions.fontSize withDefault:nil]; + UIColor *fontColor = [titleOptions.color withDefault:nil]; + + NSDictionary *titleTextAttributes = + [RNNFontAttributesCreator createFromDictionary:self.getScrollEdgeAppearance.titleTextAttributes + fontFamily:fontFamily + fontSize:fontSize + fontWeight:fontWeight + color:fontColor + centered:YES]; + + id attrib = titleTextAttributes[NSParagraphStyleAttributeName]; + if ([attrib isKindOfClass:[NSMutableParagraphStyle class]]) { + ((NSMutableParagraphStyle *)titleTextAttributes[NSParagraphStyleAttributeName]).lineBreakMode = + NSLineBreakByTruncatingTail; + } + + self.getScrollEdgeAppearance.titleTextAttributes = titleTextAttributes; +} + - (void)setLargeTitleAttributes:(RNNLargeTitleOptions *)largeTitleOptions { NSString *fontFamily = [largeTitleOptions.fontFamily withDefault:nil]; NSString *fontWeight = [largeTitleOptions.fontWeight withDefault:nil]; diff --git a/src/interfaces/Options.ts b/src/interfaces/Options.ts index 05320abfca..4d00e76843 100644 --- a/src/interfaces/Options.ts +++ b/src/interfaces/Options.ts @@ -453,7 +453,37 @@ export interface OptionsTopBarScrollEdgeAppearanceBackground { translucent?: boolean; } +export interface OptionsTopBarScrollEdgeAppearanceTitle { + /** + * Font size + */ + fontSize?: number; + /** + * Text color + */ + color?: Color; + /** + * Set the font family for the title + */ + fontFamily?: FontFamily; + /** + * Set the font style for the title + */ + fontStyle?: FontStyle; + /** + * Specifies font weight. The values 'normal' and 'bold' are supported + * for most fonts. Not all fonts have a variant for each of the numeric + * values, in that case the closest one is chosen. + */ + fontWeight?: FontWeight; +} + export interface OptionsTopBarScrollEdgeAppearance { + /** + * Title configuration applied when the scroll view reaches the edge + * ### (iOS specific) + */ + title?: OptionsTopBarScrollEdgeAppearanceTitle; background?: OptionsTopBarScrollEdgeAppearanceBackground; active: boolean; /**