@zero-bits/react-native-hot-update 1.0.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/README.md +159 -0
- package/es/constants.d.ts +20 -0
- package/es/constants.js +20 -0
- package/es/index.d.ts +4 -0
- package/es/index.js +3 -0
- package/es/initialize.d.ts +14 -0
- package/es/initialize.js +32 -0
- package/es/updateProvider.d.ts +75 -0
- package/es/updateProvider.js +74 -0
- package/es/updateState.d.ts +25 -0
- package/es/updateState.js +166 -0
- package/es/usePushyUpdate.d.ts +17 -0
- package/es/usePushyUpdate.js +108 -0
- package/es/widget/animated.overlay.d.ts +12 -0
- package/es/widget/animated.overlay.js +96 -0
- package/es/widget/content.widget.d.ts +5 -0
- package/es/widget/content.widget.js +55 -0
- package/es/widget/description.widget.d.ts +5 -0
- package/es/widget/description.widget.js +33 -0
- package/es/widget/download.modal.widget.d.ts +5 -0
- package/es/widget/download.modal.widget.js +130 -0
- package/es/widget/footer.widget.d.ts +5 -0
- package/es/widget/footer.widget.js +153 -0
- package/es/widget/title.widget.d.ts +5 -0
- package/es/widget/title.widget.js +27 -0
- package/es/widget/update.modal.widget.d.ts +5 -0
- package/es/widget/update.modal.widget.js +50 -0
- package/lib/constants.d.ts +20 -0
- package/lib/constants.js +26 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +36 -0
- package/lib/initialize.d.ts +14 -0
- package/lib/initialize.js +38 -0
- package/lib/updateProvider.d.ts +75 -0
- package/lib/updateProvider.js +83 -0
- package/lib/updateState.d.ts +25 -0
- package/lib/updateState.js +176 -0
- package/lib/usePushyUpdate.d.ts +17 -0
- package/lib/usePushyUpdate.js +114 -0
- package/lib/widget/animated.overlay.d.ts +12 -0
- package/lib/widget/animated.overlay.js +104 -0
- package/lib/widget/content.widget.d.ts +5 -0
- package/lib/widget/content.widget.js +63 -0
- package/lib/widget/description.widget.d.ts +5 -0
- package/lib/widget/description.widget.js +41 -0
- package/lib/widget/download.modal.widget.d.ts +5 -0
- package/lib/widget/download.modal.widget.js +138 -0
- package/lib/widget/footer.widget.d.ts +5 -0
- package/lib/widget/footer.widget.js +161 -0
- package/lib/widget/title.widget.d.ts +5 -0
- package/lib/widget/title.widget.js +35 -0
- package/lib/widget/update.modal.widget.d.ts +5 -0
- package/lib/widget/update.modal.widget.js +59 -0
- package/package.json +30 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
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."); }
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
10
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
+
import { useState } from 'react';
|
|
12
|
+
import { useUpdate } from 'react-native-update';
|
|
13
|
+
import { useUpdateState } from "./updateState";
|
|
14
|
+
/**
|
|
15
|
+
* @description 更新检查钩子
|
|
16
|
+
* @returns 更新检查钩子
|
|
17
|
+
*/
|
|
18
|
+
export default function usePushyUpdate() {
|
|
19
|
+
var _useUpdate = useUpdate(),
|
|
20
|
+
checkUpdate = _useUpdate.checkUpdate,
|
|
21
|
+
updateInfo = _useUpdate.updateInfo,
|
|
22
|
+
downloadUpdate = _useUpdate.downloadUpdate,
|
|
23
|
+
switchVersion = _useUpdate.switchVersion,
|
|
24
|
+
switchVersionLater = _useUpdate.switchVersionLater,
|
|
25
|
+
progress = _useUpdate.progress,
|
|
26
|
+
markSuccess = _useUpdate.markSuccess;
|
|
27
|
+
var _useUpdateState = useUpdateState(),
|
|
28
|
+
showUpdateModal = _useUpdateState.showUpdateModal,
|
|
29
|
+
startDownloadFlow = _useUpdateState.startDownloadFlow;
|
|
30
|
+
var _useState = useState(false),
|
|
31
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
32
|
+
isChecking = _useState2[0],
|
|
33
|
+
setIsChecking = _useState2[1];
|
|
34
|
+
var _useState3 = useState(null),
|
|
35
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
36
|
+
error = _useState4[0],
|
|
37
|
+
setError = _useState4[1];
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @description 检查更新
|
|
41
|
+
* @param flag false=静默检查(仅有更新时弹窗)/ true=手动触发(无论结果都弹窗)
|
|
42
|
+
* @returns 检查更新结果
|
|
43
|
+
*/
|
|
44
|
+
function checkUpdateApp() {
|
|
45
|
+
return _checkUpdateApp.apply(this, arguments);
|
|
46
|
+
}
|
|
47
|
+
function _checkUpdateApp() {
|
|
48
|
+
_checkUpdateApp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
49
|
+
var flag,
|
|
50
|
+
updateInfos,
|
|
51
|
+
hasValidInfo,
|
|
52
|
+
_args = arguments;
|
|
53
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
54
|
+
while (1) switch (_context.prev = _context.next) {
|
|
55
|
+
case 0:
|
|
56
|
+
flag = _args.length > 0 && _args[0] !== undefined ? _args[0] : false;
|
|
57
|
+
setIsChecking(true);
|
|
58
|
+
setError(null);
|
|
59
|
+
_context.prev = 3;
|
|
60
|
+
_context.next = 6;
|
|
61
|
+
return checkUpdate();
|
|
62
|
+
case 6:
|
|
63
|
+
updateInfos = _context.sent;
|
|
64
|
+
hasValidInfo = (updateInfos === null || updateInfos === void 0 ? void 0 : updateInfos.upToDate) || (updateInfos === null || updateInfos === void 0 ? void 0 : updateInfos.update) || (updateInfos === null || updateInfos === void 0 ? void 0 : updateInfos.expired);
|
|
65
|
+
if (hasValidInfo) {
|
|
66
|
+
_context.next = 10;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
return _context.abrupt("return", updateInfos);
|
|
70
|
+
case 10:
|
|
71
|
+
if (!(!flag && updateInfos !== null && updateInfos !== void 0 && updateInfos.upToDate)) {
|
|
72
|
+
_context.next = 12;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
return _context.abrupt("return", updateInfos);
|
|
76
|
+
case 12:
|
|
77
|
+
showUpdateModal();
|
|
78
|
+
return _context.abrupt("return", updateInfos);
|
|
79
|
+
case 16:
|
|
80
|
+
_context.prev = 16;
|
|
81
|
+
_context.t0 = _context["catch"](3);
|
|
82
|
+
console.warn('检查更新失败:', _context.t0);
|
|
83
|
+
setError(_context.t0);
|
|
84
|
+
case 20:
|
|
85
|
+
_context.prev = 20;
|
|
86
|
+
setIsChecking(false);
|
|
87
|
+
return _context.finish(20);
|
|
88
|
+
case 23:
|
|
89
|
+
case "end":
|
|
90
|
+
return _context.stop();
|
|
91
|
+
}
|
|
92
|
+
}, _callee, null, [[3, 16, 20, 23]]);
|
|
93
|
+
}));
|
|
94
|
+
return _checkUpdateApp.apply(this, arguments);
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
checkUpdateApp: checkUpdateApp,
|
|
98
|
+
updateInfo: updateInfo,
|
|
99
|
+
isChecking: isChecking,
|
|
100
|
+
error: error,
|
|
101
|
+
startDownloadFlow: startDownloadFlow,
|
|
102
|
+
downloadUpdate: downloadUpdate,
|
|
103
|
+
switchVersion: switchVersion,
|
|
104
|
+
switchVersionLater: switchVersionLater,
|
|
105
|
+
progress: progress,
|
|
106
|
+
markSuccess: markSuccess
|
|
107
|
+
};
|
|
108
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface Props {
|
|
3
|
+
children?: React.ReactNode;
|
|
4
|
+
visible: boolean;
|
|
5
|
+
onAnimationComplete?: (visible: boolean) => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* @description 动画弹窗原子组件
|
|
9
|
+
* @returns 动画弹窗原子组件
|
|
10
|
+
*/
|
|
11
|
+
export default function AnimatedOverlay({ children, visible, onAnimationComplete }: Props): any;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
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); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
14
|
+
import { Animated, StyleSheet, Easing } from 'react-native';
|
|
15
|
+
/**
|
|
16
|
+
* @description 动画弹窗原子组件
|
|
17
|
+
* @returns 动画弹窗原子组件
|
|
18
|
+
*/
|
|
19
|
+
export default function AnimatedOverlay(_ref) {
|
|
20
|
+
var children = _ref.children,
|
|
21
|
+
visible = _ref.visible,
|
|
22
|
+
onAnimationComplete = _ref.onAnimationComplete;
|
|
23
|
+
var _useState = useState(visible),
|
|
24
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
25
|
+
mounted = _useState2[0],
|
|
26
|
+
setMounted = _useState2[1];
|
|
27
|
+
var isComponentMounted = useRef(true);
|
|
28
|
+
var opacity = useRef(new Animated.Value(0)).current;
|
|
29
|
+
var scale = useRef(new Animated.Value(0.9)).current;
|
|
30
|
+
useEffect(function () {
|
|
31
|
+
return function () {
|
|
32
|
+
isComponentMounted.current = false;
|
|
33
|
+
};
|
|
34
|
+
}, []);
|
|
35
|
+
useEffect(function () {
|
|
36
|
+
if (visible) {
|
|
37
|
+
setMounted(true);
|
|
38
|
+
Animated.parallel([Animated.timing(opacity, {
|
|
39
|
+
toValue: 1,
|
|
40
|
+
duration: 250,
|
|
41
|
+
easing: Easing.out(Easing.ease),
|
|
42
|
+
useNativeDriver: true
|
|
43
|
+
}), Animated.spring(scale, {
|
|
44
|
+
toValue: 1,
|
|
45
|
+
friction: 8,
|
|
46
|
+
tension: 40,
|
|
47
|
+
useNativeDriver: true
|
|
48
|
+
})]).start(function () {
|
|
49
|
+
if (isComponentMounted.current) onAnimationComplete === null || onAnimationComplete === void 0 || onAnimationComplete(true);
|
|
50
|
+
});
|
|
51
|
+
} else {
|
|
52
|
+
Animated.parallel([Animated.timing(opacity, {
|
|
53
|
+
toValue: 0,
|
|
54
|
+
duration: 200,
|
|
55
|
+
easing: Easing.in(Easing.ease),
|
|
56
|
+
useNativeDriver: true
|
|
57
|
+
}), Animated.timing(scale, {
|
|
58
|
+
toValue: 0.9,
|
|
59
|
+
duration: 200,
|
|
60
|
+
easing: Easing.in(Easing.ease),
|
|
61
|
+
useNativeDriver: true
|
|
62
|
+
})]).start(function () {
|
|
63
|
+
if (isComponentMounted.current) {
|
|
64
|
+
setMounted(false);
|
|
65
|
+
onAnimationComplete === null || onAnimationComplete === void 0 || onAnimationComplete(false);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}, [visible]);
|
|
70
|
+
if (!mounted) return null;
|
|
71
|
+
return /*#__PURE__*/React.createElement(Animated.View, {
|
|
72
|
+
style: [Style.container, {
|
|
73
|
+
opacity: opacity
|
|
74
|
+
}]
|
|
75
|
+
}, /*#__PURE__*/React.createElement(Animated.View, {
|
|
76
|
+
style: [Style.contentWrapper, {
|
|
77
|
+
transform: [{
|
|
78
|
+
scale: scale
|
|
79
|
+
}]
|
|
80
|
+
}]
|
|
81
|
+
}, children));
|
|
82
|
+
}
|
|
83
|
+
var Style = StyleSheet.create({
|
|
84
|
+
container: _objectSpread(_objectSpread({
|
|
85
|
+
backgroundColor: 'rgba(0,0,0,.4)'
|
|
86
|
+
}, StyleSheet.absoluteFillObject), {}, {
|
|
87
|
+
justifyContent: 'center',
|
|
88
|
+
flexDirection: 'column',
|
|
89
|
+
elevation: 999,
|
|
90
|
+
zIndex: 999
|
|
91
|
+
}),
|
|
92
|
+
contentWrapper: {
|
|
93
|
+
justifyContent: 'center',
|
|
94
|
+
alignItems: 'center'
|
|
95
|
+
}
|
|
96
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { ScrollView, Text, StyleSheet } from 'react-native';
|
|
3
|
+
import { useUpdate } from 'react-native-update';
|
|
4
|
+
import { HotUpdateContext } from "../updateProvider";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @description 更新内容原子组件
|
|
8
|
+
* @returns 更新内容原子组件
|
|
9
|
+
*/
|
|
10
|
+
export default function ContentWidget() {
|
|
11
|
+
var _useUpdate = useUpdate(),
|
|
12
|
+
updateInfo = _useUpdate.updateInfo;
|
|
13
|
+
var config = useContext(HotUpdateContext);
|
|
14
|
+
var primaryColor = config.themeColor || 'rgba(52,92,255,1)';
|
|
15
|
+
if (updateInfo !== null && updateInfo !== void 0 && updateInfo.upToDate) return null;
|
|
16
|
+
/**
|
|
17
|
+
* @description 解析更新内容
|
|
18
|
+
* @returns 更新内容
|
|
19
|
+
*/
|
|
20
|
+
function parseDescription() {
|
|
21
|
+
try {
|
|
22
|
+
var _updateInfo$descripti;
|
|
23
|
+
if (!(updateInfo !== null && updateInfo !== void 0 && updateInfo.description)) return [];
|
|
24
|
+
var description = (_updateInfo$descripti = updateInfo.description) === null || _updateInfo$descripti === void 0 ? void 0 : _updateInfo$descripti.replace(/\\n/g, '\n');
|
|
25
|
+
return description.split('\n');
|
|
26
|
+
} catch (err) {}
|
|
27
|
+
return [(updateInfo === null || updateInfo === void 0 ? void 0 : updateInfo.description) || '修复应用bug'];
|
|
28
|
+
}
|
|
29
|
+
var messages = parseDescription();
|
|
30
|
+
return /*#__PURE__*/React.createElement(ScrollView, {
|
|
31
|
+
style: Style.container,
|
|
32
|
+
contentContainerStyle: Style.contentContainer
|
|
33
|
+
}, messages.map(function (text, index) {
|
|
34
|
+
return /*#__PURE__*/React.createElement(Text, {
|
|
35
|
+
key: index,
|
|
36
|
+
style: [Style.text, {
|
|
37
|
+
color: primaryColor
|
|
38
|
+
}]
|
|
39
|
+
}, index + 1, ".", text);
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
var Style = StyleSheet.create({
|
|
43
|
+
container: {
|
|
44
|
+
maxHeight: 250,
|
|
45
|
+
marginVertical: 10
|
|
46
|
+
},
|
|
47
|
+
contentContainer: {
|
|
48
|
+
paddingHorizontal: 20,
|
|
49
|
+
flexDirection: 'column'
|
|
50
|
+
},
|
|
51
|
+
text: {
|
|
52
|
+
fontSize: 14,
|
|
53
|
+
marginTop: 4
|
|
54
|
+
}
|
|
55
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { View, Text, StyleSheet } from 'react-native';
|
|
3
|
+
import { useUpdate } from 'react-native-update';
|
|
4
|
+
import { HotUpdateContext } from "../updateProvider";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @description 更新提示原子组件
|
|
8
|
+
* @returns 更新提示原子组件
|
|
9
|
+
*/
|
|
10
|
+
export default function DescriptWidget() {
|
|
11
|
+
var _useUpdate = useUpdate(),
|
|
12
|
+
updateInfo = _useUpdate.updateInfo;
|
|
13
|
+
var config = useContext(HotUpdateContext);
|
|
14
|
+
var locale = config.localeText;
|
|
15
|
+
var description = '';
|
|
16
|
+
if (updateInfo !== null && updateInfo !== void 0 && updateInfo.expired) description = locale.updateExpired;else if (updateInfo !== null && updateInfo !== void 0 && updateInfo.upToDate) description = locale.updateUpToDate;else if (updateInfo !== null && updateInfo !== void 0 && updateInfo.update) description = "".concat(locale.updateAvailable, "\uFF0C\u7248\u672C\u53F7\u4E3A").concat(updateInfo === null || updateInfo === void 0 ? void 0 : updateInfo.name, "\uFF0C\u8BF7\u53CA\u65F6\u66F4\u65B0\uFF0C\u66F4\u65B0\u5185\u5BB9\u5982\u4E0B\uFF1A");
|
|
17
|
+
if (!description) return null;
|
|
18
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
19
|
+
style: Style.container
|
|
20
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
21
|
+
style: Style.title
|
|
22
|
+
}, description));
|
|
23
|
+
}
|
|
24
|
+
var Style = StyleSheet.create({
|
|
25
|
+
container: {
|
|
26
|
+
marginTop: 10,
|
|
27
|
+
paddingHorizontal: 20
|
|
28
|
+
},
|
|
29
|
+
title: {
|
|
30
|
+
fontSize: 14,
|
|
31
|
+
lineHeight: 20
|
|
32
|
+
}
|
|
33
|
+
});
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
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); }
|
|
7
|
+
import React, { useContext } from 'react';
|
|
8
|
+
import { View, StyleSheet, Text } from 'react-native';
|
|
9
|
+
import { useUpdate } from 'react-native-update';
|
|
10
|
+
import { HotUpdateContext } from "../updateProvider";
|
|
11
|
+
import { useUpdateState } from "../updateState";
|
|
12
|
+
import AnimatedOverlay from "./animated.overlay";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @description 下载弹窗组件
|
|
16
|
+
* @returns 下载弹窗组件
|
|
17
|
+
*/
|
|
18
|
+
export default function DownloadWidget() {
|
|
19
|
+
var _useUpdate = useUpdate(),
|
|
20
|
+
_useUpdate$progress = _useUpdate.progress,
|
|
21
|
+
_useUpdate$progress2 = _useUpdate$progress === void 0 ? {} : _useUpdate$progress,
|
|
22
|
+
_useUpdate$progress2$ = _useUpdate$progress2.received,
|
|
23
|
+
received = _useUpdate$progress2$ === void 0 ? 0 : _useUpdate$progress2$,
|
|
24
|
+
_useUpdate$progress2$2 = _useUpdate$progress2.total,
|
|
25
|
+
total = _useUpdate$progress2$2 === void 0 ? 0 : _useUpdate$progress2$2;
|
|
26
|
+
var _useUpdateState = useUpdateState(),
|
|
27
|
+
isDownloadVisible = _useUpdateState.isDownloadVisible,
|
|
28
|
+
hideDownloadModal = _useUpdateState.hideDownloadModal;
|
|
29
|
+
var config = useContext(HotUpdateContext);
|
|
30
|
+
var locale = config.localeText;
|
|
31
|
+
var primaryColor = config.themeColor || 'rgba(52,92,255,1)';
|
|
32
|
+
var isStarted = total > 0;
|
|
33
|
+
var percent = isStarted ? Math.floor(received / total * 100) : 0;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @description 格式化字节
|
|
37
|
+
* @param bytes 字节数
|
|
38
|
+
* @returns 格式化后的字节数
|
|
39
|
+
*/
|
|
40
|
+
var formatBytes = function formatBytes(bytes) {
|
|
41
|
+
if (bytes === 0) return '0 B';
|
|
42
|
+
var k = 1024;
|
|
43
|
+
var sizes = ['B', 'KB', 'MB', 'GB'];
|
|
44
|
+
var i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
45
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
|
46
|
+
};
|
|
47
|
+
var content = null;
|
|
48
|
+
if (config.renderDownloadModal) {
|
|
49
|
+
content = config.renderDownloadModal({
|
|
50
|
+
received: received,
|
|
51
|
+
total: total
|
|
52
|
+
}, {
|
|
53
|
+
hideModal: hideDownloadModal
|
|
54
|
+
});
|
|
55
|
+
} else {
|
|
56
|
+
content = /*#__PURE__*/React.createElement(View, {
|
|
57
|
+
style: Style.content
|
|
58
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
59
|
+
style: Style.header
|
|
60
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
61
|
+
style: Style.title
|
|
62
|
+
}, locale.downloadingTitle)), /*#__PURE__*/React.createElement(View, {
|
|
63
|
+
style: Style.progress
|
|
64
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
65
|
+
style: Style.progressTrack
|
|
66
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
67
|
+
style: _objectSpread(_objectSpread({}, Style.bar), {}, {
|
|
68
|
+
backgroundColor: primaryColor,
|
|
69
|
+
width: "".concat(percent, "%")
|
|
70
|
+
})
|
|
71
|
+
})), /*#__PURE__*/React.createElement(Text, {
|
|
72
|
+
style: Style.gress
|
|
73
|
+
}, percent, "%")), /*#__PURE__*/React.createElement(View, {
|
|
74
|
+
style: Style.info
|
|
75
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
76
|
+
style: Style.recived
|
|
77
|
+
}, locale.downloadedBytes, formatBytes(received)), /*#__PURE__*/React.createElement(Text, {
|
|
78
|
+
style: {
|
|
79
|
+
fontSize: 12
|
|
80
|
+
}
|
|
81
|
+
}, locale.totalBytes, formatBytes(total))));
|
|
82
|
+
}
|
|
83
|
+
return /*#__PURE__*/React.createElement(AnimatedOverlay, {
|
|
84
|
+
visible: isDownloadVisible
|
|
85
|
+
}, content);
|
|
86
|
+
}
|
|
87
|
+
var Style = StyleSheet.create({
|
|
88
|
+
content: {
|
|
89
|
+
backgroundColor: 'white',
|
|
90
|
+
marginHorizontal: 20,
|
|
91
|
+
borderRadius: 8,
|
|
92
|
+
padding: 20,
|
|
93
|
+
flexDirection: 'column',
|
|
94
|
+
width: '90%',
|
|
95
|
+
maxWidth: 400
|
|
96
|
+
},
|
|
97
|
+
header: {
|
|
98
|
+
height: 30
|
|
99
|
+
},
|
|
100
|
+
title: {
|
|
101
|
+
fontSize: 16
|
|
102
|
+
},
|
|
103
|
+
progress: {
|
|
104
|
+
flexDirection: 'row',
|
|
105
|
+
alignItems: 'center'
|
|
106
|
+
},
|
|
107
|
+
progressTrack: {
|
|
108
|
+
flex: 1,
|
|
109
|
+
height: 10,
|
|
110
|
+
backgroundColor: '#eee',
|
|
111
|
+
borderRadius: 5,
|
|
112
|
+
flexDirection: 'row',
|
|
113
|
+
overflow: 'hidden'
|
|
114
|
+
},
|
|
115
|
+
bar: {
|
|
116
|
+
height: '100%'
|
|
117
|
+
},
|
|
118
|
+
gress: {
|
|
119
|
+
marginLeft: 10,
|
|
120
|
+
fontSize: 12
|
|
121
|
+
},
|
|
122
|
+
info: {
|
|
123
|
+
flexDirection: 'row',
|
|
124
|
+
marginTop: 10
|
|
125
|
+
},
|
|
126
|
+
recived: {
|
|
127
|
+
flex: 1,
|
|
128
|
+
fontSize: 12
|
|
129
|
+
}
|
|
130
|
+
});
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import React, { useContext, useMemo } from 'react';
|
|
2
|
+
import { View, Platform, StyleSheet, Alert, Linking, TouchableOpacity, Text } from 'react-native';
|
|
3
|
+
import { useUpdate } from 'react-native-update';
|
|
4
|
+
import { useUpdateState } from "../updateState";
|
|
5
|
+
import { openAppStore } from 'react-native-market-linking';
|
|
6
|
+
import { HotUpdateContext } from "../updateProvider";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @description 更新弹窗底部操作按钮组件
|
|
10
|
+
* @returns 更新弹窗底部操作按钮组件
|
|
11
|
+
*/
|
|
12
|
+
export default function FooterWidget() {
|
|
13
|
+
var isAndroid = Platform.OS === 'android';
|
|
14
|
+
var _useUpdate = useUpdate(),
|
|
15
|
+
updateInfo = _useUpdate.updateInfo;
|
|
16
|
+
var _useUpdateState = useUpdateState(),
|
|
17
|
+
hideUpdateModal = _useUpdateState.hideUpdateModal,
|
|
18
|
+
startDownloadFlow = _useUpdateState.startDownloadFlow;
|
|
19
|
+
var config = useContext(HotUpdateContext);
|
|
20
|
+
var locale = config.localeText;
|
|
21
|
+
var primaryColor = config.themeColor || 'rgba(52,92,255,1)';
|
|
22
|
+
var isForceUpdate = useMemo(function () {
|
|
23
|
+
try {
|
|
24
|
+
if (!(updateInfo !== null && updateInfo !== void 0 && updateInfo.metaInfo)) return false;
|
|
25
|
+
var meta = JSON.parse(updateInfo.metaInfo);
|
|
26
|
+
return meta.force === true || meta.forceUpdate === true;
|
|
27
|
+
} catch (_unused) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}, [updateInfo === null || updateInfo === void 0 ? void 0 : updateInfo.metaInfo]);
|
|
31
|
+
function appStoreUpdate() {
|
|
32
|
+
if (!isForceUpdate) hideUpdateModal();
|
|
33
|
+
if (config.iosAppId) {
|
|
34
|
+
openAppStore(config.iosAppId);
|
|
35
|
+
} else {
|
|
36
|
+
Alert.alert('提示', locale.alertMissingAppId);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function openH5ApkDownloadPage() {
|
|
40
|
+
if (!isForceUpdate) hideUpdateModal();
|
|
41
|
+
if (!(updateInfo !== null && updateInfo !== void 0 && updateInfo.downloadUrl)) {
|
|
42
|
+
Alert.alert('提示', locale.alertMissingDownloadUrl);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
Linking.canOpenURL(updateInfo === null || updateInfo === void 0 ? void 0 : updateInfo.downloadUrl).then(function (supported) {
|
|
46
|
+
if (supported) return Linking.openURL(updateInfo === null || updateInfo === void 0 ? void 0 : updateInfo.downloadUrl);
|
|
47
|
+
Alert.alert('提示', locale.alertCantOpenDownloadUrl);
|
|
48
|
+
}).catch(function () {
|
|
49
|
+
Alert.alert('提示', locale.alertDownloadUrlFailed);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
var PrimaryBtn = function PrimaryBtn(_ref) {
|
|
53
|
+
var title = _ref.title,
|
|
54
|
+
onPress = _ref.onPress,
|
|
55
|
+
style = _ref.style;
|
|
56
|
+
return /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
57
|
+
style: [Style.button, {
|
|
58
|
+
backgroundColor: primaryColor
|
|
59
|
+
}, style],
|
|
60
|
+
onPress: onPress
|
|
61
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
62
|
+
style: Style.primaryText
|
|
63
|
+
}, title));
|
|
64
|
+
};
|
|
65
|
+
var GhostBtn = function GhostBtn(_ref2) {
|
|
66
|
+
var title = _ref2.title,
|
|
67
|
+
onPress = _ref2.onPress,
|
|
68
|
+
style = _ref2.style;
|
|
69
|
+
return /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
70
|
+
style: [Style.button, Style.ghostButton, {
|
|
71
|
+
borderColor: primaryColor
|
|
72
|
+
}, style],
|
|
73
|
+
onPress: onPress
|
|
74
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
75
|
+
style: [Style.ghostText, {
|
|
76
|
+
color: primaryColor
|
|
77
|
+
}]
|
|
78
|
+
}, title));
|
|
79
|
+
};
|
|
80
|
+
function renderActionButton() {
|
|
81
|
+
if (updateInfo !== null && updateInfo !== void 0 && updateInfo.upToDate) return /*#__PURE__*/React.createElement(PrimaryBtn, {
|
|
82
|
+
title: locale.btnGotIt,
|
|
83
|
+
onPress: hideUpdateModal
|
|
84
|
+
});
|
|
85
|
+
if (updateInfo !== null && updateInfo !== void 0 && updateInfo.update) return [!isForceUpdate && /*#__PURE__*/React.createElement(GhostBtn, {
|
|
86
|
+
key: "plus",
|
|
87
|
+
title: locale.btnUpdateLater,
|
|
88
|
+
onPress: hideUpdateModal,
|
|
89
|
+
style: {
|
|
90
|
+
marginRight: 15
|
|
91
|
+
}
|
|
92
|
+
}), /*#__PURE__*/React.createElement(PrimaryBtn, {
|
|
93
|
+
key: "submit",
|
|
94
|
+
title: locale.btnUpdateNow,
|
|
95
|
+
onPress: startDownloadFlow
|
|
96
|
+
})];
|
|
97
|
+
if (updateInfo !== null && updateInfo !== void 0 && updateInfo.expired) return [!isForceUpdate && /*#__PURE__*/React.createElement(GhostBtn, {
|
|
98
|
+
key: "unable",
|
|
99
|
+
title: locale.btnUpdateLater,
|
|
100
|
+
onPress: hideUpdateModal,
|
|
101
|
+
style: {
|
|
102
|
+
marginRight: 10
|
|
103
|
+
}
|
|
104
|
+
}), /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
105
|
+
key: "store",
|
|
106
|
+
style: [Style.button, isAndroid ? [Style.ghostButton, {
|
|
107
|
+
borderColor: primaryColor
|
|
108
|
+
}] : {
|
|
109
|
+
backgroundColor: primaryColor
|
|
110
|
+
}],
|
|
111
|
+
onPress: appStoreUpdate
|
|
112
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
113
|
+
style: isAndroid ? [Style.ghostText, {
|
|
114
|
+
color: primaryColor
|
|
115
|
+
}] : Style.primaryText
|
|
116
|
+
}, locale.btnAppStore)), isAndroid && /*#__PURE__*/React.createElement(PrimaryBtn, {
|
|
117
|
+
key: "install",
|
|
118
|
+
title: locale.btnDownload,
|
|
119
|
+
onPress: openH5ApkDownloadPage,
|
|
120
|
+
style: {
|
|
121
|
+
marginLeft: 10
|
|
122
|
+
}
|
|
123
|
+
})];
|
|
124
|
+
}
|
|
125
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
126
|
+
style: Style.container
|
|
127
|
+
}, renderActionButton());
|
|
128
|
+
}
|
|
129
|
+
var Style = StyleSheet.create({
|
|
130
|
+
container: {
|
|
131
|
+
marginHorizontal: 15,
|
|
132
|
+
flexDirection: 'row',
|
|
133
|
+
marginTop: 20
|
|
134
|
+
},
|
|
135
|
+
button: {
|
|
136
|
+
flex: 1,
|
|
137
|
+
height: 40,
|
|
138
|
+
borderRadius: 4,
|
|
139
|
+
justifyContent: 'center',
|
|
140
|
+
alignItems: 'center'
|
|
141
|
+
},
|
|
142
|
+
ghostButton: {
|
|
143
|
+
backgroundColor: 'transparent',
|
|
144
|
+
borderWidth: 1
|
|
145
|
+
},
|
|
146
|
+
primaryText: {
|
|
147
|
+
color: '#fff',
|
|
148
|
+
fontSize: 14
|
|
149
|
+
},
|
|
150
|
+
ghostText: {
|
|
151
|
+
fontSize: 14
|
|
152
|
+
}
|
|
153
|
+
});
|