js: add navbar set center api
This commit is contained in:
parent
cc5a7ab011
commit
d8649ac539
@ -118,6 +118,30 @@ class NavbarDemo extends Panel {
|
||||
})
|
||||
}
|
||||
}),
|
||||
label('setCenter').apply({
|
||||
width: 200,
|
||||
height: 50,
|
||||
backgroundColor: colors[0],
|
||||
textSize: 30,
|
||||
textColor: Color.WHITE,
|
||||
layoutConfig: layoutConfig().just(),
|
||||
onClick: () => {
|
||||
navbar(context).setCenter(hlayout([
|
||||
text({
|
||||
width: 70,
|
||||
height: 44,
|
||||
textColor: Color.BLACK,
|
||||
layoutConfig: layoutConfig().just().configAlignment(Gravity.Center),
|
||||
text: "Center",
|
||||
}),
|
||||
]).apply({
|
||||
backgroundColor: Color.RED
|
||||
}))
|
||||
.catch(e => {
|
||||
modal(context).alert(e)
|
||||
})
|
||||
}
|
||||
}),
|
||||
label('Pop').apply({
|
||||
width: 200,
|
||||
height: 50,
|
||||
|
@ -1914,7 +1914,8 @@ var List = /** @class */ (function (_super) {
|
||||
}
|
||||
};
|
||||
List.prototype.scrollToItem = function (context, index, config) {
|
||||
var animated = config === null || config === void 0 ? void 0 : config.animated;
|
||||
var _a;
|
||||
var animated = (_a = config) === null || _a === void 0 ? void 0 : _a.animated;
|
||||
return this.nativeChannel(context, 'scrollToItem')({ index: index, animated: animated, });
|
||||
};
|
||||
List.prototype.reset = function () {
|
||||
@ -2844,7 +2845,14 @@ function navbar(context) {
|
||||
panel.addHeadView("navbar_right", view);
|
||||
}
|
||||
return context.callNative('navbar', 'setRight', view.toModel());
|
||||
},
|
||||
setCenter: function (view) {
|
||||
if (panel) {
|
||||
panel.clearHeadViews("navbar_center");
|
||||
panel.addHeadView("navbar_center", view);
|
||||
}
|
||||
return context.callNative('navbar', 'setCenter', view.toModel());
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1420,7 +1420,8 @@ class List extends Superview {
|
||||
}
|
||||
}
|
||||
scrollToItem(context, index, config) {
|
||||
const animated = config === null || config === void 0 ? void 0 : config.animated;
|
||||
var _a;
|
||||
const animated = (_a = config) === null || _a === void 0 ? void 0 : _a.animated;
|
||||
return this.nativeChannel(context, 'scrollToItem')({ index, animated, });
|
||||
}
|
||||
reset() {
|
||||
@ -2169,7 +2170,14 @@ function navbar(context) {
|
||||
panel.addHeadView("navbar_right", view);
|
||||
}
|
||||
return context.callNative('navbar', 'setRight', view.toModel());
|
||||
},
|
||||
setCenter: (view) => {
|
||||
if (panel) {
|
||||
panel.clearHeadViews("navbar_center");
|
||||
panel.addHeadView("navbar_center", view);
|
||||
}
|
||||
return context.callNative('navbar', 'setCenter', view.toModel());
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1705,7 +1705,7 @@ var doric = (function (exports) {
|
||||
(module.exports = function (key, value) {
|
||||
return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {});
|
||||
})('versions', []).push({
|
||||
version: '3.6.5',
|
||||
version: '3.6.4',
|
||||
mode: 'global',
|
||||
copyright: '© 2020 Denis Pushkarev (zloirock.ru)'
|
||||
});
|
||||
@ -6489,13 +6489,7 @@ var doric = (function (exports) {
|
||||
defer = functionBindContext(port.postMessage, port, 1);
|
||||
// Browsers with postMessage, skip WebWorkers
|
||||
// IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
|
||||
} else if (
|
||||
global_1.addEventListener &&
|
||||
typeof postMessage == 'function' &&
|
||||
!global_1.importScripts &&
|
||||
!fails(post) &&
|
||||
location.protocol !== 'file:'
|
||||
) {
|
||||
} else if (global_1.addEventListener && typeof postMessage == 'function' && !global_1.importScripts && !fails(post)) {
|
||||
defer = post;
|
||||
global_1.addEventListener('message', listener, false);
|
||||
// IE8-
|
||||
@ -9867,7 +9861,7 @@ var doric = (function (exports) {
|
||||
var INVALID_PORT = 'Invalid port';
|
||||
|
||||
var ALPHA = /[A-Za-z]/;
|
||||
var ALPHANUMERIC = /[\d+-.A-Za-z]/;
|
||||
var ALPHANUMERIC = /[\d+\-.A-Za-z]/;
|
||||
var DIGIT = /\d/;
|
||||
var HEX_START = /^(0x|0X)/;
|
||||
var OCT = /^[0-7]+$/;
|
||||
@ -11678,8 +11672,8 @@ var doric = (function (exports) {
|
||||
if (cleanup != null) { subscriptionState.cleanup = typeof cleanup.unsubscribe === 'function'
|
||||
? function () { subscription.unsubscribe(); }
|
||||
: aFunction$1(cleanup); }
|
||||
} catch (error$1) {
|
||||
subscriptionObserver.error(error$1);
|
||||
} catch (error) {
|
||||
subscriptionObserver.error(error);
|
||||
return;
|
||||
} if (subscriptionClosed(subscriptionState)) { cleanupSubscription(subscriptionState); }
|
||||
};
|
||||
@ -13179,7 +13173,7 @@ var doric = (function (exports) {
|
||||
// some Chrome versions have non-configurable methods on DOMTokenList
|
||||
if (CollectionPrototype$1[METHOD_NAME] !== es_array_iterator[METHOD_NAME]) { try {
|
||||
createNonEnumerableProperty(CollectionPrototype$1, METHOD_NAME, es_array_iterator[METHOD_NAME]);
|
||||
} catch (error$1) {
|
||||
} catch (error) {
|
||||
CollectionPrototype$1[METHOD_NAME] = es_array_iterator[METHOD_NAME];
|
||||
} }
|
||||
} }
|
||||
|
@ -2879,7 +2879,8 @@ class List extends Superview {
|
||||
}
|
||||
}
|
||||
scrollToItem(context, index, config) {
|
||||
const animated = config === null || config === void 0 ? void 0 : config.animated;
|
||||
var _a;
|
||||
const animated = (_a = config) === null || _a === void 0 ? void 0 : _a.animated;
|
||||
return this.nativeChannel(context, 'scrollToItem')({ index, animated, });
|
||||
}
|
||||
reset() {
|
||||
@ -3628,7 +3629,14 @@ function navbar(context) {
|
||||
panel.addHeadView("navbar_right", view);
|
||||
}
|
||||
return context.callNative('navbar', 'setRight', view.toModel());
|
||||
},
|
||||
setCenter: (view) => {
|
||||
if (panel) {
|
||||
panel.clearHeadViews("navbar_center");
|
||||
panel.addHeadView("navbar_center", view);
|
||||
}
|
||||
return context.callNative('navbar', 'setCenter', view.toModel());
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
1
doric-js/index.d.ts
vendored
1
doric-js/index.d.ts
vendored
@ -765,6 +765,7 @@ declare module 'doric/lib/src/native/navbar' {
|
||||
setBgColor: (color: Color) => Promise<any>;
|
||||
setLeft: (view: View) => Promise<any>;
|
||||
setRight: (view: View) => Promise<any>;
|
||||
setCenter: (view: View) => Promise<any>;
|
||||
};
|
||||
}
|
||||
|
||||
|
1
doric-js/lib/src/native/navbar.d.ts
vendored
1
doric-js/lib/src/native/navbar.d.ts
vendored
@ -8,4 +8,5 @@ export declare function navbar(context: BridgeContext): {
|
||||
setBgColor: (color: Color) => Promise<any>;
|
||||
setLeft: (view: View) => Promise<any>;
|
||||
setRight: (view: View) => Promise<any>;
|
||||
setCenter: (view: View) => Promise<any>;
|
||||
};
|
||||
|
@ -31,6 +31,13 @@ export function navbar(context) {
|
||||
panel.addHeadView("navbar_right", view);
|
||||
}
|
||||
return context.callNative('navbar', 'setRight', view.toModel());
|
||||
},
|
||||
setCenter: (view) => {
|
||||
if (panel) {
|
||||
panel.clearHeadViews("navbar_center");
|
||||
panel.addHeadView("navbar_center", view);
|
||||
}
|
||||
return context.callNative('navbar', 'setCenter', view.toModel());
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -48,7 +48,8 @@ export class List extends Superview {
|
||||
}
|
||||
}
|
||||
scrollToItem(context, index, config) {
|
||||
const animated = config === null || config === void 0 ? void 0 : config.animated;
|
||||
var _a;
|
||||
const animated = (_a = config) === null || _a === void 0 ? void 0 : _a.animated;
|
||||
return this.nativeChannel(context, 'scrollToItem')({ index, animated, });
|
||||
}
|
||||
reset() {
|
||||
|
@ -51,6 +51,13 @@ export function navbar(context: BridgeContext) {
|
||||
panel.addHeadView("navbar_right", view)
|
||||
}
|
||||
return context.callNative('navbar', 'setRight', view.toModel())
|
||||
}
|
||||
},
|
||||
setCenter: (view: View) => {
|
||||
if (panel) {
|
||||
panel.clearHeadViews("navbar_center")
|
||||
panel.addHeadView("navbar_center", view)
|
||||
}
|
||||
return context.callNative('navbar', 'setCenter', view.toModel())
|
||||
},
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user