uicore-ts 1.0.551 → 1.0.557
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/compiledScripts/UIRoute.js +9 -1
- package/compiledScripts/UIRoute.js.map +2 -2
- package/compiledScripts/UIViewController.d.ts +3 -0
- package/compiledScripts/UIViewController.js +3 -0
- package/compiledScripts/UIViewController.js.map +2 -2
- package/package.json +1 -1
- package/scripts/UIRoute.ts +23 -17
- package/scripts/UIViewController.ts +35 -31
|
@@ -59,9 +59,17 @@ class UIRoute extends Array {
|
|
|
59
59
|
return new UIRoute(window.location.hash);
|
|
60
60
|
}
|
|
61
61
|
apply() {
|
|
62
|
-
|
|
62
|
+
const stringRepresentation = this.stringRepresentation;
|
|
63
|
+
if (new UIRoute(window.location.hash).stringRepresentation == stringRepresentation) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
window.location.hash = stringRepresentation;
|
|
63
67
|
}
|
|
64
68
|
applyByReplacingCurrentRouteInHistory() {
|
|
69
|
+
const stringRepresentation = this.stringRepresentation;
|
|
70
|
+
if (new UIRoute(window.location.hash).stringRepresentation == stringRepresentation) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
65
73
|
window.location.replace(this.linkRepresentation);
|
|
66
74
|
}
|
|
67
75
|
copy() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/UIRoute.ts"],
|
|
4
|
-
"sourcesContent": ["import { IS_NIL, IS_NOT, NO, ValueOf } from \"./UIObject\"\nimport { UIViewController } from \"./UIViewController\"\n\n\nexport type PropType<TObj, TProp extends keyof TObj> = TObj[TProp];\n\nexport type UIRouteParameters<T = any> = {\n \n [key: string]: string;\n \n} | T;\n\n\nexport interface UIRouteComponent<T = any> {\n \n name: string;\n parameters: UIRouteParameters<T>;\n \n}\n\n\nexport class UIRoute extends Array<UIRouteComponent> {\n \n constructor(hash?: string) {\n \n super()\n \n if (!hash || !hash.startsWith) {\n \n return\n \n }\n \n if (hash.startsWith(\"#\")) {\n hash = hash.slice(1)\n }\n \n hash = decodeURIComponent(hash)\n \n const components = hash.split(\"]\")\n components.forEach(component => {\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA4C;AAqBrC,MAAM,gBAAgB,MAAwB;AAAA,EAEjD,YAAY,MAAe;AAEvB,UAAM;AAEN,QAAI,CAAC,QAAQ,CAAC,KAAK,YAAY;AAE3B;AAAA,IAEJ;AAEA,QAAI,KAAK,WAAW,GAAG,GAAG;AACtB,aAAO,KAAK,MAAM,CAAC;AAAA,IACvB;AAEA,WAAO,mBAAmB,IAAI;AAE9B,UAAM,aAAa,KAAK,MAAM,GAAG;AACjC,eAAW,QAAQ,eAAa;AAE5B,YAAM,gBAAgB,UAAU,MAAM,GAAG,EAAE;AAC3C,YAAM,aAAqC,CAAC;AAE5C,UAAI,CAAC,eAAe;AAChB;AAAA,MACJ;AAEA,YAAM,mBAAmB,UAAU,MAAM,GAAG,EAAE,MAAM;AACpD,YAAM,uBAAuB,iBAAiB,MAAM,GAAG,KAAK,CAAC;AAE7D,2BAAqB,QAAQ,gBAAc;AAEvC,cAAM,mBAAmB,WAAW,MAAM,GAAG;AAC7C,cAAM,MAAM,mBAAmB,iBAAiB,EAAE;AAClD,cAAM,QAAQ,mBAAmB,iBAAiB,EAAE;AAEpD,YAAI,KAAK;AACL,qBAAW,OAAO;AAAA,QACtB;AAAA,MAEJ,CAAC;AAGD,WAAK,KAAK;AAAA,QACN,MAAM;AAAA,QACN;AAAA,MACJ,CAAC;AAAA,IAEL,CAAC;AAAA,EAGL;AAAA,EAGA,WAAW,eAAe;AAEtB,WAAO,IAAI,QAAQ,OAAO,SAAS,IAAI;AAAA,EAE3C;AAAA,
|
|
4
|
+
"sourcesContent": ["import { IS_NIL, IS_NOT, NO, ValueOf } from \"./UIObject\"\nimport { UIViewController } from \"./UIViewController\"\n\n\nexport type PropType<TObj, TProp extends keyof TObj> = TObj[TProp];\n\nexport type UIRouteParameters<T = any> = {\n \n [key: string]: string;\n \n} | T;\n\n\nexport interface UIRouteComponent<T = any> {\n \n name: string;\n parameters: UIRouteParameters<T>;\n \n}\n\n\nexport class UIRoute extends Array<UIRouteComponent> {\n \n constructor(hash?: string) {\n \n super()\n \n if (!hash || !hash.startsWith) {\n \n return\n \n }\n \n if (hash.startsWith(\"#\")) {\n hash = hash.slice(1)\n }\n \n hash = decodeURIComponent(hash)\n \n const components = hash.split(\"]\")\n components.forEach(component => {\n \n const componentName = component.split(\"[\")[0]\n const parameters: Record<string, string> = {}\n \n if (!componentName) {\n return\n }\n \n const parametersString = component.split(\"[\")[1] || \"\"\n const parameterPairStrings = parametersString.split(\",\") || []\n \n parameterPairStrings.forEach(pairString => {\n \n const keyAndValueArray = pairString.split(\":\")\n const key = decodeURIComponent(keyAndValueArray[0])\n const value = decodeURIComponent(keyAndValueArray[1])\n \n if (key) {\n parameters[key] = value\n }\n \n })\n \n \n this.push({\n name: componentName,\n parameters: parameters\n })\n \n })\n \n \n }\n \n \n static get currentRoute() {\n \n return new UIRoute(window.location.hash)\n \n }\n \n \n apply() {\n \n const stringRepresentation = this.stringRepresentation\n if (new UIRoute(window.location.hash).stringRepresentation == stringRepresentation) {\n return\n }\n \n window.location.hash = stringRepresentation\n \n }\n \n \n applyByReplacingCurrentRouteInHistory() {\n \n const stringRepresentation = this.stringRepresentation\n if (new UIRoute(window.location.hash).stringRepresentation == stringRepresentation) {\n return\n }\n \n window.location.replace(this.linkRepresentation)\n \n }\n \n \n override copy() {\n const result = new UIRoute(this.stringRepresentation)\n return result\n }\n \n \n routeByRemovingComponentsOtherThanOnesNamed(componentNames: string[]) {\n const result = this.copy()\n const indexesToRemove: number[] = []\n result.forEach(function (component, index, array) {\n if (!componentNames.contains(component.name)) {\n indexesToRemove.push(index)\n }\n })\n indexesToRemove.forEach(function (indexToRemove, index, array) {\n result.removeElementAtIndex(indexToRemove)\n })\n return result\n }\n \n \n routeByRemovingComponentNamed(componentName: string) {\n const result = this.copy()\n const componentIndex = result.findIndex(function (component, index) {\n return (component.name == componentName)\n })\n if (componentIndex != -1) {\n result.splice(componentIndex, 1)\n }\n return result\n }\n \n \n routeByRemovingParameterInComponent(componentName: string, parameterName: string, removeComponentIfEmpty = NO) {\n let result = this.copy()\n let parameters = result.componentWithName(componentName)?.parameters ?? {}\n delete parameters[parameterName]\n result = result.routeWithComponent(componentName, parameters)\n if (removeComponentIfEmpty && Object.keys(parameters).length == 0) {\n result = result.routeByRemovingComponentNamed(componentName)\n }\n return result\n }\n \n routeBySettingParameterInComponent(componentName: string, parameterName: string, valueToSet: string) {\n let result = this.copy()\n if (IS_NIL(valueToSet) || IS_NIL(parameterName)) {\n return result\n }\n let parameters = result.componentWithName(componentName)?.parameters\n if (IS_NOT(parameters)) {\n parameters = {}\n }\n parameters[parameterName] = valueToSet\n result = result.routeWithComponent(componentName, parameters)\n return result\n }\n \n \n routeWithViewControllerComponent<T extends typeof UIViewController>(\n viewController: T,\n parameters: UIRouteParameters<{ [P in keyof T[\"ParameterIdentifierName\"]]: string }>,\n extendParameters: boolean = NO\n ) {\n \n return this.routeWithComponent(viewController.routeComponentName, parameters, extendParameters)\n \n }\n \n routeWithComponent(name: string, parameters: UIRouteParameters, extendParameters: boolean = NO) {\n \n const result = this.copy()\n let component = result.componentWithName(name)\n if (IS_NOT(component)) {\n component = {\n name: name,\n parameters: {}\n }\n result.push(component)\n }\n \n if (IS_NOT(parameters)) {\n \n parameters = {}\n \n }\n \n if (extendParameters) {\n component.parameters = Object.assign(component.parameters, parameters)\n }\n else {\n component.parameters = parameters\n }\n \n return result\n \n }\n \n navigateBySettingComponent(name: string, parameters: UIRouteParameters, extendParameters: boolean = NO) {\n \n this.routeWithComponent(name, parameters, extendParameters).apply()\n \n }\n \n \n componentWithViewController<T extends typeof UIViewController>(viewController: T): UIRouteComponent<{ [P in ValueOf<T[\"ParameterIdentifierName\"]>]: string }> | undefined {\n \n return this.componentWithName(viewController.routeComponentName)\n \n }\n \n componentWithName(name: string): UIRouteComponent | undefined {\n let result\n this.forEach(function (component, index, self) {\n if (component.name == name) {\n result = component\n }\n })\n return result\n }\n \n \n get linkRepresentation() {\n return \"#\" + this.stringRepresentation\n }\n \n \n get stringRepresentation() {\n \n let result = \"\"\n this.forEach(function (component, index, self) {\n result = result + component.name\n const parameters = component.parameters\n result = result + \"[\"\n Object.keys(parameters).forEach(function (key, index, keys) {\n if (index) {\n result = result + \",\"\n }\n result = result + encodeURIComponent(key) + \":\" + encodeURIComponent(parameters[key])\n })\n result = result + \"]\"\n })\n \n return result\n \n }\n \n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA4C;AAqBrC,MAAM,gBAAgB,MAAwB;AAAA,EAEjD,YAAY,MAAe;AAEvB,UAAM;AAEN,QAAI,CAAC,QAAQ,CAAC,KAAK,YAAY;AAE3B;AAAA,IAEJ;AAEA,QAAI,KAAK,WAAW,GAAG,GAAG;AACtB,aAAO,KAAK,MAAM,CAAC;AAAA,IACvB;AAEA,WAAO,mBAAmB,IAAI;AAE9B,UAAM,aAAa,KAAK,MAAM,GAAG;AACjC,eAAW,QAAQ,eAAa;AAE5B,YAAM,gBAAgB,UAAU,MAAM,GAAG,EAAE;AAC3C,YAAM,aAAqC,CAAC;AAE5C,UAAI,CAAC,eAAe;AAChB;AAAA,MACJ;AAEA,YAAM,mBAAmB,UAAU,MAAM,GAAG,EAAE,MAAM;AACpD,YAAM,uBAAuB,iBAAiB,MAAM,GAAG,KAAK,CAAC;AAE7D,2BAAqB,QAAQ,gBAAc;AAEvC,cAAM,mBAAmB,WAAW,MAAM,G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;AAEpB,mBAAa,CAAC;AAAA,IAElB;AAEA,QAAI,kBAAkB;AAClB,gBAAU,aAAa,OAAO,OAAO,UAAU,YAAY,UAAU;AAAA,IACzE,OACK;AACD,gBAAU,aAAa;AAAA,IAC3B;AAEA,WAAO;AAAA,EAEX;AAAA,EAEA,2BAA2B,MAAc,YAA+B,mBAA4B,oBAAI;AAEpG,SAAK,mBAAmB,MAAM,YAAY,gBAAgB,EAAE,MAAM;AAAA,EAEtE;AAAA,EAGA,4BAA+D,gBAA2G;AAEtK,WAAO,KAAK,kBAAkB,eAAe,kBAAkB;AAAA,EAEnE;AAAA,EAEA,kBAAkB,MAA4C;AAC1D,QAAI;AACJ,SAAK,QAAQ,SAAU,WAAW,OAAO,MAAM;AAC3C,UAAI,UAAU,QAAQ,MAAM;AACxB,iBAAS;AAAA,MACb;AAAA,IACJ,CAAC;AACD,WAAO;AAAA,EACX;AAAA,EAGA,IAAI,qBAAqB;AACrB,WAAO,MAAM,KAAK;AAAA,EACtB;AAAA,EAGA,IAAI,uBAAuB;AAEvB,QAAI,SAAS;AACb,SAAK,QAAQ,SAAU,WAAW,OAAO,MAAM;AAC3C,eAAS,SAAS,UAAU;AAC5B,YAAM,aAAa,UAAU;AAC7B,eAAS,SAAS;AAClB,aAAO,KAAK,UAAU,EAAE,QAAQ,SAAU,KAAKA,QAAO,MAAM;AACxD,YAAIA,QAAO;AACP,mBAAS,SAAS;AAAA,QACtB;AACA,iBAAS,SAAS,mBAAmB,GAAG,IAAI,MAAM,mBAAmB,WAAW,IAAI;AAAA,MACxF,CAAC;AACD,eAAS,SAAS;AAAA,IACtB,CAAC;AAED,WAAO;AAAA,EAEX;AAGJ;",
|
|
6
6
|
"names": ["index"]
|
|
7
7
|
}
|
|
@@ -9,6 +9,9 @@ export declare class UIViewController extends UIObject {
|
|
|
9
9
|
static readonly routeComponentName: string;
|
|
10
10
|
static readonly ParameterIdentifierName: any;
|
|
11
11
|
constructor(view: UIView);
|
|
12
|
+
get routeComponent(): import("./UIRoute").UIRouteComponent<{
|
|
13
|
+
[x: string]: string;
|
|
14
|
+
}> | undefined;
|
|
12
15
|
handleRouteRecursively(route: UIRoute): void;
|
|
13
16
|
handleRoute(route: UIRoute): Promise<void>;
|
|
14
17
|
viewWillAppear(): Promise<void>;
|
|
@@ -50,6 +50,9 @@ class UIViewController extends import_UIObject.UIObject {
|
|
|
50
50
|
this.childViewControllers = [];
|
|
51
51
|
this.view.viewController = this;
|
|
52
52
|
}
|
|
53
|
+
get routeComponent() {
|
|
54
|
+
return import_UIRoute.UIRoute.currentRoute.componentWithViewController(this.class);
|
|
55
|
+
}
|
|
53
56
|
handleRouteRecursively(route) {
|
|
54
57
|
this.handleRoute(route);
|
|
55
58
|
this.childViewControllers.forEach((controller) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/UIViewController.ts"],
|
|
4
|
-
"sourcesContent": ["import { UIDialogView } from \"./UIDialogView\"\nimport { FIRST_OR_NIL, IS,
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,
|
|
4
|
+
"sourcesContent": ["import { UIDialogView } from \"./UIDialogView\"\nimport { FIRST_OR_NIL, IS, NO, UIObject, YES } from \"./UIObject\"\nimport { UIRoute } from \"./UIRoute\"\nimport { UIView, UIViewBroadcastEvent } from \"./UIView\"\n\n\nexport class UIViewController extends UIObject {\n \n \n parentViewController?: UIViewController\n childViewControllers: UIViewController[] = []\n static readonly routeComponentName: string\n static readonly ParameterIdentifierName: any\n \n constructor(public view: UIView) {\n \n super()\n \n this.view.viewController = this\n \n }\n \n \n get routeComponent() {\n return UIRoute.currentRoute.componentWithViewController(this.class)\n }\n \n handleRouteRecursively(route: UIRoute) {\n \n this.handleRoute(route)\n \n this.childViewControllers.forEach(controller => {\n \n controller.handleRouteRecursively(route)\n \n })\n \n }\n \n async handleRoute(route: UIRoute) {\n \n \n }\n \n \n async viewWillAppear() {\n \n \n }\n \n \n async viewDidAppear() {\n \n \n }\n \n \n async viewWillDisappear() {\n \n \n }\n \n async viewDidDisappear() {\n \n \n }\n \n \n updateViewConstraints() {\n \n \n }\n \n updateViewStyles() {\n \n \n }\n \n layoutViewSubviews() {\n \n \n }\n \n _triggerLayoutViewSubviews() {\n \n if (this.view.needsLayout) {\n \n this.view.layoutSubviews()\n \n this.viewDidLayoutSubviews()\n \n }\n \n }\n \n viewWillLayoutSubviews() {\n \n this.updateViewConstraints()\n this.updateViewStyles()\n \n }\n \n viewDidLayoutSubviews() {\n \n // this.childViewControllers.forEach(function (controller, index, controllers) {\n \n // controller._layoutViewSubviews();\n \n // })\n \n \n }\n \n \n viewDidReceiveBroadcastEvent(event: UIViewBroadcastEvent) {\n \n \n }\n \n \n get core() {\n return this.view.core\n }\n \n hasChildViewController(viewController: UIViewController) {\n \n // This is for performance reasons\n if (!IS(viewController)) {\n return NO\n }\n \n for (let i = 0; i < this.childViewControllers.length; i++) {\n \n const childViewController = this.childViewControllers[i]\n \n if (childViewController == viewController) {\n return YES\n }\n \n }\n \n return NO\n \n }\n \n addChildViewController(viewController: UIViewController) {\n if (!this.hasChildViewController(viewController)) {\n viewController.willMoveToParentViewController(this)\n this.childViewControllers.push(viewController)\n this.view.addSubview(viewController.view)\n viewController.didMoveToParentViewController(this)\n }\n }\n \n \n removeFromParentViewController() {\n \n this.parentViewController?.removeChildViewController(this)\n \n }\n \n willMoveToParentViewController(parentViewController: UIViewController) {\n \n }\n \n \n didMoveToParentViewController(parentViewController: UIViewController) {\n \n this.parentViewController = parentViewController\n \n }\n \n removeChildViewController(controller: UIViewController) {\n \n controller = FIRST_OR_NIL(controller)\n controller.viewWillDisappear()\n if (IS(controller.parentViewController)) {\n \n const index = this.parentViewController?.childViewControllers.indexOf(this) ?? -1\n if (index > -1) {\n this.parentViewController?.childViewControllers.splice(index, 1)\n this.view.removeFromSuperview()\n this.parentViewController = undefined\n }\n \n }\n if (IS(controller.view)) {\n controller.view.removeFromSuperview()\n }\n controller.viewDidDisappear()\n \n }\n \n \n addChildViewControllerInContainer(controller: UIViewController, containerView: UIView) {\n \n controller = FIRST_OR_NIL(controller)\n containerView = FIRST_OR_NIL(containerView)\n controller.viewWillAppear()\n this.addChildViewController(controller)\n containerView.addSubview(controller.view)\n \n controller.handleRouteRecursively(UIRoute.currentRoute)\n \n controller.didMoveToParentViewController(this)\n controller.viewDidAppear()\n \n \n }\n \n addChildViewControllerInDialogView(controller: UIViewController, dialogView: UIDialogView) {\n \n controller = FIRST_OR_NIL(controller)\n dialogView = FIRST_OR_NIL(dialogView)\n controller.viewWillAppear()\n this.addChildViewController(controller)\n dialogView.view = controller.view\n \n const originalDismissFunction = dialogView.dismiss.bind(dialogView)\n \n dialogView.dismiss = animated => {\n \n originalDismissFunction(animated)\n \n this.removeChildViewController(controller)\n \n }\n \n controller.handleRouteRecursively(UIRoute.currentRoute)\n \n controller.didMoveToParentViewController(this)\n controller.viewDidAppear()\n \n }\n \n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAoD;AACpD,qBAAwB;AAIjB,MAAM,yBAAyB,yBAAS;AAAA,EAQ3C,YAAmB,MAAc;AAE7B,UAAM;AAFS;AAJnB,gCAA2C,CAAC;AAQxC,SAAK,KAAK,iBAAiB;AAAA,EAE/B;AAAA,EAGA,IAAI,iBAAiB;AACjB,WAAO,uBAAQ,aAAa,4BAA4B,KAAK,KAAK;AAAA,EACtE;AAAA,EAEA,uBAAuB,OAAgB;AAEnC,SAAK,YAAY,KAAK;AAEtB,SAAK,qBAAqB,QAAQ,gBAAc;AAE5C,iBAAW,uBAAuB,KAAK;AAAA,IAE3C,CAAC;AAAA,EAEL;AAAA,EAEM,YAAY,OAAgB;A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|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uicore-ts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.557",
|
|
4
4
|
"description": "UICore is a library to build native-like user interfaces using pure Typescript. No HTML is needed at all. Components are described as TS classes and all user interactions are handled explicitly. This library is strongly inspired by the UIKit framework that is used in IOS. In addition, UICore has tools to handle URL based routing, array sorting and filtering and adds a number of other utilities for convenience.",
|
|
5
5
|
"main": "compiledScripts/index.js",
|
|
6
6
|
"types": "compiledScripts/index.d.ts",
|
package/scripts/UIRoute.ts
CHANGED
|
@@ -39,35 +39,35 @@ export class UIRoute extends Array<UIRouteComponent> {
|
|
|
39
39
|
|
|
40
40
|
const components = hash.split("]")
|
|
41
41
|
components.forEach(component => {
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
const componentName = component.split("[")[0]
|
|
44
44
|
const parameters: Record<string, string> = {}
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
if (!componentName) {
|
|
47
47
|
return
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
const parametersString = component.split("[")[1] || ""
|
|
51
51
|
const parameterPairStrings = parametersString.split(",") || []
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
parameterPairStrings.forEach(pairString => {
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
const keyAndValueArray = pairString.split(":")
|
|
56
56
|
const key = decodeURIComponent(keyAndValueArray[0])
|
|
57
57
|
const value = decodeURIComponent(keyAndValueArray[1])
|
|
58
|
-
|
|
58
|
+
|
|
59
59
|
if (key) {
|
|
60
60
|
parameters[key] = value
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
})
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
|
|
65
|
+
|
|
66
66
|
this.push({
|
|
67
67
|
name: componentName,
|
|
68
68
|
parameters: parameters
|
|
69
69
|
})
|
|
70
|
-
|
|
70
|
+
|
|
71
71
|
})
|
|
72
72
|
|
|
73
73
|
|
|
@@ -81,24 +81,30 @@ export class UIRoute extends Array<UIRouteComponent> {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
84
|
apply() {
|
|
88
85
|
|
|
89
|
-
|
|
86
|
+
const stringRepresentation = this.stringRepresentation
|
|
87
|
+
if (new UIRoute(window.location.hash).stringRepresentation == stringRepresentation) {
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
window.location.hash = stringRepresentation
|
|
90
92
|
|
|
91
93
|
}
|
|
92
94
|
|
|
93
95
|
|
|
94
96
|
applyByReplacingCurrentRouteInHistory() {
|
|
95
97
|
|
|
98
|
+
const stringRepresentation = this.stringRepresentation
|
|
99
|
+
if (new UIRoute(window.location.hash).stringRepresentation == stringRepresentation) {
|
|
100
|
+
return
|
|
101
|
+
}
|
|
102
|
+
|
|
96
103
|
window.location.replace(this.linkRepresentation)
|
|
97
104
|
|
|
98
105
|
}
|
|
99
106
|
|
|
100
107
|
|
|
101
|
-
|
|
102
108
|
override copy() {
|
|
103
109
|
const result = new UIRoute(this.stringRepresentation)
|
|
104
110
|
return result
|
|
@@ -241,9 +247,9 @@ export class UIRoute extends Array<UIRouteComponent> {
|
|
|
241
247
|
})
|
|
242
248
|
result = result + "]"
|
|
243
249
|
})
|
|
244
|
-
|
|
250
|
+
|
|
245
251
|
return result
|
|
246
|
-
|
|
252
|
+
|
|
247
253
|
}
|
|
248
254
|
|
|
249
255
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UIDialogView } from "./UIDialogView"
|
|
2
|
-
import { FIRST_OR_NIL, IS,
|
|
2
|
+
import { FIRST_OR_NIL, IS, NO, UIObject, YES } from "./UIObject"
|
|
3
3
|
import { UIRoute } from "./UIRoute"
|
|
4
4
|
import { UIView, UIViewBroadcastEvent } from "./UIView"
|
|
5
5
|
|
|
@@ -21,55 +21,59 @@ export class UIViewController extends UIObject {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
|
|
24
|
+
get routeComponent() {
|
|
25
|
+
return UIRoute.currentRoute.componentWithViewController(this.class)
|
|
26
|
+
}
|
|
27
|
+
|
|
24
28
|
handleRouteRecursively(route: UIRoute) {
|
|
25
29
|
|
|
26
30
|
this.handleRoute(route)
|
|
27
|
-
|
|
28
|
-
this.childViewControllers.forEach(controller => {
|
|
29
31
|
|
|
32
|
+
this.childViewControllers.forEach(controller => {
|
|
33
|
+
|
|
30
34
|
controller.handleRouteRecursively(route)
|
|
31
|
-
|
|
35
|
+
|
|
32
36
|
})
|
|
33
37
|
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
async handleRoute(route: UIRoute) {
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
|
|
42
|
+
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
|
|
42
46
|
async viewWillAppear() {
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
|
|
48
|
+
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
|
|
48
52
|
async viewDidAppear() {
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
|
|
54
|
+
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
|
|
54
58
|
async viewWillDisappear() {
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
|
|
60
|
+
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
async viewDidDisappear() {
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
|
|
65
|
+
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
|
|
65
69
|
updateViewConstraints() {
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
|
|
71
|
+
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
updateViewStyles() {
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
|
|
76
|
+
|
|
73
77
|
}
|
|
74
78
|
|
|
75
79
|
layoutViewSubviews() {
|
|
@@ -150,13 +154,13 @@ export class UIViewController extends UIObject {
|
|
|
150
154
|
|
|
151
155
|
|
|
152
156
|
removeFromParentViewController() {
|
|
153
|
-
|
|
157
|
+
|
|
154
158
|
this.parentViewController?.removeChildViewController(this)
|
|
155
|
-
|
|
159
|
+
|
|
156
160
|
}
|
|
157
161
|
|
|
158
162
|
willMoveToParentViewController(parentViewController: UIViewController) {
|
|
159
|
-
|
|
163
|
+
|
|
160
164
|
}
|
|
161
165
|
|
|
162
166
|
|
|
@@ -167,18 +171,18 @@ export class UIViewController extends UIObject {
|
|
|
167
171
|
}
|
|
168
172
|
|
|
169
173
|
removeChildViewController(controller: UIViewController) {
|
|
170
|
-
|
|
174
|
+
|
|
171
175
|
controller = FIRST_OR_NIL(controller)
|
|
172
176
|
controller.viewWillDisappear()
|
|
173
177
|
if (IS(controller.parentViewController)) {
|
|
174
|
-
|
|
178
|
+
|
|
175
179
|
const index = this.parentViewController?.childViewControllers.indexOf(this) ?? -1
|
|
176
180
|
if (index > -1) {
|
|
177
181
|
this.parentViewController?.childViewControllers.splice(index, 1)
|
|
178
182
|
this.view.removeFromSuperview()
|
|
179
183
|
this.parentViewController = undefined
|
|
180
184
|
}
|
|
181
|
-
|
|
185
|
+
|
|
182
186
|
}
|
|
183
187
|
if (IS(controller.view)) {
|
|
184
188
|
controller.view.removeFromSuperview()
|
|
@@ -189,7 +193,7 @@ export class UIViewController extends UIObject {
|
|
|
189
193
|
|
|
190
194
|
|
|
191
195
|
addChildViewControllerInContainer(controller: UIViewController, containerView: UIView) {
|
|
192
|
-
|
|
196
|
+
|
|
193
197
|
controller = FIRST_OR_NIL(controller)
|
|
194
198
|
containerView = FIRST_OR_NIL(containerView)
|
|
195
199
|
controller.viewWillAppear()
|
|
@@ -200,22 +204,22 @@ export class UIViewController extends UIObject {
|
|
|
200
204
|
|
|
201
205
|
controller.didMoveToParentViewController(this)
|
|
202
206
|
controller.viewDidAppear()
|
|
203
|
-
|
|
204
|
-
|
|
207
|
+
|
|
208
|
+
|
|
205
209
|
}
|
|
206
210
|
|
|
207
211
|
addChildViewControllerInDialogView(controller: UIViewController, dialogView: UIDialogView) {
|
|
208
|
-
|
|
212
|
+
|
|
209
213
|
controller = FIRST_OR_NIL(controller)
|
|
210
214
|
dialogView = FIRST_OR_NIL(dialogView)
|
|
211
215
|
controller.viewWillAppear()
|
|
212
216
|
this.addChildViewController(controller)
|
|
213
217
|
dialogView.view = controller.view
|
|
214
|
-
|
|
218
|
+
|
|
215
219
|
const originalDismissFunction = dialogView.dismiss.bind(dialogView)
|
|
216
|
-
|
|
217
|
-
dialogView.dismiss = animated => {
|
|
218
220
|
|
|
221
|
+
dialogView.dismiss = animated => {
|
|
222
|
+
|
|
219
223
|
originalDismissFunction(animated)
|
|
220
224
|
|
|
221
225
|
this.removeChildViewController(controller)
|