uilib-native 4.2.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/DynamicFonts/FontDownloader.d.ts +41 -0
- package/components/DynamicFonts/{FontDownloader.ts → FontDownloader.js} +33 -67
- package/components/DynamicFonts/FontLoader.d.ts +35 -0
- package/components/DynamicFonts/{FontLoader.ts → FontLoader.js} +20 -54
- package/components/DynamicFonts/NoPermissionsAcquirer.d.ts +3 -0
- package/components/DynamicFonts/{NoPermissionsAcquirer.ts → NoPermissionsAcquirer.js} +2 -2
- package/components/DynamicFonts/PermissionsAcquirer.android.d.ts +13 -0
- package/components/DynamicFonts/{PermissionsAcquirer.android.ts → PermissionsAcquirer.android.js} +8 -24
- package/components/DynamicFonts/PermissionsAcquirer.ios.js +2 -0
- package/components/DynamicFonts/{PermissionsAcquirer.ios.ts → PermissionsAcquirer.web.d.ts} +0 -1
- package/components/DynamicFonts/PermissionsAcquirer.web.js +2 -0
- package/components/DynamicFonts/RNFSPackage.d.ts +2 -0
- package/components/DynamicFonts/RNFSPackage.js +5 -0
- package/components/DynamicFonts/index.d.ts +61 -0
- package/components/DynamicFonts/index.js +154 -0
- package/components/HighlighterOverlayView.js +40 -0
- package/components/HighlighterOverlayView.web.js +15 -0
- package/components/Keyboard/KeyboardInput/CustomKeyboardView/CustomKeyboardView.android.d.ts +7 -0
- package/components/Keyboard/KeyboardInput/CustomKeyboardView/CustomKeyboardView.android.js +28 -0
- package/components/Keyboard/KeyboardInput/CustomKeyboardView/CustomKeyboardView.ios.d.ts +19 -0
- package/components/Keyboard/KeyboardInput/CustomKeyboardView/{CustomKeyboardView.ios.tsx → CustomKeyboardView.ios.js} +25 -33
- package/components/Keyboard/KeyboardInput/CustomKeyboardView/index.d.ts +4 -0
- package/components/Keyboard/KeyboardInput/CustomKeyboardView/index.js +10 -0
- package/components/Keyboard/KeyboardInput/CustomKeyboardView/{index.web.tsx → index.web.js} +2 -7
- package/components/Keyboard/KeyboardInput/CustomKeyboardViewBase.d.ts +24 -0
- package/components/Keyboard/KeyboardInput/CustomKeyboardViewBase.js +67 -0
- package/components/Keyboard/KeyboardInput/KeyboardAccessoryView.d.ts +74 -0
- package/components/Keyboard/KeyboardInput/{KeyboardAccessoryView.tsx → KeyboardAccessoryView.js} +24 -104
- package/components/Keyboard/KeyboardInput/KeyboardRegistry.d.ts +71 -0
- package/components/Keyboard/KeyboardInput/{KeyboardRegistry.ts → KeyboardRegistry.js} +28 -19
- package/components/Keyboard/KeyboardInput/TextInputKeyboardManager/TextInputKeyboardManager.android.d.ts +4 -0
- package/components/Keyboard/KeyboardInput/TextInputKeyboardManager/{TextInputKeyboardManager.android.ts → TextInputKeyboardManager.android.js} +2 -5
- package/components/Keyboard/KeyboardInput/TextInputKeyboardManager/TextInputKeyboardManager.ios.d.ts +10 -0
- package/components/Keyboard/KeyboardInput/TextInputKeyboardManager/{TextInputKeyboardManager.ios.ts → TextInputKeyboardManager.ios.js} +15 -15
- package/components/Keyboard/KeyboardInput/TextInputKeyboardManager/index.d.ts +4 -0
- package/components/Keyboard/KeyboardInput/TextInputKeyboardManager/index.js +6 -0
- package/components/Keyboard/KeyboardInput/utils/EventEmitterManager.d.ts +10 -0
- package/components/Keyboard/KeyboardInput/utils/{EventEmitterManager.ts → EventEmitterManager.js} +8 -14
- package/components/Keyboard/KeyboardInput/utils/KeyboardUtils.d.ts +11 -0
- package/components/Keyboard/KeyboardInput/utils/{KeyboardUtils.ts → KeyboardUtils.js} +3 -3
- package/components/Keyboard/KeyboardTracking/KeyboardAwareInsetsView.d.ts +16 -0
- package/components/Keyboard/KeyboardTracking/{KeyboardAwareInsetsView.tsx → KeyboardAwareInsetsView.js} +11 -13
- package/components/Keyboard/KeyboardTracking/KeyboardTrackingView/KeyboardTrackingView.android.d.ts +12 -0
- package/components/Keyboard/KeyboardTracking/KeyboardTrackingView/KeyboardTrackingView.android.js +17 -0
- package/components/Keyboard/KeyboardTracking/KeyboardTrackingView/KeyboardTrackingView.ios.d.ts +24 -0
- package/components/Keyboard/KeyboardTracking/KeyboardTrackingView/{KeyboardTrackingView.ios.tsx → KeyboardTrackingView.ios.js} +5 -14
- package/components/Keyboard/KeyboardTracking/KeyboardTrackingView/index.d.ts +81 -0
- package/components/Keyboard/KeyboardTracking/KeyboardTrackingView/index.js +22 -0
- package/components/Keyboard/KeyboardTracking/KeyboardTrackingView/{index.web.tsx → index.web.js} +2 -6
- package/components/Keyboard/index.d.ts +40 -0
- package/components/Keyboard/index.js +13 -0
- package/components/SafeArea/SafeAreaInsetsManager.d.ts +20 -0
- package/components/SafeArea/{SafeAreaInsetsManager.ts → SafeAreaInsetsManager.js} +23 -26
- package/components/SafeArea/SafeAreaSpacerView.d.ts +10 -0
- package/components/SafeArea/SafeAreaSpacerView.js +14 -0
- package/components/SafeArea/SafeAreaSpacerView.web.d.ts +10 -0
- package/components/SafeArea/SafeAreaSpacerView.web.js +9 -0
- package/components/index.js +6 -0
- package/package.json +8 -3
- package/react-native.config.js +22 -0
- package/scripts/releaseNative.js +56 -0
- package/android/build/.transforms/693a7b223f458db1594dd91fc3a98873/results.bin +0 -1
- package/android/build/.transforms/693a7b223f458db1594dd91fc3a98873/transformed/classes/classes.dex +0 -0
- package/android/build/.transforms/919c4721f192d8eb61942547d8ca6581/results.bin +0 -1
- package/android/build/.transforms/919c4721f192d8eb61942547d8ca6581/transformed/classes/classes.dex +0 -0
- package/android/build/generated/source/buildConfig/debug/com/wix/reactnativeuilib/BuildConfig.java +0 -10
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +0 -9
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +0 -18
- package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +0 -4
- package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +0 -1
- package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/compile_r_class_jar/debug/R.jar +0 -0
- package/android/build/intermediates/compile_symbol_list/debug/R.txt +0 -1962
- package/android/build/intermediates/compiled_local_resources/debug/out/layout_wheel_picker.xml.flat +0 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +0 -2
- package/android/build/intermediates/incremental/debug/packageDebugResources/merged.dir/values/values.xml +0 -15
- package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +0 -7
- package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +0 -2
- package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +0 -2
- package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +0 -2
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/BuildConfig.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/UiLibPackageList.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/dynamicfont/DynamicFontModule.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/dynamicfont/DynamicFontPackage.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/highlighterview/HighlightFrame.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/highlighterview/HighlightViewTagParams.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/highlighterview/HighlighterView.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/highlighterview/HighlighterViewManager$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/highlighterview/HighlighterViewManager.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/highlighterview/HighlighterViewPackage.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/highlighterview/ReactHacks.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/highlighterview/ReflectionUtils.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/highlighterview/UiUtils.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/AppContextHolder$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/AppContextHolder.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/CustomKeyboardLayout$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/CustomKeyboardLayout$2.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/CustomKeyboardLayout$3.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/CustomKeyboardLayout$4.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/CustomKeyboardLayout$5.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/CustomKeyboardLayout.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/CustomKeyboardRootView.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/CustomKeyboardRootViewManager.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/CustomKeyboardRootViewShadow.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/KeyboardInputModule.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/KeyboardInputPackage.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/ReactContextHolder.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/ReactScreenMonitor$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/ReactScreenMonitor$Listener.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/ReactScreenMonitor.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/ReactSoftKeyboardMonitor$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/ReactSoftKeyboardMonitor$2.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/ReactSoftKeyboardMonitor$Listener.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/ReactSoftKeyboardMonitor.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/utils/PredicateFunc.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils$2.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/utils/ViewUtils$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/utils/ViewUtils$VisibleViewClassMatchPredicate.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/keyboardinput/utils/ViewUtils.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/textinput/DefaultKeyListener.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/textinput/KeyListenerProxy.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerModule$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerModule.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerPackage.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/textinput/ViewUtils.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/utils/LogForwarder$LogType.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/wix/reactnativeuilib/utils/LogForwarder.class +0 -0
- package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +0 -11
- package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +0 -11
- package/android/build/intermediates/merged_manifest/debug/AndroidManifest.xml +0 -9
- package/android/build/intermediates/navigation_json/debug/navigation.json +0 -1
- package/android/build/intermediates/packaged_manifests/debug/output-metadata.json +0 -18
- package/android/build/intermediates/packaged_res/debug/layout/wheel_picker.xml +0 -9
- package/android/build/intermediates/packaged_res/debug/values/values.xml +0 -15
- package/android/build/intermediates/runtime_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +0 -1455
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -25
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/components/DynamicFonts/RNFSPackage.ts +0 -6
- package/components/DynamicFonts/index.ts +0 -194
- package/components/HighlighterOverlayView.tsx +0 -90
- package/components/HighlighterOverlayView.web.tsx +0 -58
- package/components/Keyboard/KeyboardInput/CustomKeyboardView/CustomKeyboardView.android.tsx +0 -31
- package/components/Keyboard/KeyboardInput/CustomKeyboardView/index.tsx +0 -16
- package/components/Keyboard/KeyboardInput/CustomKeyboardViewBase.tsx +0 -83
- package/components/Keyboard/KeyboardInput/TextInputKeyboardManager/index.ts +0 -9
- package/components/Keyboard/KeyboardTracking/KeyboardTrackingView/KeyboardTrackingView.android.tsx +0 -15
- package/components/Keyboard/KeyboardTracking/KeyboardTrackingView/index.tsx +0 -96
- package/components/Keyboard/index.ts +0 -15
- package/components/SafeArea/SafeAreaSpacerView.tsx +0 -19
- package/components/SafeArea/SafeAreaSpacerView.web.tsx +0 -14
- package/components/index.ts +0 -16
- /package/components/DynamicFonts/{PermissionsAcquirer.web.ts → PermissionsAcquirer.ios.d.ts} +0 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import FontLoader, { FontExtension } from "./FontLoader";
|
|
2
|
+
import FontDownloader from "./FontDownloader";
|
|
3
|
+
// @ts-expect-error
|
|
4
|
+
import PermissionsAcquirer from "./PermissionsAcquirer";
|
|
5
|
+
import NoPermissionsAcquirer from "./NoPermissionsAcquirer";
|
|
6
|
+
const DEFAULT_FONT_LOAD_ERROR_MESSAGE = 'Unable to load this font.';
|
|
7
|
+
export { FontExtension };
|
|
8
|
+
export default class DynamicFonts {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
const {
|
|
11
|
+
debug = __DEV__,
|
|
12
|
+
doNotRequestPermissions
|
|
13
|
+
} = props;
|
|
14
|
+
this.props = {
|
|
15
|
+
fontLoadErrorMessage: DEFAULT_FONT_LOAD_ERROR_MESSAGE,
|
|
16
|
+
...props
|
|
17
|
+
};
|
|
18
|
+
this.permissionsAcquirer = doNotRequestPermissions ? new NoPermissionsAcquirer() : new PermissionsAcquirer(this.props.permissionsAcquirerProps ?? {});
|
|
19
|
+
this.fontLoader = new FontLoader({
|
|
20
|
+
debug
|
|
21
|
+
});
|
|
22
|
+
const fontDownloadingProps = this.props.fontDownloadingProps ?? {};
|
|
23
|
+
this.fontDownloader = new FontDownloader({
|
|
24
|
+
...fontDownloadingProps,
|
|
25
|
+
debug
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
log(message, ...optionalParams) {
|
|
29
|
+
const {
|
|
30
|
+
debug
|
|
31
|
+
} = this.props;
|
|
32
|
+
if (debug) {
|
|
33
|
+
console.log(message, optionalParams);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async loadFont(input) {
|
|
37
|
+
const {
|
|
38
|
+
fontLoadErrorMessage
|
|
39
|
+
} = this.props;
|
|
40
|
+
try {
|
|
41
|
+
return await this.fontLoader.loadFont(input);
|
|
42
|
+
} catch (err) {
|
|
43
|
+
return Promise.reject({
|
|
44
|
+
source: 'uilib:FontDownloader:loadFont',
|
|
45
|
+
message: `${fontLoadErrorMessage} fontName: ${input.fontName} error: ${JSON.stringify(err)}`
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Get font - download from uri (or from cache if already downloaded) and load it to memory
|
|
52
|
+
* You need to handle errors in the form of Promise.reject
|
|
53
|
+
* @param fontUri the uri of the font (to be downloaded from)
|
|
54
|
+
* @param fontName the full name of the font
|
|
55
|
+
* @param fontExtension the extension of the font, i.e. '.ttf' or '.otf'
|
|
56
|
+
* @param timeout milliseconds for the download to complete in (defaults to 5000)
|
|
57
|
+
*/
|
|
58
|
+
async getFont({
|
|
59
|
+
fontUri,
|
|
60
|
+
fontName,
|
|
61
|
+
fontExtension,
|
|
62
|
+
timeout = 5000
|
|
63
|
+
}) {
|
|
64
|
+
const {
|
|
65
|
+
fontLoadErrorMessage
|
|
66
|
+
} = this.props;
|
|
67
|
+
await this.permissionsAcquirer.getPermissions();
|
|
68
|
+
if (await this.fontDownloader.isFontDownloaded(fontName, fontExtension)) {
|
|
69
|
+
this.log(fontName, 'Already downloaded');
|
|
70
|
+
} else {
|
|
71
|
+
await this.fontDownloader.downloadFont(fontUri, fontName, fontExtension, timeout);
|
|
72
|
+
}
|
|
73
|
+
const base64FontString = await this.fontDownloader.readFontFromDisk(fontName, fontExtension);
|
|
74
|
+
if (base64FontString) {
|
|
75
|
+
this.log(fontName, 'Loading');
|
|
76
|
+
const _fontName = await this.loadFont({
|
|
77
|
+
fontName,
|
|
78
|
+
base64FontString,
|
|
79
|
+
fontExtension
|
|
80
|
+
});
|
|
81
|
+
this.log(_fontName, 'Finished loading');
|
|
82
|
+
return Promise.resolve(_fontName);
|
|
83
|
+
} else {
|
|
84
|
+
return Promise.reject({
|
|
85
|
+
source: 'uilib:FontDownloader:getFont',
|
|
86
|
+
message: `${fontLoadErrorMessage} fontName: ${fontName}`
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async getFonts(fonts) {
|
|
91
|
+
await this.permissionsAcquirer.getPermissions();
|
|
92
|
+
if (fonts instanceof Array) {
|
|
93
|
+
return Promise.all(fonts.filter(font => font).map(font => this.getFont(font)));
|
|
94
|
+
} else {
|
|
95
|
+
return Promise.resolve([await this.getFont(fonts)]);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
buildFontData(rootUri, fontName, fontExtension, fontNamePrefix) {
|
|
99
|
+
const _fontName = `${fontNamePrefix ?? ''}${fontName}`;
|
|
100
|
+
const fullFontName = `${_fontName}.${fontExtension}`;
|
|
101
|
+
return {
|
|
102
|
+
fontUri: `${rootUri}${fullFontName}`,
|
|
103
|
+
fontName: _fontName,
|
|
104
|
+
fontExtension,
|
|
105
|
+
fullFontName
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// eslint-disable-next-line max-params
|
|
110
|
+
async getFontFamily(rootUri, fontNames, fontExtension, fontNamePrefix, retries = 1) {
|
|
111
|
+
const fonts = fontNames.map(fontName => this.buildFontData(rootUri, fontName, fontExtension, fontNamePrefix));
|
|
112
|
+
let fontsLoaded = [];
|
|
113
|
+
let tryCounter = 0;
|
|
114
|
+
while (fontsLoaded.length < fontNames.length && tryCounter < retries) {
|
|
115
|
+
try {
|
|
116
|
+
++tryCounter;
|
|
117
|
+
// TODO: we should return successful loaded fonts and not fail all of them
|
|
118
|
+
fontsLoaded = await this.getFonts(fonts);
|
|
119
|
+
} catch (error) {
|
|
120
|
+
this.log(`getFontFamily failed (try #${tryCounter}) error:`, error);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return Promise.resolve(fontsLoaded);
|
|
124
|
+
}
|
|
125
|
+
async deleteFontFromDisk(fontName, fontExtension, fontNamePrefix) {
|
|
126
|
+
const fontInput = this.buildFontData('', fontName, fontExtension, fontNamePrefix);
|
|
127
|
+
await this.fontDownloader.deleteFontFromDisk(fontInput.fullFontName);
|
|
128
|
+
}
|
|
129
|
+
async deleteFont(fontName, fontExtension) {
|
|
130
|
+
await this.permissionsAcquirer.getPermissions();
|
|
131
|
+
await this.deleteFontFromDisk(fontName, fontExtension);
|
|
132
|
+
}
|
|
133
|
+
async deleteFontFamily(fontNames, fontExtension, fontNamePrefix) {
|
|
134
|
+
await this.permissionsAcquirer.getPermissions();
|
|
135
|
+
fontNames.forEach(async fontName => {
|
|
136
|
+
await this.deleteFontFromDisk(fontName, fontExtension, fontNamePrefix);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
async isFontDownloaded(fontName, fontExtension) {
|
|
140
|
+
return await this.fontDownloader.isFontDownloaded(fontName, fontExtension);
|
|
141
|
+
}
|
|
142
|
+
async isFontFamilyDownloaded(rootUri, fontNames, fontExtension, fontNamePrefix) {
|
|
143
|
+
const fonts = fontNames.map(fontName => this.buildFontData(rootUri, fontName, fontExtension, fontNamePrefix));
|
|
144
|
+
try {
|
|
145
|
+
const areDownloaded = await Promise.all(fonts.filter(font => font).map(font => {
|
|
146
|
+
return this.fontDownloader.isFontDownloaded(font.fontName, font.fontExtension);
|
|
147
|
+
}));
|
|
148
|
+
return Promise.resolve(areDownloaded.every(v => v === true));
|
|
149
|
+
} catch (error) {
|
|
150
|
+
this.log(`isFontFamilyDownloaded failed error:`, error);
|
|
151
|
+
return Promise.resolve(false);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { requireNativeComponent, processColor, Platform, StyleSheet, Modal } from 'react-native';
|
|
3
|
+
const NativeHighlighterView = requireNativeComponent('HighlighterView');
|
|
4
|
+
const DefaultOverlayColor = 'rgba(0, 0, 0, 0.5)';
|
|
5
|
+
const HighlighterOverlayView = props => {
|
|
6
|
+
const {
|
|
7
|
+
overlayColor,
|
|
8
|
+
borderRadius,
|
|
9
|
+
strokeColor,
|
|
10
|
+
strokeWidth,
|
|
11
|
+
visible,
|
|
12
|
+
onRequestClose,
|
|
13
|
+
highlightFrame,
|
|
14
|
+
style,
|
|
15
|
+
children,
|
|
16
|
+
highlightViewTag,
|
|
17
|
+
highlightViewTagParams,
|
|
18
|
+
minimumRectSize,
|
|
19
|
+
innerPadding
|
|
20
|
+
} = props;
|
|
21
|
+
let overlayColorToUse = overlayColor || DefaultOverlayColor;
|
|
22
|
+
let strokeColorToUse = strokeColor;
|
|
23
|
+
if (Platform.OS === 'android') {
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
overlayColorToUse = processColor(overlayColorToUse);
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
strokeColorToUse = processColor(strokeColorToUse);
|
|
28
|
+
}
|
|
29
|
+
return <Modal visible={!!visible} animationType={'fade'} transparent onRequestClose={() => onRequestClose?.()}>
|
|
30
|
+
<NativeHighlighterView
|
|
31
|
+
// @ts-ignore, this became private, not sure if I should remove it
|
|
32
|
+
highlightFrame={highlightFrame} style={[style, {
|
|
33
|
+
...StyleSheet.absoluteFillObject,
|
|
34
|
+
backgroundColor: 'transparent'
|
|
35
|
+
}]} overlayColor={overlayColorToUse} borderRadius={borderRadius} strokeColor={strokeColorToUse} strokeWidth={strokeWidth} highlightViewTag={highlightViewTag} highlightViewTagParams={highlightViewTagParams} minimumRectSize={minimumRectSize} innerPadding={innerPadding} />
|
|
36
|
+
{children}
|
|
37
|
+
</Modal>;
|
|
38
|
+
};
|
|
39
|
+
HighlighterOverlayView.displayName = 'IGNORE';
|
|
40
|
+
export default HighlighterOverlayView;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal } from 'react-native';
|
|
3
|
+
const HighlighterOverlayView = props => {
|
|
4
|
+
const {
|
|
5
|
+
visible,
|
|
6
|
+
onRequestClose,
|
|
7
|
+
children
|
|
8
|
+
} = props;
|
|
9
|
+
return <Modal visible={!!visible} animationType={'fade'} transparent onRequestClose={() => onRequestClose?.()}>
|
|
10
|
+
|
|
11
|
+
{children}
|
|
12
|
+
</Modal>;
|
|
13
|
+
};
|
|
14
|
+
HighlighterOverlayView.displayName = 'IGNORE';
|
|
15
|
+
export default HighlighterOverlayView;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import CustomKeyboardViewBase, { CustomKeyboardViewBaseProps } from '../CustomKeyboardViewBase';
|
|
3
|
+
export default class CustomKeyboardView extends CustomKeyboardViewBase<CustomKeyboardViewBaseProps> {
|
|
4
|
+
static displayName: string;
|
|
5
|
+
componentDidUpdate(prevProps: CustomKeyboardViewBaseProps): Promise<void>;
|
|
6
|
+
render(): React.JSX.Element;
|
|
7
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { requireNativeComponent } from 'react-native';
|
|
3
|
+
import TextInputKeyboardManager from "../TextInputKeyboardManager/TextInputKeyboardManager.android";
|
|
4
|
+
import KeyboardRegistry from "../KeyboardRegistry";
|
|
5
|
+
import CustomKeyboardViewBase from "../CustomKeyboardViewBase";
|
|
6
|
+
const CustomKeyboardViewNativeAndroid = requireNativeComponent('CustomKeyboardViewNativeTemp');
|
|
7
|
+
export default class CustomKeyboardView extends CustomKeyboardViewBase {
|
|
8
|
+
static displayName = 'IGNORE';
|
|
9
|
+
async componentDidUpdate(prevProps) {
|
|
10
|
+
const {
|
|
11
|
+
component
|
|
12
|
+
} = this.props;
|
|
13
|
+
if (prevProps.component !== component && !component) {
|
|
14
|
+
await TextInputKeyboardManager.reset();
|
|
15
|
+
}
|
|
16
|
+
super.componentDidUpdate(prevProps);
|
|
17
|
+
}
|
|
18
|
+
render() {
|
|
19
|
+
const {
|
|
20
|
+
component,
|
|
21
|
+
initialProps
|
|
22
|
+
} = this.props;
|
|
23
|
+
const KeyboardComponent = component && KeyboardRegistry.getKeyboard(component);
|
|
24
|
+
return <CustomKeyboardViewNativeAndroid>
|
|
25
|
+
{KeyboardComponent && <KeyboardComponent {...initialProps} />}
|
|
26
|
+
</CustomKeyboardViewNativeAndroid>;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import CustomKeyboardViewBase, { CustomKeyboardViewBaseProps } from './../CustomKeyboardViewBase';
|
|
2
|
+
export type CustomKeyboardViewProps = CustomKeyboardViewBaseProps & {
|
|
3
|
+
/**
|
|
4
|
+
* The reference to the actual text input (or the keyboard may not reset when instructed to, etc.)
|
|
5
|
+
*/
|
|
6
|
+
inputRef?: any;
|
|
7
|
+
useSafeArea?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export default class CustomKeyboardView extends CustomKeyboardViewBase<CustomKeyboardViewProps> {
|
|
10
|
+
static displayName: string;
|
|
11
|
+
static defaultProps: {
|
|
12
|
+
initialProps: {};
|
|
13
|
+
useSafeArea: boolean;
|
|
14
|
+
};
|
|
15
|
+
constructor(props: CustomKeyboardViewProps);
|
|
16
|
+
componentWillUnmount(): void;
|
|
17
|
+
componentDidUpdate(prevProps: CustomKeyboardViewProps): void;
|
|
18
|
+
render(): null;
|
|
19
|
+
}
|
|
@@ -1,54 +1,48 @@
|
|
|
1
|
-
import TextInputKeyboardManager from
|
|
2
|
-
import KeyboardRegistry from
|
|
3
|
-
import CustomKeyboardViewBase
|
|
4
|
-
|
|
5
|
-
export type CustomKeyboardViewProps = CustomKeyboardViewBaseProps & {
|
|
6
|
-
/**
|
|
7
|
-
* The reference to the actual text input (or the keyboard may not reset when instructed to, etc.)
|
|
8
|
-
*/
|
|
9
|
-
inputRef?: any;
|
|
10
|
-
useSafeArea?: boolean;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default class CustomKeyboardView extends CustomKeyboardViewBase<CustomKeyboardViewProps> {
|
|
1
|
+
import TextInputKeyboardManager from "./../TextInputKeyboardManager/TextInputKeyboardManager.ios";
|
|
2
|
+
import KeyboardRegistry from "./../KeyboardRegistry";
|
|
3
|
+
import CustomKeyboardViewBase from "./../CustomKeyboardViewBase";
|
|
4
|
+
export default class CustomKeyboardView extends CustomKeyboardViewBase {
|
|
14
5
|
static displayName = 'IGNORE';
|
|
15
|
-
|
|
16
6
|
static defaultProps = {
|
|
17
7
|
initialProps: {},
|
|
18
8
|
useSafeArea: true
|
|
19
9
|
};
|
|
20
|
-
|
|
21
|
-
constructor(props: CustomKeyboardViewProps) {
|
|
10
|
+
constructor(props) {
|
|
22
11
|
super(props);
|
|
23
|
-
|
|
24
|
-
|
|
12
|
+
const {
|
|
13
|
+
component
|
|
14
|
+
} = props;
|
|
25
15
|
if (component) {
|
|
26
16
|
this.registeredRequestShowKeyboard = false;
|
|
27
17
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
KeyboardRegistry.addListener('onToggleExpandedKeyboard', args => {
|
|
19
|
+
const {
|
|
20
|
+
inputRef,
|
|
21
|
+
initialProps
|
|
22
|
+
} = this.props;
|
|
31
23
|
if (inputRef) {
|
|
32
24
|
if (this.keyboardExpandedToggle[args.keyboardId] === undefined) {
|
|
33
25
|
this.keyboardExpandedToggle[args.keyboardId] = false;
|
|
34
26
|
}
|
|
35
27
|
this.keyboardExpandedToggle[args.keyboardId] = !this.keyboardExpandedToggle[args.keyboardId];
|
|
36
|
-
TextInputKeyboardManager.toggleExpandKeyboard(inputRef,
|
|
37
|
-
this.keyboardExpandedToggle[args.keyboardId],
|
|
38
|
-
initialProps.expandWithLayoutAnimation);
|
|
28
|
+
TextInputKeyboardManager.toggleExpandKeyboard(inputRef, this.keyboardExpandedToggle[args.keyboardId], initialProps.expandWithLayoutAnimation);
|
|
39
29
|
}
|
|
40
30
|
});
|
|
41
31
|
}
|
|
42
|
-
|
|
43
32
|
componentWillUnmount() {
|
|
44
33
|
KeyboardRegistry.removeListeners('onToggleExpandedKeyboard');
|
|
45
34
|
super.componentWillUnmount();
|
|
46
35
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
36
|
+
componentDidUpdate(prevProps) {
|
|
37
|
+
const {
|
|
38
|
+
inputRef: nextInputRef,
|
|
39
|
+
component: nextComponent,
|
|
40
|
+
initialProps: nextInitialProps,
|
|
41
|
+
useSafeArea
|
|
42
|
+
} = this.props;
|
|
43
|
+
const {
|
|
44
|
+
component
|
|
45
|
+
} = prevProps;
|
|
52
46
|
if (nextInputRef && nextComponent !== component) {
|
|
53
47
|
if (nextComponent) {
|
|
54
48
|
TextInputKeyboardManager.setInputComponent(nextInputRef, {
|
|
@@ -60,11 +54,9 @@ export default class CustomKeyboardView extends CustomKeyboardViewBase<CustomKey
|
|
|
60
54
|
TextInputKeyboardManager.removeInputComponent(nextInputRef);
|
|
61
55
|
}
|
|
62
56
|
}
|
|
63
|
-
|
|
64
57
|
super.componentDidUpdate(prevProps);
|
|
65
58
|
}
|
|
66
|
-
|
|
67
59
|
render() {
|
|
68
60
|
return null;
|
|
69
61
|
}
|
|
70
|
-
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
import { default as CustomKeyboardViewIOS } from "./CustomKeyboardView.ios";
|
|
4
|
+
import { default as CustomKeyboardViewAndroid } from "./CustomKeyboardView.android";
|
|
5
|
+
const IsAndroid = Platform.OS === 'android';
|
|
6
|
+
const CustomKeyboardView = props => {
|
|
7
|
+
const Container = IsAndroid ? CustomKeyboardViewAndroid : CustomKeyboardViewIOS;
|
|
8
|
+
return <Container {...props} />;
|
|
9
|
+
};
|
|
10
|
+
export default CustomKeyboardView;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { EventSubscription } from 'react-native';
|
|
3
|
+
export type CustomKeyboardViewBaseProps = {
|
|
4
|
+
inputRef?: any;
|
|
5
|
+
initialProps?: any;
|
|
6
|
+
component?: string;
|
|
7
|
+
onItemSelected?: (component?: string, args?: any) => void;
|
|
8
|
+
onRequestShowKeyboard?: (keyboardId: string) => void;
|
|
9
|
+
children?: React.ReactChild | React.ReactChild[];
|
|
10
|
+
};
|
|
11
|
+
export default class CustomKeyboardViewBase<T extends CustomKeyboardViewBaseProps> extends Component<T> {
|
|
12
|
+
static defaultProps: {
|
|
13
|
+
initialProps: {};
|
|
14
|
+
};
|
|
15
|
+
registeredRequestShowKeyboard: boolean;
|
|
16
|
+
keyboardExpandedToggle: any;
|
|
17
|
+
keyboardEventListeners: EventSubscription[];
|
|
18
|
+
constructor(props: T);
|
|
19
|
+
shouldComponentUpdate(nextProps: T): boolean;
|
|
20
|
+
componentWillUnmount(): void;
|
|
21
|
+
addOnItemSelectListener(onItemSelected: CustomKeyboardViewBaseProps['onItemSelected'], component: CustomKeyboardViewBaseProps['component']): void;
|
|
22
|
+
componentDidUpdate(prevProps: T): void;
|
|
23
|
+
registerListener(props: T, nextProps: T): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Component } from 'react';
|
|
2
|
+
import KeyboardRegistry from "./KeyboardRegistry";
|
|
3
|
+
export default class CustomKeyboardViewBase extends Component {
|
|
4
|
+
static defaultProps = {
|
|
5
|
+
initialProps: {}
|
|
6
|
+
};
|
|
7
|
+
registeredRequestShowKeyboard = false;
|
|
8
|
+
keyboardEventListeners = [];
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
const {
|
|
12
|
+
component,
|
|
13
|
+
onItemSelected
|
|
14
|
+
} = props;
|
|
15
|
+
if (component) {
|
|
16
|
+
this.addOnItemSelectListener(onItemSelected, component);
|
|
17
|
+
}
|
|
18
|
+
this.keyboardExpandedToggle = {};
|
|
19
|
+
}
|
|
20
|
+
shouldComponentUpdate(nextProps) {
|
|
21
|
+
return nextProps.component !== this.props.component;
|
|
22
|
+
}
|
|
23
|
+
componentWillUnmount() {
|
|
24
|
+
const {
|
|
25
|
+
component
|
|
26
|
+
} = this.props;
|
|
27
|
+
KeyboardRegistry.removeListeners('onRequestShowKeyboard');
|
|
28
|
+
if (this.keyboardEventListeners) {
|
|
29
|
+
this.keyboardEventListeners.forEach(eventListener => eventListener.remove());
|
|
30
|
+
}
|
|
31
|
+
if (component) {
|
|
32
|
+
KeyboardRegistry.removeListeners(`${component}.onItemSelected`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
addOnItemSelectListener(onItemSelected, component) {
|
|
36
|
+
if (onItemSelected) {
|
|
37
|
+
KeyboardRegistry.addListener(`${component}.onItemSelected`, args => {
|
|
38
|
+
onItemSelected(component, args);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
componentDidUpdate(prevProps) {
|
|
43
|
+
const {
|
|
44
|
+
onRequestShowKeyboard
|
|
45
|
+
} = this.props;
|
|
46
|
+
if (onRequestShowKeyboard && !this.registeredRequestShowKeyboard) {
|
|
47
|
+
this.registeredRequestShowKeyboard = true;
|
|
48
|
+
KeyboardRegistry.addListener('onRequestShowKeyboard', args => {
|
|
49
|
+
onRequestShowKeyboard(args.keyboardId);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
this.registerListener(prevProps, this.props);
|
|
53
|
+
}
|
|
54
|
+
registerListener(props, nextProps) {
|
|
55
|
+
const {
|
|
56
|
+
component,
|
|
57
|
+
onItemSelected
|
|
58
|
+
} = nextProps;
|
|
59
|
+
if (component && props.component !== component) {
|
|
60
|
+
if (props.component) {
|
|
61
|
+
KeyboardRegistry.removeListeners(`${props.component}.onItemSelected`);
|
|
62
|
+
}
|
|
63
|
+
KeyboardRegistry.removeListeners(`${component}.onItemSelected`);
|
|
64
|
+
this.addOnItemSelectListener(onItemSelected, component);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { LayoutChangeEvent } from 'react-native';
|
|
3
|
+
import { KeyboardTrackingViewProps } from '../KeyboardTracking/KeyboardTrackingView';
|
|
4
|
+
type kbTrackingViewProps = Pick<KeyboardTrackingViewProps, 'scrollBehavior' | 'revealKeyboardInteractive' | 'manageScrollView' | 'requiresSameParentToManageScrollView' | 'allowHitsOutsideBounds' | 'addBottomView' | 'bottomViewColor' | 'useSafeArea' | 'usesBottomTabs'>;
|
|
5
|
+
export type KeyboardAccessoryViewProps = kbTrackingViewProps & {
|
|
6
|
+
/**
|
|
7
|
+
* Content to be rendered above the keyboard
|
|
8
|
+
*/
|
|
9
|
+
renderContent?: () => React.ReactElement;
|
|
10
|
+
/**
|
|
11
|
+
* iOS only.
|
|
12
|
+
* The reference to the actual text input (or the keyboard may not reset when instructed to, etc.).
|
|
13
|
+
* This is required.
|
|
14
|
+
*/
|
|
15
|
+
kbInputRef?: any;
|
|
16
|
+
/**
|
|
17
|
+
* The keyboard ID (the componentID sent to KeyboardRegistry)
|
|
18
|
+
*/
|
|
19
|
+
kbComponent?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The props that will be sent to the KeyboardComponent
|
|
22
|
+
*/
|
|
23
|
+
kbInitialProps?: any;
|
|
24
|
+
/**
|
|
25
|
+
* A callback for when the height is changed
|
|
26
|
+
*/
|
|
27
|
+
onHeightChanged?: (height: number) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Callback that will be called when an item on the keyboard has been pressed.
|
|
30
|
+
*/
|
|
31
|
+
onItemSelected?: (component?: string, args?: any) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Callback that will be called if KeyboardRegistry.requestShowKeyboard is called.
|
|
34
|
+
*/
|
|
35
|
+
onRequestShowKeyboard?: () => void;
|
|
36
|
+
/**
|
|
37
|
+
* Callback that will be called once the keyboard has been closed
|
|
38
|
+
*/
|
|
39
|
+
onKeyboardResigned?: () => void;
|
|
40
|
+
children?: React.ReactChild;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* @description: View that allows replacing the default keyboard with other components
|
|
44
|
+
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/nativeComponentScreens/keyboardAccessory/KeyboardAccessoryViewScreen.js
|
|
45
|
+
* @gif: https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/KeyboardAccessoryView/KeyboardAccessoryView.gif?raw=true
|
|
46
|
+
*/
|
|
47
|
+
declare class KeyboardAccessoryView extends Component<KeyboardAccessoryViewProps> {
|
|
48
|
+
static scrollBehaviors: {
|
|
49
|
+
NONE: any;
|
|
50
|
+
SCROLL_TO_BOTTOM_INVERTED_ONLY: any;
|
|
51
|
+
FIXED_OFFSET: any;
|
|
52
|
+
};
|
|
53
|
+
static defaultProps: {
|
|
54
|
+
revealKeyboardInteractive: boolean;
|
|
55
|
+
manageScrollView: boolean;
|
|
56
|
+
requiresSameParentToManageScrollView: boolean;
|
|
57
|
+
addBottomView: boolean;
|
|
58
|
+
allowHitsOutsideBounds: boolean;
|
|
59
|
+
scrollBehavior: any;
|
|
60
|
+
};
|
|
61
|
+
customInputControllerEventsSubscriber: any;
|
|
62
|
+
trackingViewRef: any;
|
|
63
|
+
constructor(props: KeyboardAccessoryViewProps);
|
|
64
|
+
componentWillUnmount(): void;
|
|
65
|
+
onContainerComponentHeightChanged(event: LayoutChangeEvent): void;
|
|
66
|
+
onAndroidBackPressed(): boolean;
|
|
67
|
+
getNativeProps(): Promise<any>;
|
|
68
|
+
registerForKeyboardResignedEvent(): void;
|
|
69
|
+
registerAndroidBackHandler(): void;
|
|
70
|
+
processInitialProps(): any;
|
|
71
|
+
scrollToStart(): void;
|
|
72
|
+
render(): React.JSX.Element;
|
|
73
|
+
}
|
|
74
|
+
export default KeyboardAccessoryView;
|