Skip to content

Commit c378a49

Browse files
committed
refactor: rename scrollViewPinning to scrollable
1 parent 6014a31 commit c378a49

9 files changed

Lines changed: 43 additions & 42 deletions

File tree

android/src/main/java/com/lodev09/truesheet/TrueSheetContainerView.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class TrueSheetContainerView(reactContext: ThemedReactContext) :
3737

3838
var insetAdjustment: String = "automatic"
3939
var scrollViewBottomInset: Int = 0
40-
var scrollViewPinningEnabled: Boolean = false
40+
var scrollableEnabled: Boolean = false
4141
var scrollableOptions: ReadableMap? = null
4242
set(value) {
4343
field = value
@@ -53,9 +53,9 @@ class TrueSheetContainerView(reactContext: ThemedReactContext) :
5353
clipToPadding = false
5454
}
5555

56-
fun setupContentScrollViewPinning() {
56+
fun setupScrollable() {
5757
val bottomInset = if (insetAdjustment == "automatic") scrollViewBottomInset else 0
58-
contentView?.setupScrollViewPinning(scrollViewPinningEnabled, bottomInset)
58+
contentView?.setupScrollable(scrollableEnabled, bottomInset)
5959
}
6060

6161
fun setupKeyboardHandler() {

android/src/main/java/com/lodev09/truesheet/TrueSheetContentView.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ class TrueSheetContentView(private val reactContext: ThemedReactContext) : React
5252
}
5353
}
5454

55-
fun setupScrollViewPinning(enabled: Boolean, bottomInset: Int) {
55+
fun setupScrollable(enabled: Boolean, bottomInset: Int) {
5656
if (!enabled) {
57-
clearScrollViewPinning()
57+
clearScrollable()
5858
return
5959
}
6060

@@ -89,7 +89,7 @@ class TrueSheetContentView(private val reactContext: ThemedReactContext) : React
8989
}
9090
}
9191

