@neko-os/ui 0.5.4 → 0.6.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/dist/NekoUI.js +12 -9
- package/dist/abstractions/WindowOverlay.js +3 -0
- package/dist/abstractions/WindowOverlay.native.js +21 -0
- package/dist/abstractions/helpers/storage.js +14 -4
- package/dist/abstractions/helpers/storage.native.js +9 -1
- package/dist/components/feedback/notifications/NotificationsHandler.js +10 -6
- package/dist/components/index.js +3 -1
- package/dist/components/inputs/DateInput.js +10 -6
- package/dist/components/inputs/InputWrapper.js +2 -3
- package/dist/components/inputs/NumberWheelInput.js +50 -0
- package/dist/components/inputs/NumberWheelPicker.js +43 -0
- package/dist/components/inputs/UploadInput.js +4 -4
- package/dist/components/inputs/WheelPicker.js +49 -0
- package/dist/components/inputs/WheelPicker.native.js +88 -0
- package/dist/components/inputs/WheelPicker.web.js +1 -0
- package/dist/components/inputs/dateWheelPicker/DateWheelPicker.js +24 -0
- package/dist/components/inputs/dateWheelPicker/DayWheelPicker.js +48 -0
- package/dist/components/inputs/dateWheelPicker/MonthWheelPicker.js +19 -0
- package/dist/components/inputs/dateWheelPicker/QuarterWheelPicker.js +61 -0
- package/dist/components/inputs/dateWheelPicker/WeekWheelPicker.js +66 -0
- package/dist/components/inputs/dateWheelPicker/YearWheelPicker.js +35 -0
- package/dist/components/inputs/index.js +5 -1
- package/dist/components/inputs/upload/Upload.native.js +60 -52
- package/dist/components/inputs/upload/useUploadState.js +11 -3
- package/dist/components/measurements/FeetInchesInput.js +91 -0
- package/dist/components/measurements/LengthInput.js +32 -0
- package/dist/components/measurements/LengthText.js +10 -0
- package/dist/components/measurements/MeasurementHandler.js +26 -0
- package/dist/components/measurements/WeightInput.js +25 -0
- package/dist/components/measurements/WeightText.js +10 -0
- package/dist/components/measurements/helpers/detectMeasurementSystem.js +15 -0
- package/dist/components/measurements/helpers/detectMeasurementSystem.native.js +9 -0
- package/dist/components/measurements/helpers/index.js +2 -0
- package/dist/components/measurements/helpers/length.js +112 -0
- package/dist/components/measurements/helpers/weight.js +56 -0
- package/dist/components/measurements/index.js +9 -0
- package/dist/components/measurements/useLengthFormatter.js +35 -0
- package/dist/components/measurements/useLocalInputValue.js +32 -0
- package/dist/components/measurements/useWeightFormatter.js +29 -0
- package/dist/components/routing/ReturnButton.js +20 -0
- package/dist/components/routing/ReturnButton.native.js +20 -0
- package/dist/components/routing/ReturnButton.web.js +2 -0
- package/dist/components/routing/ReturnLink.js +25 -0
- package/dist/components/routing/ReturnLink.native.js +25 -0
- package/dist/components/routing/ReturnLink.web.js +2 -0
- package/dist/components/routing/RoutedStepsContent.js +21 -0
- package/dist/components/routing/RoutedStepsContent.native.js +94 -0
- package/dist/components/routing/RoutedStepsContent.web.js +3 -0
- package/dist/components/routing/index.js +3 -0
- package/dist/components/state/StatePresenter.js +1 -1
- package/dist/components/steps/StepsHandler.js +2 -0
- package/dist/components/structure/TopBar.js +18 -16
- package/dist/components/theme/ThemePickerDrawer.js +1 -1
- package/dist/helpers/compress.js +61 -0
- package/dist/helpers/compress.native.js +49 -0
- package/dist/helpers/files.js +7 -0
- package/dist/helpers/files.native.js +55 -0
- package/dist/helpers/index.js +6 -1
- package/dist/helpers/media.js +4 -0
- package/dist/helpers/media.native.js +41 -0
- package/dist/helpers/numbers.js +13 -0
- package/dist/helpers/pickAssets.js +7 -0
- package/dist/helpers/pickAssets.native.js +66 -0
- package/dist/helpers/storage.js +17 -0
- package/dist/i18n/I18n.js +4 -4
- package/dist/index.js +1 -1
- package/dist/responsive/responsiveHooks.js +14 -0
- package/package.json +2 -14
- package/src/NekoUI.js +16 -13
- package/src/abstractions/WindowOverlay.js +3 -0
- package/src/abstractions/WindowOverlay.native.js +21 -0
- package/src/abstractions/helpers/storage.js +13 -3
- package/src/abstractions/helpers/storage.native.js +8 -0
- package/src/components/feedback/notifications/NotificationsHandler.js +12 -8
- package/src/components/index.js +2 -0
- package/src/components/inputs/DateInput.js +8 -4
- package/src/components/inputs/InputWrapper.js +1 -2
- package/src/components/inputs/NumberWheelInput.js +50 -0
- package/src/components/inputs/NumberWheelPicker.js +43 -0
- package/src/components/inputs/UploadInput.js +2 -2
- package/src/components/inputs/WheelPicker.js +49 -0
- package/src/components/inputs/WheelPicker.native.js +88 -0
- package/src/components/inputs/WheelPicker.web.js +1 -0
- package/src/components/inputs/dateWheelPicker/DateWheelPicker.js +24 -0
- package/src/components/inputs/dateWheelPicker/DayWheelPicker.js +48 -0
- package/src/components/inputs/dateWheelPicker/MonthWheelPicker.js +19 -0
- package/src/components/inputs/dateWheelPicker/QuarterWheelPicker.js +61 -0
- package/src/components/inputs/dateWheelPicker/WeekWheelPicker.js +66 -0
- package/src/components/inputs/dateWheelPicker/YearWheelPicker.js +35 -0
- package/src/components/inputs/index.js +4 -0
- package/src/components/inputs/upload/Upload.native.js +58 -50
- package/src/components/inputs/upload/useUploadState.js +11 -3
- package/src/components/measurements/FeetInchesInput.js +91 -0
- package/src/components/measurements/LengthInput.js +32 -0
- package/src/components/measurements/LengthText.js +10 -0
- package/src/components/measurements/MeasurementHandler.js +26 -0
- package/src/components/measurements/WeightInput.js +25 -0
- package/src/components/measurements/WeightText.js +10 -0
- package/src/components/measurements/helpers/detectMeasurementSystem.js +15 -0
- package/src/components/measurements/helpers/detectMeasurementSystem.native.js +9 -0
- package/src/components/measurements/helpers/index.js +2 -0
- package/src/components/measurements/helpers/length.js +112 -0
- package/src/components/measurements/helpers/weight.js +56 -0
- package/src/components/measurements/index.js +9 -0
- package/src/components/measurements/useLengthFormatter.js +35 -0
- package/src/components/measurements/useLocalInputValue.js +32 -0
- package/src/components/measurements/useWeightFormatter.js +29 -0
- package/src/components/routing/ReturnButton.js +20 -0
- package/src/components/routing/ReturnButton.native.js +20 -0
- package/src/components/routing/ReturnButton.web.js +2 -0
- package/src/components/routing/ReturnLink.js +25 -0
- package/src/components/routing/ReturnLink.native.js +25 -0
- package/src/components/routing/ReturnLink.web.js +2 -0
- package/src/components/routing/RoutedStepsContent.js +21 -0
- package/src/components/routing/RoutedStepsContent.native.js +94 -0
- package/src/components/routing/RoutedStepsContent.web.js +3 -0
- package/src/components/routing/index.js +3 -0
- package/src/components/state/StatePresenter.js +1 -1
- package/src/components/steps/StepsHandler.js +2 -0
- package/src/components/structure/TopBar.js +16 -14
- package/src/components/theme/ThemePickerDrawer.js +1 -1
- package/src/helpers/compress.js +61 -0
- package/src/helpers/compress.native.js +49 -0
- package/src/helpers/files.js +7 -0
- package/src/helpers/files.native.js +55 -0
- package/src/helpers/index.js +6 -1
- package/src/helpers/media.js +4 -0
- package/src/helpers/media.native.js +41 -0
- package/src/helpers/numbers.js +13 -0
- package/src/helpers/pickAssets.js +7 -0
- package/src/helpers/pickAssets.native.js +66 -0
- package/src/helpers/storage.js +17 -0
- package/src/i18n/I18n.js +2 -2
- package/src/index.js +1 -1
- package/src/responsive/responsiveHooks.js +14 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {try {var i = n[a](c),u = i.value;} catch (n) {return void e(n);}i.done ? t(u) : Promise.resolve(u).then(r, o);}function _asyncToGenerator(n) {return function () {var t = this,e = arguments;return new Promise(function (r, o) {var a = n.apply(t, e);function _next(n) {asyncGeneratorStep(a, r, o, _next, _throw, "next", n);}function _throw(n) {asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);}_next(void 0);});};}var IMAGE_DEFAULTS = { maxWidth: 1920, maxHeight: 1920, quality: 0.8 };
|
|
2
|
+
|
|
3
|
+
function isImage(asset) {var _asset$type;
|
|
4
|
+
return asset == null ? void 0 : (_asset$type = asset.type) == null ? void 0 : _asset$type.startsWith('image/');
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function loadImage(src) {
|
|
8
|
+
return new Promise(function (resolve, reject) {
|
|
9
|
+
var img = new Image();
|
|
10
|
+
img.onload = function () {return resolve(img);};
|
|
11
|
+
img.onerror = reject;
|
|
12
|
+
img.src = src;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
var ALPHA_TYPES = new Set(['image/png', 'image/webp', 'image/gif']);
|
|
17
|
+
|
|
18
|
+
function compressWithCanvas(img, _ref) {var maxWidth = _ref.maxWidth,maxHeight = _ref.maxHeight,quality = _ref.quality,mimeType = _ref.mimeType;
|
|
19
|
+
var width = img.width,height = img.height;
|
|
20
|
+
if (width > maxWidth || height > maxHeight) {
|
|
21
|
+
var ratio = Math.min(maxWidth / width, maxHeight / height);
|
|
22
|
+
width = Math.round(width * ratio);
|
|
23
|
+
height = Math.round(height * ratio);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var canvas = document.createElement('canvas');
|
|
27
|
+
canvas.width = width;
|
|
28
|
+
canvas.height = height;
|
|
29
|
+
var ctx = canvas.getContext('2d');
|
|
30
|
+
ctx.drawImage(img, 0, 0, width, height);
|
|
31
|
+
|
|
32
|
+
var outputType = ALPHA_TYPES.has(mimeType) ? mimeType : 'image/jpeg';
|
|
33
|
+
|
|
34
|
+
return new Promise(function (resolve) {
|
|
35
|
+
canvas.toBlob(
|
|
36
|
+
function (blob) {return resolve(blob ? { uri: URL.createObjectURL(blob), width: width, height: height } : null);},
|
|
37
|
+
outputType,
|
|
38
|
+
quality
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function compressAsset(_x) {return _compressAsset.apply(this, arguments);}function _compressAsset() {_compressAsset = _asyncToGenerator(function* (asset) {var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
44
|
+
if (!(asset != null && asset.uri) || !isImage(asset)) return asset;
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
var opts = Object.assign({}, IMAGE_DEFAULTS, options.image);
|
|
48
|
+
var img = yield loadImage(asset.uri);
|
|
49
|
+
var result = yield compressWithCanvas(img, Object.assign({}, opts, { mimeType: asset.type }));
|
|
50
|
+
if (!result) return asset;
|
|
51
|
+
return Object.assign({}, asset, { uri: result.uri, width: result.width, height: result.height });
|
|
52
|
+
} catch (e) {
|
|
53
|
+
console.warn('[neko-ui compress] web image compression failed:', e == null ? void 0 : e.message);
|
|
54
|
+
return asset;
|
|
55
|
+
}
|
|
56
|
+
});return _compressAsset.apply(this, arguments);}
|
|
57
|
+
|
|
58
|
+
export function compressAssets(assets) {var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
59
|
+
if (!(assets != null && assets.length)) return Promise.resolve(assets || []);
|
|
60
|
+
return Promise.all(assets.map(function (a) {return compressAsset(a, options);}));
|
|
61
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {try {var i = n[a](c),u = i.value;} catch (n) {return void e(n);}i.done ? t(u) : Promise.resolve(u).then(r, o);}function _asyncToGenerator(n) {return function () {var t = this,e = arguments;return new Promise(function (r, o) {var a = n.apply(t, e);function _next(n) {asyncGeneratorStep(a, r, o, _next, _throw, "next", n);}function _throw(n) {asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);}_next(void 0);});};}var ImageCompressor;
|
|
2
|
+
var VideoCompressor;
|
|
3
|
+
try {
|
|
4
|
+
var RNC = require('react-native-compressor');
|
|
5
|
+
ImageCompressor = RNC.Image;
|
|
6
|
+
VideoCompressor = RNC.Video;
|
|
7
|
+
} catch (_unused) {}
|
|
8
|
+
|
|
9
|
+
var IMAGE_DEFAULTS = { maxWidth: 1920, maxHeight: 1920, quality: 0.8 };
|
|
10
|
+
var VIDEO_DEFAULTS = { maxSize: 720 };
|
|
11
|
+
|
|
12
|
+
function isImage(asset) {var _asset$type;
|
|
13
|
+
return asset == null ? void 0 : (_asset$type = asset.type) == null ? void 0 : _asset$type.startsWith('image/');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function isVideo(asset) {var _asset$type2;
|
|
17
|
+
return asset == null ? void 0 : (_asset$type2 = asset.type) == null ? void 0 : _asset$type2.startsWith('video/');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function compressAsset(_x) {return _compressAsset.apply(this, arguments);}function _compressAsset() {_compressAsset = _asyncToGenerator(function* (asset) {var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
21
|
+
if (!(asset != null && asset.uri)) return asset;
|
|
22
|
+
|
|
23
|
+
if (isImage(asset) && ImageCompressor) {
|
|
24
|
+
try {
|
|
25
|
+
var uri = yield ImageCompressor.compress(asset.uri, Object.assign({}, IMAGE_DEFAULTS, options.image));
|
|
26
|
+
return Object.assign({}, asset, { uri: uri });
|
|
27
|
+
} catch (e) {
|
|
28
|
+
console.warn('[neko-ui compress] image failed, keeping original:', e == null ? void 0 : e.message);
|
|
29
|
+
return asset;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (isVideo(asset) && VideoCompressor) {
|
|
34
|
+
try {
|
|
35
|
+
var _uri = yield VideoCompressor.compress(asset.uri, Object.assign({}, VIDEO_DEFAULTS, options.video));
|
|
36
|
+
return Object.assign({}, asset, { uri: _uri });
|
|
37
|
+
} catch (e) {
|
|
38
|
+
console.warn('[neko-ui compress] video failed, keeping original:', e == null ? void 0 : e.message);
|
|
39
|
+
return asset;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return asset;
|
|
44
|
+
});return _compressAsset.apply(this, arguments);}
|
|
45
|
+
|
|
46
|
+
export function compressAssets(assets) {var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
47
|
+
if (!(assets != null && assets.length)) return Promise.resolve(assets || []);
|
|
48
|
+
return Promise.all(assets.map(function (a) {return compressAsset(a, options);}));
|
|
49
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
function _construct(t, e, r) {if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);var o = [null];o.push.apply(o, e);var p = new (t.bind.apply(t, o))();return r && _setPrototypeOf(p, r.prototype), p;}function _setPrototypeOf(t, e) {return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {return t.__proto__ = e, t;}, _setPrototypeOf(t, e);}function _isNativeReflectConstruct() {try {var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));} catch (t) {}return (_isNativeReflectConstruct = function _isNativeReflectConstruct() {return !!t;})();}function _toConsumableArray(r) {return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();}function _nonIterableSpread() {throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _arrayWithoutHoles(r) {if (Array.isArray(r)) return _arrayLikeToArray(r);}function _toArray(r) {return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest();}function _nonIterableRest() {throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(r, a) {if (r) {if ("string" == typeof r) return _arrayLikeToArray(r, a);var t = {}.toString.call(r).slice(8, -1);return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;}}function _arrayLikeToArray(r, a) {(null == a || a > r.length) && (a = r.length);for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];return n;}function _iterableToArray(r) {if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);}function _arrayWithHoles(r) {if (Array.isArray(r)) return r;}var FS;
|
|
2
|
+
try {
|
|
3
|
+
FS = require('expo-file-system');
|
|
4
|
+
} catch (_unused) {}
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
function resolveDir(target) {
|
|
9
|
+
var _split$filter = (target || '').split('/').filter(Boolean),_split$filter2 = _toArray(_split$filter),base = _split$filter2[0],rest = _split$filter2.slice(1);
|
|
10
|
+
if (base !== 'cache' && base !== 'document') {
|
|
11
|
+
console.warn(`[neko-ui files] target base "${base}" unknown — using document dir. Use "document" or "cache".`);
|
|
12
|
+
}
|
|
13
|
+
var root = base === 'cache' ? FS.Paths.cache : FS.Paths.document;
|
|
14
|
+
var dir = _construct(FS.Directory, [root].concat(_toConsumableArray(rest)));
|
|
15
|
+
try {
|
|
16
|
+
dir.create({ intermediates: true, idempotent: true });
|
|
17
|
+
} catch (e) {
|
|
18
|
+
console.warn('[neko-ui files] dir create failed:', e == null ? void 0 : e.message);
|
|
19
|
+
}
|
|
20
|
+
return dir;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var seq = 0;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
export function persistFile(uri) {var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document/files';var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},name = _ref.name;
|
|
34
|
+
if (!FS || !uri) return uri;
|
|
35
|
+
try {
|
|
36
|
+
var ext = (name == null ? void 0 : name.split('.').pop()) || uri.split('?')[0].split('.').pop() || 'jpg';
|
|
37
|
+
var filename = `${Date.now()}_${seq++}_${Math.round(Math.random() * 1e6)}.${ext}`;
|
|
38
|
+
var dest = new FS.File(resolveDir(target), filename);
|
|
39
|
+
new FS.File(uri).copy(dest);
|
|
40
|
+
return dest.uri;
|
|
41
|
+
} catch (e) {
|
|
42
|
+
console.warn('[neko-ui files] persistFile failed, keeping uri:', e == null ? void 0 : e.message);
|
|
43
|
+
return uri;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
export function removeFile(uri) {
|
|
49
|
+
if (!FS || !uri) return;
|
|
50
|
+
try {
|
|
51
|
+
new FS.File(uri).delete();
|
|
52
|
+
} catch (e) {
|
|
53
|
+
console.warn('[neko-ui files] removeFile failed:', e == null ? void 0 : e.message);
|
|
54
|
+
}
|
|
55
|
+
}
|
package/dist/helpers/index.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
export * from "./compress";
|
|
1
2
|
export * from "./debounce";
|
|
2
|
-
export * from "./
|
|
3
|
+
export * from "./files";
|
|
4
|
+
export * from "./media";
|
|
5
|
+
export * from "./numbers";
|
|
6
|
+
export * from "./pickAssets";
|
|
3
7
|
export * from "./random";
|
|
4
8
|
export * from "./storage";
|
|
9
|
+
export * from "./string";
|
|
5
10
|
export * from "./weekStart";
|
|
6
11
|
export * from "./weekStartSetup";
|
|
7
12
|
export * from "./../abstractions/helpers/useSafeAreaInsets";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {try {var i = n[a](c),u = i.value;} catch (n) {return void e(n);}i.done ? t(u) : Promise.resolve(u).then(r, o);}function _asyncToGenerator(n) {return function () {var t = this,e = arguments;return new Promise(function (r, o) {var a = n.apply(t, e);function _next(n) {asyncGeneratorStep(a, r, o, _next, _throw, "next", n);}function _throw(n) {asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);}_next(void 0);});};}
|
|
2
|
+
|
|
3
|
+
export var openCamera = function () {var _ref = _asyncToGenerator(function* () {return [];});return function openCamera() {return _ref.apply(this, arguments);};}();
|
|
4
|
+
export var openLibrary = function () {var _ref2 = _asyncToGenerator(function* () {return [];});return function openLibrary() {return _ref2.apply(this, arguments);};}();
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {try {var i = n[a](c),u = i.value;} catch (n) {return void e(n);}i.done ? t(u) : Promise.resolve(u).then(r, o);}function _asyncToGenerator(n) {return function () {var t = this,e = arguments;return new Promise(function (r, o) {var a = n.apply(t, e);function _next(n) {asyncGeneratorStep(a, r, o, _next, _throw, "next", n);}function _throw(n) {asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);}_next(void 0);});};}var ImagePicker;
|
|
2
|
+
try {
|
|
3
|
+
ImagePicker = require('expo-image-picker');
|
|
4
|
+
} catch (_unused) {}
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
function normalizeImageResult(asset) {
|
|
9
|
+
return {
|
|
10
|
+
uri: asset.uri,
|
|
11
|
+
name: asset.fileName || asset.uri.split('/').pop(),
|
|
12
|
+
type: asset.mimeType || asset.type || 'image/jpeg',
|
|
13
|
+
size: asset.fileSize || asset.filesize,
|
|
14
|
+
width: asset.width,
|
|
15
|
+
height: asset.height
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
export function openCamera() {return _openCamera.apply(this, arguments);}function _openCamera() {_openCamera = _asyncToGenerator(function* () {var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
25
|
+
if (!ImagePicker) return [];
|
|
26
|
+
var permission = yield ImagePicker.requestCameraPermissionsAsync();
|
|
27
|
+
if (!permission.granted) return [];
|
|
28
|
+
var result = yield ImagePicker.launchCameraAsync(options);
|
|
29
|
+
if (result.canceled) return [];
|
|
30
|
+
return result.assets.map(normalizeImageResult);
|
|
31
|
+
});return _openCamera.apply(this, arguments);}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
export function openLibrary() {return _openLibrary.apply(this, arguments);}function _openLibrary() {_openLibrary = _asyncToGenerator(function* () {var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
35
|
+
if (!ImagePicker) return [];
|
|
36
|
+
var permission = yield ImagePicker.requestMediaLibraryPermissionsAsync();
|
|
37
|
+
if (!permission.granted) return [];
|
|
38
|
+
var result = yield ImagePicker.launchImageLibraryAsync(options);
|
|
39
|
+
if (result.canceled) return [];
|
|
40
|
+
return result.assets.map(normalizeImageResult);
|
|
41
|
+
});return _openLibrary.apply(this, arguments);}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { is } from 'ramda';
|
|
2
|
+
|
|
3
|
+
export function fixedDecimals(num) {var count = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
|
|
4
|
+
if (!num) return num;
|
|
5
|
+
if (Number.isInteger(num)) return num;
|
|
6
|
+
if (is(String, num)) num = parseFloat(num);
|
|
7
|
+
|
|
8
|
+
var decimalPart = num.toString().split('.')[1];
|
|
9
|
+
if (decimalPart && decimalPart.length > count) {
|
|
10
|
+
return parseFloat(num.toFixed(count));
|
|
11
|
+
}
|
|
12
|
+
return num;
|
|
13
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {try {var i = n[a](c),u = i.value;} catch (n) {return void e(n);}i.done ? t(u) : Promise.resolve(u).then(r, o);}function _asyncToGenerator(n) {return function () {var t = this,e = arguments;return new Promise(function (r, o) {var a = n.apply(t, e);function _next(n) {asyncGeneratorStep(a, r, o, _next, _throw, "next", n);}function _throw(n) {asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);}_next(void 0);});};}export function pickFromCamera() {return _pickFromCamera.apply(this, arguments);}function _pickFromCamera() {_pickFromCamera = _asyncToGenerator(function* () {var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},_ref$multiple = _ref.multiple,multiple = _ref$multiple === void 0 ? false : _ref$multiple;
|
|
2
|
+
return multiple ? [] : null;
|
|
3
|
+
});return _pickFromCamera.apply(this, arguments);}
|
|
4
|
+
|
|
5
|
+
export function pickFromLibrary() {return _pickFromLibrary.apply(this, arguments);}function _pickFromLibrary() {_pickFromLibrary = _asyncToGenerator(function* () {var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},_ref2$multiple = _ref2.multiple,multiple = _ref2$multiple === void 0 ? false : _ref2$multiple;
|
|
6
|
+
return multiple ? [] : null;
|
|
7
|
+
});return _pickFromLibrary.apply(this, arguments);}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {try {var i = n[a](c),u = i.value;} catch (n) {return void e(n);}i.done ? t(u) : Promise.resolve(u).then(r, o);}function _asyncToGenerator(n) {return function () {var t = this,e = arguments;return new Promise(function (r, o) {var a = n.apply(t, e);function _next(n) {asyncGeneratorStep(a, r, o, _next, _throw, "next", n);}function _throw(n) {asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);}_next(void 0);});};}import { openCamera, openLibrary } from "./media";
|
|
2
|
+
import { compressAsset, compressAssets } from "./compress";
|
|
3
|
+
import { persistFile } from "./files";
|
|
4
|
+
|
|
5
|
+
var MediaLibrary;
|
|
6
|
+
try {
|
|
7
|
+
MediaLibrary = require('expo-media-library');
|
|
8
|
+
} catch (_unused) {}function
|
|
9
|
+
|
|
10
|
+
saveAssetsToLibrary(_x) {return _saveAssetsToLibrary.apply(this, arguments);}function _saveAssetsToLibrary() {_saveAssetsToLibrary = _asyncToGenerator(function* (assets) {
|
|
11
|
+
if (!MediaLibrary || !(assets != null && assets.length)) return;
|
|
12
|
+
try {
|
|
13
|
+
var perm = yield MediaLibrary.requestPermissionsAsync(true);
|
|
14
|
+
if (!perm.granted) return;
|
|
15
|
+
for (var a of assets) {
|
|
16
|
+
try {
|
|
17
|
+
yield MediaLibrary.saveToLibraryAsync(a.uri);
|
|
18
|
+
} catch (e) {
|
|
19
|
+
console.warn('[neko-ui pick] saveToLibrary failed:', e == null ? void 0 : e.message);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
} catch (e) {
|
|
23
|
+
console.warn('[neko-ui pick] saveToLibrary permission error:', e == null ? void 0 : e.message);
|
|
24
|
+
}
|
|
25
|
+
});return _saveAssetsToLibrary.apply(this, arguments);}
|
|
26
|
+
|
|
27
|
+
function persistAsset(asset, persistTo) {
|
|
28
|
+
if (!persistTo) return asset;
|
|
29
|
+
return Object.assign({}, asset, { uri: persistFile(asset.uri, persistTo, { name: asset.name }) });
|
|
30
|
+
}function
|
|
31
|
+
|
|
32
|
+
processAssets(_x2) {return _processAssets.apply(this, arguments);}function _processAssets() {_processAssets = _asyncToGenerator(function* (assets) {var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},_ref3$compress = _ref3.compress,compress = _ref3$compress === void 0 ? true : _ref3$compress,persistTo = _ref3.persistTo;
|
|
33
|
+
var result = assets;
|
|
34
|
+
if (compress !== false) {
|
|
35
|
+
var compressOpts = typeof compress === 'object' ? compress : {};
|
|
36
|
+
result = yield compressAssets(result, compressOpts);
|
|
37
|
+
}
|
|
38
|
+
if (persistTo) {
|
|
39
|
+
result = result.map(function (a) {return persistAsset(a, persistTo);});
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
});return _processAssets.apply(this, arguments);}
|
|
43
|
+
|
|
44
|
+
export function pickFromCamera() {return _pickFromCamera.apply(this, arguments);}function _pickFromCamera() {_pickFromCamera = _asyncToGenerator(function* () {var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},_ref$multiple = _ref.multiple,multiple = _ref$multiple === void 0 ? false : _ref$multiple,maxCount = _ref.maxCount,mediaTypes = _ref.mediaTypes,persistTo = _ref.persistTo,compress = _ref.compress,saveToLibrary = _ref.saveToLibrary;
|
|
45
|
+
var assets = yield openCamera({
|
|
46
|
+
allowsMultipleSelection: multiple,
|
|
47
|
+
selectionLimit: maxCount || 0,
|
|
48
|
+
mediaTypes: mediaTypes
|
|
49
|
+
});
|
|
50
|
+
if (!assets.length) return multiple ? [] : null;
|
|
51
|
+
|
|
52
|
+
if (saveToLibrary) yield saveAssetsToLibrary(assets);
|
|
53
|
+
var result = yield processAssets(assets, { compress: compress, persistTo: persistTo });
|
|
54
|
+
return multiple ? result : result[0];
|
|
55
|
+
});return _pickFromCamera.apply(this, arguments);}
|
|
56
|
+
|
|
57
|
+
export function pickFromLibrary() {return _pickFromLibrary.apply(this, arguments);}function _pickFromLibrary() {_pickFromLibrary = _asyncToGenerator(function* () {var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},_ref2$multiple = _ref2.multiple,multiple = _ref2$multiple === void 0 ? false : _ref2$multiple,maxCount = _ref2.maxCount,mediaTypes = _ref2.mediaTypes,persistTo = _ref2.persistTo,compress = _ref2.compress;
|
|
58
|
+
var assets = yield openLibrary({
|
|
59
|
+
allowsMultipleSelection: multiple,
|
|
60
|
+
selectionLimit: maxCount || 0,
|
|
61
|
+
mediaTypes: mediaTypes
|
|
62
|
+
});
|
|
63
|
+
if (!assets.length) return multiple ? [] : null;
|
|
64
|
+
var result = yield processAssets(assets, { compress: compress, persistTo: persistTo });
|
|
65
|
+
return multiple ? result : result[0];
|
|
66
|
+
});return _pickFromLibrary.apply(this, arguments);}
|
package/dist/helpers/storage.js
CHANGED
|
@@ -41,6 +41,21 @@ function getAsync(key, defaultValue) {
|
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
function notifyAll(value) {
|
|
45
|
+
Object.keys(listeners).forEach(function (key) {return notify(key, value);});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function clear() {
|
|
49
|
+
AbsStorage.clear();
|
|
50
|
+
notifyAll(undefined);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function clearAsync() {
|
|
54
|
+
return AbsStorage.clearAsync().then(function () {
|
|
55
|
+
notifyAll(undefined);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
44
59
|
function formatStoragedValue(value) {
|
|
45
60
|
try {
|
|
46
61
|
if (!value) return value;
|
|
@@ -73,4 +88,6 @@ AbsStorage, {
|
|
|
73
88
|
setAsync: setAsync,
|
|
74
89
|
get: get,
|
|
75
90
|
getAsync: getAsync,
|
|
91
|
+
clear: clear,
|
|
92
|
+
clearAsync: clearAsync,
|
|
76
93
|
useState: useState });
|
package/dist/i18n/I18n.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["ns", "context"];function _objectWithoutProperties(e, t) {if (null == e) return {};var o,r,i = _objectWithoutPropertiesLoose(e, t);if (Object.getOwnPropertySymbols) {var n = Object.getOwnPropertySymbols(e);for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);}return i;}function _objectWithoutPropertiesLoose(r, e) {if (null == r) return {};var t = {};for (var n in r) if ({}.hasOwnProperty.call(r, n)) {if (-1 !== e.indexOf(n)) continue;t[n] = r[n];}return t;}function asyncGeneratorStep(n, t, e, r, o, a, c) {try {var i = n[a](c),u = i.value;} catch (n) {return void e(n);}i.done ? t(u) : Promise.resolve(u).then(r, o);}function _asyncToGenerator(n) {return function () {var t = this,e = arguments;return new Promise(function (r, o) {var a = n.apply(t, e);function _next(n) {asyncGeneratorStep(a, r, o, _next, _throw, "next", n);}function _throw(n) {asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);}_next(void 0);});};}function _classCallCheck(a, n) {if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");}function _defineProperties(e, r) {for (var t = 0; t < r.length; t++) {var o = r[t];o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);}}function _createClass(e, r, t) {return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e;}function _toPropertyKey(t) {var i = _toPrimitive(t, "string");return "symbol" == typeof i ? i : i + "";}function _toPrimitive(t, r) {if ("object" != typeof t || !t) return t;var e = t[Symbol.toPrimitive];if (void 0 !== e) {var i = e.call(t, r || "default");if ("object" != typeof i) return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return ("string" === r ? String : Number)(t);}export var I18n = function () {
|
|
1
|
+
var _excluded = ["ns", "context", "default"];function _objectWithoutProperties(e, t) {if (null == e) return {};var o,r,i = _objectWithoutPropertiesLoose(e, t);if (Object.getOwnPropertySymbols) {var n = Object.getOwnPropertySymbols(e);for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);}return i;}function _objectWithoutPropertiesLoose(r, e) {if (null == r) return {};var t = {};for (var n in r) if ({}.hasOwnProperty.call(r, n)) {if (-1 !== e.indexOf(n)) continue;t[n] = r[n];}return t;}function asyncGeneratorStep(n, t, e, r, o, a, c) {try {var i = n[a](c),u = i.value;} catch (n) {return void e(n);}i.done ? t(u) : Promise.resolve(u).then(r, o);}function _asyncToGenerator(n) {return function () {var t = this,e = arguments;return new Promise(function (r, o) {var a = n.apply(t, e);function _next(n) {asyncGeneratorStep(a, r, o, _next, _throw, "next", n);}function _throw(n) {asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);}_next(void 0);});};}function _classCallCheck(a, n) {if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");}function _defineProperties(e, r) {for (var t = 0; t < r.length; t++) {var o = r[t];o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);}}function _createClass(e, r, t) {return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e;}function _toPropertyKey(t) {var i = _toPrimitive(t, "string");return "symbol" == typeof i ? i : i + "";}function _toPrimitive(t, r) {if ("object" != typeof t || !t) return t;var e = t[Symbol.toPrimitive];if (void 0 !== e) {var i = e.call(t, r || "default");if ("object" != typeof i) return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return ("string" === r ? String : Number)(t);}export var I18n = function () {
|
|
2
2
|
function I18n() {var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};_classCallCheck(this, I18n);
|
|
3
3
|
this.language = options.language || 'en';
|
|
4
4
|
this.fallback = options.fallback || 'en';
|
|
@@ -26,7 +26,7 @@ var _excluded = ["ns", "context"];function _objectWithoutProperties(e, t) {if (n
|
|
|
26
26
|
});function tAsync(_x) {return _tAsync.apply(this, arguments);}return tAsync;}() }, { key: "t", value:
|
|
27
27
|
|
|
28
28
|
function t(key) {var _this$resources$this$2;var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
29
|
-
var _opts$ns2 = opts.ns,ns = _opts$ns2 === void 0 ? 'common' : _opts$ns2,context = opts.context,vars = _objectWithoutProperties(opts, _excluded);
|
|
29
|
+
var _opts$ns2 = opts.ns,ns = _opts$ns2 === void 0 ? 'common' : _opts$ns2,context = opts.context,defaultVal = opts.default,vars = _objectWithoutProperties(opts, _excluded);
|
|
30
30
|
var count = vars == null ? void 0 : vars.count;
|
|
31
31
|
if (key.includes(':')) {
|
|
32
32
|
var splittedKey = key.split(':');
|
|
@@ -37,9 +37,9 @@ var _excluded = ["ns", "context"];function _objectWithoutProperties(e, t) {if (n
|
|
|
37
37
|
var value = this._resolveKey(langData, key, count, context);
|
|
38
38
|
if (context) console.log(context, value);
|
|
39
39
|
|
|
40
|
-
if (!value) {var _this$resources$this$3;
|
|
40
|
+
if (!value) {var _this$resources$this$3, _ref, _this$_resolveKey;
|
|
41
41
|
var fallbackData = (_this$resources$this$3 = this.resources[this.fallback]) == null ? void 0 : _this$resources$this$3[ns];
|
|
42
|
-
value = this._resolveKey(fallbackData, key, count, context)
|
|
42
|
+
value = (_ref = (_this$_resolveKey = this._resolveKey(fallbackData, key, count, context)) != null ? _this$_resolveKey : defaultVal) != null ? _ref : key;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
return this._interpolate(value, vars);
|
package/dist/index.js
CHANGED
|
@@ -27,6 +27,20 @@ export function useGetResponsiveValue() {
|
|
|
27
27
|
|
|
28
28
|
if (!isObj) return value;
|
|
29
29
|
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
var bpNames = breakpoints.map(function (b) {return b.name;});
|
|
34
|
+
var isResponsiveKey = function isResponsiveKey(k) {return (
|
|
35
|
+
k === 'df' ||
|
|
36
|
+
k === 'native' ||
|
|
37
|
+
k === 'web' ||
|
|
38
|
+
k === 'ios' ||
|
|
39
|
+
k === 'android' ||
|
|
40
|
+
bpNames.includes(k) ||
|
|
41
|
+
/^(\w+)[du]$/.test(k) && bpNames.includes(k.slice(0, -1)));};
|
|
42
|
+
if (!Object.keys(value).some(isResponsiveKey)) return value;
|
|
43
|
+
|
|
30
44
|
if (value[screen]) return value[screen];
|
|
31
45
|
|
|
32
46
|
var keys = Object.keys(value);var _loop = function _loop()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neko-os/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"author": "Christian Storch <ccstorch@gmail.com>",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -22,21 +22,9 @@
|
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@remixicon/react": "^4.6.0",
|
|
25
|
-
"expo-linear-gradient": "~14.1.5",
|
|
26
25
|
"dayjs": "*",
|
|
27
26
|
"ramda": "^0.31.3",
|
|
28
|
-
"react": "*"
|
|
29
|
-
"react-native": "*",
|
|
30
|
-
"react-native-gesture-handler": "^2.28.0",
|
|
31
|
-
"react-native-reanimated": "^4.1.0",
|
|
32
|
-
"react-native-remix-icon": "^4.6.3",
|
|
33
|
-
"react-native-web": "*",
|
|
34
|
-
"react-native-safe-area-context": "*"
|
|
35
|
-
},
|
|
36
|
-
"peerDependenciesMeta": {
|
|
37
|
-
"react-native-safe-area-context": {
|
|
38
|
-
"optional": true
|
|
39
|
-
}
|
|
27
|
+
"react": "*"
|
|
40
28
|
},
|
|
41
29
|
"dependencies": {
|
|
42
30
|
"prop-types": "^15.8.1",
|
package/src/NekoUI.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { initFirstDayOfWeek } from './helpers/weekStartSetup'
|
|
2
2
|
import { DynamicStyleTag } from './DynamicStyleTag'
|
|
3
3
|
import { I18nProvider } from './i18n'
|
|
4
|
+
import { MeasurementHandler } from './components/measurements/MeasurementHandler'
|
|
4
5
|
import { ModalsHandler } from './components/modals/modal/handler/ModalsHandler'
|
|
5
6
|
import { NotificationsHandler } from './components/feedback/notifications/NotificationsHandler'
|
|
6
7
|
import { OverlayHandler } from './components/structure/overlay/OverlayHandler'
|
|
@@ -12,23 +13,25 @@ import { useThemeHandler } from './theme'
|
|
|
12
13
|
|
|
13
14
|
initFirstDayOfWeek()
|
|
14
15
|
|
|
15
|
-
export function NekoUI({ children, i18n, ...props }) {
|
|
16
|
+
export function NekoUI({ children, i18n, measurementSystem, ...props }) {
|
|
16
17
|
return (
|
|
17
18
|
<ThemeHandler {...props}>
|
|
18
19
|
<DynamicStyleTag />
|
|
19
20
|
<ResponsiveHandler>
|
|
20
|
-
<
|
|
21
|
-
<
|
|
22
|
-
<
|
|
23
|
-
<
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
<MeasurementHandler measurementSystem={measurementSystem}>
|
|
22
|
+
<PortalHandler>
|
|
23
|
+
<ModalsHandler>
|
|
24
|
+
<I18nProvider i18n={i18n}>
|
|
25
|
+
<NotificationsHandler>
|
|
26
|
+
<OverlayHandler>
|
|
27
|
+
{children}
|
|
28
|
+
<FixedComponents />
|
|
29
|
+
</OverlayHandler>
|
|
30
|
+
</NotificationsHandler>
|
|
31
|
+
</I18nProvider>
|
|
32
|
+
</ModalsHandler>
|
|
33
|
+
</PortalHandler>
|
|
34
|
+
</MeasurementHandler>
|
|
32
35
|
</ResponsiveHandler>
|
|
33
36
|
</ThemeHandler>
|
|
34
37
|
)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Platform } from 'react-native'
|
|
2
|
+
|
|
3
|
+
let AbsWindowOverlay = ({ children }) => children
|
|
4
|
+
|
|
5
|
+
// iOS native-stack modals (presentation: 'modal') present a UIViewController above
|
|
6
|
+
// the RN root view, covering anything rendered inside it regardless of zIndex.
|
|
7
|
+
// FullWindowOverlay renders above presented view controllers and passes touches
|
|
8
|
+
// through empty areas. On Android/web screens stay in the same window, so the
|
|
9
|
+
// passthrough is enough.
|
|
10
|
+
if (Platform.OS === 'ios') {
|
|
11
|
+
try {
|
|
12
|
+
const { FullWindowOverlay } = require('react-native-screens') || {}
|
|
13
|
+
if (FullWindowOverlay) {
|
|
14
|
+
AbsWindowOverlay = ({ children }) => <FullWindowOverlay>{children}</FullWindowOverlay>
|
|
15
|
+
}
|
|
16
|
+
} catch {
|
|
17
|
+
console.warn('react-native-screens not installed. Notifications may render behind native iOS modals.')
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { AbsWindowOverlay }
|
|
@@ -3,7 +3,7 @@ function set(key, value) {
|
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
function setAsync(key, value) {
|
|
6
|
-
return Promise.
|
|
6
|
+
return Promise.resolve(set(key, value))
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
function get(key) {
|
|
@@ -11,7 +11,7 @@ function get(key) {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
function getAsync(key) {
|
|
14
|
-
return Promise.
|
|
14
|
+
return Promise.resolve(get(key))
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
function remove(key) {
|
|
@@ -19,7 +19,15 @@ function remove(key) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
function removeAsync(key) {
|
|
22
|
-
return Promise.
|
|
22
|
+
return Promise.resolve(remove(key))
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function clear() {
|
|
26
|
+
return localStorage.clear()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function clearAsync() {
|
|
30
|
+
return Promise.resolve(clear())
|
|
23
31
|
}
|
|
24
32
|
|
|
25
33
|
export const AbsStorage = {
|
|
@@ -29,4 +37,6 @@ export const AbsStorage = {
|
|
|
29
37
|
getAsync,
|
|
30
38
|
remove,
|
|
31
39
|
removeAsync,
|
|
40
|
+
clear,
|
|
41
|
+
clearAsync,
|
|
32
42
|
}
|
|
@@ -7,6 +7,9 @@ let getAsync = () => Promise.resolve(get())
|
|
|
7
7
|
let remove = () => console.warn('expo-sqlite not installed. Neko Storage needs expo-sqlite to work properly')
|
|
8
8
|
let removeAsync = () => Promise.resolve(remove())
|
|
9
9
|
|
|
10
|
+
let clear = () => console.warn('expo-sqlite not installed. Neko Storage needs expo-sqlite to work properly')
|
|
11
|
+
let clearAsync = () => Promise.resolve(clear())
|
|
12
|
+
|
|
10
13
|
try {
|
|
11
14
|
const StorageModule = require('expo-sqlite/kv-store')
|
|
12
15
|
if (StorageModule?.default) {
|
|
@@ -19,6 +22,9 @@ try {
|
|
|
19
22
|
|
|
20
23
|
remove = Storage.removeItemSync.bind(Storage)
|
|
21
24
|
removeAsync = Storage.removeItem.bind(Storage)
|
|
25
|
+
|
|
26
|
+
clear = Storage.clearSync.bind(Storage)
|
|
27
|
+
clearAsync = Storage.clearAsync.bind(Storage)
|
|
22
28
|
}
|
|
23
29
|
} catch (e) {
|
|
24
30
|
console.log('expo-sqlite not available:', e)
|
|
@@ -31,4 +37,6 @@ export const AbsStorage = {
|
|
|
31
37
|
getAsync,
|
|
32
38
|
remove,
|
|
33
39
|
removeAsync,
|
|
40
|
+
clear,
|
|
41
|
+
clearAsync,
|
|
34
42
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { is } from 'ramda'
|
|
2
2
|
import React from 'react'
|
|
3
3
|
|
|
4
|
+
import { AbsWindowOverlay } from '../../../abstractions/WindowOverlay'
|
|
4
5
|
import { Notification } from './Notification'
|
|
5
|
-
import { SafeAreaView } from '../../structure/SafeAreaView'
|
|
6
6
|
import { View } from '../../structure/View'
|
|
7
7
|
import { useResponsiveValue } from '../../../responsive/responsiveHooks'
|
|
8
|
+
import { useSafeAreaInsets } from '../../../abstractions/helpers/useSafeAreaInsets'
|
|
8
9
|
|
|
9
10
|
const NotificationsContext = React.createContext(null)
|
|
10
11
|
|
|
@@ -35,6 +36,7 @@ export function useNotifier() {
|
|
|
35
36
|
|
|
36
37
|
export function NotificationsHandler({ children }) {
|
|
37
38
|
const width = useResponsiveValue({ sm: '100%', df: 400 })
|
|
39
|
+
const insets = useSafeAreaInsets()
|
|
38
40
|
const [messages, setMessages] = React.useState([])
|
|
39
41
|
|
|
40
42
|
const add = React.useCallback((key, data) => {
|
|
@@ -52,13 +54,15 @@ export function NotificationsHandler({ children }) {
|
|
|
52
54
|
{children}
|
|
53
55
|
|
|
54
56
|
{!!messages.length && (
|
|
55
|
-
<
|
|
56
|
-
<
|
|
57
|
-
{
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
<AbsWindowOverlay>
|
|
58
|
+
<View fixed top={0} right={0} padding="md" width={width} maxWidth="100%" pointerEvents="box-none" zIndex={600}>
|
|
59
|
+
<View paddingT={insets.top} paddingR={insets.right} gap="xs" pointerEvents="box-none">
|
|
60
|
+
{messages.map(({ key, ...item }) => (
|
|
61
|
+
<Notification key={key} {...item} />
|
|
62
|
+
))}
|
|
63
|
+
</View>
|
|
64
|
+
</View>
|
|
65
|
+
</AbsWindowOverlay>
|
|
62
66
|
)}
|
|
63
67
|
</NotificationsContext.Provider>
|
|
64
68
|
)
|