Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 20
Inline code block support#35
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
ba7383616bc41e57ae99238722128932cfb0f857f105d3eaeb5e10f568994f2a957796a02ae79978e4bf25f8fe154f53835a56e99e41fffc12fafec13f549baf45538b16e4030bb5ad07ade765a5dd0d019ac198d71acb1b6d2f3939ca967451d13a2301494cacf86645cfd7a0f2320dc19e2615be018db54ddf7078482f14afaa879ab4addc751809c667d9bf25726f366f268882eb1b3572272a02a452c9e919d4298bedb986aa63a99d7e6640182a97474e07d60b1b1fbaa28eb2eaefb45d99bff7920632bd7df2b226ef8172976c773b5101822196caec387a36b39a390aecf0a28a85b6853e178dc73dbe999f2bac98711f1fdc6db29dcfbad1ee7a8c3925dbb05ead1b1e91a60840f64ee0687c9e20b35a78d0eac0345ac7934bbddce0e681ff8bcd6c87520a6e91e6ef7a723bca78a3eb1b2d15e9ffe8f0f0bc76307975705dc98d15c2edb63c394043fcee9ab33967861ee255dc20ea8ebb3c360bdff20d01bbbed62adfe3bdc358fb14af72678f9aa0f7627fd45aafcf050ae234993ff989bd271a7bf88386eab88331e22ba838eb371e48eb0002804029fbe4ee6154148717d20c21f45a1109839a68d53905412ef633b2a5ed5fbb2b9dacbcb3c76cbd34366ed39f261ddc2d19445bff9e0c7c86464b70b906f5e244c64f509eb220760a02569dd6b83e0062330c66b21b75c6d539a16d70ae9ab0243a326144e6df5cdf914e8cc1a614fc947e1bd1ef3706f0c1c038b525017565e49c5e46507ea97cf204f5df208b6b9ae49b173a8f0f4e2575389fc7636e9d4bf95d3b1f99c26e245ff68af1a18d70583c3a945422fdde1a51344e58b2cb2f3aa51f7314bfe6fbeb60fb0b0baf8ff569cd1a49085b335d7edc662b8c6c51c244c8c0c6f252f729aae1b3635ad1f14789c9812f5a11b52bb1d1d9df7f60211b96158432df86a6ddeff0ef1e686c0db4ec5165b6eaFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| /* | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
| #import <UIKit/UIKit.h> | ||
| NS_ASSUME_NONNULL_BEGIN | ||
| @interface RCTTextCodeBlock : NSLayoutManager | ||
| @end | ||
| NS_ASSUME_NONNULL_END |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| /* | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
| #import "RCTTextCodeBlock.h" | ||
| #import "RCTTextAttributes.h" | ||
| @implementation RCTTextCodeBlock | ||
| - (UIColor*)hexStringToColor:(NSString *)stringToConvert | ||
azimgd marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| { | ||
| NSString *noHashString = [stringToConvert stringByReplacingOccurrencesOfString:@"#" withString:@""]; | ||
| NSScanner *stringScanner = [NSScanner scannerWithString:noHashString]; | ||
| unsigned hex; | ||
| if (![stringScanner scanHexInt:&hex]) return nil; | ||
| int r = (hex >> 16) & 0xFF; | ||
| int g = (hex >> 8) & 0xFF; | ||
| int b = (hex) & 0xFF; | ||
| return [UIColor colorWithRed:r / 255.0f green:g / 255.0f blue:b / 255.0f alpha:1.0f]; | ||
| } | ||
| -(void)drawBackgroundForGlyphRange:(NSRange)glyphsToShow atPoint:(CGPoint)origin { | ||
| [super drawBackgroundForGlyphRange:glyphsToShow atPoint:origin]; | ||
| if ((glyphsToShow.location + glyphsToShow.length) > [[self textStorage] length]) { | ||
| return; | ||
| } | ||
| [[self textStorage] enumerateAttribute:RCTTextAttributesIsTextCodeBlockAttributeName | ||
| inRange:glyphsToShow | ||
| options:0 | ||
| usingBlock:^(NSDictionary *textCodeBlock, NSRange range, __unused BOOL *stop) { | ||
| NSString *backgroundColor = [textCodeBlock objectForKey:@"backgroundColor"]; | ||
| NSString *borderColor = [textCodeBlock objectForKey:@"borderColor"]; | ||
| float borderRadius = [[textCodeBlock objectForKey:@"borderRadius"] floatValue]; | ||
| float borderWidth = [[textCodeBlock objectForKey:@"borderWidth"] floatValue]; | ||
| CGContextRef context = UIGraphicsGetCurrentContext(); | ||
| CGContextSetFillColorWithColor(context, [self hexStringToColor:backgroundColor].CGColor); | ||
| CGContextSetStrokeColorWithColor(context, [self hexStringToColor:borderColor].CGColor); | ||
| if (!backgroundColor) { | ||
azimgd marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| return; | ||
| } | ||
| // Enumerates line fragments intersecting with the whole text container. | ||
| [self enumerateLineFragmentsForGlyphRange:range | ||
| usingBlock:^(CGRect rect, CGRect usedRect, NSTextContainer * _Nonnull textContainer, NSRange lineGlyphRange, BOOL * _Nonnull stop) { | ||
| __block UIBezierPath *textCodeBlockPath = nil; | ||
| NSRange lineRange = NSIntersectionRange(range, lineGlyphRange); | ||
| [self enumerateEnclosingRectsForGlyphRange:lineRange | ||
| withinSelectedGlyphRange:lineRange | ||
| inTextContainer:textContainer | ||
| usingBlock:^(CGRect enclosingRect, __unused BOOL *anotherStop) { | ||
| BOOL isFirstLine = lineGlyphRange.location == 0; | ||
| BOOL isLastLine = range.length + range.location == lineGlyphRange.length + lineGlyphRange.location; | ||
| long corners = ( | ||
| (isFirstLine ? (UIRectCornerTopLeft | UIRectCornerBottomLeft) : 0) | | ||
| (isLastLine ? (UIRectCornerTopRight | UIRectCornerBottomRight) : 0) | ||
| ); | ||
| CGRect resultRect = CGRectMake( | ||
| enclosingRect.origin.x, | ||
| enclosingRect.origin.y + (borderWidth / 2), | ||
| enclosingRect.size.width + ((isFirstLine && isLastLine) || isLastLine ? 0 : 5), | ||
| enclosingRect.size.height - borderWidth | ||
| ); | ||
| UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:resultRect byRoundingCorners:corners cornerRadii:CGSizeMake(borderRadius, borderRadius)]; | ||
| if (textCodeBlockPath) { | ||
| [textCodeBlockPath appendPath:path]; | ||
| } else { | ||
| textCodeBlockPath = path; | ||
| } | ||
| textCodeBlockPath.lineWidth = borderWidth; | ||
| [textCodeBlockPath stroke]; | ||
| [textCodeBlockPath fill]; | ||
| }]; | ||
| }]; | ||
| }]; | ||
| } | ||
| @end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @flow strict-local | ||
| */ | ||
| import type {ColorValue} from 'react-native/Libraries/StyleSheet/StyleSheet'; | ||
| export type TextCodeBlockProp = $ReadOnly<{| | ||
| /** | ||
| * The background color of the text code block. | ||
| */ | ||
| backgroundColor?: ?ColorValue, | ||
| /** | ||
| * The border color of the text code block. | ||
| */ | ||
| borderColor?: ?ColorValue, | ||
| /** | ||
| * The border radius of the text code block. | ||
| */ | ||
| borderRadius?: ?number, | ||
| /** | ||
| * The border width of the text code block. | ||
| */ | ||
| borderWidth?: ?number, | ||
| |}>; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,19 @@ | ||
| # Expensify Release | ||
| To release this fork to npm there are a couple manual steps needed. | ||
| If updating the base react-native version of the fork: | ||
| 1. Update the `version` variable on line 15 in `sdks/hermes-engine/hermes-engine.podspec` with the version of react-native the fork is based on. For example `version = '0.69.3'`. | ||
| 2. Download hermesc from the version of react-native the fork is based on. This can be done by opening the url `https://registry.npmjs.com/react-native/-/react-native-<version>.tgz`. For example `https://registry.npmjs.com/react-native/-/react-native-0.69.3.tgz`. Then copy `sdks/hermesc` to the same directory inside your react-native repository. | ||
| 3. Commit the updated files. | ||
| Build and publish the fork: | ||
| 1. Clean previous build if there is one in `android` folder with `rm -rf android`. | ||
| 2. Run `node scripts/set-rn-version.js --to-version <version>` where version is the version of the **fork** that is being published, note that this might be different that the version the fork is based on we used previously. For example `node scripts/set-rn-version.js --to-version 0.69.4`. | ||
| 3. Run `CIRCLE_TAG=<version> node ./scripts/publish-npm.js` where version is the same as the one in the previous step. For example `CIRCLE_TAG=0.69.4 node ./scripts/publish-npm.js`. | ||
azimgd marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| <h1 align="center"> | ||
| <a href="https://reactnative.dev/"> | ||
| React Native | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -160,6 +160,8 @@ public class ViewProps { | ||
| public static final String ACCESSIBILITY_LABELLED_BY = "accessibilityLabelledBy"; | ||
| public static final String IMPORTANT_FOR_ACCESSIBILITY = "importantForAccessibility"; | ||
| public static final String TEXT_CODE_BLOCK = "textCodeBlock"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this could sit under Author There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's already placed under that block, not ? I think we are good here. Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I agree that will be better. I think blocks are separated with new lines so it should be placed on line 112. Author There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can't agree, there are two main blocks separated with comments "affect or don't affect layout". I have specifically placed it there so it's easier to distinguish in the future diffs. | ||
| // DEPRECATED | ||
| public static final String ROTATION = "rotation"; | ||
| public static final String SCALE_X = "scaleX"; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -385,4 +385,15 @@ public void setPointerEvents(ReactScrollView view, @Nullable String pointerEvent | ||
| public void setScrollEventThrottle(ReactScrollView view, int scrollEventThrottle) { | ||
| view.setScrollEventThrottle(scrollEventThrottle); | ||
| } | ||
| @ReactProp(name = "verticalScrollbarPosition") | ||
| public void setVerticalScrollbarPosition(ReactScrollView view, String position) { | ||
| if ("right".equals(position)) { | ||
| view.setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_RIGHT); | ||
| } else if ("left".equals(position)) { | ||
| view.setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_LEFT); | ||
| } else { | ||
| view.setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_DEFAULT); | ||
| } | ||
| } | ||
azimgd marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to understand this change, what is the effect of this config? Can it increase RAM usage or affect rendering performance? etc. Sounds related to GPU.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strange, this comes from Expensify-0.71.0-alpha1: https://github.com/facebook/react-native/blob/f16348ca033bb29a5c750faf7b8e99eaef8fdfed/Libraries/NativeComponent/BaseViewConfig.ios.js#L186