92-
fun clearScrollViewPinning() {
92+
fun clearScrollable() {
9393
pinnedScrollView?.setPadding(
9494
pinnedScrollView!!.paddingLeft,
9595
pinnedScrollView!!.paddingTop,

android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
120120
if (child is TrueSheetContainerView) {
121121
child.delegate = this
122122
viewController.createSheet()
123-
setupContentScrollViewPinning()
123+
setupScrollable()
124124

125125
val surfaceId = UIManagerHelper.getSurfaceId(this)
126126
eventDispatcher?.dispatchEvent(MountEvent(surfaceId, id))
@@ -186,7 +186,7 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
186186
* Reconfigures the sheet if it's currently presented.
187187
*/
188188
fun finalizeUpdates() {
189-
setupContentScrollViewPinning()
189+
setupScrollable()
190190

191191
if (viewController.isPresented) {
192192
viewController.sheetView?.setupBackground()
@@ -256,26 +256,26 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
256256

257257
fun setInsetAdjustment(insetAdjustment: String) {
258258
viewController.insetAdjustment = insetAdjustment
259-
setupContentScrollViewPinning()
259+
setupScrollable()
260260
}
261261

262262
fun setScrollable(scrollable: Boolean) {
263263
viewController.scrollable = scrollable
264-
setupContentScrollViewPinning()
264+
setupScrollable()
265265
}
266266

267267
fun setScrollableOptions(options: ReadableMap?) {
268268
viewController.scrollableOptions = options
269-
setupContentScrollViewPinning()
269+
setupScrollable()
270270
}
271271

272-
private fun setupContentScrollViewPinning() {
272+
private fun setupScrollable() {
273273
viewController.containerView?.let {
274274
it.insetAdjustment = viewController.insetAdjustment
275-
it.scrollViewPinningEnabled = viewController.scrollable
275+
it.scrollableEnabled = viewController.scrollable
276276
it.scrollViewBottomInset = viewController.contentBottomInset
277277
it.scrollableOptions = viewController.scrollableOptions
278-
it.setupContentScrollViewPinning()
278+
it.setupScrollable()
279279
}
280280
}
281281

example/shared/src/components/sheets/PromptSheet.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export const PromptSheet = forwardRef((props: PromptSheetProps, ref: Ref<TrueShe
9292
nestedScrollEnabled
9393
keyboardShouldPersistTaps="handled"
9494
contentContainerStyle={styles.content}
95+
scrollIndicatorInsets={{ bottom: FOOTER_HEIGHT }}
9596
>
9697
<Input ref={input1Ref} placeholder="First name" />
9798
<Input ref={input2Ref} placeholder="Last name" />

ios/TrueSheetContainerView.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ NS_ASSUME_NONNULL_BEGIN
3939
@property (nonatomic, weak, nullable) id<TrueSheetContainerViewDelegate> delegate;
4040

4141
/**
42-
* Enable ScrollView pinning
42+
* Enable scrollable content
4343
*/
44-
@property (nonatomic, assign) BOOL scrollViewPinningEnabled;
44+
@property (nonatomic, assign) BOOL scrollableEnabled;
4545

4646
/**
47-
* Inset adjustment mode for pinned ScrollView
47+
* Inset adjustment mode for scrollable content
4848
*/
4949
@property (nonatomic, copy, nullable) NSString *insetAdjustment;
5050

@@ -69,9 +69,9 @@ NS_ASSUME_NONNULL_BEGIN
6969
- (void)layoutFooter;
7070

7171
/**
72-
* Setup ScrollView pinning
72+
* Setup scrollable content
7373
*/
74-
- (void)setupContentScrollViewPinning;
74+
- (void)setupScrollable;
7575

7676
/**
7777
* Setup keyboard observer for content and footer

ios/TrueSheetContainerView.mm

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ @implementation TrueSheetContainerView {
3434
TrueSheetHeaderView *_headerView;
3535
TrueSheetFooterView *_footerView;
3636
TrueSheetKeyboardObserver *_keyboardObserver;
37-
BOOL _scrollViewPinningSet;
37+
BOOL _scrollableSet;
3838
}
3939

4040
#pragma mark - Initialization
@@ -52,7 +52,7 @@ - (instancetype)initWithFrame:(CGRect)frame {
5252
_contentView = nil;
5353
_headerView = nil;
5454
_footerView = nil;
55-
_scrollViewPinningSet = NO;
55+
_scrollableSet = NO;
5656
}
5757
return self;
5858
}
@@ -81,9 +81,9 @@ - (void)layoutFooter {
8181
}
8282
}
8383

84-
- (void)setScrollViewPinningEnabled:(BOOL)scrollViewPinningEnabled {
85-
_scrollViewPinningEnabled = scrollViewPinningEnabled;
86-
_scrollViewPinningSet = YES;
84+
- (void)setScrollableEnabled:(BOOL)scrollableEnabled {
85+
_scrollableEnabled = scrollableEnabled;
86+
_scrollableSet = YES;
8787
}
8888

8989
- (void)setScrollableOptions:(NSDictionary *)scrollableOptions {
@@ -96,13 +96,13 @@ - (void)setScrollableOptions:(NSDictionary *)scrollableOptions {
9696
}
9797
}
9898

99-
- (void)setupContentScrollViewPinning {
100-
if (_scrollViewPinningSet && _contentView) {
99+
- (void)setupScrollable {
100+
if (_scrollableSet && _contentView) {
101101
CGFloat bottomInset = 0;
102102
if ([_insetAdjustment isEqualToString:@"automatic"]) {
103103
bottomInset = [WindowUtil keyWindow].safeAreaInsets.bottom;
104104
}
105-
[_contentView setupScrollViewPinning:_scrollViewPinningEnabled bottomInset:bottomInset];
105+
[_contentView setupScrollable:_scrollableEnabled bottomInset:bottomInset];
106106
}
107107
}
108108

@@ -169,7 +169,7 @@ - (void)contentViewDidChangeSize:(CGSize)newSize {
169169
}
170170

171171
- (void)contentViewDidChangeChildren {
172-
[self setupContentScrollViewPinning];
172+
[self setupScrollable];
173173
}
174174

175175
#pragma mark - TrueSheetHeaderViewDelegate

ios/TrueSheetContentView.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ NS_ASSUME_NONNULL_BEGIN
3535
- (RCTScrollViewComponentView *_Nullable)findScrollView;
3636

3737
/**
38-
* Setup ScrollView pinning
39-
* @param pinned Whether to pin the scroll view
38+
* Setup scrollable content
39+
* @param enabled Whether scrollable is enabled
4040
* @param bottomInset Bottom content inset for the scroll view
4141
*/
42-
- (void)setupScrollViewPinning:(BOOL)pinned bottomInset:(CGFloat)bottomInset;
42+
- (void)setupScrollable:(BOOL)enabled bottomInset:(CGFloat)bottomInset;
4343

4444
/**
4545
* Update the pinned scroll view's height to fill the container

ios/TrueSheetContentView.mm

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childCompo
6565
[self.delegate contentViewDidChangeChildren];
6666
}
6767

68-
#pragma mark - ScrollView Pinning
68+
#pragma mark - Scrollable
6969

70-
- (void)clearPinning {
70+
- (void)clearScrollable {
7171
if (_pinnedScrollView) {
7272
CGRect frame = _pinnedScrollView.frame;
7373
frame.size.height = _originalScrollViewHeight;
@@ -87,13 +87,13 @@ - (void)clearPinning {
8787
_originalIndicatorBottomInset = 0;
8888
}
8989

90-
- (void)setupScrollViewPinning:(BOOL)pinned bottomInset:(CGFloat)bottomInset {
91-
if (!pinned) {
92-
[self clearPinning];
90+
- (void)setupScrollable:(BOOL)enabled bottomInset:(CGFloat)bottomInset {
91+
if (!enabled) {
92+
[self clearScrollable];
9393
return;
9494
}
9595

96-
// Already pinned with same inset
96+
// Already set up with same inset
9797
if (_pinnedScrollView && _bottomInset == bottomInset) {
9898
return;
9999
}
@@ -232,7 +232,7 @@ - (void)keyboardWillHide:(NSTimeInterval)duration curve:(UIViewAnimationOptions)
232232

233233
- (void)prepareForRecycle {
234234
[super prepareForRecycle];
235-
[self clearPinning];
235+
[self clearScrollable];
236236
}
237237

238238
@end

ios/TrueSheetView.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &
254254
_controller.insetAdjustment = _insetAdjustment;
255255

256256
if (_containerView) {
257-
_containerView.scrollViewPinningEnabled = _scrollable;
257+
_containerView.scrollableEnabled = _scrollable;
258258
_containerView.insetAdjustment = _insetAdjustment;
259259
_containerView.scrollableOptions = _scrollableOptions;
260260
}
@@ -299,7 +299,7 @@ - (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask {
299299
return;
300300

301301
if (_containerView) {
302-
[_containerView setupContentScrollViewPinning];
302+
[_containerView setupScrollable];
303303
}
304304

305305
if (_controller.isPresented) {
@@ -366,10 +366,10 @@ - (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childCompone
366366
_controller.headerHeight = @(headerHeight);
367367
}
368368

369-
_containerView.scrollViewPinningEnabled = _scrollable;
369+
_containerView.scrollableEnabled = _scrollable;
370370
_containerView.insetAdjustment = _insetAdjustment;
371371
_containerView.scrollableOptions = _scrollableOptions;
372-
[_containerView setupContentScrollViewPinning];
372+
[_containerView setupScrollable];
373373

374374
if (_eventEmitter) {
375375
[TrueSheetLifecycleEvents emitMount:_eventEmitter];

0 commit comments

Comments
 (0)