iOS: implement NestedSlider slidePosition
This commit is contained in:
parent
18d5050c7a
commit
91d5d016f9
File diff suppressed because one or more lines are too long
@ -37,9 +37,10 @@ export class SliderInListDemo extends Panel {
|
|||||||
(
|
(
|
||||||
<ListItem layoutConfig={layoutConfig().mostWidth().fitHeight()}>
|
<ListItem layoutConfig={layoutConfig().mostWidth().fitHeight()}>
|
||||||
<Slider
|
<Slider
|
||||||
layoutConfig={layoutConfig().mostWidth().justHeight()}
|
layoutConfig={layoutConfig()
|
||||||
height={50}
|
.mostWidth()
|
||||||
backgroundColor={Color.RED}
|
.fitHeight()
|
||||||
|
.configMinHeight(1)}
|
||||||
itemCount={imageUrls.length}
|
itemCount={imageUrls.length}
|
||||||
onPageSlided={function (idx) {
|
onPageSlided={function (idx) {
|
||||||
const sliderView = this as unknown as Slider;
|
const sliderView = this as unknown as Slider;
|
||||||
|
@ -61,6 +61,15 @@ - (void)blendView:(UIScrollView *)view forPropName:(NSString *)name propValue:(i
|
|||||||
self.view.scrollsToTop = [prop boolValue];
|
self.view.scrollsToTop = [prop boolValue];
|
||||||
} else if ([@"onPageSlided" isEqualToString:name]) {
|
} else if ([@"onPageSlided" isEqualToString:name]) {
|
||||||
self.onPageSelectedFuncId = prop;
|
self.onPageSelectedFuncId = prop;
|
||||||
|
} else if ([@"slidePosition" isEqualToString:name]) {
|
||||||
|
NSUInteger slidePosition = [prop unsignedIntegerValue];
|
||||||
|
if (self.view.width > 0 && ((NSUInteger) self.view.contentOffset.x / self.view.width) == slidePosition) {
|
||||||
|
} else {
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
[self.view setContentOffset:CGPointMake(slidePosition * self.view.width, self.view.contentOffset.y)
|
||||||
|
animated:NO];
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
[super blendView:view forPropName:name propValue:prop];
|
[super blendView:view forPropName:name propValue:prop];
|
||||||
}
|
}
|
||||||
|
@ -208,15 +208,23 @@ - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collection
|
|||||||
DoricSlideItemNode *node = cell.doricSlideItemNode;
|
DoricSlideItemNode *node = cell.doricSlideItemNode;
|
||||||
node.viewId = model[@"id"];
|
node.viewId = model[@"id"];
|
||||||
[node blend:props];
|
[node blend:props];
|
||||||
[node.view.doricLayout apply:CGSizeMake(collectionView.width, collectionView.height)];
|
CGFloat maxWidth = collectionView.width;
|
||||||
|
if (collectionView.doricLayout.widthSpec == DoricLayoutFit) {
|
||||||
|
maxWidth = [[UIScreen mainScreen] bounds].size.width;
|
||||||
|
}
|
||||||
|
CGFloat maxHeight = collectionView.height;
|
||||||
|
if (collectionView.doricLayout.heightSpec == DoricLayoutFit) {
|
||||||
|
maxHeight = [[UIScreen mainScreen] bounds].size.height;
|
||||||
|
}
|
||||||
|
[node.view.doricLayout apply:CGSizeMake(maxWidth, maxHeight)];
|
||||||
[node requestLayout];
|
[node requestLayout];
|
||||||
BOOL needLayout = NO;
|
BOOL needLayout = NO;
|
||||||
if (self.view.doricLayout.widthSpec == DoricLayoutFit && self.view.width < node.view.width) {
|
if (collectionView.doricLayout.widthSpec == DoricLayoutFit && collectionView.width < node.view.width) {
|
||||||
self.view.width = node.view.width;
|
self.view.width = node.view.width;
|
||||||
needLayout = YES;
|
needLayout = YES;
|
||||||
}
|
}
|
||||||
if (self.view.doricLayout.heightSpec == DoricLayoutFit && self.view.height < node.view.height) {
|
if (collectionView.doricLayout.heightSpec == DoricLayoutFit && collectionView.height < node.view.height) {
|
||||||
self.view.height = node.view.height;
|
collectionView.height = node.view.height;
|
||||||
needLayout = YES;
|
needLayout = YES;
|
||||||
}
|
}
|
||||||
if (needLayout) {
|
if (needLayout) {
|
||||||
@ -238,6 +246,11 @@ - (void)scheduleLayout {
|
|||||||
self.scheduledLayout = NO;
|
self.scheduledLayout = NO;
|
||||||
DoricSuperNode *node = self.superNode;
|
DoricSuperNode *node = self.superNode;
|
||||||
while (node.superNode != nil) {
|
while (node.superNode != nil) {
|
||||||
|
if ([node.view isKindOfClass:UITableView.class]) {
|
||||||
|
UITableView *tableView = (UITableView *) node.view;
|
||||||
|
[tableView reloadData];
|
||||||
|
return;
|
||||||
|
}
|
||||||
node = node.superNode;
|
node = node.superNode;
|
||||||
}
|
}
|
||||||
[node requestLayout];
|
[node requestLayout];
|
||||||
|
@ -3627,6 +3627,10 @@ var NestedSlider = /** @class */ (function (_super) {
|
|||||||
Property,
|
Property,
|
||||||
__metadata$5("design:type", Boolean)
|
__metadata$5("design:type", Boolean)
|
||||||
], NestedSlider.prototype, "scrollsToTop", void 0);
|
], NestedSlider.prototype, "scrollsToTop", void 0);
|
||||||
|
__decorate$5([
|
||||||
|
InconsistProperty,
|
||||||
|
__metadata$5("design:type", Number)
|
||||||
|
], NestedSlider.prototype, "slidePosition", void 0);
|
||||||
return NestedSlider;
|
return NestedSlider;
|
||||||
}(Group));
|
}(Group));
|
||||||
|
|
||||||
|
@ -2788,6 +2788,10 @@ __decorate$5([
|
|||||||
Property,
|
Property,
|
||||||
__metadata$5("design:type", Boolean)
|
__metadata$5("design:type", Boolean)
|
||||||
], NestedSlider.prototype, "scrollsToTop", void 0);
|
], NestedSlider.prototype, "scrollsToTop", void 0);
|
||||||
|
__decorate$5([
|
||||||
|
InconsistProperty,
|
||||||
|
__metadata$5("design:type", Number)
|
||||||
|
], NestedSlider.prototype, "slidePosition", void 0);
|
||||||
|
|
||||||
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
||||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||||
|
@ -4328,6 +4328,10 @@ __decorate$5([
|
|||||||
Property,
|
Property,
|
||||||
__metadata$5("design:type", Boolean)
|
__metadata$5("design:type", Boolean)
|
||||||
], NestedSlider.prototype, "scrollsToTop", void 0);
|
], NestedSlider.prototype, "scrollsToTop", void 0);
|
||||||
|
__decorate$5([
|
||||||
|
InconsistProperty,
|
||||||
|
__metadata$5("design:type", Number)
|
||||||
|
], NestedSlider.prototype, "slidePosition", void 0);
|
||||||
|
|
||||||
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
||||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||||
|
1
doric-js/index.d.ts
vendored
1
doric-js/index.d.ts
vendored
@ -1333,6 +1333,7 @@ declare module "doric" {
|
|||||||
* Take effect only on iOS
|
* Take effect only on iOS
|
||||||
*/
|
*/
|
||||||
scrollsToTop?: boolean;
|
scrollsToTop?: boolean;
|
||||||
|
slidePosition?: number;
|
||||||
addSlideItem(view: View): void;
|
addSlideItem(view: View): void;
|
||||||
slidePage(context: BridgeContext, page: number, smooth?: boolean): Promise<any>;
|
slidePage(context: BridgeContext, page: number, smooth?: boolean): Promise<any>;
|
||||||
getSlidedPage(context: BridgeContext): Promise<number>;
|
getSlidedPage(context: BridgeContext): Promise<number>;
|
||||||
|
1
doric-js/lib/src/widget/nestedSlider.d.ts
vendored
1
doric-js/lib/src/widget/nestedSlider.d.ts
vendored
@ -11,6 +11,7 @@ export declare class NestedSlider extends Group {
|
|||||||
* Take effect only on iOS
|
* Take effect only on iOS
|
||||||
*/
|
*/
|
||||||
scrollsToTop?: boolean;
|
scrollsToTop?: boolean;
|
||||||
|
slidePosition?: number;
|
||||||
addSlideItem(view: View): void;
|
addSlideItem(view: View): void;
|
||||||
slidePage(context: BridgeContext, page: number, smooth?: boolean): Promise<any>;
|
slidePage(context: BridgeContext, page: number, smooth?: boolean): Promise<any>;
|
||||||
getSlidedPage(context: BridgeContext): Promise<number>;
|
getSlidedPage(context: BridgeContext): Promise<number>;
|
||||||
|
@ -22,7 +22,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import { Group, Property } from '../ui/view';
|
import { Group, Property, InconsistProperty } from '../ui/view';
|
||||||
export class NestedSlider extends Group {
|
export class NestedSlider extends Group {
|
||||||
addSlideItem(view) {
|
addSlideItem(view) {
|
||||||
this.addChild(view);
|
this.addChild(view);
|
||||||
@ -50,3 +50,7 @@ __decorate([
|
|||||||
Property,
|
Property,
|
||||||
__metadata("design:type", Boolean)
|
__metadata("design:type", Boolean)
|
||||||
], NestedSlider.prototype, "scrollsToTop", void 0);
|
], NestedSlider.prototype, "scrollsToTop", void 0);
|
||||||
|
__decorate([
|
||||||
|
InconsistProperty,
|
||||||
|
__metadata("design:type", Number)
|
||||||
|
], NestedSlider.prototype, "slidePosition", void 0);
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import { Group, View, Property } from '../ui/view'
|
import { Group, View, Property, InconsistProperty } from '../ui/view'
|
||||||
import { BridgeContext } from '../runtime/global'
|
import { BridgeContext } from '../runtime/global'
|
||||||
|
|
||||||
|
|
||||||
@ -35,6 +35,9 @@ export class NestedSlider extends Group {
|
|||||||
@Property
|
@Property
|
||||||
scrollsToTop?: boolean
|
scrollsToTop?: boolean
|
||||||
|
|
||||||
|
@InconsistProperty
|
||||||
|
slidePosition?: number
|
||||||
|
|
||||||
addSlideItem(view: View) {
|
addSlideItem(view: View) {
|
||||||
this.addChild(view)
|
this.addChild(view)
|
||||||
}
|
}
|
||||||
|
10
doric-web/dist/index.js
vendored
10
doric-web/dist/index.js
vendored
@ -3608,7 +3608,7 @@ __decorate$b([
|
|||||||
__metadata$b("design:type", Function)
|
__metadata$b("design:type", Function)
|
||||||
], List.prototype, "onScrollEnd", void 0);
|
], List.prototype, "onScrollEnd", void 0);
|
||||||
__decorate$b([
|
__decorate$b([
|
||||||
Property,
|
InconsistProperty,
|
||||||
__metadata$b("design:type", Number)
|
__metadata$b("design:type", Number)
|
||||||
], List.prototype, "scrolledPosition", void 0);
|
], List.prototype, "scrolledPosition", void 0);
|
||||||
__decorate$b([
|
__decorate$b([
|
||||||
@ -3762,6 +3762,10 @@ __decorate$a([
|
|||||||
Property,
|
Property,
|
||||||
__metadata$a("design:type", Object)
|
__metadata$a("design:type", Object)
|
||||||
], Slider.prototype, "slideStyle", void 0);
|
], Slider.prototype, "slideStyle", void 0);
|
||||||
|
__decorate$a([
|
||||||
|
InconsistProperty,
|
||||||
|
__metadata$a("design:type", Number)
|
||||||
|
], Slider.prototype, "slidePosition", void 0);
|
||||||
function slider(config) {
|
function slider(config) {
|
||||||
const ret = new Slider;
|
const ret = new Slider;
|
||||||
ret.apply(config);
|
ret.apply(config);
|
||||||
@ -4399,6 +4403,10 @@ __decorate$5([
|
|||||||
Property,
|
Property,
|
||||||
__metadata$5("design:type", Boolean)
|
__metadata$5("design:type", Boolean)
|
||||||
], NestedSlider.prototype, "scrollsToTop", void 0);
|
], NestedSlider.prototype, "scrollsToTop", void 0);
|
||||||
|
__decorate$5([
|
||||||
|
InconsistProperty,
|
||||||
|
__metadata$5("design:type", Number)
|
||||||
|
], NestedSlider.prototype, "slidePosition", void 0);
|
||||||
|
|
||||||
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
||||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||||
|
2
doric-web/dist/index.js.map
vendored
2
doric-web/dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user