Skip to content

Commit

Permalink
feat: add keyboard avoiding view
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuan Luong authored and Tuan Luong committed Dec 1, 2021
1 parent fbba566 commit ba6700c
Show file tree
Hide file tree
Showing 11 changed files with 196 additions and 85 deletions.
72 changes: 37 additions & 35 deletions example/ios/CollapsibleExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
2D02E4BD1E0B4A84006451C7 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
2D02E4BF1E0B4AB3006451C7 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
2DCD954D1E0B4F2C00145EB5 /* CollapsibleExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* CollapsibleExampleTests.m */; };
4C39C56BAD484C67AA576FFA /* libPods-CollapsibleExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CA3E69C5B9553B26FBA2DF04 /* libPods-CollapsibleExample.a */; };
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
CF949926C9B2FB5E622E1B03 /* libPods-CollapsibleExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F5EF525A5B84B47D5151D95B /* libPods-CollapsibleExample.a */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -49,12 +49,12 @@
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = CollapsibleExample/main.m; sourceTree = "<group>"; };
2D02E47B1E0B4A5D006451C7 /* CollapsibleExample-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "CollapsibleExample-tvOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
2D02E4901E0B4A5D006451C7 /* CollapsibleExample-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "CollapsibleExample-tvOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
47F7ED3B7971BE374F7B8635 /* Pods-CollapsibleExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CollapsibleExample.debug.xcconfig"; path = "Target Support Files/Pods-CollapsibleExample/Pods-CollapsibleExample.debug.xcconfig"; sourceTree = "<group>"; };
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = CollapsibleExample/LaunchScreen.storyboard; sourceTree = "<group>"; };
CA3E69C5B9553B26FBA2DF04 /* libPods-CollapsibleExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-CollapsibleExample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
E00ACF0FDA8BF921659E2F9A /* Pods-CollapsibleExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CollapsibleExample.release.xcconfig"; path = "Target Support Files/Pods-CollapsibleExample/Pods-CollapsibleExample.release.xcconfig"; sourceTree = "<group>"; };
CA9C5E93DDB2948D402C739A /* Pods-CollapsibleExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CollapsibleExample.debug.xcconfig"; path = "Target Support Files/Pods-CollapsibleExample/Pods-CollapsibleExample.debug.xcconfig"; sourceTree = "<group>"; };
DE9B08DEBE20374F878341C7 /* Pods-CollapsibleExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CollapsibleExample.release.xcconfig"; path = "Target Support Files/Pods-CollapsibleExample/Pods-CollapsibleExample.release.xcconfig"; sourceTree = "<group>"; };
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
ED2971642150620600B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS12.0.sdk/System/Library/Frameworks/JavaScriptCore.framework; sourceTree = DEVELOPER_DIR; };
F5EF525A5B84B47D5151D95B /* libPods-CollapsibleExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-CollapsibleExample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -69,7 +69,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
4C39C56BAD484C67AA576FFA /* libPods-CollapsibleExample.a in Frameworks */,
CF949926C9B2FB5E622E1B03 /* libPods-CollapsibleExample.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -126,16 +126,16 @@
children = (
ED297162215061F000B7C4FE /* JavaScriptCore.framework */,
ED2971642150620600B7C4FE /* JavaScriptCore.framework */,
CA3E69C5B9553B26FBA2DF04 /* libPods-CollapsibleExample.a */,
F5EF525A5B84B47D5151D95B /* libPods-CollapsibleExample.a */,
);
name = Frameworks;
sourceTree = "<group>";
};
6B9684456A2045ADE5A6E47E /* Pods */ = {
isa = PBXGroup;
children = (
47F7ED3B7971BE374F7B8635 /* Pods-CollapsibleExample.debug.xcconfig */,
E00ACF0FDA8BF921659E2F9A /* Pods-CollapsibleExample.release.xcconfig */,
CA9C5E93DDB2948D402C739A /* Pods-CollapsibleExample.debug.xcconfig */,
DE9B08DEBE20374F878341C7 /* Pods-CollapsibleExample.release.xcconfig */,
);
path = Pods;
sourceTree = "<group>";
Expand Down Expand Up @@ -198,14 +198,14 @@
isa = PBXNativeTarget;
buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "CollapsibleExample" */;
buildPhases = (
4F0A6FC082772762E3E4C96C /* [CP] Check Pods Manifest.lock */,
3220FEC3544BA5FA60FEEEB7 /* [CP] Check Pods Manifest.lock */,
FD10A7F022414F080027D42C /* Start Packager */,
13B07F871A680F5B00A75B9A /* Sources */,
13B07F8C1A680F5B00A75B9A /* Frameworks */,
13B07F8E1A680F5B00A75B9A /* Resources */,
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
C1D60D28B925C94BD88E79D7 /* [CP] Copy Pods Resources */,
98038AC17C0DA41A0E475048 /* [CP] Embed Pods Frameworks */,
6B71F767E1D2123EDCA46D95 /* [CP] Embed Pods Frameworks */,
1B5862C159B9205B90BDE2E3 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -349,6 +349,24 @@
shellPath = /bin/sh;
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh";
};
1B5862C159B9205B90BDE2E3 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-CollapsibleExample/Pods-CollapsibleExample-resources.sh",
"${PODS_CONFIGURATION_BUILD_DIR}/React-Core/AccessibilityResources.bundle",
);
name = "[CP] Copy Pods Resources";
outputPaths = (
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/AccessibilityResources.bundle",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CollapsibleExample/Pods-CollapsibleExample-resources.sh\"\n";
showEnvVarsInLog = 0;
};
2D02E4CB1E0B4B27006451C7 /* Bundle React Native Code And Images */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand All @@ -363,7 +381,7 @@
shellPath = /bin/sh;
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh";
};
4F0A6FC082772762E3E4C96C /* [CP] Check Pods Manifest.lock */ = {
3220FEC3544BA5FA60FEEEB7 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
Expand All @@ -385,7 +403,7 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
98038AC17C0DA41A0E475048 /* [CP] Embed Pods Frameworks */ = {
6B71F767E1D2123EDCA46D95 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
Expand All @@ -403,24 +421,6 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CollapsibleExample/Pods-CollapsibleExample-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
C1D60D28B925C94BD88E79D7 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-CollapsibleExample/Pods-CollapsibleExample-resources.sh",
"${PODS_CONFIGURATION_BUILD_DIR}/React-Core/AccessibilityResources.bundle",
);
name = "[CP] Copy Pods Resources";
outputPaths = (
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/AccessibilityResources.bundle",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CollapsibleExample/Pods-CollapsibleExample-resources.sh\"\n";
showEnvVarsInLog = 0;
};
FD10A7F022414F080027D42C /* Start Packager */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -555,12 +555,13 @@
};
13B07F941A680F5B00A75B9A /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 47F7ED3B7971BE374F7B8635 /* Pods-CollapsibleExample.debug.xcconfig */;
baseConfigurationReference = CA9C5E93DDB2948D402C739A /* Pods-CollapsibleExample.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
ENABLE_BITCODE = NO;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "i386 arm64";
INFOPLIST_FILE = CollapsibleExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
Expand All @@ -578,11 +579,12 @@
};
13B07F951A680F5B00A75B9A /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = E00ACF0FDA8BF921659E2F9A /* Pods-CollapsibleExample.release.xcconfig */;
baseConfigurationReference = DE9B08DEBE20374F878341C7 /* Pods-CollapsibleExample.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "i386 arm64";
INFOPLIST_FILE = CollapsibleExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
Expand Down Expand Up @@ -735,7 +737,7 @@
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 i386";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -796,7 +798,7 @@
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 i386";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,52 @@
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
4 changes: 4 additions & 0 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@ target 'CollapsibleExample' do
# use_flipper!()
post_install do |installer|
react_native_post_install(installer)

installer.pods_project.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64 i386"
end
end
end
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,6 @@ SPEC CHECKSUMS:
RNScreens: 21b73c94c9117e1110a79ee0ee80c93ccefed8ce
Yoga: c36762154e856af6b7e3605e40b66a1f84044d12

PODFILE CHECKSUM: 69701926c43adba0d37cec23a6672f27d660945b
PODFILE CHECKSUM: 4f9ac1f7798cd4790a3cc8d1c0660a1bf1f4e044

COCOAPODS: 1.11.2
27 changes: 22 additions & 5 deletions example/src/screens/CollapsibleList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import React, { useState } from 'react';
import { Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import React, { useRef, useState } from 'react';
import {
Image,
StyleSheet,
Text,
TextInput,
TouchableOpacity,
View,
} from 'react-native';
import {
CollapsibleContainer,
CollapsibleHeaderContainer,
Expand All @@ -15,14 +22,18 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context';
function CollapsibleList() {
const [currentTab, setCurrentTab] = useState(0);
const { top } = useSafeAreaInsets();
const textInput = useRef(null);

function renderHeder(props: any) {
return <CollapsibleHeaderText title="Collapsible view" {...props} />;
}

return (
<View style={styles.container}>
<CollapsibleContainer style={styles.contentContainer}>
<CollapsibleContainer
style={styles.contentContainer}
textInputRefs={[textInput]}
>
<CollapsibleHeaderContainer>
<View pointerEvents="box-none" style={styles.infoContainer}>
<View style={styles.backgroundTop} />
Expand All @@ -37,7 +48,12 @@ function CollapsibleList() {
<Text style={styles.name}>Alan Walker</Text>
</View>
<CollapsibleView renderHeader={renderHeder}>
<View style={styles.collapsibleView} />
<View style={styles.collapsibleView} pointerEvents="box-none">
<TextInput
ref={textInput}
placeholder="Avoiding keyboard textinput"
/>
</View>
</CollapsibleView>
<StickyView style={{ paddingTop: top }}>
<View style={styles.tabsContainer}>
Expand Down Expand Up @@ -150,7 +166,8 @@ const styles = StyleSheet.create({
color: '#7339B3',
},
collapsibleView: {
height: 100,
height: 500,
backgroundColor: 'yellow',
justifyContent: 'flex-end',
},
});
Loading

0 comments on commit ba6700c

Please sign in to comment.