Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ios/RNNScrollEdgeAppearanceOptions.h
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 2 additions & 0 deletions ios/RNNScrollEdgeAppearanceOptions.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
28 changes: 28 additions & 0 deletions ios/TopBarAppearancePresenter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand Down
30 changes: 30 additions & 0 deletions src/interfaces/Options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/**
Expand Down