-
Notifications
You must be signed in to change notification settings - Fork 102
Expand file tree
/
Copy pathRCTMarkdownStyle.mm
More file actions
95 lines (67 loc) · 3.7 KB
/
RCTMarkdownStyle.mm
File metadata and controls
95 lines (67 loc) · 3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#import <RNLiveMarkdown/RCTMarkdownStyle.h>
#ifdef RCT_NEW_ARCH_ENABLED
#import <React/RCTConversions.h>
#else
#import <React/RCTConvert.h>
#endif /* RCT_NEW_ARCH_ENABLED */
@implementation RCTMarkdownStyle
#ifdef RCT_NEW_ARCH_ENABLED
- (instancetype)initWithStruct:(const facebook::react::MarkdownTextInputDecoratorViewMarkdownStyleStruct &)style
{
if (self = [super init]) {
_syntaxColor = RCTUIColorFromSharedColor(style.syntax.color);
_linkColor = RCTUIColorFromSharedColor(style.link.color);
_h1FontSize = style.h1.fontSize;
_emojiFontSize = style.emoji.fontSize;
_blockquoteBorderColor = RCTUIColorFromSharedColor(style.blockquote.borderColor);
_blockquoteBorderWidth = style.blockquote.borderWidth;
_blockquoteMarginLeft = style.blockquote.marginLeft;
_blockquotePaddingLeft = style.blockquote.paddingLeft;
_codeFontFamily = RCTNSStringFromString(style.code.fontFamily);
_codeFontSize = style.code.fontSize;
_codeColor = RCTUIColorFromSharedColor(style.code.color);
_codeBackgroundColor = RCTUIColorFromSharedColor(style.code.backgroundColor);
_preFontFamily = RCTNSStringFromString(style.pre.fontFamily);
_preFontSize = style.pre.fontSize;
_preColor = RCTUIColorFromSharedColor(style.pre.color);
_preBackgroundColor = RCTUIColorFromSharedColor(style.pre.backgroundColor);
_mentionHereColor = RCTUIColorFromSharedColor(style.mentionHere.color);
_mentionHereBackgroundColor = RCTUIColorFromSharedColor(style.mentionHere.backgroundColor);
_mentionUserColor = RCTUIColorFromSharedColor(style.mentionUser.color);
_mentionUserBackgroundColor = RCTUIColorFromSharedColor(style.mentionUser.backgroundColor);
_mentionReportColor = RCTUIColorFromSharedColor(style.mentionReport.color);
_mentionReportBackgroundColor = RCTUIColorFromSharedColor(style.mentionReport.backgroundColor);
}
return self;
}
#else
- (instancetype)initWithDictionary:(NSDictionary *)json
{
if (self = [super init]) {
_syntaxColor = [RCTConvert UIColor:json[@"syntax"][@"color"]];
_linkColor = [RCTConvert UIColor:json[@"link"][@"color"]];
_h1FontSize = [RCTConvert CGFloat:json[@"h1"][@"fontSize"]];
_emojiFontSize = [RCTConvert CGFloat:json[@"emoji"][@"fontSize"]];
_blockquoteBorderColor = [RCTConvert UIColor:json[@"blockquote"][@"borderColor"]];
_blockquoteBorderWidth = [RCTConvert CGFloat:json[@"blockquote"][@"borderWidth"]];
_blockquoteMarginLeft = [RCTConvert CGFloat:json[@"blockquote"][@"marginLeft"]];
_blockquotePaddingLeft = [RCTConvert CGFloat:json[@"blockquote"][@"paddingLeft"]];
_codeFontFamily = [RCTConvert NSString:json[@"code"][@"fontFamily"]];
_codeFontSize = [RCTConvert CGFloat:json[@"code"][@"fontSize"]];
_codeColor = [RCTConvert UIColor:json[@"code"][@"color"]];
_codeBackgroundColor = [RCTConvert UIColor:json[@"code"][@"backgroundColor"]];
_preFontFamily = [RCTConvert NSString:json[@"pre"][@"fontFamily"]];
_preFontSize = [RCTConvert CGFloat:json[@"pre"][@"fontSize"]];
_preColor = [RCTConvert UIColor:json[@"pre"][@"color"]];
_preBackgroundColor = [RCTConvert UIColor:json[@"pre"][@"backgroundColor"]];
_mentionHereColor = [RCTConvert UIColor:json[@"mentionHere"][@"color"]];
_mentionHereBackgroundColor = [RCTConvert UIColor:json[@"mentionHere"][@"backgroundColor"]];
_mentionUserColor = [RCTConvert UIColor:json[@"mentionUser"][@"color"]];
_mentionUserBackgroundColor = [RCTConvert UIColor:json[@"mentionUser"][@"backgroundColor"]];
_mentionReportColor = [RCTConvert UIColor:json[@"mentionReport"][@"color"]];
_mentionReportBackgroundColor = [RCTConvert UIColor:json[@"mentionReport"][@"backgroundColor"]];
}
return self;
}
#endif /* RCT_NEW_ARCH_ENABLED */
@end