Files
notesnook/apps/mobile/patches/react-native-tooltips+1.0.3.patch
Ammar Ahmed 4843d1c39e mobile: update mobile app to react-native 0.72.0 (#2814)
* mobile: upgrade to react-native 0.71

* mobile: update to react-native 0.72.0

* mobile: fix release build on android

* mobile: fix editor stuck in loading state

* mobile: fix bootsplash logo in dark mode

* mobile: update patch files

* mobile: cleanup

* mobile: increase delay

* mobile: add logs on upload

* mobile: ensure editor is ready before note loading

* mobile: fix ui

* mobile: fix

* ci: update workflow

* ci: undo workflow changes

---------

Signed-off-by: Ammar Ahmed <40239442+ammarahm-ed@users.noreply.github.com>
2023-06-26 21:50:20 +05:00

297 lines
11 KiB
Diff

diff --git a/node_modules/react-native-tooltips/RNTooltips.js b/node_modules/react-native-tooltips/RNTooltips.js
index 7dd4478..cf33173 100644
--- a/node_modules/react-native-tooltips/RNTooltips.js
+++ b/node_modules/react-native-tooltips/RNTooltips.js
@@ -1,11 +1,11 @@
import { PureComponent } from "react";
import {
findNodeHandle,
- ViewPropTypes,
NativeModules,
Platform
} from "react-native";
import PropTypes from "prop-types";
+import {ViewPropTypes} from "deprecated-react-native-prop-types";
let { RNTooltips } = NativeModules;
diff --git a/node_modules/react-native-tooltips/ios/RNTooltips.podspec b/node_modules/react-native-tooltips/RNTooltips.podspec
similarity index 87%
rename from node_modules/react-native-tooltips/ios/RNTooltips.podspec
rename to node_modules/react-native-tooltips/RNTooltips.podspec
index 0ccfd23..7771e6f 100644
--- a/node_modules/react-native-tooltips/ios/RNTooltips.podspec
+++ b/node_modules/react-native-tooltips/RNTooltips.podspec
@@ -1,6 +1,6 @@
require 'json'
-package = JSON.parse(File.read(File.join(__dir__, '../package.json')))
+package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
Pod::Spec.new do |s|
s.name = 'RNTooltips'
@@ -13,7 +13,6 @@ Pod::Spec.new do |s|
s.source = { :git => 'https://github.com/prscX/react-native-tooltips.git', :tag => s.version }
s.platform = :ios, '9.0'
- s.ios.deployment_target = '8.0'
s.preserve_paths = 'LICENSE', 'package.json'
s.source_files = '**/*.{h,m}'
diff --git a/node_modules/react-native-tooltips/android/build.gradle b/node_modules/react-native-tooltips/android/build.gradle
index 978045f..401b458 100644
--- a/node_modules/react-native-tooltips/android/build.gradle
+++ b/node_modules/react-native-tooltips/android/build.gradle
@@ -3,8 +3,9 @@ buildscript {
repositories {
google()
mavenCentral()
+ maven { url 'https://jitpack.io' }
maven { url "https://maven.google.com" }
- jcenter()
+
}
dependencies {
@@ -15,12 +16,12 @@ buildscript {
apply plugin: 'com.android.library'
android {
- compileSdkVersion 29
- buildToolsVersion '29.0.2'
+ compileSdkVersion 31
+ buildToolsVersion '31.0.0'
defaultConfig {
- minSdkVersion 16
- targetSdkVersion 29
+ minSdkVersion 21
+ targetSdkVersion 31
versionCode 1
versionName "1.0"
}
@@ -36,5 +37,5 @@ repositories {
dependencies {
implementation 'com.facebook.react:react-native:+'
- implementation 'com.github.florent37:viewtooltip:1.1.6'
+ implementation 'com.github.florent37:ViewTooltip:f79a8955ef'
}
diff --git a/node_modules/react-native-tooltips/ios/RNTooltips.h b/node_modules/react-native-tooltips/ios/RNTooltips.h
index a150e3e..096ad86 100644
--- a/node_modules/react-native-tooltips/ios/RNTooltips.h
+++ b/node_modules/react-native-tooltips/ios/RNTooltips.h
@@ -1,6 +1,11 @@
#import "RCTUIManager.h"
#import <UIKit/UIKit.h>
+#if __has_include("RCTBridgeModule.h")
+#import "RCTBridgeModule.h"
+#else
+#import <React/RCTBridgeModule.h>
+#endif
#import <SexyTooltip/SexyTooltip.h>
diff --git a/node_modules/react-native-tooltips/ios/RNTooltips.m b/node_modules/react-native-tooltips/ios/RNTooltips.m
index fb96466..75a6fdb 100644
--- a/node_modules/react-native-tooltips/ios/RNTooltips.m
+++ b/node_modules/react-native-tooltips/ios/RNTooltips.m
@@ -1,4 +1,6 @@
#import "RNTooltips.h"
+#import "RCTUIManager.h"
+#import "RCTUIManagerUtils.h"
@interface TooltipDelegate : NSObject <SexyTooltipDelegate>
@@ -7,9 +9,15 @@ @interface TooltipDelegate : NSObject <SexyTooltipDelegate>
@end
@implementation TooltipDelegate
+bool didHide = NO;
+
- (void)tooltipDidDismiss:(SexyTooltip *)tooltip {
+ if (didHide == YES) return;
+ tooltip.delegate = nil;
tooltip = nil;
+ didHide = YES;
_onHide(@[]);
+
}
@end
@@ -17,77 +25,120 @@ - (void)tooltipDidDismiss:(SexyTooltip *)tooltip {
@implementation RNTooltips
-SexyTooltip *toolTip;
+NSMutableDictionary *tooltips;
@synthesize bridge = _bridge;
+- (instancetype)init
+{
+ self = [super init];
+ tooltips = [NSMutableDictionary dictionary];
+ return self;
+}
+
- (dispatch_queue_t)methodQueue
{
return dispatch_get_main_queue();
}
RCT_EXPORT_MODULE()
-
RCT_EXPORT_METHOD(Show:(nonnull NSNumber *)targetViewTag inParentView:(nonnull NSNumber *)parentViewTag props:(NSDictionary *)props onHide:(RCTResponseSenderBlock)onHide)
{
- UIView *target = [self.bridge.uiManager viewForReactTag: targetViewTag];
- UIView *parentView = [self.bridge.uiManager viewForReactTag:parentViewTag];
- if (!parentView) {
- // parent is null, then return
- return;
- }
-
- NSString *text = [props objectForKey: @"text"];
-// NSNumber *position = [props objectForKey: @"position"]; // not used yet
-// NSNumber *align = [props objectForKey: @"align"]; // not used yet
- NSNumber *autoHide = [props objectForKey: @"autoHide"];
- NSNumber *duration = [props objectForKey: @"duration"];
- NSNumber *clickToHide = [props objectForKey: @"clickToHide"];
- NSNumber *corner = [props objectForKey: @"corner"];
- NSString *tintColor = [props objectForKey: @"tintColor"];
- NSString *textColor = [props objectForKey: @"textColor"];
- NSNumber *textSize = [props objectForKey: @"textSize"];
-// NSNumber *gravity = [props objectForKey: @"gravity"]; not used yet
- NSNumber *shadow = [props objectForKey: @"shadow"];
- NSNumber *arrow = [props objectForKey: @"arrow"];
-
- NSMutableAttributedString *attributes = [[NSMutableAttributedString alloc] initWithString: text];
- [attributes addAttribute:NSForegroundColorAttributeName value:[RNTooltips colorFromHexCode: textColor] range:NSMakeRange(0, text.length)];
- [attributes addAttribute:NSFontAttributeName value: [UIFont systemFontOfSize: [textSize floatValue]] range:NSMakeRange(0,text.length)];
-
- toolTip = [[SexyTooltip alloc] initWithAttributedString: attributes sizedToView:parentView];
- toolTip.layer.zPosition = 9999; // make sure the tooltips is always in front of other views.
-
- TooltipDelegate *delegate = [[TooltipDelegate alloc] init];
- delegate.onHide = onHide;
- [toolTip setDelegate: delegate];
-
- toolTip.color = [RNTooltips colorFromHexCode: tintColor];
- toolTip.cornerRadius = [corner floatValue];
- toolTip.dismissesOnTap = [clickToHide boolValue];
- toolTip.padding = UIEdgeInsetsMake(6.0, 8.0, 6.0, 8.0);
-
- if (![arrow boolValue]) {
- toolTip.arrowHeight = 0;
- }
- if ([shadow boolValue]) {
- toolTip.hasShadow = YES;
- }
- if ([autoHide boolValue]) {
- [toolTip dismissInTimeInterval:(NSTimeInterval) [duration floatValue] animated: YES];
+ UIView *target = [self.bridge.uiManager viewForReactTag: targetViewTag];
+ UIView *parentView = [self.bridge.uiManager viewForReactTag:parentViewTag];
+ if (!parentView) {
+ return;
+ }
+ NSString *text = props[@"text"];
+ NSNumber *position = props[@"position"];
+ // NSNumber *align = [props objectForKey: @"align"]; // not used yet
+ NSNumber *autoHide = props[@"autoHide"];
+ NSNumber *duration = props[@"duration"];
+ NSNumber *clickToHide = props[@"clickToHide"];
+ NSNumber *corner = props[@"corner"];
+ NSString *tintColor = props[@"tintColor"];
+ NSString *textColor = props[@"textColor"];
+ NSNumber *textSize = props[@"textSize"];
+ // NSNumber *gravity = [props objectForKey: @"gravity"]; not used yet
+ NSNumber *shadow = props[@"shadow"];
+ NSNumber *arrow = props[@"arrow"];
+
+ NSMutableAttributedString *attributes = [[NSMutableAttributedString alloc] initWithString: text];
+ [attributes addAttribute:NSForegroundColorAttributeName value:[RNTooltips colorFromHexCode: textColor] range:NSMakeRange(0, text.length)];
+ [attributes addAttribute:NSFontAttributeName value: [UIFont systemFontOfSize: [textSize floatValue]] range:NSMakeRange(0,text.length)];
+
+ SexyTooltip *toolTip = [[SexyTooltip alloc] initWithAttributedString: attributes sizedToView:parentView];
+
+ if (position != nil) {
+ [toolTip setPermittedArrowDirections:@[@([self getPosition:position])]];
+ [toolTip setArrowDirection:[self getPosition:position]];
+ }
+
+ TooltipDelegate *delegate = [[TooltipDelegate alloc] init];
+ delegate.onHide = onHide;
+ [toolTip setDelegate: delegate];
+ toolTip.color = [RNTooltips colorFromHexCode: tintColor];
+ toolTip.cornerRadius = [corner floatValue];
+ toolTip.dismissesOnTap = [clickToHide boolValue];
+ toolTip.padding = UIEdgeInsetsMake(6.0, 8.0, 6.0, 8.0);
+
+ if (![arrow boolValue]) {
+ toolTip.arrowHeight = 0;
+ }
+ if ([shadow boolValue]) {
+ toolTip.hasShadow = YES;
+ }
+ if ([autoHide boolValue]) {
+ [self dismissAfterDelay:targetViewTag.stringValue duration:duration];
+ }
+
+ [toolTip presentFromView:target animated:YES];
+ [parentView.superview bringSubviewToFront:toolTip];
+ [tooltips setObject:toolTip forKey:targetViewTag.stringValue];
+}
+
+- (SexyTooltipArrowDirection) getPosition:(NSNumber *)position {
+ if (position.intValue == 1) {
+ return SexyTooltipArrowDirectionRight;
+ } else if (position.intValue == 2) {
+ return SexyTooltipArrowDirectionLeft;
+ } else if (position.intValue == 3) {
+ return SexyTooltipArrowDirectionDown;
+ } else if (position.intValue == 4) {
+ return SexyTooltipArrowDirectionUp;
+ } else {
+ return SexyTooltipArrowDirectionDown;
}
- [toolTip presentFromView:target animated:YES];
+}
+
+- (void) dismissAfterDelay:(NSString*)viewTag duration:(NSNumber *)duration {
+
+ float delay = [duration floatValue]/1000;
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC*delay),
+ dispatch_get_main_queue(), ^{
+ if (tooltips[viewTag] == nil) {
+ return;
+ }
+ SexyTooltip *tooltip = tooltips[viewTag];
+ [tooltip dismissAnimated:true];
+ tooltip.delegate = nil;
+ tooltip = nil;
+ [tooltips removeObjectForKey:viewTag];
+ });
}
RCT_EXPORT_METHOD(Dismiss:(nonnull NSNumber *)view) {
- if (toolTip == nil) {
- return;
- }
+ if (tooltips[view.stringValue] == nil) {
+ return;
+ }
+
+ SexyTooltip *tooltip = tooltips[view.stringValue];
+ [tooltip dismiss];
+ tooltip = nil;
+ [tooltips removeObjectForKey:view.stringValue];
- [toolTip dismiss];
- toolTip = nil;
}