├── .gitignore ├── .travis.yml ├── Examples ├── Podfile ├── Podfile.lock ├── Pods │ ├── Local Podspecs │ │ └── RATreeView.podspec.json │ ├── Manifest.lock │ ├── Pods.xcodeproj │ │ └── project.pbxproj │ └── Target Support Files │ │ ├── Pods-RATreeViewBasicExample │ │ ├── Info.plist │ │ ├── Pods-RATreeViewBasicExample-acknowledgements.markdown │ │ ├── Pods-RATreeViewBasicExample-acknowledgements.plist │ │ ├── Pods-RATreeViewBasicExample-dummy.m │ │ ├── Pods-RATreeViewBasicExample-frameworks.sh │ │ ├── Pods-RATreeViewBasicExample-resources.sh │ │ ├── Pods-RATreeViewBasicExample-umbrella.h │ │ ├── Pods-RATreeViewBasicExample.debug.xcconfig │ │ ├── Pods-RATreeViewBasicExample.modulemap │ │ └── Pods-RATreeViewBasicExample.release.xcconfig │ │ ├── Pods-RATreeViewBasicExampleSwift │ │ ├── Info.plist │ │ ├── Pods-RATreeViewBasicExampleSwift-acknowledgements.markdown │ │ ├── Pods-RATreeViewBasicExampleSwift-acknowledgements.plist │ │ ├── Pods-RATreeViewBasicExampleSwift-dummy.m │ │ ├── Pods-RATreeViewBasicExampleSwift-frameworks.sh │ │ ├── Pods-RATreeViewBasicExampleSwift-resources.sh │ │ ├── Pods-RATreeViewBasicExampleSwift-umbrella.h │ │ ├── Pods-RATreeViewBasicExampleSwift.debug.xcconfig │ │ ├── Pods-RATreeViewBasicExampleSwift.modulemap │ │ └── Pods-RATreeViewBasicExampleSwift.release.xcconfig │ │ ├── Pods-RATreeViewTVExample │ │ ├── Info.plist │ │ ├── Pods-RATreeViewTVExample-acknowledgements.markdown │ │ ├── Pods-RATreeViewTVExample-acknowledgements.plist │ │ ├── Pods-RATreeViewTVExample-dummy.m │ │ ├── Pods-RATreeViewTVExample-frameworks.sh │ │ ├── Pods-RATreeViewTVExample-resources.sh │ │ ├── Pods-RATreeViewTVExample-umbrella.h │ │ ├── Pods-RATreeViewTVExample.debug.xcconfig │ │ ├── Pods-RATreeViewTVExample.modulemap │ │ └── Pods-RATreeViewTVExample.release.xcconfig │ │ ├── RATreeView-iOS │ │ ├── Info.plist │ │ ├── RATreeView-iOS-dummy.m │ │ ├── RATreeView-iOS-prefix.pch │ │ ├── RATreeView-iOS-umbrella.h │ │ ├── RATreeView-iOS.modulemap │ │ └── RATreeView-iOS.xcconfig │ │ └── RATreeView-tvOS │ │ ├── Info.plist │ │ ├── RATreeView-tvOS-dummy.m │ │ ├── RATreeView-tvOS-prefix.pch │ │ ├── RATreeView-tvOS-umbrella.h │ │ ├── RATreeView-tvOS.modulemap │ │ └── RATreeView-tvOS.xcconfig ├── RATreeViewBasicExample │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ └── LaunchScreen.storyboard │ ├── Info.plist │ ├── RAAppDelegate.h │ ├── RAAppDelegate.m │ ├── RADataObject.h │ ├── RADataObject.m │ ├── RATableViewCell.h │ ├── RATableViewCell.m │ ├── RATableViewCell.xib │ ├── RAViewController.h │ ├── RAViewController.m │ └── main.m ├── RATreeViewBasicExampleSwift │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ ├── TreeTableViewCell.swift │ ├── TreeTableViewCell.xib │ └── TreeViewController.swift ├── RATreeViewExamples.xcodeproj │ └── project.pbxproj ├── RATreeViewTVExample │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ ├── App Icon & Top Shelf Image.brandassets │ │ │ ├── App Icon - Large.imagestack │ │ │ │ ├── Back.imagestacklayer │ │ │ │ │ ├── Content.imageset │ │ │ │ │ │ └── Contents.json │ │ │ │ │ └── Contents.json │ │ │ │ ├── Contents.json │ │ │ │ ├── Front.imagestacklayer │ │ │ │ │ ├── Content.imageset │ │ │ │ │ │ └── Contents.json │ │ │ │ │ └── Contents.json │ │ │ │ └── Middle.imagestacklayer │ │ │ │ │ ├── Content.imageset │ │ │ │ │ └── Contents.json │ │ │ │ │ └── Contents.json │ │ │ ├── App Icon - Small.imagestack │ │ │ │ ├── Back.imagestacklayer │ │ │ │ │ ├── Content.imageset │ │ │ │ │ │ └── Contents.json │ │ │ │ │ └── Contents.json │ │ │ │ ├── Contents.json │ │ │ │ ├── Front.imagestacklayer │ │ │ │ │ ├── Content.imageset │ │ │ │ │ │ └── Contents.json │ │ │ │ │ └── Contents.json │ │ │ │ └── Middle.imagestacklayer │ │ │ │ │ ├── Content.imageset │ │ │ │ │ └── Contents.json │ │ │ │ │ └── Contents.json │ │ │ ├── Contents.json │ │ │ └── Top Shelf Image.imageset │ │ │ │ └── Contents.json │ │ ├── Contents.json │ │ └── LaunchImage.launchimage │ │ │ └── Contents.json │ ├── Base.lproj │ │ └── Main.storyboard │ ├── Info.plist │ ├── TreeTableViewCell.swift │ ├── TreeTableViewCell.xib │ └── ViewController.swift └── Shared │ └── DataObject.swift ├── LICENCE.md ├── RATreeView.podspec.json ├── RATreeView ├── Framework │ └── Info.plist ├── RATreeView.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ ├── RATreeView-iOS.xcscheme │ │ ├── RATreeView-tvOS.xcscheme │ │ ├── RATreeView.xcscheme │ │ └── RATreeViewTests.xcscheme ├── RATreeView │ ├── Private Files │ │ ├── RABatchChangeEntity.h │ │ ├── RABatchChangeEntity.m │ │ ├── RABatchChanges.h │ │ ├── RABatchChanges.m │ │ ├── RATableView.h │ │ ├── RATableView.m │ │ ├── RATreeNode.h │ │ ├── RATreeNode.m │ │ ├── RATreeNodeCollectionController.h │ │ ├── RATreeNodeCollectionController.m │ │ ├── RATreeNodeController.h │ │ ├── RATreeNodeController.m │ │ ├── RATreeNodeItem+ClassExtension.h │ │ ├── RATreeNodeItem+Private.h │ │ ├── RATreeNodeItem+Private.m │ │ ├── RATreeNodeItem.h │ │ ├── RATreeNodeItem.m │ │ ├── RATreeNode_ClassExtension.h │ │ ├── RATreeView+Enums.h │ │ ├── RATreeView+Enums.m │ │ ├── RATreeView+Private.h │ │ ├── RATreeView+Private.m │ │ ├── RATreeView+RATreeNodeCollectionControllerDataSource.h │ │ ├── RATreeView+RATreeNodeCollectionControllerDataSource.m │ │ ├── RATreeView+TableViewDataSource.h │ │ ├── RATreeView+TableViewDataSource.m │ │ ├── RATreeView+TableViewDelegate.h │ │ ├── RATreeView+TableViewDelegate.m │ │ └── RATreeView_ClassExtension.h │ ├── RATreeView.h │ └── RATreeView.m └── RATreeViewTests │ ├── Info.plist │ ├── RABatchChangeEntityTests.m │ └── RATreeViewTests.m ├── README.md └── Screens ├── PullToRefresh.png ├── animation.gif └── tvos_animation.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | */build/* 3 | build/* 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | *.xcworkspace 13 | !default.xcworkspace 14 | xcuserdata 15 | profile 16 | *.moved-aside 17 | 18 | */private 19 | .DS_Store 20 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | osx_image: xcode7.3 2 | language: objective-c 3 | script: 4 | - xctool test -project RATreeView/RATreeView.xcodeproj -scheme RATreeViewTests -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO 5 | - xctool test -project RATreeView/RATreeView.xcodeproj -scheme RATreeViewTests -sdk appletvsimulator ONLY_ACTIVE_ARCH=NO 6 | -------------------------------------------------------------------------------- /Examples/Podfile: -------------------------------------------------------------------------------- 1 | source 'https://github.com/CocoaPods/Specs.git' 2 | 3 | workspace 'RATreeViewExamples.xcworkspace' 4 | use_frameworks! 5 | 6 | target 'RATreeViewBasicExample' do 7 | platform :ios, '7.0' 8 | pod 'RATreeView', :path => './../RATreeView.podspec.json' 9 | end 10 | 11 | target 'RATreeViewBasicExampleSwift' do 12 | platform :ios, '7.0' 13 | pod 'RATreeView', :path => './../RATreeView.podspec.json' 14 | end 15 | 16 | target 'RATreeViewTVExample' do 17 | platform :tvos, '9.0' 18 | pod 'RATreeView', :path => './../RATreeView.podspec.json' 19 | end 20 | -------------------------------------------------------------------------------- /Examples/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - RATreeView (2.1.0) 3 | 4 | DEPENDENCIES: 5 | - RATreeView (from `./../RATreeView.podspec.json`) 6 | 7 | EXTERNAL SOURCES: 8 | RATreeView: 9 | :path: "./../RATreeView.podspec.json" 10 | 11 | SPEC CHECKSUMS: 12 | RATreeView: 9d4d7cad59613b8526ce06b117ca023ff31ba7d2 13 | 14 | PODFILE CHECKSUM: a8e34ea1a77eb62b50d76fa26cb69613861d60f7 15 | 16 | COCOAPODS: 1.0.1 17 | -------------------------------------------------------------------------------- /Examples/Pods/Local Podspecs/RATreeView.podspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "RATreeView", 3 | "version": "2.1.0", 4 | "summary": "RATreeView provide you a great support to display the tree structures on iOS.", 5 | "homepage": "https://github.com/Augustyniak/RATreeView", 6 | "screenshots": "https://raw.github.com/Augustyniak/RATreeView/master/Screens/animation.gif", 7 | "license": { 8 | "type": "MIT", 9 | "file": "LICENCE.md" 10 | }, 11 | "authors": { 12 | "Rafal Augustyniak": "rafalaugustyniak@gmail.com" 13 | }, 14 | "source": { 15 | "git": "https://github.com/Augustyniak/RATreeView.git", 16 | "tag": "v2.1.0" 17 | }, 18 | "platforms": { 19 | "ios": "7.0", 20 | "tvos": "9.0" 21 | }, 22 | "source_files": "RATreeView/RATreeView/**/*.{h,m}", 23 | "public_header_files": "RATreeView/RATreeView/RATreeView.h", 24 | "requires_arc": true 25 | } 26 | -------------------------------------------------------------------------------- /Examples/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - RATreeView (2.1.0) 3 | 4 | DEPENDENCIES: 5 | - RATreeView (from `./../RATreeView.podspec.json`) 6 | 7 | EXTERNAL SOURCES: 8 | RATreeView: 9 | :path: "./../RATreeView.podspec.json" 10 | 11 | SPEC CHECKSUMS: 12 | RATreeView: 9d4d7cad59613b8526ce06b117ca023ff31ba7d2 13 | 14 | PODFILE CHECKSUM: a8e34ea1a77eb62b50d76fa26cb69613861d60f7 15 | 16 | COCOAPODS: 1.0.1 17 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewBasicExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewBasicExample/Pods-RATreeViewBasicExample-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## RATreeView 5 | 6 | The MIT License (MIT) 7 | 8 | Copyright (c) 2013 Rafał Augustyniak 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy of 11 | this software and associated documentation files (the "Software"), to deal in 12 | the Software without restriction, including without limitation the rights to 13 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 14 | the Software, and to permit persons to whom the Software is furnished to do so, 15 | subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 22 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 23 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 24 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 25 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | Generated by CocoaPods - https://cocoapods.org 27 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewBasicExample/Pods-RATreeViewBasicExample-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | The MIT License (MIT) 18 | 19 | Copyright (c) 2013 Rafał Augustyniak 20 | 21 | Permission is hereby granted, free of charge, to any person obtaining a copy of 22 | this software and associated documentation files (the "Software"), to deal in 23 | the Software without restriction, including without limitation the rights to 24 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 25 | the Software, and to permit persons to whom the Software is furnished to do so, 26 | subject to the following conditions: 27 | 28 | The above copyright notice and this permission notice shall be included in all 29 | copies or substantial portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 33 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 34 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 35 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 36 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 37 | Title 38 | RATreeView 39 | Type 40 | PSGroupSpecifier 41 | 42 | 43 | FooterText 44 | Generated by CocoaPods - https://cocoapods.org 45 | Title 46 | 47 | Type 48 | PSGroupSpecifier 49 | 50 | 51 | StringsTable 52 | Acknowledgements 53 | Title 54 | Acknowledgements 55 | 56 | 57 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewBasicExample/Pods-RATreeViewBasicExample-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_RATreeViewBasicExample : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_RATreeViewBasicExample 5 | @end 6 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewBasicExample/Pods-RATreeViewBasicExample-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements \"$1\"" 63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1" 64 | fi 65 | } 66 | 67 | # Strip invalid architectures 68 | strip_invalid_archs() { 69 | binary="$1" 70 | # Get architectures for current file 71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 72 | stripped="" 73 | for arch in $archs; do 74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 75 | # Strip non-valid architectures in-place 76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 77 | stripped="$stripped $arch" 78 | fi 79 | done 80 | if [[ "$stripped" ]]; then 81 | echo "Stripped $binary of architectures:$stripped" 82 | fi 83 | } 84 | 85 | 86 | if [[ "$CONFIGURATION" == "Debug" ]]; then 87 | install_framework "$BUILT_PRODUCTS_DIR/RATreeView-iOS/RATreeView.framework" 88 | fi 89 | if [[ "$CONFIGURATION" == "Release" ]]; then 90 | install_framework "$BUILT_PRODUCTS_DIR/RATreeView-iOS/RATreeView.framework" 91 | fi 92 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewBasicExample/Pods-RATreeViewBasicExample-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | case "${TARGETED_DEVICE_FAMILY}" in 12 | 1,2) 13 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 14 | ;; 15 | 1) 16 | TARGET_DEVICE_ARGS="--target-device iphone" 17 | ;; 18 | 2) 19 | TARGET_DEVICE_ARGS="--target-device ipad" 20 | ;; 21 | *) 22 | TARGET_DEVICE_ARGS="--target-device mac" 23 | ;; 24 | esac 25 | 26 | realpath() { 27 | DIRECTORY="$(cd "${1%/*}" && pwd)" 28 | FILENAME="${1##*/}" 29 | echo "$DIRECTORY/$FILENAME" 30 | } 31 | 32 | install_resource() 33 | { 34 | if [[ "$1" = /* ]] ; then 35 | RESOURCE_PATH="$1" 36 | else 37 | RESOURCE_PATH="${PODS_ROOT}/$1" 38 | fi 39 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 40 | cat << EOM 41 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 42 | EOM 43 | exit 1 44 | fi 45 | case $RESOURCE_PATH in 46 | *.storyboard) 47 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 48 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 49 | ;; 50 | *.xib) 51 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 52 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 53 | ;; 54 | *.framework) 55 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 56 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 57 | echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 58 | rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 59 | ;; 60 | *.xcdatamodel) 61 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" 62 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 63 | ;; 64 | *.xcdatamodeld) 65 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" 66 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 67 | ;; 68 | *.xcmappingmodel) 69 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" 70 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 71 | ;; 72 | *.xcassets) 73 | ABSOLUTE_XCASSET_FILE=$(realpath "$RESOURCE_PATH") 74 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 75 | ;; 76 | *) 77 | echo "$RESOURCE_PATH" 78 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 79 | ;; 80 | esac 81 | } 82 | 83 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 84 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 85 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 86 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 87 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 88 | fi 89 | rm -f "$RESOURCES_TO_COPY" 90 | 91 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 92 | then 93 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 94 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 95 | while read line; do 96 | if [[ $line != "`realpath $PODS_ROOT`*" ]]; then 97 | XCASSET_FILES+=("$line") 98 | fi 99 | done <<<"$OTHER_XCASSETS" 100 | 101 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 102 | fi 103 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewBasicExample/Pods-RATreeViewBasicExample-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | FOUNDATION_EXPORT double Pods_RATreeViewBasicExampleVersionNumber; 5 | FOUNDATION_EXPORT const unsigned char Pods_RATreeViewBasicExampleVersionString[]; 6 | 7 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewBasicExample/Pods-RATreeViewBasicExample.debug.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/RATreeView-iOS" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 4 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/RATreeView-iOS/RATreeView.framework/Headers" 5 | OTHER_LDFLAGS = $(inherited) -framework "RATreeView" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewBasicExample/Pods-RATreeViewBasicExample.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_RATreeViewBasicExample { 2 | umbrella header "Pods-RATreeViewBasicExample-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewBasicExample/Pods-RATreeViewBasicExample.release.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/RATreeView-iOS" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 4 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/RATreeView-iOS/RATreeView.framework/Headers" 5 | OTHER_LDFLAGS = $(inherited) -framework "RATreeView" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewBasicExampleSwift/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewBasicExampleSwift/Pods-RATreeViewBasicExampleSwift-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## RATreeView 5 | 6 | The MIT License (MIT) 7 | 8 | Copyright (c) 2013 Rafał Augustyniak 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy of 11 | this software and associated documentation files (the "Software"), to deal in 12 | the Software without restriction, including without limitation the rights to 13 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 14 | the Software, and to permit persons to whom the Software is furnished to do so, 15 | subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 22 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 23 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 24 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 25 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | Generated by CocoaPods - https://cocoapods.org 27 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewBasicExampleSwift/Pods-RATreeViewBasicExampleSwift-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | The MIT License (MIT) 18 | 19 | Copyright (c) 2013 Rafał Augustyniak 20 | 21 | Permission is hereby granted, free of charge, to any person obtaining a copy of 22 | this software and associated documentation files (the "Software"), to deal in 23 | the Software without restriction, including without limitation the rights to 24 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 25 | the Software, and to permit persons to whom the Software is furnished to do so, 26 | subject to the following conditions: 27 | 28 | The above copyright notice and this permission notice shall be included in all 29 | copies or substantial portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 33 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 34 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 35 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 36 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 37 | Title 38 | RATreeView 39 | Type 40 | PSGroupSpecifier 41 | 42 | 43 | FooterText 44 | Generated by CocoaPods - https://cocoapods.org 45 | Title 46 | 47 | Type 48 | PSGroupSpecifier 49 | 50 | 51 | StringsTable 52 | Acknowledgements 53 | Title 54 | Acknowledgements 55 | 56 | 57 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewBasicExampleSwift/Pods-RATreeViewBasicExampleSwift-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_RATreeViewBasicExampleSwift : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_RATreeViewBasicExampleSwift 5 | @end 6 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewBasicExampleSwift/Pods-RATreeViewBasicExampleSwift-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements \"$1\"" 63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1" 64 | fi 65 | } 66 | 67 | # Strip invalid architectures 68 | strip_invalid_archs() { 69 | binary="$1" 70 | # Get architectures for current file 71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 72 | stripped="" 73 | for arch in $archs; do 74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 75 | # Strip non-valid architectures in-place 76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 77 | stripped="$stripped $arch" 78 | fi 79 | done 80 | if [[ "$stripped" ]]; then 81 | echo "Stripped $binary of architectures:$stripped" 82 | fi 83 | } 84 | 85 | 86 | if [[ "$CONFIGURATION" == "Debug" ]]; then 87 | install_framework "$BUILT_PRODUCTS_DIR/RATreeView-iOS/RATreeView.framework" 88 | fi 89 | if [[ "$CONFIGURATION" == "Release" ]]; then 90 | install_framework "$BUILT_PRODUCTS_DIR/RATreeView-iOS/RATreeView.framework" 91 | fi 92 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewBasicExampleSwift/Pods-RATreeViewBasicExampleSwift-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | case "${TARGETED_DEVICE_FAMILY}" in 12 | 1,2) 13 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 14 | ;; 15 | 1) 16 | TARGET_DEVICE_ARGS="--target-device iphone" 17 | ;; 18 | 2) 19 | TARGET_DEVICE_ARGS="--target-device ipad" 20 | ;; 21 | *) 22 | TARGET_DEVICE_ARGS="--target-device mac" 23 | ;; 24 | esac 25 | 26 | realpath() { 27 | DIRECTORY="$(cd "${1%/*}" && pwd)" 28 | FILENAME="${1##*/}" 29 | echo "$DIRECTORY/$FILENAME" 30 | } 31 | 32 | install_resource() 33 | { 34 | if [[ "$1" = /* ]] ; then 35 | RESOURCE_PATH="$1" 36 | else 37 | RESOURCE_PATH="${PODS_ROOT}/$1" 38 | fi 39 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 40 | cat << EOM 41 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 42 | EOM 43 | exit 1 44 | fi 45 | case $RESOURCE_PATH in 46 | *.storyboard) 47 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 48 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 49 | ;; 50 | *.xib) 51 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 52 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 53 | ;; 54 | *.framework) 55 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 56 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 57 | echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 58 | rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 59 | ;; 60 | *.xcdatamodel) 61 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" 62 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 63 | ;; 64 | *.xcdatamodeld) 65 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" 66 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 67 | ;; 68 | *.xcmappingmodel) 69 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" 70 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 71 | ;; 72 | *.xcassets) 73 | ABSOLUTE_XCASSET_FILE=$(realpath "$RESOURCE_PATH") 74 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 75 | ;; 76 | *) 77 | echo "$RESOURCE_PATH" 78 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 79 | ;; 80 | esac 81 | } 82 | 83 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 84 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 85 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 86 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 87 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 88 | fi 89 | rm -f "$RESOURCES_TO_COPY" 90 | 91 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 92 | then 93 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 94 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 95 | while read line; do 96 | if [[ $line != "`realpath $PODS_ROOT`*" ]]; then 97 | XCASSET_FILES+=("$line") 98 | fi 99 | done <<<"$OTHER_XCASSETS" 100 | 101 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 102 | fi 103 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewBasicExampleSwift/Pods-RATreeViewBasicExampleSwift-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | FOUNDATION_EXPORT double Pods_RATreeViewBasicExampleSwiftVersionNumber; 5 | FOUNDATION_EXPORT const unsigned char Pods_RATreeViewBasicExampleSwiftVersionString[]; 6 | 7 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewBasicExampleSwift/Pods-RATreeViewBasicExampleSwift.debug.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/RATreeView-iOS" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 4 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/RATreeView-iOS/RATreeView.framework/Headers" 5 | OTHER_LDFLAGS = $(inherited) -framework "RATreeView" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewBasicExampleSwift/Pods-RATreeViewBasicExampleSwift.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_RATreeViewBasicExampleSwift { 2 | umbrella header "Pods-RATreeViewBasicExampleSwift-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewBasicExampleSwift/Pods-RATreeViewBasicExampleSwift.release.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/RATreeView-iOS" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 4 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/RATreeView-iOS/RATreeView.framework/Headers" 5 | OTHER_LDFLAGS = $(inherited) -framework "RATreeView" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewTVExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | UIRequiredDeviceCapabilities 26 | 27 | arm64 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewTVExample/Pods-RATreeViewTVExample-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## RATreeView 5 | 6 | The MIT License (MIT) 7 | 8 | Copyright (c) 2013 Rafał Augustyniak 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy of 11 | this software and associated documentation files (the "Software"), to deal in 12 | the Software without restriction, including without limitation the rights to 13 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 14 | the Software, and to permit persons to whom the Software is furnished to do so, 15 | subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 22 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 23 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 24 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 25 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | Generated by CocoaPods - https://cocoapods.org 27 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewTVExample/Pods-RATreeViewTVExample-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | The MIT License (MIT) 18 | 19 | Copyright (c) 2013 Rafał Augustyniak 20 | 21 | Permission is hereby granted, free of charge, to any person obtaining a copy of 22 | this software and associated documentation files (the "Software"), to deal in 23 | the Software without restriction, including without limitation the rights to 24 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 25 | the Software, and to permit persons to whom the Software is furnished to do so, 26 | subject to the following conditions: 27 | 28 | The above copyright notice and this permission notice shall be included in all 29 | copies or substantial portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 33 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 34 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 35 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 36 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 37 | Title 38 | RATreeView 39 | Type 40 | PSGroupSpecifier 41 | 42 | 43 | FooterText 44 | Generated by CocoaPods - https://cocoapods.org 45 | Title 46 | 47 | Type 48 | PSGroupSpecifier 49 | 50 | 51 | StringsTable 52 | Acknowledgements 53 | Title 54 | Acknowledgements 55 | 56 | 57 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewTVExample/Pods-RATreeViewTVExample-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_RATreeViewTVExample : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_RATreeViewTVExample 5 | @end 6 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewTVExample/Pods-RATreeViewTVExample-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements \"$1\"" 63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1" 64 | fi 65 | } 66 | 67 | # Strip invalid architectures 68 | strip_invalid_archs() { 69 | binary="$1" 70 | # Get architectures for current file 71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 72 | stripped="" 73 | for arch in $archs; do 74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 75 | # Strip non-valid architectures in-place 76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 77 | stripped="$stripped $arch" 78 | fi 79 | done 80 | if [[ "$stripped" ]]; then 81 | echo "Stripped $binary of architectures:$stripped" 82 | fi 83 | } 84 | 85 | 86 | if [[ "$CONFIGURATION" == "Debug" ]]; then 87 | install_framework "$BUILT_PRODUCTS_DIR/RATreeView-tvOS/RATreeView.framework" 88 | fi 89 | if [[ "$CONFIGURATION" == "Release" ]]; then 90 | install_framework "$BUILT_PRODUCTS_DIR/RATreeView-tvOS/RATreeView.framework" 91 | fi 92 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewTVExample/Pods-RATreeViewTVExample-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | case "${TARGETED_DEVICE_FAMILY}" in 12 | 1,2) 13 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 14 | ;; 15 | 1) 16 | TARGET_DEVICE_ARGS="--target-device iphone" 17 | ;; 18 | 2) 19 | TARGET_DEVICE_ARGS="--target-device ipad" 20 | ;; 21 | *) 22 | TARGET_DEVICE_ARGS="--target-device mac" 23 | ;; 24 | esac 25 | 26 | realpath() { 27 | DIRECTORY="$(cd "${1%/*}" && pwd)" 28 | FILENAME="${1##*/}" 29 | echo "$DIRECTORY/$FILENAME" 30 | } 31 | 32 | install_resource() 33 | { 34 | if [[ "$1" = /* ]] ; then 35 | RESOURCE_PATH="$1" 36 | else 37 | RESOURCE_PATH="${PODS_ROOT}/$1" 38 | fi 39 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 40 | cat << EOM 41 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 42 | EOM 43 | exit 1 44 | fi 45 | case $RESOURCE_PATH in 46 | *.storyboard) 47 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 48 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 49 | ;; 50 | *.xib) 51 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 52 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 53 | ;; 54 | *.framework) 55 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 56 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 57 | echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 58 | rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 59 | ;; 60 | *.xcdatamodel) 61 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" 62 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 63 | ;; 64 | *.xcdatamodeld) 65 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" 66 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 67 | ;; 68 | *.xcmappingmodel) 69 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" 70 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 71 | ;; 72 | *.xcassets) 73 | ABSOLUTE_XCASSET_FILE=$(realpath "$RESOURCE_PATH") 74 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 75 | ;; 76 | *) 77 | echo "$RESOURCE_PATH" 78 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 79 | ;; 80 | esac 81 | } 82 | 83 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 84 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 85 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 86 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 87 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 88 | fi 89 | rm -f "$RESOURCES_TO_COPY" 90 | 91 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 92 | then 93 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 94 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 95 | while read line; do 96 | if [[ $line != "`realpath $PODS_ROOT`*" ]]; then 97 | XCASSET_FILES+=("$line") 98 | fi 99 | done <<<"$OTHER_XCASSETS" 100 | 101 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 102 | fi 103 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewTVExample/Pods-RATreeViewTVExample-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | FOUNDATION_EXPORT double Pods_RATreeViewTVExampleVersionNumber; 5 | FOUNDATION_EXPORT const unsigned char Pods_RATreeViewTVExampleVersionString[]; 6 | 7 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewTVExample/Pods-RATreeViewTVExample.debug.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/RATreeView-tvOS" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 4 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/RATreeView-tvOS/RATreeView.framework/Headers" 5 | OTHER_LDFLAGS = $(inherited) -framework "RATreeView" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewTVExample/Pods-RATreeViewTVExample.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_RATreeViewTVExample { 2 | umbrella header "Pods-RATreeViewTVExample-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/Pods-RATreeViewTVExample/Pods-RATreeViewTVExample.release.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/RATreeView-tvOS" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 4 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/RATreeView-tvOS/RATreeView.framework/Headers" 5 | OTHER_LDFLAGS = $(inherited) -framework "RATreeView" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/RATreeView-iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 2.1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/RATreeView-iOS/RATreeView-iOS-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_RATreeView_iOS : NSObject 3 | @end 4 | @implementation PodsDummy_RATreeView_iOS 5 | @end 6 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/RATreeView-iOS/RATreeView-iOS-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/RATreeView-iOS/RATreeView-iOS-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "RATreeView.h" 4 | 5 | FOUNDATION_EXPORT double RATreeViewVersionNumber; 6 | FOUNDATION_EXPORT const unsigned char RATreeViewVersionString[]; 7 | 8 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/RATreeView-iOS/RATreeView-iOS.modulemap: -------------------------------------------------------------------------------- 1 | framework module RATreeView { 2 | umbrella header "RATreeView-iOS-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/RATreeView-iOS/RATreeView-iOS.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/RATreeView-iOS 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 4 | PODS_BUILD_DIR = $BUILD_DIR 5 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 8 | SKIP_INSTALL = YES 9 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/RATreeView-tvOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 2.1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | UIRequiredDeviceCapabilities 26 | 27 | arm64 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/RATreeView-tvOS/RATreeView-tvOS-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_RATreeView_tvOS : NSObject 3 | @end 4 | @implementation PodsDummy_RATreeView_tvOS 5 | @end 6 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/RATreeView-tvOS/RATreeView-tvOS-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/RATreeView-tvOS/RATreeView-tvOS-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "RATreeView.h" 4 | 5 | FOUNDATION_EXPORT double RATreeViewVersionNumber; 6 | FOUNDATION_EXPORT const unsigned char RATreeViewVersionString[]; 7 | 8 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/RATreeView-tvOS/RATreeView-tvOS.modulemap: -------------------------------------------------------------------------------- 1 | framework module RATreeView { 2 | umbrella header "RATreeView-tvOS-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Examples/Pods/Target Support Files/RATreeView-tvOS/RATreeView-tvOS.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/RATreeView-tvOS 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 4 | PODS_BUILD_DIR = $BUILD_DIR 5 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 8 | SKIP_INSTALL = YES 9 | -------------------------------------------------------------------------------- /Examples/RATreeViewBasicExample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /Examples/RATreeViewBasicExample/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Examples/RATreeViewBasicExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UIStatusBarTintParameters 32 | 33 | UINavigationBar 34 | 35 | Style 36 | UIBarStyleDefault 37 | Translucent 38 | 39 | 40 | 41 | UISupportedInterfaceOrientations 42 | 43 | UIInterfaceOrientationPortrait 44 | UIInterfaceOrientationLandscapeLeft 45 | UIInterfaceOrientationLandscapeRight 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /Examples/RATreeViewBasicExample/RAAppDelegate.h: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2013 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | #import 22 | 23 | @class RAViewController; 24 | 25 | @interface RAAppDelegate : UIResponder 26 | 27 | @property (strong, nonatomic) UIWindow *window; 28 | 29 | @property (strong, nonatomic) RAViewController *viewController; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Examples/RATreeViewBasicExample/RAAppDelegate.m: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | #import "RAAppDelegate.h" 22 | 23 | #import "RAViewController.h" 24 | 25 | @implementation RAAppDelegate 26 | 27 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 28 | { 29 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 30 | self.viewController = [RAViewController new]; 31 | 32 | UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController]; 33 | self.window.rootViewController = navigationController; 34 | [self.window makeKeyAndVisible]; 35 | return YES; 36 | } 37 | 38 | - (void)applicationWillResignActive:(UIApplication *)application 39 | { 40 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 41 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 42 | } 43 | 44 | - (void)applicationDidEnterBackground:(UIApplication *)application 45 | { 46 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 47 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 48 | } 49 | 50 | - (void)applicationWillEnterForeground:(UIApplication *)application 51 | { 52 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 53 | } 54 | 55 | - (void)applicationDidBecomeActive:(UIApplication *)application 56 | { 57 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 58 | } 59 | 60 | - (void)applicationWillTerminate:(UIApplication *)application 61 | { 62 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 63 | } 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /Examples/RATreeViewBasicExample/RADataObject.h: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2013 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | #import 22 | 23 | @interface RADataObject : NSObject 24 | 25 | @property (strong, nonatomic) NSString *name; 26 | @property (strong, nonatomic) NSArray *children; 27 | 28 | - (id)initWithName:(NSString *)name children:(NSArray *)array; 29 | 30 | + (id)dataObjectWithName:(NSString *)name children:(NSArray *)children; 31 | 32 | - (void)addChild:(id)child; 33 | - (void)removeChild:(id)child; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Examples/RATreeViewBasicExample/RADataObject.m: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | #import "RADataObject.h" 22 | 23 | @implementation RADataObject 24 | 25 | 26 | - (id)initWithName:(NSString *)name children:(NSArray *)children 27 | { 28 | self = [super init]; 29 | if (self) { 30 | self.children = [NSArray arrayWithArray:children]; 31 | self.name = name; 32 | } 33 | return self; 34 | } 35 | 36 | + (id)dataObjectWithName:(NSString *)name children:(NSArray *)children 37 | { 38 | return [[self alloc] initWithName:name children:children]; 39 | } 40 | 41 | - (void)addChild:(id)child 42 | { 43 | NSMutableArray *children = [self.children mutableCopy]; 44 | [children insertObject:child atIndex:0]; 45 | self.children = [children copy]; 46 | } 47 | 48 | - (void)removeChild:(id)child 49 | { 50 | NSMutableArray *children = [self.children mutableCopy]; 51 | [children removeObject:child]; 52 | self.children = [children copy]; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /Examples/RATreeViewBasicExample/RATableViewCell.h: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | #import 22 | 23 | @interface RATableViewCell : UITableViewCell 24 | 25 | @property (nonatomic, copy) void (^additionButtonTapAction)(id sender); 26 | @property (nonatomic) BOOL additionButtonHidden; 27 | 28 | - (void)setupWithTitle:(NSString *)title detailText:(NSString *)detailText level:(NSInteger)level additionButtonHidden:(BOOL)additionButtonHidden; 29 | - (void)setAdditionButtonHidden:(BOOL)additionButtonHidden animated:(BOOL)animated; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Examples/RATreeViewBasicExample/RATableViewCell.m: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | #import "RATableViewCell.h" 22 | 23 | #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0] 24 | 25 | @interface RATableViewCell () 26 | 27 | @property (weak, nonatomic) IBOutlet UILabel *detailedLabel; 28 | @property (weak, nonatomic) IBOutlet UILabel *customTitleLabel; 29 | @property (weak, nonatomic) IBOutlet UIButton *additionButton; 30 | 31 | @end 32 | 33 | @implementation RATableViewCell 34 | 35 | - (void)awakeFromNib 36 | { 37 | [super awakeFromNib]; 38 | 39 | self.selectedBackgroundView = [UIView new]; 40 | self.selectedBackgroundView.backgroundColor = [UIColor clearColor]; 41 | 42 | } 43 | 44 | - (void)prepareForReuse 45 | { 46 | [super prepareForReuse]; 47 | 48 | self.additionButtonHidden = NO; 49 | } 50 | 51 | 52 | - (void)setupWithTitle:(NSString *)title detailText:(NSString *)detailText level:(NSInteger)level additionButtonHidden:(BOOL)additionButtonHidden 53 | { 54 | self.customTitleLabel.text = title; 55 | self.detailedLabel.text = detailText; 56 | self.additionButtonHidden = additionButtonHidden; 57 | 58 | if (level == 0) { 59 | self.detailTextLabel.textColor = [UIColor blackColor]; 60 | } 61 | 62 | if (level == 0) { 63 | self.backgroundColor = UIColorFromRGB(0xF7F7F7); 64 | } else if (level == 1) { 65 | self.backgroundColor = UIColorFromRGB(0xD1EEFC); 66 | } else if (level >= 2) { 67 | self.backgroundColor = UIColorFromRGB(0xE0F8D8); 68 | } 69 | 70 | CGFloat left = 11 + 20 * level; 71 | 72 | CGRect titleFrame = self.customTitleLabel.frame; 73 | titleFrame.origin.x = left; 74 | self.customTitleLabel.frame = titleFrame; 75 | 76 | CGRect detailsFrame = self.detailedLabel.frame; 77 | detailsFrame.origin.x = left; 78 | self.detailedLabel.frame = detailsFrame; 79 | } 80 | 81 | 82 | #pragma mark - Properties 83 | 84 | - (void)setAdditionButtonHidden:(BOOL)additionButtonHidden 85 | { 86 | [self setAdditionButtonHidden:additionButtonHidden animated:NO]; 87 | } 88 | 89 | - (void)setAdditionButtonHidden:(BOOL)additionButtonHidden animated:(BOOL)animated 90 | { 91 | _additionButtonHidden = additionButtonHidden; 92 | [UIView animateWithDuration:animated ? 0.2 : 0 animations:^{ 93 | self.additionButton.hidden = additionButtonHidden; 94 | }]; 95 | } 96 | 97 | 98 | #pragma mark - Actions 99 | 100 | - (IBAction)additionButtonTapped:(id)sender 101 | { 102 | if (self.additionButtonTapAction) { 103 | self.additionButtonTapAction(sender); 104 | } 105 | } 106 | 107 | @end 108 | -------------------------------------------------------------------------------- /Examples/RATreeViewBasicExample/RATableViewCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 24 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /Examples/RATreeViewBasicExample/RAViewController.h: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | #import 21 | 22 | @interface RAViewController : UIViewController 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Examples/RATreeViewBasicExample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // RATreeViewBasicExample 4 | // 5 | // Created by Rafal Augustyniak on 15/11/15. 6 | // Copyright © 2015 com.Augustyniak. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "RAAppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([RAAppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Examples/RATreeViewBasicExampleSwift/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // RATreeViewBasicExampleSwift 4 | // 5 | // Created by Rafal Augustyniak on 21/11/15. 6 | // Copyright © 2015 com.Augustyniak. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | let navigationController = UINavigationController(rootViewController: TreeViewController()) 18 | window = UIWindow(frame: UIScreen.main.bounds) 19 | window?.rootViewController = navigationController; 20 | window?.makeKeyAndVisible() 21 | return true 22 | } 23 | 24 | } 25 | 26 | -------------------------------------------------------------------------------- /Examples/RATreeViewBasicExampleSwift/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "83.5x83.5", 66 | "scale" : "2x" 67 | } 68 | ], 69 | "info" : { 70 | "version" : 1, 71 | "author" : "xcode" 72 | } 73 | } -------------------------------------------------------------------------------- /Examples/RATreeViewBasicExampleSwift/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Examples/RATreeViewBasicExampleSwift/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UIStatusBarTintParameters 32 | 33 | UINavigationBar 34 | 35 | Style 36 | UIBarStyleDefault 37 | Translucent 38 | 39 | 40 | 41 | UISupportedInterfaceOrientations 42 | 43 | UIInterfaceOrientationPortrait 44 | UIInterfaceOrientationLandscapeLeft 45 | UIInterfaceOrientationLandscapeRight 46 | 47 | UISupportedInterfaceOrientations~ipad 48 | 49 | UIInterfaceOrientationPortrait 50 | UIInterfaceOrientationPortraitUpsideDown 51 | UIInterfaceOrientationLandscapeLeft 52 | UIInterfaceOrientationLandscapeRight 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /Examples/RATreeViewBasicExampleSwift/TreeTableViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TreeTableViewCell.swift 3 | // RATreeViewExamples 4 | // 5 | // Created by Rafal Augustyniak on 22/11/15. 6 | // Copyright © 2015 com.Augustyniak. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class TreeTableViewCell : UITableViewCell { 12 | 13 | @IBOutlet private weak var additionalButton: UIButton! 14 | @IBOutlet private weak var detailsLabel: UILabel! 15 | @IBOutlet private weak var customTitleLabel: UILabel! 16 | 17 | private var additionalButtonHidden : Bool { 18 | get { 19 | return additionalButton.isHidden; 20 | } 21 | set { 22 | additionalButton.isHidden = newValue; 23 | } 24 | } 25 | 26 | override func awakeFromNib() { 27 | selectedBackgroundView? = UIView() 28 | selectedBackgroundView?.backgroundColor = .clear 29 | } 30 | 31 | var additionButtonActionBlock : ((TreeTableViewCell) -> Void)?; 32 | 33 | func setup(withTitle title: String, detailsText: String, level : Int, additionalButtonHidden: Bool) { 34 | customTitleLabel.text = title 35 | detailsLabel.text = detailsText 36 | self.additionalButtonHidden = additionalButtonHidden 37 | 38 | let backgroundColor: UIColor 39 | if level == 0 { 40 | backgroundColor = UIColor(red: 247.0/255.0, green: 247.0/255.0, blue: 247.0/255.0, alpha: 1.0) 41 | } else if level == 1 { 42 | backgroundColor = UIColor(red: 209.0/255.0, green: 238.0/255.0, blue: 252.0/255.0, alpha: 1.0) 43 | } else { 44 | backgroundColor = UIColor(red: 224.0/255.0, green: 248.0/255.0, blue: 216.0/255.0, alpha: 1.0) 45 | } 46 | 47 | self.backgroundColor = backgroundColor 48 | self.contentView.backgroundColor = backgroundColor 49 | 50 | let left = 11.0 + 20.0 * CGFloat(level) 51 | self.customTitleLabel.frame.origin.x = left 52 | self.detailsLabel.frame.origin.x = left 53 | } 54 | 55 | func additionButtonTapped(_ sender : AnyObject) -> Void { 56 | if let action = additionButtonActionBlock { 57 | action(self) 58 | } 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /Examples/RATreeViewBasicExampleSwift/TreeTableViewCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 25 | 33 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /Examples/RATreeViewBasicExampleSwift/TreeViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TreeViewController.swift 3 | // RATreeViewExamples 4 | // 5 | // Created by Rafal Augustyniak on 21/11/15. 6 | // Copyright © 2015 com.Augustyniak. All rights reserved. 7 | // 8 | 9 | 10 | import UIKit 11 | import RATreeView 12 | 13 | class TreeViewController: UIViewController, RATreeViewDelegate, RATreeViewDataSource { 14 | 15 | var treeView : RATreeView! 16 | var data : [DataObject] 17 | var editButton : UIBarButtonItem! 18 | 19 | convenience init() { 20 | self.init(nibName : nil, bundle: nil) 21 | } 22 | 23 | override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { 24 | data = TreeViewController.commonInit() 25 | super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) 26 | } 27 | 28 | required init?(coder aDecoder: NSCoder) { 29 | data = TreeViewController.commonInit() 30 | super.init(coder: aDecoder) 31 | } 32 | 33 | override func viewDidLoad() { 34 | super.viewDidLoad() 35 | 36 | view.backgroundColor = .white 37 | 38 | title = "Things" 39 | setupTreeView() 40 | updateNavigationBarButtons() 41 | } 42 | 43 | func setupTreeView() -> Void { 44 | treeView = RATreeView(frame: view.bounds) 45 | treeView.register(UINib(nibName: String(describing: TreeTableViewCell.self), bundle: nil), forCellReuseIdentifier: String(describing: TreeTableViewCell.self)) 46 | treeView.autoresizingMask = [.flexibleWidth, .flexibleHeight] 47 | treeView.delegate = self; 48 | treeView.dataSource = self; 49 | treeView.treeFooterView = UIView() 50 | treeView.backgroundColor = .clear 51 | view.addSubview(treeView) 52 | } 53 | 54 | func updateNavigationBarButtons() -> Void { 55 | let systemItem = treeView.isEditing ? UIBarButtonSystemItem.done : UIBarButtonSystemItem.edit; 56 | self.editButton = UIBarButtonItem(barButtonSystemItem: systemItem, target: self, action: #selector(TreeViewController.editButtonTapped(_:))) 57 | self.navigationItem.rightBarButtonItem = self.editButton; 58 | } 59 | 60 | func editButtonTapped(_ sender: AnyObject) -> Void { 61 | treeView.setEditing(!treeView.isEditing, animated: true) 62 | updateNavigationBarButtons() 63 | } 64 | 65 | 66 | //MARK: RATreeView data source 67 | 68 | func treeView(_ treeView: RATreeView, numberOfChildrenOfItem item: Any?) -> Int { 69 | if let item = item as? DataObject { 70 | return item.children.count 71 | } else { 72 | return self.data.count 73 | } 74 | } 75 | 76 | func treeView(_ treeView: RATreeView, child index: Int, ofItem item: Any?) -> Any { 77 | if let item = item as? DataObject { 78 | return item.children[index] 79 | } else { 80 | return data[index] as AnyObject 81 | } 82 | } 83 | 84 | func treeView(_ treeView: RATreeView, cellForItem item: Any?) -> UITableViewCell { 85 | let cell = treeView.dequeueReusableCell(withIdentifier: String(describing: TreeTableViewCell.self)) as! TreeTableViewCell 86 | let item = item as! DataObject 87 | 88 | let level = treeView.levelForCell(forItem: item) 89 | let detailsText = "Number of children \(item.children.count)" 90 | cell.selectionStyle = .none 91 | cell.setup(withTitle: item.name, detailsText: detailsText, level: level, additionalButtonHidden: false) 92 | cell.additionButtonActionBlock = { [weak treeView] cell in 93 | guard let treeView = treeView else { 94 | return; 95 | } 96 | let item = treeView.item(for: cell) as! DataObject 97 | let newItem = DataObject(name: "Added value") 98 | item.addChild(newItem) 99 | treeView.insertItems(at: IndexSet(integer: item.children.count-1), inParent: item, with: RATreeViewRowAnimationNone); 100 | treeView.reloadRows(forItems: [item], with: RATreeViewRowAnimationNone) 101 | } 102 | return cell 103 | } 104 | 105 | //MARK: RATreeView delegate 106 | 107 | func treeView(_ treeView: RATreeView, commit editingStyle: UITableViewCellEditingStyle, forRowForItem item: Any) { 108 | guard editingStyle == .delete else { return; } 109 | let item = item as! DataObject 110 | let parent = treeView.parent(forItem: item) as? DataObject 111 | 112 | let index: Int 113 | if let parent = parent { 114 | index = parent.children.index(where: { dataObject in 115 | return dataObject === item 116 | })! 117 | parent.removeChild(item) 118 | 119 | } else { 120 | index = self.data.index(where: { dataObject in 121 | return dataObject === item; 122 | })! 123 | self.data.remove(at: index) 124 | } 125 | 126 | self.treeView.deleteItems(at: IndexSet(integer: index), inParent: parent, with: RATreeViewRowAnimationRight) 127 | if let parent = parent { 128 | self.treeView.reloadRows(forItems: [parent], with: RATreeViewRowAnimationNone) 129 | } 130 | } 131 | } 132 | 133 | 134 | private extension TreeViewController { 135 | 136 | static func commonInit() -> [DataObject] { 137 | let phone1 = DataObject(name: "Phone 1") 138 | let phone2 = DataObject(name: "Phone 2") 139 | let phone3 = DataObject(name: "Phone 3") 140 | let phone4 = DataObject(name: "Phone 4") 141 | let phones = DataObject(name: "Phones", children: [phone1, phone2, phone3, phone4]) 142 | 143 | let notebook1 = DataObject(name: "Notebook 1") 144 | let notebook2 = DataObject(name: "Notebook 2") 145 | 146 | let computer1 = DataObject(name: "Computer 1", children: [notebook1, notebook2]) 147 | let computer2 = DataObject(name: "Computer 2") 148 | let computer3 = DataObject(name: "Computer 3") 149 | let computers = DataObject(name: "Computers", children: [computer1, computer2, computer3]) 150 | 151 | let cars = DataObject(name: "Cars") 152 | let bikes = DataObject(name: "Bikes") 153 | let houses = DataObject(name: "Houses") 154 | let flats = DataObject(name: "Flats") 155 | let motorbikes = DataObject(name: "motorbikes") 156 | let drinks = DataObject(name: "Drinks") 157 | let food = DataObject(name: "Food") 158 | let sweets = DataObject(name: "Sweets") 159 | let watches = DataObject(name: "Watches") 160 | let walls = DataObject(name: "Walls") 161 | 162 | return [phones, computers, cars, bikes, houses, flats, motorbikes, drinks, food, sweets, watches, walls] 163 | } 164 | 165 | } 166 | 167 | -------------------------------------------------------------------------------- /Examples/RATreeViewTVExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // RATreeViewTVExample 4 | // 5 | // Created by Rafal Augustyniak on 21/08/16. 6 | // Copyright © 2016 com.Augustyniak. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /Examples/RATreeViewTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Content.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "tv", 5 | "scale" : "1x" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Examples/RATreeViewTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Examples/RATreeViewTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "layers" : [ 3 | { 4 | "filename" : "Front.imagestacklayer" 5 | }, 6 | { 7 | "filename" : "Middle.imagestacklayer" 8 | }, 9 | { 10 | "filename" : "Back.imagestacklayer" 11 | } 12 | ], 13 | "info" : { 14 | "version" : 1, 15 | "author" : "xcode" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Examples/RATreeViewTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Content.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "tv", 5 | "scale" : "1x" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Examples/RATreeViewTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Examples/RATreeViewTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "tv", 5 | "scale" : "1x" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Examples/RATreeViewTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Examples/RATreeViewTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Content.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "tv", 5 | "scale" : "1x" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Examples/RATreeViewTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Examples/RATreeViewTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "layers" : [ 3 | { 4 | "filename" : "Front.imagestacklayer" 5 | }, 6 | { 7 | "filename" : "Middle.imagestacklayer" 8 | }, 9 | { 10 | "filename" : "Back.imagestacklayer" 11 | } 12 | ], 13 | "info" : { 14 | "version" : 1, 15 | "author" : "xcode" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Examples/RATreeViewTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Content.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "tv", 5 | "scale" : "1x" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Examples/RATreeViewTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Examples/RATreeViewTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "tv", 5 | "scale" : "1x" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Examples/RATreeViewTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Examples/RATreeViewTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "assets" : [ 3 | { 4 | "size" : "1280x768", 5 | "idiom" : "tv", 6 | "filename" : "App Icon - Large.imagestack", 7 | "role" : "primary-app-icon" 8 | }, 9 | { 10 | "size" : "400x240", 11 | "idiom" : "tv", 12 | "filename" : "App Icon - Small.imagestack", 13 | "role" : "primary-app-icon" 14 | }, 15 | { 16 | "size" : "1920x720", 17 | "idiom" : "tv", 18 | "filename" : "Top Shelf Image.imageset", 19 | "role" : "top-shelf-image" 20 | } 21 | ], 22 | "info" : { 23 | "version" : 1, 24 | "author" : "xcode" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Examples/RATreeViewTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "tv", 5 | "scale" : "1x" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Examples/RATreeViewTVExample/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Examples/RATreeViewTVExample/Assets.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "landscape", 5 | "idiom" : "tv", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "9.0", 8 | "scale" : "1x" 9 | } 10 | ], 11 | "info" : { 12 | "version" : 1, 13 | "author" : "xcode" 14 | } 15 | } -------------------------------------------------------------------------------- /Examples/RATreeViewTVExample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Examples/RATreeViewTVExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | arm64 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Examples/RATreeViewTVExample/TreeTableViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TreeTableViewCell.swift 3 | // RATreeViewExamples 4 | // 5 | // Created by Rafal Augustyniak on 31/08/16. 6 | // Copyright © 2016 com.Augustyniak. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class TreeTableViewCell : UITableViewCell { 12 | 13 | @IBOutlet private weak var customTitleLabel: UILabel! 14 | @IBOutlet weak var customTitleLabelLeadingConstraint: NSLayoutConstraint! 15 | @IBOutlet private weak var detailsLabel: UILabel! 16 | 17 | override func awakeFromNib() { 18 | selectedBackgroundView? = UIView() 19 | selectedBackgroundView?.backgroundColor = .clear 20 | } 21 | 22 | var additionButtonActionBlock : ((TreeTableViewCell) -> Void)?; 23 | 24 | func setup(withTitle title: String, detailsText: String, level : Int) { 25 | customTitleLabel.text = title 26 | detailsLabel.text = detailsText 27 | self.backgroundView = UIView() 28 | 29 | var color: UIColor 30 | if level == 0 { 31 | color = UIColor(red: 247.0/255.0, green: 247.0/255.0, blue: 247.0/255.0, alpha: 0.25) 32 | } else if level == 1 { 33 | color = UIColor(red: 209.0/255.0, green: 238.0/255.0, blue: 252.0/255.0, alpha: 0.25) 34 | } else { 35 | color = UIColor(red: 224.0/255.0, green: 248.0/255.0, blue: 216.0/255.0, alpha: 0.25) 36 | } 37 | 38 | self.backgroundView?.backgroundColor = color 39 | 40 | let left = 30 + 40 * CGFloat(level) 41 | self.customTitleLabelLeadingConstraint.constant = left 42 | } 43 | 44 | func additionButtonTapped(_ sender : AnyObject) -> Void { 45 | if let action = additionButtonActionBlock { 46 | action(self) 47 | } 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /Examples/RATreeViewTVExample/TreeTableViewCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 23 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Examples/RATreeViewTVExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // RATreeViewTVExample 4 | // 5 | // Created by Rafal Augustyniak on 21/08/16. 6 | // Copyright © 2016 com.Augustyniak. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import RATreeView 11 | 12 | class ViewController: UIViewController, RATreeViewDataSource { 13 | var data : [DataObject] = DataObject.defaultTreeRootChildren() 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | let treeView = RATreeView() 19 | view.addSubview(treeView) 20 | treeView.frame = view.bounds 21 | treeView.dataSource = self 22 | treeView.register(UINib(nibName: String(describing: TreeTableViewCell.self), bundle: nil), forCellReuseIdentifier: String(describing: TreeTableViewCell.self)) 23 | } 24 | 25 | func treeView(_ treeView: RATreeView, numberOfChildrenOfItem item: Any?) -> Int { 26 | if let item = item as? DataObject { 27 | return item.children.count 28 | } else { 29 | return data.count 30 | } 31 | } 32 | 33 | func treeView(_ treeView: RATreeView, cellForItem item: Any?) -> UITableViewCell { 34 | guard let cell = treeView.dequeueReusableCell(withIdentifier: String(describing: TreeTableViewCell.self)) as? TreeTableViewCell, 35 | let item = item as? DataObject else { 36 | fatalError() 37 | } 38 | 39 | let level = treeView.levelForCell(forItem: item) 40 | cell.setup(withTitle: item.name, detailsText: "Number of children: \(item.children.count)", level: level) 41 | 42 | return cell 43 | } 44 | 45 | func treeView(_ treeView: RATreeView, child index: Int, ofItem item: Any?) -> Any { 46 | if item == nil { 47 | return data[index] 48 | } else if let item = item as? DataObject { 49 | return item.children[index] 50 | } else { 51 | fatalError() 52 | } 53 | } 54 | 55 | func treeView(_ treeView: RATreeView, canEditRowForItem item: Any) -> Bool { 56 | return false 57 | } 58 | 59 | func treeView(_ treeView: RATreeView, commit editingStyle: UITableViewCellEditingStyle, forRowForItem item: Any) { 60 | 61 | } 62 | 63 | } 64 | 65 | -------------------------------------------------------------------------------- /Examples/Shared/DataObject.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DataObject.swift 3 | // RATreeViewExamples 4 | // 5 | // Created by Rafal Augustyniak on 22/11/15. 6 | // Copyright © 2015 com.Augustyniak. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | class DataObject 13 | { 14 | let name : String 15 | var children : [DataObject] 16 | 17 | init(name : String, children: [DataObject]) { 18 | self.name = name 19 | self.children = children 20 | } 21 | 22 | convenience init(name : String) { 23 | self.init(name: name, children: [DataObject]()) 24 | } 25 | 26 | func addChild(_ child : DataObject) { 27 | self.children.append(child) 28 | } 29 | 30 | func removeChild(_ child : DataObject) { 31 | self.children = self.children.filter( {$0 !== child}) 32 | } 33 | } 34 | 35 | 36 | extension DataObject { 37 | 38 | static func defaultTreeRootChildren() -> [DataObject] { 39 | let phone1 = DataObject(name: "Phone 1") 40 | let phone2 = DataObject(name: "Phone 2") 41 | let phone3 = DataObject(name: "Phone 3") 42 | let phone4 = DataObject(name: "Phone 4") 43 | let phones = DataObject(name: "Phones", children: [phone1, phone2, phone3, phone4]) 44 | 45 | let notebook1 = DataObject(name: "Notebook 1") 46 | let notebook2 = DataObject(name: "Notebook 2") 47 | 48 | let computer1 = DataObject(name: "Computer 1", children: [notebook1, notebook2]) 49 | let computer2 = DataObject(name: "Computer 2") 50 | let computer3 = DataObject(name: "Computer 3") 51 | let computers = DataObject(name: "Computers", children: [computer1, computer2, computer3]) 52 | 53 | let cars = DataObject(name: "Cars") 54 | let bikes = DataObject(name: "Bikes") 55 | let houses = DataObject(name: "Houses") 56 | let flats = DataObject(name: "Flats") 57 | let motorbikes = DataObject(name: "Motorbikes") 58 | let drinks = DataObject(name: "Drinks") 59 | let food = DataObject(name: "Food") 60 | let sweets = DataObject(name: "Sweets") 61 | let watches = DataObject(name: "Watches") 62 | let walls = DataObject(name: "Walls") 63 | 64 | return [phones, computers, cars, bikes, houses, flats, motorbikes, drinks, food, sweets, watches, walls] 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /LICENCE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Rafał Augustyniak 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /RATreeView.podspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "RATreeView", 3 | "version": "2.1.2", 4 | "summary": "RATreeView provide you a great support to display the tree structures on iOS.", 5 | "homepage": "https://github.com/Augustyniak/RATreeView", 6 | "screenshots": "https://raw.github.com/Augustyniak/RATreeView/master/Screens/animation.gif", 7 | "license": { 8 | "type": "MIT", 9 | "file": "LICENCE.md" 10 | }, 11 | "authors": { 12 | "Rafal Augustyniak": "rafalaugustyniak@gmail.com" 13 | }, 14 | "source": { 15 | "git": "https://github.com/Augustyniak/RATreeView.git", 16 | "tag": "v2.1.2" 17 | }, 18 | "platforms": { 19 | "ios": "7.0", 20 | "tvos": "9.0" 21 | }, 22 | "source_files": "RATreeView/RATreeView/**/*.{h,m}", 23 | "public_header_files": "RATreeView/RATreeView/RATreeView.h", 24 | "requires_arc": true 25 | } 26 | -------------------------------------------------------------------------------- /RATreeView/Framework/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(CURRENT_PROJECT_VERSION) 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /RATreeView/RATreeView.xcodeproj/xcshareddata/xcschemes/RATreeView-iOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /RATreeView/RATreeView.xcodeproj/xcshareddata/xcschemes/RATreeView-tvOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /RATreeView/RATreeView.xcodeproj/xcshareddata/xcschemes/RATreeView.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /RATreeView/RATreeView.xcodeproj/xcshareddata/xcschemes/RATreeViewTests.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 14 | 15 | 17 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 39 | 40 | 41 | 42 | 48 | 49 | 51 | 52 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RABatchChangeEntity.h: -------------------------------------------------------------------------------- 1 | // 2 | // RABatchChangesEntity.h 3 | // RATreeView 4 | // 5 | // Created by Rafal Augustyniak on 17/11/15. 6 | // Copyright © 2015 Rafal Augustyniak. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | 12 | 13 | typedef NS_ENUM(NSInteger, RABatchChangeType) { 14 | RABatchChangeTypeItemRowInsertion = 0, 15 | RABatchChangeTypeItemRowExpansion, 16 | RABatchChangeTypeItemRowDeletion, 17 | RABatchChangeTypeItemRowCollapse, 18 | RABatchChangeTypeItemMove 19 | }; 20 | 21 | 22 | @interface RABatchChangeEntity : NSObject 23 | 24 | @property (nonatomic) RABatchChangeType type; 25 | @property (nonatomic) NSInteger ranking; 26 | @property (nonatomic, copy) void(^updatesBlock)(); 27 | 28 | + (instancetype)batchChangeEntityWithBlock:(void(^)())updates type:(RABatchChangeType)type ranking:(NSInteger)ranking; 29 | 30 | @end 31 | 32 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RABatchChangeEntity.m: -------------------------------------------------------------------------------- 1 | // 2 | // RABatchChangesEntity.m 3 | // RATreeView 4 | // 5 | // Created by Rafal Augustyniak on 17/11/15. 6 | // Copyright © 2015 Rafal Augustyniak. All rights reserved. 7 | // 8 | 9 | 10 | #import "RABatchChangeEntity.h" 11 | 12 | 13 | @implementation RABatchChangeEntity 14 | 15 | + (instancetype)batchChangeEntityWithBlock:(void (^)())updates type:(RABatchChangeType)type ranking:(NSInteger)ranking 16 | { 17 | NSParameterAssert(updates); 18 | RABatchChangeEntity *entity = [RABatchChangeEntity new]; 19 | entity.type = type; 20 | entity.ranking = ranking; 21 | entity.updatesBlock = updates; 22 | 23 | return entity; 24 | } 25 | 26 | - (NSComparisonResult)compare:(RABatchChangeEntity *)otherEntity 27 | { 28 | if ([self destructiveOperation]) { 29 | if (![otherEntity destructiveOperation]) { 30 | return NSOrderedAscending; 31 | } else { 32 | return [@(otherEntity.ranking) compare:@(self.ranking)]; 33 | } 34 | } else if (self.type == RABatchChangeTypeItemMove && otherEntity.type != RABatchChangeTypeItemMove) { 35 | return [otherEntity destructiveOperation] ? NSOrderedAscending : NSOrderedDescending; 36 | 37 | } else if ([self constructiveOperation]) { 38 | if (![otherEntity constructiveOperation]) { 39 | return NSOrderedDescending; 40 | } else { 41 | return [@(self.ranking) compare:@(otherEntity.ranking)]; 42 | } 43 | 44 | } else { 45 | return NSOrderedSame; 46 | } 47 | } 48 | 49 | - (BOOL)constructiveOperation 50 | { 51 | return self.type == RABatchChangeTypeItemRowExpansion 52 | || self.type == RABatchChangeTypeItemRowInsertion; 53 | } 54 | 55 | - (BOOL)destructiveOperation 56 | { 57 | return self.type == RABatchChangeTypeItemRowCollapse 58 | || self.type == RABatchChangeTypeItemRowDeletion; 59 | } 60 | 61 | @end 62 | 63 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RABatchChanges.h: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | #import 22 | 23 | 24 | @interface RABatchChanges : NSObject 25 | 26 | - (void)beginUpdates; 27 | - (void)endUpdates; 28 | 29 | - (void)expandItemWithBlock:(void(^)())update atIndex:(NSInteger)index; 30 | - (void)insertItemWithBlock:(void(^)())update atIndex:(NSInteger)index; 31 | 32 | - (void)collapseItemWithBlock:(void(^)())update lastIndex:(NSInteger)index; 33 | - (void)deleteItemWithBlock:(void(^)())update lastIndex:(NSInteger)index; 34 | 35 | - (void)moveItemWithDeletionBlock:(void (^)())deletionUpdate fromLastIndex:(NSInteger)lastIndex additionBlock:(void (^)())additionUpdate toIndex:(NSInteger)index; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RABatchChanges.m: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | #import "RABatchChanges.h" 22 | #import "RABatchChangeEntity.h" 23 | 24 | 25 | @interface RABatchChanges () 26 | 27 | @property (nonatomic, strong) NSMutableArray *operationsStorage; 28 | @property (nonatomic) NSInteger batchChangesCounter; 29 | 30 | @end 31 | 32 | 33 | 34 | @implementation RABatchChanges 35 | 36 | - (id)init 37 | { 38 | self = [super init]; 39 | if (self) { 40 | _batchChangesCounter = 0; 41 | } 42 | 43 | return self; 44 | } 45 | 46 | - (void)beginUpdates 47 | { 48 | if (self.batchChangesCounter++ == 0) { 49 | self.operationsStorage = [NSMutableArray array]; 50 | } 51 | } 52 | 53 | - (void)endUpdates 54 | { 55 | self.batchChangesCounter--; 56 | if (self.batchChangesCounter == 0) { 57 | [self.operationsStorage sortUsingSelector:@selector(compare:)]; 58 | 59 | for (RABatchChangeEntity *entity in self.operationsStorage) { 60 | entity.updatesBlock(); 61 | } 62 | self.operationsStorage = nil; 63 | } 64 | } 65 | 66 | - (void)insertItemWithBlock:(void (^)())update atIndex:(NSInteger)index 67 | { 68 | RABatchChangeEntity *entity = [RABatchChangeEntity batchChangeEntityWithBlock:update 69 | type:RABatchChangeTypeItemRowInsertion 70 | ranking:index]; 71 | [self addBatchChangeEntity:entity]; 72 | } 73 | 74 | - (void)expandItemWithBlock:(void (^)())update atIndex:(NSInteger)index 75 | { 76 | RABatchChangeEntity *entity= [RABatchChangeEntity batchChangeEntityWithBlock:update 77 | type:RABatchChangeTypeItemRowExpansion 78 | ranking:index]; 79 | [self addBatchChangeEntity:entity]; 80 | } 81 | 82 | - (void)deleteItemWithBlock:(void (^)())update lastIndex:(NSInteger)lastIndex 83 | { 84 | RABatchChangeEntity *entity = [RABatchChangeEntity batchChangeEntityWithBlock:update 85 | type:RABatchChangeTypeItemRowDeletion 86 | ranking:lastIndex]; 87 | [self addBatchChangeEntity:entity]; 88 | } 89 | 90 | - (void)collapseItemWithBlock:(void (^)())update lastIndex:(NSInteger)lastIndex 91 | { 92 | RABatchChangeEntity *entity = [RABatchChangeEntity batchChangeEntityWithBlock:update 93 | type:RABatchChangeTypeItemRowCollapse 94 | ranking:lastIndex]; 95 | [self addBatchChangeEntity:entity]; 96 | } 97 | 98 | - (void)moveItemWithDeletionBlock:(void (^)())deletionUpdate fromLastIndex:(NSInteger)lastIndex additionBlock:(void (^)())additionUpdate toIndex:(NSInteger)index 99 | { 100 | RABatchChangeEntity *firstEntity = [RABatchChangeEntity batchChangeEntityWithBlock:deletionUpdate 101 | type:RABatchChangeTypeItemRowDeletion 102 | ranking:lastIndex]; 103 | 104 | RABatchChangeEntity *secondEntity = [RABatchChangeEntity batchChangeEntityWithBlock:additionUpdate 105 | type:RABatchChangeTypeItemRowInsertion 106 | ranking:index]; 107 | [self addBatchChangeEntity:firstEntity]; 108 | [self addBatchChangeEntity:secondEntity]; 109 | } 110 | 111 | #pragma mark - 112 | 113 | - (void)addBatchChangeEntity:(RABatchChangeEntity *)entity 114 | { 115 | if (self.batchChangesCounter > 0) { 116 | [self.operationsStorage addObject:entity]; 117 | } else { 118 | entity.updatesBlock(); 119 | } 120 | } 121 | 122 | 123 | 124 | @end 125 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RATableView.h: -------------------------------------------------------------------------------- 1 | // 2 | // RATableView.h 3 | // Pods 4 | // 5 | // Created by Rafal Augustyniak on 15/11/15. 6 | // 7 | // 8 | 9 | 10 | #import 11 | 12 | 13 | @interface RATableView : UITableView 14 | 15 | @property (nonatomic, nullable, weak) id tableViewDelegate; 16 | @property (nonatomic, nullable, weak) id scrollViewDelegate; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RATableView.m: -------------------------------------------------------------------------------- 1 | // 2 | // RATableView.m 3 | // Pods 4 | // 5 | // Created by Rafal Augustyniak on 15/11/15. 6 | // 7 | // 8 | 9 | 10 | #import "RATableView.h" 11 | #import 12 | 13 | 14 | @interface RATableView () 15 | 16 | @end 17 | 18 | 19 | @implementation RATableView 20 | 21 | - (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style 22 | { 23 | self = [super initWithFrame:frame style:style]; 24 | if (self) { 25 | [self commonInit]; 26 | } 27 | 28 | return self; 29 | } 30 | 31 | - (instancetype)initWithCoder:(NSCoder *)aDecoder 32 | { 33 | self = [super initWithCoder:aDecoder]; 34 | if (self) { 35 | [self commonInit]; 36 | } 37 | 38 | return self; 39 | } 40 | 41 | - (void)commonInit 42 | { 43 | [super setDelegate:self]; 44 | } 45 | 46 | - (void)setTableViewDelegate:(id)tableViewDelegate 47 | { 48 | if (_tableViewDelegate == tableViewDelegate) { 49 | return; 50 | } 51 | [super setDelegate:nil]; 52 | _tableViewDelegate = tableViewDelegate; 53 | [super setDelegate:self]; 54 | } 55 | 56 | - (void)setDelegate:(id)delegate 57 | { 58 | if (self.scrollViewDelegate == delegate) { 59 | return; 60 | } 61 | [super setDelegate:nil]; 62 | self.scrollViewDelegate = delegate; 63 | [super setDelegate:self]; 64 | } 65 | 66 | - (BOOL)respondsToSelector:(SEL)aSelector 67 | { 68 | return [super respondsToSelector:aSelector] 69 | || (SelectorBelongsToProtocol(@protocol(UIScrollViewDelegate), aSelector) && [self.scrollViewDelegate respondsToSelector:aSelector]) 70 | || (SelectorBelongsToProtocol(@protocol(UITableViewDelegate), aSelector) && [self.tableViewDelegate respondsToSelector:aSelector]); 71 | } 72 | 73 | - (id)forwardingTargetForSelector:(SEL)aSelector 74 | { 75 | if (SelectorBelongsToProtocol(@protocol(UIScrollViewDelegate), aSelector)) { 76 | return self.scrollViewDelegate; 77 | } else if (SelectorBelongsToProtocol(@protocol(UITableViewDelegate), aSelector)) { 78 | return self.tableViewDelegate; 79 | } else { 80 | return nil; 81 | } 82 | } 83 | 84 | 85 | #pragma mark - ScrollView delegate 86 | 87 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView 88 | { 89 | if ([self.scrollViewDelegate respondsToSelector:@selector(scrollViewDidScroll:)]) { 90 | [self.scrollViewDelegate scrollViewDidScroll:scrollView]; 91 | } 92 | } 93 | 94 | - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView 95 | { 96 | if ([self.scrollViewDelegate respondsToSelector:@selector(scrollViewWillBeginDragging:)]) { 97 | [self.scrollViewDelegate scrollViewWillBeginDragging:scrollView]; 98 | } 99 | } 100 | 101 | - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset 102 | { 103 | if ([self.scrollViewDelegate respondsToSelector:@selector(scrollViewWillEndDragging:withVelocity:targetContentOffset:)]) { 104 | [self.scrollViewDelegate scrollViewWillEndDragging:scrollView withVelocity:velocity targetContentOffset:targetContentOffset]; 105 | } 106 | } 107 | 108 | - (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView 109 | { 110 | if ([self.scrollViewDelegate respondsToSelector:@selector(scrollViewShouldScrollToTop:)]) { 111 | return [self.scrollViewDelegate scrollViewShouldScrollToTop:scrollView]; 112 | } 113 | return YES; 114 | } 115 | 116 | - (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView 117 | { 118 | if ([self.scrollViewDelegate respondsToSelector:@selector(scrollViewDidScroll:)]) { 119 | [self.scrollViewDelegate scrollViewDidScroll:scrollView]; 120 | } 121 | } 122 | 123 | - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView 124 | { 125 | if ([self.scrollViewDelegate respondsToSelector:@selector(scrollViewWillBeginDecelerating:)]) { 126 | [self.scrollViewDelegate scrollViewWillBeginDecelerating:scrollView]; 127 | } 128 | } 129 | 130 | - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView 131 | { 132 | if ([self.scrollViewDelegate respondsToSelector:@selector(scrollViewDidEndDecelerating:)]) { 133 | [self.scrollViewDelegate scrollViewDidEndDecelerating:scrollView]; 134 | } 135 | } 136 | 137 | - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView 138 | { 139 | if ([self.scrollViewDelegate respondsToSelector:@selector(viewForZoomingInScrollView:)]) { 140 | return [self.scrollViewDelegate viewForZoomingInScrollView:scrollView]; 141 | } 142 | return nil; 143 | } 144 | 145 | - (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(UIView *)view 146 | { 147 | if ([self.scrollViewDelegate respondsToSelector:@selector(scrollViewWillBeginZooming:withView:)]) { 148 | [self.scrollViewDelegate scrollViewWillBeginZooming:scrollView withView:view]; 149 | } 150 | } 151 | 152 | - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale 153 | { 154 | if ([self.scrollViewDelegate respondsToSelector:@selector(scrollViewDidEndZooming:withView:atScale:)]) { 155 | [self.scrollViewDelegate scrollViewDidEndZooming:scrollView withView:view atScale:scale]; 156 | } 157 | } 158 | 159 | - (void)scrollViewDidZoom:(UIScrollView *)scrollView 160 | { 161 | if ([self.scrollViewDelegate respondsToSelector:@selector(scrollViewDidZoom:)]) { 162 | [self.scrollViewDelegate scrollViewDidZoom:scrollView]; 163 | } 164 | } 165 | 166 | - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView 167 | { 168 | if ([self.scrollViewDelegate respondsToSelector:@selector(scrollViewDidEndScrollingAnimation:)]) { 169 | [self.scrollViewDelegate scrollViewDidEndScrollingAnimation:scrollView]; 170 | } 171 | } 172 | 173 | 174 | #pragma mark - 175 | 176 | static BOOL SelectorBelongsToProtocol(Protocol *protocol, SEL selector) 177 | { 178 | struct objc_method_description methodDescription = protocol_getMethodDescription(protocol, selector, NO, YES); 179 | 180 | return NULL != methodDescription.name; 181 | } 182 | 183 | @end 184 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RATreeNode.h: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | 22 | #import 23 | 24 | @class RATreeNodeItem; 25 | 26 | 27 | @interface RATreeNode : NSObject 28 | 29 | @property (nonatomic, readonly) BOOL expanded; 30 | @property (strong, nonatomic, readonly) id item; 31 | 32 | - (id)initWithLazyItem:(RATreeNodeItem *)item expandedBlock:(BOOL (^)(id))expandedBlock; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RATreeNode.m: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | 22 | #import "RATreeNode.h" 23 | 24 | #import "RATreeNodeItem.h" 25 | 26 | 27 | @interface RATreeNode () { 28 | BOOL _expanded; 29 | } 30 | 31 | @property (nonatomic) BOOL expanded; 32 | @property (nonatomic, strong) RATreeNodeItem *lazyItem; 33 | @property (nonatomic, copy) BOOL (^expandedBlock)(id); 34 | 35 | @end 36 | 37 | 38 | @implementation RATreeNode 39 | 40 | - (id)initWithLazyItem:(RATreeNodeItem *)item expandedBlock:(BOOL (^)(id))expandedBlock; 41 | { 42 | self = [super init]; 43 | if (self) { 44 | _lazyItem = item; 45 | _expandedBlock = expandedBlock; 46 | } 47 | 48 | return self; 49 | } 50 | 51 | 52 | #pragma mark - 53 | 54 | - (RATreeNodeItem *)item 55 | { 56 | return self.lazyItem.item; 57 | } 58 | 59 | - (BOOL)expanded 60 | { 61 | if (self.expandedBlock) { 62 | _expanded = self.expandedBlock(self.item); 63 | self.expandedBlock = nil; 64 | } 65 | 66 | return _expanded; 67 | } 68 | 69 | - (void)setExpanded:(BOOL)expanded 70 | { 71 | self.expandedBlock = nil; 72 | _expanded = expanded; 73 | } 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RATreeNodeCollectionController.h: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | #import 22 | 23 | @class RATreeNodeController, RATreeNode, RATreeNodeCollectionController; 24 | 25 | @protocol RATreeNodeCollectionControllerDataSource 26 | 27 | - (NSInteger)treeNodeCollectionController:(RATreeNodeCollectionController *)controller numberOfChildrenForItem:(id)item; 28 | - (id)treeNodeCollectionController:(RATreeNodeCollectionController *)controller child:(NSInteger)childIndex ofItem:(id)item; 29 | 30 | @end 31 | 32 | 33 | @interface RATreeNodeCollectionController : NSObject 34 | 35 | @property (nonatomic, weak) id dataSource; 36 | @property (nonatomic, readonly) NSInteger numberOfVisibleRowsForItems; 37 | 38 | - (RATreeNode *)treeNodeForIndex:(NSInteger)index; 39 | - (NSInteger)levelForItem:(id)item; 40 | - (id)parentForItem:(id)item; 41 | - (id)childInParent:(id)parent atIndex:(NSInteger)index; 42 | 43 | - (NSInteger)indexForItem:(id)item; 44 | - (NSInteger)lastVisibleDescendantIndexForItem:(id)item; 45 | 46 | - (void)collapseRowForItem:(id)item collapseChildren:(BOOL)collapseChildren updates:(void(^)(NSIndexSet *))updates; 47 | - (void)expandRowForItem:(id)item expandChildren:(BOOL)expandChildren updates:(void (^)(NSIndexSet *))updates; 48 | 49 | - (void)insertItemsAtIndexes:(NSIndexSet *)indexes inParent:(id)item; 50 | - (void)moveItemAtIndex:(NSInteger)index inParent:(id)parent toIndex:(NSInteger)newIndex inParent:(id)newParent updates:(void(^)(NSIndexSet *deletions, NSIndexSet *additions))updates; 51 | - (void)removeItemsAtIndexes:(NSIndexSet *)indexes inParent:(id)item updates:(void(^)(NSIndexSet *))updates; 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RATreeNodeController.h: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | #import 22 | 23 | @class RATreeNodeController, RATreeNode, RATreeNodeItem; 24 | 25 | 26 | @interface RATreeNodeController : NSObject 27 | 28 | @property (nonatomic, weak, readonly) RATreeNodeController *parentController; 29 | @property (nonatomic, strong, readonly) NSArray *childControllers; 30 | 31 | @property (nonatomic, strong, readonly) RATreeNode *treeNode; 32 | @property (nonatomic, readonly) NSInteger index; 33 | @property (nonatomic, readonly) NSInteger numberOfVisibleDescendants; 34 | @property (nonatomic, strong, readonly) NSIndexSet *descendantsIndexes; 35 | @property (nonatomic, readonly) NSInteger level; 36 | 37 | - (instancetype)initWithParent:(RATreeNodeController *)parentController item:(RATreeNodeItem *)item expandedBlock:(BOOL (^)(id))expanded; 38 | 39 | - (void)collapseAndCollapseChildren:(BOOL)collapseChildren; 40 | - (void)expandAndExpandChildren:(BOOL)expandChildren; 41 | 42 | - (void)insertChildControllers:(NSArray *)controllers atIndexes:(NSIndexSet *)indexes; 43 | - (void)moveChildControllerAtIndex:(NSInteger)index toIndex:(NSInteger)newIndex; 44 | - (void)removeChildControllersAtIndexes:(NSIndexSet *)indexes; 45 | 46 | - (NSInteger)indexForItem:(id)item; 47 | - (NSInteger)lastVisibleDescendatIndexForItem:(id)item; 48 | - (RATreeNodeController *)controllerForIndex:(NSInteger)index; 49 | - (RATreeNodeController *)controllerForItem:(id)item; 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RATreeNodeItem+ClassExtension.h: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | #import "RATreeNodeItem.h" 22 | 23 | @interface RATreeNodeItem () 24 | 25 | @property (nonatomic, strong) id item; 26 | @property (nonatomic, weak) id parent; 27 | @property (nonatomic) NSInteger index; 28 | 29 | @property (nonatomic, weak) id dataSource; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RATreeNodeItem+Private.h: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | 22 | #import "RATreeNodeItem.h" 23 | 24 | @protocol RATreeNodeItemDataSource 25 | 26 | - (id)itemForTreeNodeItem:(RATreeNodeItem *)treeNodeItem; 27 | 28 | @end 29 | 30 | 31 | @interface RATreeNodeItem (Private) 32 | 33 | @property (nonatomic, strong, readonly) id parent; 34 | @property (nonatomic, readonly) NSInteger index; 35 | @property (nonatomic, weak) id dataSource; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RATreeNodeItem+Private.m: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | #import "RATreeNodeItem+Private.h" 22 | 23 | @implementation RATreeNodeItem (Private) 24 | 25 | @dynamic dataSource; 26 | @dynamic index; 27 | @dynamic parent; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RATreeNodeItem.h: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | 22 | #import 23 | 24 | @interface RATreeNodeItem : NSObject 25 | 26 | @property (nonatomic, strong, readonly) id item; 27 | 28 | - (instancetype)initWithParent:(id)parent index:(NSInteger)index; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RATreeNodeItem.m: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | 22 | #import "RATreeNodeItem.h" 23 | #import "RATreeNodeItem+Private.h" 24 | #import "RATreeNodeItem+ClassExtension.h" 25 | 26 | 27 | @implementation RATreeNodeItem 28 | 29 | - (instancetype)initWithParent:(id)parent index:(NSInteger)index 30 | { 31 | self = [super init]; 32 | if (self) { 33 | _parent = parent; 34 | _index = index; 35 | } 36 | 37 | return self; 38 | } 39 | 40 | - (id)item 41 | { 42 | if (!_item) { 43 | _item = [self.dataSource itemForTreeNodeItem:self]; 44 | } 45 | return _item; 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RATreeNode_ClassExtension.h: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | #import "RATreeNode.h" 22 | 23 | @interface RATreeNode () 24 | 25 | @property (nonatomic) BOOL expanded; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RATreeView+Enums.h: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | #import "RATreeView.h" 22 | 23 | @interface RATreeView (Enums) 24 | 25 | //Row Animations 26 | + (UITableViewRowAnimation)tableViewRowAnimationForTreeViewRowAnimation:(RATreeViewRowAnimation)rowAnimation; 27 | 28 | #if TARGET_OS_IOS 29 | //Cell Separator Styles 30 | + (RATreeViewCellSeparatorStyle)treeViewCellSeparatorStyleForTableViewSeparatorStyle:(UITableViewCellSeparatorStyle)style; 31 | + (UITableViewCellSeparatorStyle)tableViewCellSeparatorStyleForTreeViewCellSeparatorStyle:(RATreeViewCellSeparatorStyle)style; 32 | #endif 33 | 34 | //Tree View Style 35 | + (UITableViewStyle)tableViewStyleForTreeViewStyle:(RATreeViewStyle)treeViewStyle; 36 | + (RATreeViewStyle)treeViewStyleForTableViewStyle:(UITableViewStyle)tableViewStyle; 37 | 38 | //Scroll Positions 39 | + (UITableViewScrollPosition)tableViewScrollPositionForTreeViewScrollPosition:(RATreeViewScrollPosition)scrollPosition; 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RATreeView+Enums.m: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | #import "RATreeView+Enums.h" 22 | #import "RATreeView.h" 23 | 24 | @implementation RATreeView (Enums) 25 | 26 | #pragma mark Row Animations 27 | 28 | + (UITableViewRowAnimation)tableViewRowAnimationForTreeViewRowAnimation:(RATreeViewRowAnimation)rowAnimation 29 | { 30 | switch (rowAnimation) { 31 | case RATreeViewRowAnimationFade: 32 | return UITableViewRowAnimationFade; 33 | case RATreeViewRowAnimationNone: 34 | return UITableViewRowAnimationNone; 35 | case RATreeViewRowAnimationAutomatic: 36 | return UITableViewRowAnimationAutomatic; 37 | case RATreeViewRowAnimationBottom: 38 | return UITableViewRowAnimationBottom; 39 | case RATreeViewRowAnimationLeft: 40 | return UITableViewRowAnimationLeft; 41 | case RATreeViewRowAnimationMiddle: 42 | return UITableViewRowAnimationMiddle; 43 | case RATreeViewRowAnimationRight: 44 | return UITableViewRowAnimationRight; 45 | case RATreeViewRowAnimationTop: 46 | return UITableViewRowAnimationTop; 47 | default: 48 | return UITableViewRowAnimationNone; 49 | } 50 | } 51 | 52 | #if TARGET_OS_IOS 53 | 54 | #pragma mark Cell Separator Styles 55 | 56 | + (RATreeViewCellSeparatorStyle)treeViewCellSeparatorStyleForTableViewSeparatorStyle:(UITableViewCellSeparatorStyle)style 57 | { 58 | switch (style) { 59 | case UITableViewCellSeparatorStyleNone: 60 | return RATreeViewCellSeparatorStyleNone; 61 | case UITableViewCellSeparatorStyleSingleLine: 62 | return RATreeViewCellSeparatorStyleSingleLine; 63 | case UITableViewCellSeparatorStyleSingleLineEtched: 64 | return RATreeViewCellSeparatorStyleSingleLineEtched; 65 | default: 66 | return RATreeViewCellSeparatorStyleNone; 67 | } 68 | } 69 | 70 | + (UITableViewCellSeparatorStyle)tableViewCellSeparatorStyleForTreeViewCellSeparatorStyle:(RATreeViewCellSeparatorStyle)style 71 | { 72 | switch (style) { 73 | case RATreeViewCellSeparatorStyleNone: 74 | return UITableViewCellSeparatorStyleNone; 75 | case RATreeViewCellSeparatorStyleSingleLine: 76 | return UITableViewCellSeparatorStyleSingleLine; 77 | case RATreeViewCellSeparatorStyleSingleLineEtched: 78 | return UITableViewCellSeparatorStyleSingleLineEtched; 79 | default: 80 | return UITableViewCellSeparatorStyleNone; 81 | } 82 | } 83 | 84 | #endif 85 | 86 | #pragma mark Tree View Style 87 | 88 | + (UITableViewStyle)tableViewStyleForTreeViewStyle:(RATreeViewStyle)treeViewStyle 89 | { 90 | switch (treeViewStyle) { 91 | case RATreeViewStylePlain: 92 | return UITableViewStylePlain; 93 | case RATreeViewStyleGrouped: 94 | return UITableViewStyleGrouped; 95 | } 96 | } 97 | 98 | + (RATreeViewStyle)treeViewStyleForTableViewStyle:(UITableViewStyle)tableViewStyle 99 | { 100 | switch (tableViewStyle) { 101 | case UITableViewStylePlain: 102 | return RATreeViewStylePlain; 103 | case UITableViewStyleGrouped: 104 | return RATreeViewStyleGrouped; 105 | } 106 | } 107 | #pragma mark Scroll Positions 108 | 109 | + (UITableViewScrollPosition)tableViewScrollPositionForTreeViewScrollPosition:(RATreeViewScrollPosition)scrollPosition 110 | { 111 | switch (scrollPosition) { 112 | case RATreeViewScrollPositionNone: 113 | return UITableViewScrollPositionNone; 114 | case RATreeViewScrollPositionTop: 115 | return UITableViewScrollPositionTop; 116 | case RATreeViewScrollPositionMiddle: 117 | return UITableViewScrollPositionMiddle; 118 | case RATreeViewScrollPositionBottom: 119 | return UITableViewScrollPositionBottom; 120 | default: 121 | return UITableViewScrollPositionNone; 122 | } 123 | } 124 | 125 | 126 | @end 127 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RATreeView+Private.h: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | 22 | #import "RATreeView.h" 23 | 24 | 25 | @class RATreeNode; 26 | 27 | 28 | @interface RATreeView (Private) 29 | 30 | - (RATreeNode *)treeNodeForIndexPath:(NSIndexPath *)indexPath; 31 | - (NSIndexPath *)indexPathForItem:(id)item; 32 | 33 | - (void)setupTreeStructure; 34 | 35 | - (void)collapseCellForTreeNode:(RATreeNode *)treeNode; 36 | - (void)collapseCellForTreeNode:(RATreeNode *)treeNode collapseChildren:(BOOL)collapseChildren withRowAnimation:(RATreeViewRowAnimation)rowAnimation; 37 | - (void)expandCellForTreeNode:(RATreeNode *)treeNode; 38 | - (void)expandCellForTreeNode:(RATreeNode *)treeNode expandChildren:(BOOL)expandChildren withRowAnimation:(RATreeViewRowAnimation)rowAnimation; 39 | 40 | - (void)insertItemAtIndex:(NSInteger)index inParent:(id)parent withAnimation:(RATreeViewRowAnimation)animation; 41 | - (void)removeItemAtIndex:(NSInteger)indexe inParent:(id)parent withAnimation:(RATreeViewRowAnimation)animation; 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RATreeView+Private.m: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | #import "RATreeView+Private.h" 22 | #import "RATreeView+Enums.h" 23 | #import "RATreeView+RATreeNodeCollectionControllerDataSource.h" 24 | #import "RATreeView_ClassExtension.h" 25 | 26 | #import "RABatchChanges.h" 27 | 28 | #import "RATreeNode.h" 29 | #import "RATreeNodeController.h" 30 | #import "RATreeNodeCollectionController.h" 31 | 32 | 33 | 34 | @implementation RATreeView (Private) 35 | 36 | - (void)setupTreeStructure 37 | { 38 | self.treeNodeCollectionController = [[RATreeNodeCollectionController alloc] init]; 39 | self.treeNodeCollectionController.dataSource = self; 40 | self.batchChanges = [[RABatchChanges alloc] init]; 41 | } 42 | 43 | - (NSArray *)childrenForItem:(id)item 44 | { 45 | NSParameterAssert(item); 46 | 47 | NSMutableArray *children = [NSMutableArray array]; 48 | NSInteger numberOfChildren = [self.dataSource treeView:self numberOfChildrenOfItem:item]; 49 | 50 | for (int i = 0; i < numberOfChildren; i++) { 51 | [children addObject:[self.dataSource treeView:self child:i ofItem:item]]; 52 | } 53 | 54 | return [NSArray arrayWithArray:children]; 55 | } 56 | 57 | - (RATreeNode *)treeNodeForIndexPath:(NSIndexPath *)indexPath 58 | { 59 | NSParameterAssert(indexPath.section == 0); 60 | return [self.treeNodeCollectionController treeNodeForIndex:indexPath.row]; 61 | } 62 | 63 | - (NSIndexPath *)indexPathForItem:(id)item 64 | { 65 | return [NSIndexPath indexPathForRow:[self.treeNodeCollectionController indexForItem:item] inSection:0]; 66 | } 67 | 68 | 69 | #pragma mark Collapsing and Expanding Rows 70 | 71 | - (void)collapseCellForTreeNode:(RATreeNode *)treeNode 72 | { 73 | [self collapseCellForTreeNode:treeNode collapseChildren:self.collapsesChildRowsWhenRowCollapses withRowAnimation:self.rowsCollapsingAnimation]; 74 | } 75 | 76 | - (void)collapseCellForTreeNode:(RATreeNode *)treeNode collapseChildren:(BOOL)collapseChildren withRowAnimation:(RATreeViewRowAnimation)rowAnimation 77 | { 78 | [self.tableView beginUpdates]; 79 | [self.batchChanges beginUpdates]; 80 | 81 | NSInteger index = [self.treeNodeCollectionController lastVisibleDescendantIndexForItem:treeNode.item]; 82 | 83 | __weak __typeof(self) weakSelf = self; 84 | [self.batchChanges collapseItemWithBlock:^{ 85 | UITableViewRowAnimation tableViewRowAnimation = [RATreeView tableViewRowAnimationForTreeViewRowAnimation:rowAnimation]; 86 | [weakSelf.treeNodeCollectionController collapseRowForItem:treeNode.item collapseChildren:collapseChildren updates:^(NSIndexSet *deletions) { 87 | [weakSelf.tableView deleteRowsAtIndexPaths:IndexesToIndexPaths(deletions) withRowAnimation:tableViewRowAnimation]; 88 | }]; 89 | } lastIndex:index]; 90 | 91 | [self.batchChanges endUpdates]; 92 | [self.tableView endUpdates]; 93 | } 94 | 95 | - (void)expandCellForTreeNode:(RATreeNode *)treeNode 96 | { 97 | [self expandCellForTreeNode:treeNode expandChildren:self.expandsChildRowsWhenRowExpands withRowAnimation:self.rowsExpandingAnimation]; 98 | } 99 | 100 | - (void)expandCellForTreeNode:(RATreeNode *)treeNode expandChildren:(BOOL)expandChildren withRowAnimation:(RATreeViewRowAnimation)rowAnimation 101 | { 102 | [self.tableView beginUpdates]; 103 | [self.batchChanges beginUpdates]; 104 | 105 | NSInteger index = [self.treeNodeCollectionController indexForItem:treeNode.item]; 106 | __weak __typeof(self) weakSelf = self; 107 | [self.batchChanges expandItemWithBlock:^{ 108 | UITableViewRowAnimation tableViewRowAnimation = [RATreeView tableViewRowAnimationForTreeViewRowAnimation:rowAnimation]; 109 | [weakSelf.treeNodeCollectionController expandRowForItem:treeNode.item expandChildren:expandChildren updates:^(NSIndexSet *insertions) { 110 | [weakSelf.tableView insertRowsAtIndexPaths:IndexesToIndexPaths(insertions) withRowAnimation:tableViewRowAnimation]; 111 | }]; 112 | } atIndex:index]; 113 | 114 | 115 | [self.batchChanges endUpdates]; 116 | [self.tableView endUpdates]; 117 | } 118 | 119 | - (void)insertItemAtIndex:(NSInteger)index inParent:(id)parent withAnimation:(RATreeViewRowAnimation)animation 120 | { 121 | NSInteger idx = [self.treeNodeCollectionController indexForItem:parent]; 122 | if (idx == NSNotFound) { 123 | return; 124 | } 125 | idx += index + 1; 126 | 127 | __weak __typeof(self) weakSelf = self; 128 | [self.batchChanges insertItemWithBlock:^{ 129 | [weakSelf.treeNodeCollectionController insertItemsAtIndexes:[NSIndexSet indexSetWithIndex:index] inParent:parent]; 130 | 131 | NSIndexPath *indexPath = [NSIndexPath indexPathForRow:idx inSection:0]; 132 | UITableViewRowAnimation tableViewRowAnimation = [RATreeView tableViewRowAnimationForTreeViewRowAnimation:animation]; 133 | [weakSelf.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:tableViewRowAnimation]; 134 | 135 | } atIndex:idx]; 136 | } 137 | 138 | #pragma clang diagnostic push 139 | #pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation" 140 | - (void)moveItemAtIndex:(NSInteger)index inParent:(id)parent toIndex:(NSInteger)newIndex inParent:(id)newParent 141 | #pragma clang diagnostic pop 142 | { 143 | NSInteger idx = [self.treeNodeCollectionController indexForItem:parent]; 144 | if (idx == NSNotFound) { 145 | return; 146 | } 147 | 148 | idx += index + 1; 149 | __weak __typeof(self) weakSelf = self; 150 | [self.batchChanges insertItemWithBlock:^{ 151 | [weakSelf.treeNodeCollectionController moveItemAtIndex:index inParent:parent toIndex:newIndex inParent:newParent updates:^(NSIndexSet *deletions, NSIndexSet *additions) { 152 | NSArray *deletionsArray = IndexesToIndexPaths(deletions); 153 | NSArray *additionsArray = IndexesToIndexPaths(additions); 154 | 155 | NSInteger i = 0; 156 | for (NSIndexPath *deletedIndexPath in deletionsArray) { 157 | [weakSelf.tableView moveRowAtIndexPath:deletedIndexPath toIndexPath:additionsArray[i]]; 158 | i++; 159 | } 160 | }]; 161 | } atIndex:idx]; 162 | } 163 | 164 | - (void)removeItemAtIndex:(NSInteger)index inParent:(id)parent withAnimation:(RATreeViewRowAnimation)animation 165 | { 166 | id child = [self.treeNodeCollectionController childInParent:parent atIndex:index]; 167 | NSInteger idx = [self.treeNodeCollectionController lastVisibleDescendantIndexForItem:child]; 168 | if (idx == NSNotFound) { 169 | return; 170 | } 171 | 172 | __weak __typeof(self) weakSelf = self; 173 | [self.batchChanges insertItemWithBlock:^{ 174 | [weakSelf.treeNodeCollectionController removeItemsAtIndexes:[NSIndexSet indexSetWithIndex:index] inParent:parent updates:^(NSIndexSet *removedIndexes) { 175 | UITableViewRowAnimation tableViewRowAnimation = [RATreeView tableViewRowAnimationForTreeViewRowAnimation:animation]; 176 | [weakSelf.tableView deleteRowsAtIndexPaths:IndexesToIndexPaths(removedIndexes) withRowAnimation:tableViewRowAnimation]; 177 | }]; 178 | } atIndex:idx]; 179 | } 180 | 181 | #pragma mark - 182 | 183 | static NSArray * IndexesToIndexPaths(NSIndexSet *indexes) 184 | { 185 | NSMutableArray *indexPaths = [NSMutableArray array]; 186 | [indexes enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) { 187 | [indexPaths addObject:[NSIndexPath indexPathForRow:idx inSection:0]]; 188 | }]; 189 | return [indexPaths copy]; 190 | } 191 | 192 | @end 193 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RATreeView+RATreeNodeCollectionControllerDataSource.h: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | #import "RATreeView.h" 22 | #import "RATreeNodeCollectionController.h" 23 | 24 | @interface RATreeView (RATreeNodeCollectionControllerDataSource) 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RATreeView+RATreeNodeCollectionControllerDataSource.m: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | #import "RATreeView+RATreeNodeCollectionControllerDataSource.h" 22 | 23 | @implementation RATreeView (RATreeNodeCollectionControllerDataSource) 24 | 25 | - (NSInteger)treeNodeCollectionController:(RATreeNodeCollectionController *)controller numberOfChildrenForItem:(id)item 26 | { 27 | return [self.dataSource treeView:self numberOfChildrenOfItem:item]; 28 | } 29 | 30 | - (id)treeNodeCollectionController:(RATreeNodeCollectionController *)controller child:(NSInteger)childIndex ofItem:(id)item 31 | { 32 | return [self.dataSource treeView:self child:childIndex ofItem:item]; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RATreeView+TableViewDataSource.h: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | #import "RATreeView.h" 22 | 23 | @interface RATreeView (TableViewDataSource) 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RATreeView+TableViewDataSource.m: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | #import "RATreeView+TableViewDataSource.h" 22 | #import "RATreeView+Private.h" 23 | #import "RATreeView_ClassExtension.h" 24 | 25 | #import "RATreeNodeCollectionController.h" 26 | #import "RATreeNodeController.h" 27 | #import "RATreeNode.h" 28 | 29 | @implementation RATreeView (TableViewDataSource) 30 | 31 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 32 | { 33 | return 1; 34 | } 35 | 36 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 37 | { 38 | if (self.treeNodeCollectionController == nil) { 39 | [self setupTreeStructure]; 40 | } 41 | return self.treeNodeCollectionController.numberOfVisibleRowsForItems; 42 | } 43 | 44 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 45 | { 46 | RATreeNode *treeNode = [self treeNodeForIndexPath:indexPath]; 47 | return [self.dataSource treeView:self cellForItem:treeNode.item]; 48 | } 49 | 50 | 51 | #pragma mark - Inserting or Deleting Table Rows 52 | 53 | - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 54 | { 55 | if ([self.dataSource respondsToSelector:@selector(treeView:commitEditingStyle:forRowForItem:)]) { 56 | RATreeNode *treeNode = [self treeNodeForIndexPath:indexPath]; 57 | [self.dataSource treeView:self commitEditingStyle:editingStyle forRowForItem:treeNode.item]; 58 | } 59 | } 60 | 61 | - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath 62 | { 63 | if ([self.dataSource respondsToSelector:@selector(treeView:canEditRowForItem:)]) { 64 | RATreeNode *treeNode = [self treeNodeForIndexPath:indexPath]; 65 | return [self.dataSource treeView:self canEditRowForItem:treeNode.item]; 66 | } 67 | return YES; 68 | } 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RATreeView+TableViewDelegate.h: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | #import "RATreeView.h" 22 | 23 | @interface RATreeView (TableViewDelegate) 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /RATreeView/RATreeView/Private Files/RATreeView_ClassExtension.h: -------------------------------------------------------------------------------- 1 | 2 | //The MIT License (MIT) 3 | // 4 | //Copyright (c) 2014 Rafał Augustyniak 5 | // 6 | //Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | //this software and associated documentation files (the "Software"), to deal in 8 | //the Software without restriction, including without limitation the rights to 9 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | //the Software, and to permit persons to whom the Software is furnished to do so, 11 | //subject to the following conditions: 12 | // 13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | // 20 | 21 | #import "RATreeView.h" 22 | 23 | @class RABatchChanges; 24 | 25 | 26 | @interface RATreeView () 27 | 28 | @property (nonatomic, strong) UITableView *tableView; 29 | @property (nonatomic, strong) RATreeNodeCollectionController *treeNodeCollectionController; 30 | 31 | @property (nonatomic, strong) RABatchChanges *batchChanges; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /RATreeView/RATreeViewTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | 24 | 25 | -------------------------------------------------------------------------------- /RATreeView/RATreeViewTests/RABatchChangeEntityTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // RABatchChangeEntityTests.m 3 | // RATreeView 4 | // 5 | // Created by Rafal Augustyniak on 17/11/15. 6 | // Copyright © 2015 Rafal Augustyniak. All rights reserved. 7 | // 8 | 9 | 10 | #import "RABatchChangeEntity.h" 11 | 12 | #import 13 | #import 14 | 15 | 16 | @interface RABatchChangeEntityTests : XCTestCase 17 | 18 | @end 19 | 20 | 21 | @implementation RABatchChangeEntityTests 22 | 23 | - (void)testWhetherExpansionOperationWithGreaterRankingIsGreaterThanExpansionOperationWithLowerRanking 24 | { 25 | RABatchChangeEntity *entity1 = [RABatchChangeEntity batchChangeEntityWithBlock:^{} 26 | type:RABatchChangeTypeItemRowExpansion 27 | ranking:1]; 28 | RABatchChangeEntity *entity2 = [RABatchChangeEntity batchChangeEntityWithBlock:^{} 29 | type:RABatchChangeTypeItemRowExpansion 30 | ranking:2]; 31 | NSArray *items = @[entity1, entity2]; 32 | items = [items sortedArrayUsingSelector:@selector(compare:)]; 33 | 34 | XCTAssertTrue(RAIsAscendingOrder(items, entity1, entity2)); 35 | } 36 | 37 | - (void)testWhetherCollapseOperationWithLowerRankingIsGreaterThanCollapseOperationWithGreaterRanking 38 | { 39 | RABatchChangeEntity *entity1 = [RABatchChangeEntity batchChangeEntityWithBlock:^{} 40 | type:RABatchChangeTypeItemRowCollapse 41 | ranking:1]; 42 | RABatchChangeEntity *entity2 = [RABatchChangeEntity batchChangeEntityWithBlock:^{} 43 | type:RABatchChangeTypeItemRowCollapse 44 | ranking:2]; 45 | NSArray *items = @[entity1, entity2]; 46 | items = [items sortedArrayUsingSelector:@selector(compare:)]; 47 | XCTAssertTrue(RAIsDescendingOrder(items, entity1, entity2)); 48 | } 49 | 50 | - (void)testWhetherExpansionOperationsAreGreaterThanCollapseOperations 51 | { 52 | void (^performTestScenarion)(NSInteger expansionRanking, NSInteger collapseRanking) = ^(NSInteger expansionRanking, NSInteger collapseRanking) { 53 | RABatchChangeEntity *entity1 = [RABatchChangeEntity batchChangeEntityWithBlock:^{} 54 | type:RABatchChangeTypeItemRowExpansion 55 | ranking:expansionRanking]; 56 | RABatchChangeEntity *entity2 = [RABatchChangeEntity batchChangeEntityWithBlock:^{} 57 | type:RABatchChangeTypeItemRowCollapse 58 | ranking:collapseRanking]; 59 | NSArray *items = @[entity1, entity2]; 60 | items = [items sortedArrayUsingSelector:@selector(compare:)]; 61 | XCTAssertTrue(RAIsDescendingOrder(items, entity1, entity2)); 62 | }; 63 | 64 | performTestScenarion(1, 0); 65 | performTestScenarion(1, 1); 66 | performTestScenarion(1, 2); 67 | } 68 | 69 | 70 | #pragma mark - 71 | 72 | static BOOL RAIsAscendingOrder(NSArray *items, id item1, id item2) 73 | { 74 | return RAOrdering(items, item1, item2) == NSOrderedAscending; 75 | } 76 | 77 | static BOOL RAIsDescendingOrder(NSArray *items, id item1, id item2) 78 | { 79 | return RAOrdering(items, item1, item2) == NSOrderedDescending; 80 | } 81 | 82 | static NSComparisonResult RAOrdering(NSArray *items, id item1, id item2) 83 | { 84 | NSInteger index1 = [items indexOfObject:item1]; 85 | NSInteger index2 = [items indexOfObject:item2]; 86 | return [@(index1) compare:@(index2)]; 87 | } 88 | 89 | @end 90 | -------------------------------------------------------------------------------- /RATreeView/RATreeViewTests/RATreeViewTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // RATreeViewTests.m 3 | // RATreeViewTests 4 | // 5 | // Created by Rafal Augustyniak on 15/11/15. 6 | // Copyright © 2015 Rafal Augustyniak. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RATreeViewTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation RATreeViewTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | RATreeView (iOS 7.0+, tvOS 9.0+) 2 | ============== 3 | 4 | 👷 Project created and maintained by [Rafał Augustyniak](http://augustyniak.me). You can find me on twitter ([@RaAugustyniak](https://twitter.com/RaAugustyniak)). 5 | 6 | 7 | Introduction 8 | ----------------- 9 | 10 | [![Twitter: @raaugustyniak](https://img.shields.io/badge/contact-@raaugustyniak-blue.svg?style=flat)](https://twitter.com/raaugustyniak) 11 | [![Build Status](https://img.shields.io/travis/Augustyniak/RATreeView/master.svg?style=flat)](https://travis-ci.org/Augustyniak/RATreeView) 12 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 13 | [![CocoaPods](https://img.shields.io/cocoapods/v/RATreeView.svg?style=flat)](https://github.com/Augustyniak/RATreeView) 14 | [![Platform](https://img.shields.io/cocoapods/p/RATreeView.svg?style=flat)](http://cocoadocs.org/docsets/RATreeView) 15 | [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://github.com/Augustyniak/RATreeView/blob/master/LICENCE.md) 16 | 17 | iOS | tvOS 18 | :-------------------------:|:-------------------------: 19 | [![](https://raw.github.com/Augustyniak/RATreeView/master/Screens/animation.gif)](https://raw.github.com/Augustyniak/RATreeView/master/Screens/animation.gif) | [![](https://raw.github.com/Augustyniak/RATreeView/master/Screens/tvos_animation.gif)](https://raw.github.com/Augustyniak/RATreeView/master/Screens/tvos_animation.gif) 20 | 21 | 22 | 23 | 24 | 25 | RATreeView is a class designed to provide easy and pleasant way to work with tree views on iOS and tvOS. It works as a wrapper for the UITableView, defining its own delegate and data source methods which make working with tree data structures really easy. 26 | 27 | RATreeView is highly customizable and has a lot of features. 28 | 29 | 30 | Installation 31 | ----------------- 32 | 33 | ### CocoaPods 34 | 35 | [CocoaPods](http://www.cocoapods.org) is the recommended way to add RATreeView to your project. 36 | 37 | 1. Add additional entry to your Podfile. 38 | 39 | ```ruby 40 | pod "RATreeView", "~> 2.1.2" 41 | ``` 42 | 43 | 2. Install Pod(s) running `pod install` command. 44 | 3. Include RATreeView using `#import `. 45 | 46 | ###Source files 47 | 48 | 1. Downloaded the latest version of the library using [link](https://github.com/Augustyniak/RATreeView/archive/master.zip). 49 | 2. Copy content of the downloaded (and unzipped) zip file into your project by dragging it into Project's navigator files structure. 50 | 51 | 52 | 53 | Requirements 54 | ----------------- 55 | 56 | 57 | * Xcode 5 58 | * iOS 7 or newer/tvOS 9 or newer 59 | 60 | 61 | Usage 62 | ----------------- 63 | 64 | 65 | Check out the demo for example usage of library. Make sure you read the [RATreeView documentation on Cocoa Docs](http://cocoadocs.org/docsets/RATreeView/2.1.2). 66 | 67 | 68 | ### Basics 69 | 70 | 1. Add following import in file of your project when you want to use RATreeView: 71 | 72 | ```objc 73 | // In case you are using RATreeView with CocoaPods 74 | #import 75 | ``` 76 | 77 | ```objc 78 | // In case you are using RATreeView by simply copying 79 | // source files of the RATreeView into your project 80 | #import "RATreeView.h" 81 | ``` 82 | 83 | 2. Simplest way to initialize and configure RATreeView: 84 | 85 | ```objc 86 | RATreeView *treeView = [[RATreeView alloc] initWithFrame:self.view.bounds]; 87 | treeView.delegate = self; 88 | treeView.dataSource = self; 89 | [self.view addSubview:treeView]; 90 | [treeView reloadData]; 91 | ``` 92 | 93 | 3. Implement required methods of the RATreeView's data source: 94 | 95 | ```objc 96 | - (NSInteger)treeView:(RATreeView *)treeView numberOfChildrenOfItem:(id)item 97 | { 98 | return item ? 3 : 0; 99 | } 100 | ``` 101 | 102 | ```objc 103 | - (UITableViewCell *)treeView:(RATreeView *)treeView cellForItem:(id)item treeNodeInfo:(RATreeNodeInfo *)treeNodeInfo 104 | { 105 | // create and configure cell for *item* 106 | return cell 107 | } 108 | ``` 109 | 110 | ```objc 111 | - (id)treeView:(RATreeView *)treeView child:(NSInteger)index ofItem:(id)item 112 | { 113 | return @(index); 114 | } 115 | ``` 116 | 117 | ### Adding Pull to Refresh control 118 | 119 | Adding pull to refresh gesture is really easy using `RATreeView` and standard `UIRefreshControl` control. 120 | 121 | [![](https://raw.github.com/Augustyniak/RATreeView/master/Screens/PullToRefresh.png)](https://raw.github.com/Augustyniak/RATreeView/master/Screens/PullToRefresh.png) 122 | 123 | ```objc 124 | UIRefreshControl *refreshControl = [UIRefreshControl new]; 125 | [refreshControl addTarget:self action:@selector(refreshControlChanged:) forControlEvents:UIControlEventValueChanged]; 126 | [treeView.scrollView addSubview:refreshControl]; 127 | ``` 128 | 129 | Documentation 130 | ----------------- 131 | 132 | Documentation is available on [CocoaPods](http://cocoadocs.org/docsets/RATreeView/2.1.2). 133 | 134 | TODO 135 | ----------------- 136 | 137 | - Better delegate callbacks in case of recursive collapse and expand operations. 138 | - Improved documentation. 139 | - Unit tests. 140 | - Re-order rows feature. 141 | 142 | Author 143 | ----------------- 144 | 145 | RATreeView was created by Rafał Augustyniak. You can find me on twitter ([@RaAugustyniak](https://twitter.com/RaAugustyniak)). 146 | 147 | 148 | Release Notes 149 | ----------------- 150 | 151 | Information about newer versions of the library can be found in the [releases section](https://github.com/Augustyniak/RATreeView/releases) of the repository. 152 | 153 | Version 1.0.2 154 | - Fixed bug in select and deselect operations. 155 | - Fixed bug in recursive expand operation (via @Arrnas). 156 | 157 | Version 1.0.1 158 | - Fixed bug in recursive expand operation. 159 | 160 | Version 1.0.0 161 | 162 | - Improved performance. 163 | - Added recursive expand operation. It can be performed by using `expandRowForItem: expandChildren:withRowAnimation:` method. Default behavior is non recursive expand. 164 | - Added recursive collapse operation. It can be performed by using `collapseRowForItem: expandChildren:withRowAnimation:` method. Default behavior is non recursive collapse. 165 | - Fixed bug in `itemForRowAtPoint:` method when passed point isn't inside any cell. 166 | 167 | Version 0.9.2 168 | 169 | - Fixed bug in `endUpdates` method. 170 | 171 | Version 0.9.1 172 | 173 | - Fixed behaviour of treeView:willSelectRowForItem: delegate method. 174 | 175 | Version 0.9.0 176 | 177 | - Added possiblity to change content of the RATreeView dynamically. Possible row operations: 178 | - additions 179 | - deletions 180 | - repositions 181 | - Added additional 'cell accessing' methods. 182 | - Removed `RATreeNodeInfo` class. 183 | - Added additional instance methods in RATreeView which substitute functionality provided by `RATreeNodeInfo` class. 184 | - Bug fixes. 185 | 186 | License 187 | ----------------- 188 | 189 | MIT licensed, Copyright (c) 2014 Rafał Augustyniak, [@RaAugustyniak](http://twitter.com/RaAugustyniak) 190 | 191 | -------------------------------------------------------------------------------- /Screens/PullToRefresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Augustyniak/RATreeView/e965339a3a375764a8d62ffa58861bd742682a8f/Screens/PullToRefresh.png -------------------------------------------------------------------------------- /Screens/animation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Augustyniak/RATreeView/e965339a3a375764a8d62ffa58861bd742682a8f/Screens/animation.gif -------------------------------------------------------------------------------- /Screens/tvos_animation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Augustyniak/RATreeView/e965339a3a375764a8d62ffa58861bd742682a8f/Screens/tvos_animation.gif --------------------------------------------------------------------------------