uicore-ts 1.1.127 → 1.1.141
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/UIRectangle.d.ts +1 -1
- package/compiledScripts/UIRectangle.js +2 -1
- package/compiledScripts/UIRectangle.js.map +2 -2
- package/compiledScripts/UIRootViewController.d.ts +6 -1
- package/compiledScripts/UIRootViewController.js +48 -13
- package/compiledScripts/UIRootViewController.js.map +2 -2
- package/compiledScripts/UITableView.d.ts +1 -1
- package/compiledScripts/UITableView.js +3 -2
- package/compiledScripts/UITableView.js.map +2 -2
- package/compiledScripts/UIView.d.ts +7 -0
- package/compiledScripts/UIView.js +10 -1
- package/compiledScripts/UIView.js.map +2 -2
- package/package.json +1 -1
- package/scripts/UIRectangle.ts +2 -1
- package/scripts/UIRootViewController.ts +70 -19
- package/scripts/UITableView.ts +3 -2
- package/scripts/UIView.ts +15 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uicore-ts",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.141",
|
|
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/UIRectangle.ts
CHANGED
|
@@ -917,8 +917,9 @@ export class UIRectangle extends UIObject {
|
|
|
917
917
|
}
|
|
918
918
|
|
|
919
919
|
|
|
920
|
-
assignedAsFrameOfView(view: UIView) {
|
|
920
|
+
assignedAsFrameOfView(view: UIView, isWeakFrame = view.hasWeakFrame) {
|
|
921
921
|
view.frame = this
|
|
922
|
+
view.hasWeakFrame = isWeakFrame
|
|
922
923
|
return this
|
|
923
924
|
}
|
|
924
925
|
|
|
@@ -12,7 +12,9 @@ export interface UIRootViewControllerLazyViewControllerObject<T extends typeof U
|
|
|
12
12
|
instance: InstanceType<T>;
|
|
13
13
|
class: T;
|
|
14
14
|
shouldShow: () => (Promise<boolean> | boolean);
|
|
15
|
-
isInitialized: boolean
|
|
15
|
+
isInitialized: boolean;
|
|
16
|
+
deleteOnUnload: boolean;
|
|
17
|
+
deleteInstance: () => void
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
|
|
@@ -69,38 +71,57 @@ export class UIRootViewController extends UIViewController {
|
|
|
69
71
|
|
|
70
72
|
lazyViewControllerObjectWithClass<T extends typeof UIViewController>(
|
|
71
73
|
classObject: T,
|
|
72
|
-
|
|
74
|
+
options: {
|
|
75
|
+
shouldShow?: () => (Promise<boolean> | boolean),
|
|
76
|
+
deleteOnUnload?: boolean
|
|
77
|
+
} = {}
|
|
73
78
|
): UIRootViewControllerLazyViewControllerObject<T> {
|
|
79
|
+
const shouldShow = options.shouldShow ?? (() => YES)
|
|
80
|
+
const deleteOnUnload = options.deleteOnUnload ?? NO
|
|
81
|
+
|
|
74
82
|
const result: UIRootViewControllerLazyViewControllerObject<T> = {
|
|
75
83
|
class: classObject,
|
|
76
84
|
instance: nil,
|
|
77
85
|
shouldShow: shouldShow,
|
|
78
|
-
isInitialized: NO
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
result.isInitialized = YES
|
|
85
|
-
return new classObject(
|
|
86
|
-
new UIView(classObject.name.replace("ViewController", "View"))
|
|
87
|
-
)
|
|
86
|
+
isInitialized: NO,
|
|
87
|
+
deleteOnUnload: deleteOnUnload,
|
|
88
|
+
deleteInstance: () => {
|
|
89
|
+
if (result.isInitialized) {
|
|
90
|
+
result.isInitialized = NO
|
|
91
|
+
initializeLazyInstance()
|
|
88
92
|
}
|
|
89
|
-
|
|
90
|
-
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const initializeLazyInstance = () => {
|
|
97
|
+
UIObject.configureWithObject(result, {
|
|
98
|
+
// @ts-ignore
|
|
99
|
+
instance: LAZY_VALUE(
|
|
100
|
+
() => {
|
|
101
|
+
result.isInitialized = YES
|
|
102
|
+
return new classObject(
|
|
103
|
+
new UIView(classObject.name.replace("ViewController", "View"))
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
)
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
initializeLazyInstance()
|
|
111
|
+
|
|
91
112
|
return result
|
|
92
113
|
}
|
|
93
114
|
|
|
94
115
|
|
|
95
116
|
override async handleRoute(route: UIRoute) {
|
|
96
|
-
|
|
117
|
+
|
|
97
118
|
await super.handleRoute(route)
|
|
98
|
-
|
|
119
|
+
|
|
99
120
|
UICore.languageService.updateCurrentLanguageKey()
|
|
100
|
-
|
|
121
|
+
|
|
101
122
|
// Show content view
|
|
102
123
|
await this.setContentViewControllerForRoute(route)
|
|
103
|
-
|
|
124
|
+
|
|
104
125
|
await this.setDetailsViewControllerForRoute(route)
|
|
105
126
|
|
|
106
127
|
}
|
|
@@ -113,6 +134,17 @@ export class UIRootViewController extends UIViewController {
|
|
|
113
134
|
),
|
|
114
135
|
this.contentViewControllers.mainViewController
|
|
115
136
|
)
|
|
137
|
+
|
|
138
|
+
// Delete old view controller if it has deleteOnUnload flag set
|
|
139
|
+
if (IS(this._contentViewController) && this._contentViewController !== contentViewControllerObject.instance) {
|
|
140
|
+
const oldViewControllerObject = this.contentViewControllers.allValues.find(
|
|
141
|
+
value => value.isInitialized && value.instance === this._contentViewController
|
|
142
|
+
)
|
|
143
|
+
if (oldViewControllerObject?.deleteOnUnload) {
|
|
144
|
+
oldViewControllerObject.deleteInstance()
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
116
148
|
this.contentViewController = contentViewControllerObject.instance
|
|
117
149
|
}
|
|
118
150
|
|
|
@@ -123,12 +155,31 @@ export class UIRootViewController extends UIViewController {
|
|
|
123
155
|
)
|
|
124
156
|
)
|
|
125
157
|
if (IS(route) && IS(this.detailsViewController) && IS_NOT(detailsViewControllerObject)) {
|
|
158
|
+
// Delete old details view controller if it has deleteOnUnload flag set
|
|
159
|
+
const oldViewControllerObject = this.detailsViewControllers.allValues.find(
|
|
160
|
+
value => value.isInitialized && value.instance === this._detailsViewController
|
|
161
|
+
)
|
|
162
|
+
if (oldViewControllerObject?.deleteOnUnload) {
|
|
163
|
+
oldViewControllerObject.deleteInstance()
|
|
164
|
+
}
|
|
165
|
+
|
|
126
166
|
this.detailsViewController = undefined
|
|
127
167
|
this._detailsDialogView.dismiss()
|
|
128
168
|
this.view.setNeedsLayout()
|
|
129
169
|
return
|
|
130
170
|
}
|
|
131
|
-
|
|
171
|
+
|
|
172
|
+
// Delete old details view controller if it has deleteOnUnload flag set and is being replaced
|
|
173
|
+
if (IS(this._detailsViewController) && this._detailsViewController !== detailsViewControllerObject?.instance) {
|
|
174
|
+
const oldViewControllerObject = this.detailsViewControllers.allValues.find(
|
|
175
|
+
value => value.isInitialized && value.instance === this._detailsViewController
|
|
176
|
+
)
|
|
177
|
+
if (oldViewControllerObject?.deleteOnUnload) {
|
|
178
|
+
oldViewControllerObject.deleteInstance()
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
this.detailsViewController = detailsViewControllerObject?.instance
|
|
132
183
|
}
|
|
133
184
|
|
|
134
185
|
get contentViewController(): UIViewController | undefined {
|
package/scripts/UITableView.ts
CHANGED
|
@@ -197,6 +197,7 @@ export class UITableView extends UINativeScrollView {
|
|
|
197
197
|
invalidateSizeOfRowWithIndex(index: number, animateChange = NO) {
|
|
198
198
|
if (this._rowPositions?.[index]) {
|
|
199
199
|
this._rowPositions[index].isValid = NO
|
|
200
|
+
this._rowPositions.slice(index, -1).everyElement.isValid = NO
|
|
200
201
|
}
|
|
201
202
|
this._highestValidRowPositionIndex = Math.min(this._highestValidRowPositionIndex, index - 1)
|
|
202
203
|
this._needsDrawingOfVisibleRowsBeforeLayout = YES
|
|
@@ -624,8 +625,8 @@ export class UITableView extends UINativeScrollView {
|
|
|
624
625
|
}
|
|
625
626
|
|
|
626
627
|
|
|
627
|
-
override
|
|
628
|
-
super.
|
|
628
|
+
override clearIntrinsicSizeCache() {
|
|
629
|
+
super.clearIntrinsicSizeCache()
|
|
629
630
|
this.invalidateSizeOfRowWithIndex(0)
|
|
630
631
|
}
|
|
631
632
|
|
package/scripts/UIView.ts
CHANGED
|
@@ -1130,6 +1130,20 @@ export class UIView extends UIObject {
|
|
|
1130
1130
|
}
|
|
1131
1131
|
}
|
|
1132
1132
|
|
|
1133
|
+
// If YES, then the view is not counted in intrinsic content size calculation.
|
|
1134
|
+
// This should be used for things like background views that just take the shape of the parent view.
|
|
1135
|
+
hasWeakFrame = NO
|
|
1136
|
+
// Set view as having a weak frame and set the frame.
|
|
1137
|
+
public set weakFrame(rectangle: UIRectangle & { zIndex?: number }) {
|
|
1138
|
+
this.hasWeakFrame = YES
|
|
1139
|
+
this.frame = rectangle
|
|
1140
|
+
}
|
|
1141
|
+
// Set view as having a strong frame and set the frame.
|
|
1142
|
+
public set strongFrame(rectangle: UIRectangle & { zIndex?: number }) {
|
|
1143
|
+
this.hasWeakFrame = NO
|
|
1144
|
+
this.frame = rectangle
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1133
1147
|
|
|
1134
1148
|
setFrame(rectangle: UIRectangle & { zIndex?: number }, zIndex = 0, performUncheckedLayout = NO) {
|
|
1135
1149
|
|
|
@@ -3763,7 +3777,7 @@ export class UIView extends UIObject {
|
|
|
3763
3777
|
|
|
3764
3778
|
const framePoints: UIPoint[] = []
|
|
3765
3779
|
this.subviews.forEach(subview => {
|
|
3766
|
-
if (subview == this._loadingView) {
|
|
3780
|
+
if (subview == this._loadingView || subview.hasWeakFrame) {
|
|
3767
3781
|
return
|
|
3768
3782
|
}
|
|
3769
3783
|
subview.layoutIfNeeded()
|