Skip to content

Commit

Permalink
feat(ios): nested scroll api support
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwcg committed Dec 9, 2024
1 parent b319df3 commit b0a99f0
Show file tree
Hide file tree
Showing 13 changed files with 657 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ @implementation HippyNextBaseListViewManager
HIPPY_EXPORT_VIEW_PROPERTY(showScrollIndicator, BOOL)
HIPPY_EXPORT_VIEW_PROPERTY(scrollEnabled, BOOL)
HIPPY_EXPORT_VIEW_PROPERTY(horizontal, BOOL)
HIPPY_EXPORT_VIEW_PROPERTY(nestedScrollPriority, HippyNestedScrollPriority)
HIPPY_EXPORT_VIEW_PROPERTY(nestedScrollTopPriority, HippyNestedScrollPriority)
HIPPY_EXPORT_VIEW_PROPERTY(nestedScrollLeftPriority, HippyNestedScrollPriority)
HIPPY_EXPORT_VIEW_PROPERTY(nestedScrollBottomPriority, HippyNestedScrollPriority)
HIPPY_EXPORT_VIEW_PROPERTY(nestedScrollRightPriority, HippyNestedScrollPriority)


- (UIView *)view {
return [[HippyNextBaseListView alloc] init];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/

#import <UIKit/UIKit.h>
#import "HippyScrollView.h"

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -35,8 +36,11 @@ NS_ASSUME_NONNULL_BEGIN

@end

@interface HippyNextListTableView : UICollectionView

/// Custom tableView (collectionView) of Hippy
@interface HippyNextListTableView : UICollectionView <HippyNestedScrollProtocol>

/// Layout delegate
@property (nonatomic, weak) id<HippyNextListTableViewLayoutProtocol> layoutDelegate;

@end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@
*/

#import "HippyNextListTableView.h"
#import "HippyScrollView.h"

@implementation HippyNextListTableView

@synthesize lastContentOffset;
@synthesize activeInnerScrollView;
@synthesize activeOuterScrollView;
@synthesize nestedGestureDelegate;
@synthesize cascadeLockForNestedScroll;

/**
* we need scroll indicator to be at top
* indicator is UIImageView type at lower ios version
Expand All @@ -45,4 +52,14 @@ - (void)layoutSubviews {
}
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
if (self.nestedGestureDelegate &&
gestureRecognizer == self.panGestureRecognizer &&
[self.nestedGestureDelegate respondsToSelector:@selector(shouldRecognizeScrollGestureSimultaneouslyWithView:)]) {
return [self.nestedGestureDelegate shouldRecognizeScrollGestureSimultaneouslyWithView:otherGestureRecognizer.view];
}
return NO;
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*!
* iOS SDK
*
* Tencent is pleased to support the open source community by making
* Hippy available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "HippyScrollView.h"

NS_ASSUME_NONNULL_BEGIN

/// A coordinator responsible for managing scroll priorities
@interface HippyNestedScrollCoordinator : NSObject <UIScrollViewDelegate, HippyNestedScrollGestureDelegate>

/// Priority of nestedScroll in all direction.
@property (nonatomic, assign) HippyNestedScrollPriority nestedScrollPriority;
/// Priority of nestedScroll in specific direction (finger move from bottom to top).
@property (nonatomic, assign) HippyNestedScrollPriority nestedScrollTopPriority;
/// Priority of nestedScroll in specific direction (finger move from right to left).
@property (nonatomic, assign) HippyNestedScrollPriority nestedScrollLeftPriority;
/// Priority of nestedScroll in specific direction (finger move from top to bottom).
@property (nonatomic, assign) HippyNestedScrollPriority nestedScrollBottomPriority;
/// Priority of nestedScroll in specific direction (finger move from left to right).
@property (nonatomic, assign) HippyNestedScrollPriority nestedScrollRightPriority;

/// The inner scrollable view
@property (nonatomic, weak) UIScrollView<HippyNestedScrollProtocol> *innerScrollView;
/// The outer scrollable view
@property (nonatomic, weak) UIScrollView<HippyNestedScrollProtocol> *outerScrollView;

@end

NS_ASSUME_NONNULL_END
Loading

0 comments on commit b0a99f0

Please sign in to comment.