Skip to content

Commit

Permalink
Merge pull request #152 from fermoya/develop
Browse files Browse the repository at this point in the history
Version 1.13.0
  • Loading branch information
fermoya authored Nov 2, 2020
2 parents 0883ceb + 2fc85da commit 2c7816c
Show file tree
Hide file tree
Showing 15 changed files with 138 additions and 68 deletions.
21 changes: 1 addition & 20 deletions .github/workflows/build-platforms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,4 @@ jobs:
- uses: actions/checkout@v2

- name: Run script
run: |
gem install xcpretty
SCHEMES=( SwiftUIPager_Catalyst SwiftUIPager_macOS SwiftUIPager_iOS SwiftUIPager_watchOS SwiftUIPager_tvOS )
PLATFORMS=( "platform=macOS,variant=Mac Catalyst" "platform=macOS" "generic/platform=iOS" "generic/platform=watchOS" "generic/platform=tvOS" )
DIR=$(xcodebuild -project SwiftUIPager.xcodeproj -showBuildSettings | grep -m 1 "BUILD_DIR" | grep -oEi "\/.*")
for i in ${!SCHEMES[@]}; do
xcodebuild clean build -scheme ${SCHEMES[$i]} \
-project SwiftUIPager.xcodeproj \
-destination "${PLATFORMS[$i]}" | xcpretty
COUNT=$(find $DIR -maxdepth 1 -type d | wc -l)
if [ $COUNT -eq 2 ]; then
echo "$(tput setaf 2)Build succeded for target ${SCHEMES[$i]}$(tput sgr0)"
else
echo "$(tput setaf 1)Build failed for target ${SCHEMES[$i]}$(tput sgr0)"
exit 1
fi
done
run: ./scripts/build_platforms.sh
4 changes: 3 additions & 1 deletion .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ jobs:
token: '${{ secrets.PERSONAL_TOKEN }}'

- name: Bump version and push tag
uses: anothrNick/github-tag-action@1.30.0
uses: anothrNick/github-tag-action@1.33.0
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
TAG_CONTEXT: repo
RELEASE_BRANCHES: master
DEFAULT_BUMP: none
WITH_V: false
PRERELEASE_SUFFIX: beta
VERBOSE: false
19 changes: 10 additions & 9 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ jobs:
- uses: actions/checkout@v2

- name: Create XCFramework
uses: unsignedapps/swift-create-xcframework@v1
id: xcframework
run: ./scripts/build_xcframework.sh

- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: SwiftUIPager.xcframework.zip
path: ${{ steps.xcframework.outputs.path }}

create_release:
name: Create Release and Upload artfifacts
Expand All @@ -32,11 +39,7 @@ jobs:
run: |
name=VERSION::${GITHUB_REF/refs\/tags\//}
echo "Tag: $name"
if [[ "$name" == *"beta"* ]]; then
prerelease=true
else
prerelease=false
fi
if [[ "$name" == *"beta"* ]]; then prerelease=true; else prerelease=false; fi
echo ::set-output name=prerelease::$prerelease
- name: Create Release
Expand All @@ -55,10 +58,8 @@ jobs:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: SwiftUIPager.zip
name: SwiftUIPager.xcframework.zip
path: ./

- run: mv SwiftUIPager.zip SwiftUIPager.xcframework.zip

- name: Upload Release Asset
id: upload-release-asset
Expand Down
32 changes: 4 additions & 28 deletions .github/workflows/rebase-legacy-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
name: Rebase branch legacy-projects

on:
# Trigger the workflow on push pull request or manually
push:
branches: [ develop ]

Expand All @@ -13,7 +12,9 @@ jobs:
rebase:
name: Checkout legacy-projects and rebase
runs-on: ubuntu-latest
steps:
steps:
- uses: actions/checkout@v2

- name: Automatic Rebase
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
Expand All @@ -22,29 +23,4 @@ jobs:
USER_EMAIL: [email protected]
OUTDATED_BRANCH: legacy-projects
BASE_BRANCH: develop
run: |
FOLDER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f2)
git clone https://x-access-token:[email protected]/$GITHUB_REPOSITORY.git
cd $FOLDER
git checkout $OUTDATED_BRANCH
echo Adding origin as $GITHUB_REPOSITORY
git remote set-url origin https://x-access-token:[email protected]/$GITHUB_REPOSITORY.git
git config --global user.email "$USER_EMAIL"
git config --global user.name "$USER_NAME"
git fetch origin $BASE_BRANCH
echo git pull --rebase origin $OUTDATED_BRANCH
git pull --rebase origin $OUTDATED_BRANCH
echo Rebasing $BASE_BRANCH onto $OUTDATED_BRANCH
echo git rebase origin/$BASE_BRANCH
git rebase origin/$BASE_BRANCH
echo git push --force-with-lease origin $OUTDATED_BRANCH
git push --force-with-lease origin $OUTDATED_BRANCH
cd ..
rm -rf $FOLDER
run: ./scripts/rebase.sh
9 changes: 9 additions & 0 deletions Documentation/Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ whereas a value greater than one will make it look like a box:

<img src="/resources/usage/page_aspect_ratio_greater_than_1.png" alt="itemAspectRatio greater than 1" height="640"/>

### Pagination sensitivity

By default, `Pager` will increase/decrease the current `page` if this shift is greather than 50% of its relative size. If you wish to make this transition easier or, on the contrary, make it harder to happen, use `sensitivity` to modify this relative value. For instance, to make transitions easier:

```swift
Pager(...)
.sensitivity(.high)
```

### Orientation and direction

By default, `Pager` will create a horizontal container. Use `vertical` to create a vertical pager:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Create vertical or horizontal pagers, align the cards, change the direction of t
- [Initialization](Documentation/Usage.md#initialization)
- [UI customization](Documentation/Usage.md#ui-customization)
- [Configure your page size](Documentation/Usage.md#configure-your-page-size)
- [Pagination sensitivity](Documentation/Usage.md#pagination-sensitivity)
- [Orientation and direction](Documentation/Usage.md#orientation-and-direction)
- [Alignment](Documentation/Usage.md#alignment)
- [Multiple pagination](Documentation/Usage.md#multiple-pagination)
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftUIPager/Helpers/CGPoint+Angle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ extension CGPoint {

}

@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
extension Angle {
var isAlongXAxis: Bool {
let degrees = ((Int(self.degrees.rounded()) % 360) + 360) % 360
Expand Down
2 changes: 2 additions & 0 deletions Sources/SwiftUIPager/Pager+Buildable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ extension Pager: Buildable, PagerProxy {
#if !os(tvOS)

/// Sensitivity used to determine whether or not to swipe the page
///
/// - Parameter value: sensitivity to be applied when paginating
public func sensitivity(_ value: PaginationSensitivity) -> Self {
mutating(keyPath: \.sensitivity, value: value)
}
Expand Down
12 changes: 6 additions & 6 deletions Sources/SwiftUIPager/Pager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,12 @@ public struct Pager<Element, ID, PageView>: View where PageView: View, Element:
/// Initializes a new `Pager`.
///
/// - Parameter page: Binding to the page index
/// - Parameter data: Array of items to populate the content
/// - Parameter data: Collection of items to populate the content
/// - Parameter id: KeyPath to identifiable property
/// - Parameter content: Factory method to build new pages
public init(page: Binding<Int>, data: [Element], id: KeyPath<Element, ID>, @ViewBuilder content: @escaping (Element) -> PageView) {
public init<Data: RandomAccessCollection>(page: Binding<Int>, data: Data, id: KeyPath<Element, ID>, @ViewBuilder content: @escaping (Element) -> PageView) where Data.Index == Int, Data.Element == Element {
self._page = page
self.data = data
self.data = Array(data)
self.id = id
self.content = content
}
Expand Down Expand Up @@ -228,10 +228,10 @@ extension Pager where ID == Element.ID, Element : Identifiable {

/// Initializes a new Pager.
///
/// - Parameter data: Array of items to populate the content
/// - Parameter data: Collection of items to populate the content
/// - Parameter content: Factory method to build new pages
public init(page: Binding<Int>, data: [Element], @ViewBuilder content: @escaping (Element) -> PageView) {
self.init(page: page, data: data, id: \Element.id, content: content)
public init<Data: RandomAccessCollection>(page: Binding<Int>, data: Data, @ViewBuilder content: @escaping (Element) -> PageView) where Data.Index == Int, Data.Element == Element {
self.init(page: page, data: Array(data), id: \Element.id, content: content)
}

}
2 changes: 2 additions & 0 deletions Sources/SwiftUIPager/PagerContent+Buildable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ extension Pager.PagerContent: Buildable, PagerProxy {
#if !os(tvOS)

/// Sensitivity used to determine whether or not to swipe the page
///
/// - Parameter value: sensitivity to be applied when paginating
func sensitivity(_ value: PaginationSensitivity) -> Self {
mutating(keyPath: \.sensitivity, value: value)
}
Expand Down
8 changes: 4 additions & 4 deletions SwiftUIPager.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@

/* Begin PBXFileReference section */
172F4D6023DF830600FD2F15 /* SwiftUIPager.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftUIPager.framework; sourceTree = BUILT_PRODUCTS_DIR; };
172F4D6123DF830600FD2F15 /* Info-macOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "Info-macOS.plist"; path = "/Users/fernando.moyaderivas/Documents/Playgrounds/SwiftUIPager/SwiftUIPager/Info-macOS.plist"; sourceTree = "<absolute>"; };
172F4D6123DF830600FD2F15 /* Info-macOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-macOS.plist"; sourceTree = "<group>"; };
172F4D7823DF8A6400FD2F15 /* SwiftUIPager.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftUIPager.framework; sourceTree = BUILT_PRODUCTS_DIR; };
172F4D7B23DF8A6400FD2F15 /* Info-watchOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-watchOS.plist"; sourceTree = "<group>"; };
6B0F33DD24B4A4DE006031BE /* OnDeactivateModifier.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnDeactivateModifier.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -548,7 +548,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "rm -rd \"SwiftUIPager.xcframework\"\nxcodebuild archive -scheme SwiftUIPager_macOS \\\n -destination \"platform=macOS\" \\\n -archivePath \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.macOS.xcarchive\" \\\n SKIP_INSTALL=NO \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES\n\nxcodebuild archive -scheme SwiftUIPager_iOS \\\n -destination \"generic/platform=iOS\" \\\n -archivePath \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.iOS.xcarchive\" \\\n SKIP_INSTALL=NO \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES\n\nxcodebuild archive -scheme SwiftUIPager_iOS \\\n -destination \"generic/platform=iOS Simulator\" \\\n -archivePath \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.iOS-simulator.xcarchive\" \\\n SKIP_INSTALL=NO \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES\n\nxcodebuild archive -scheme SwiftUIPager_Catalyst \\\n -destination \"platform=macOS,variant=Mac Catalyst\" \\\n -archivePath \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.macCatalyst.xcarchive\" \\\n SKIP_INSTALL=NO \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES\n\nxcodebuild archive -scheme SwiftUIPager_watchOS \\\n -destination \"generic/platform=watchOS\" \\\n -archivePath \"$TEMP_DIR/SwiftUIPager//SwiftUIPager.watchOS.xcarchive\" \\\n SKIP_INSTALL=NO \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES\n\nxcodebuild archive -scheme SwiftUIPager_watchOS \\\n -destination \"generic/platform=watchOS Simulator\" \\\n -archivePath \"$TEMP_DIR/SwiftUIPager//SwiftUIPager.watchOS-simulator.xcarchive\" \\\n SKIP_INSTALL=NO \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES\n\nxcodebuild archive -scheme SwiftUIPager_tvOS \\\n -destination \"generic/platform=tvOS\" \\\n -archivePath \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.tvOS.xcarchive\" \\\n SKIP_INSTALL=NO \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES\n\nxcodebuild archive -scheme SwiftUIPager_tvOS \\\n -destination \"generic/platform=tvOS Simulator\" \\\n -archivePath \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.tvOS-simulator.xcarchive\" \\\n SKIP_INSTALL=NO \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES\n\nxcodebuild -create-xcframework \\\n -framework \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.macOS.xcarchive/Products/Library/Frameworks/SwiftUIPager.framework\" \\\n -framework \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.iOS.xcarchive/Products/Library/Frameworks/SwiftUIPager.framework\" \\\n -framework \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.iOS-simulator.xcarchive/Products/Library/Frameworks/SwiftUIPager.framework\" \\\n -framework \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.macCatalyst.xcarchive/Products/Library/Frameworks/SwiftUIPager.framework\" \\\n -framework \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.watchOS.xcarchive/Products/Library/Frameworks/SwiftUIPager.framework\" \\\n -framework \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.watchOS-simulator.xcarchive/Products/Library/Frameworks/SwiftUIPager.framework\" \\\n -framework \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.tvOS.xcarchive/Products/Library/Frameworks/SwiftUIPager.framework\" \\\n -framework \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.tvOS-simulator.xcarchive/Products/Library/Frameworks/SwiftUIPager.framework\" \\\n -output \"SwiftUIPager.xcframework\"\n";
shellScript = "./scripts/build_xcframework.sh\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down Expand Up @@ -691,7 +691,7 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "$(SRCROOT)/SwiftUIPager/Info-macOS.plist";
INFOPLIST_FILE = "$(SRCROOT)/SwiftUIPager/SupportFiles/Info-macOS.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -723,7 +723,7 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "$(SRCROOT)/SwiftUIPager/Info-macOS.plist";
INFOPLIST_FILE = "$(SRCROOT)/SwiftUIPager/SupportFiles/Info-macOS.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions scripts/build_platforms.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
gem install xcpretty

SCHEMES=( SwiftUIPager_Catalyst SwiftUIPager_macOS SwiftUIPager_iOS SwiftUIPager_watchOS SwiftUIPager_tvOS )
PLATFORMS=( "platform=macOS,variant=Mac Catalyst" "platform=macOS" "generic/platform=iOS" "generic/platform=watchOS" "generic/platform=tvOS" )

rm -rd $DIR
for i in ${!SCHEMES[@]}; do
xcodebuild clean build -scheme ${SCHEMES[$i]} \
-project SwiftUIPager.xcodeproj \
-destination "${PLATFORMS[$i]}" || exit 1
done
55 changes: 55 additions & 0 deletions scripts/build_xcframework.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
gem install xcpretty

LIB_NAME="SwiftUIPager"
PROJ_PATH="$LIB_NAME.xcodeproj"
BUILD_PATH=".build"
FRAMEWORKS_PATH="$BUILD_PATH/frameworks"
XCFRAMEWORK_NAME="$LIB_NAME.xcframework"
XCFRAMEWORK_ZIP="$XCFRAMEWORK_NAME.zip"
XCFRAMEWORK_PATH="$BUILD_PATH/$XCFRAMEWORK_NAME"
XCFRAMEWORK_ZIP_PATH="$BUILD_PATH/$XCFRAMEWORK_ZIP"
rm $XCFRAMEWORK_ZIP_PATH

SCHEMES=( SwiftUIPager_Catalyst SwiftUIPager_macOS SwiftUIPager_iOS SwiftUIPager_watchOS SwiftUIPager_tvOS )
PLATFORMS=(
"platform=macOS,variant=Mac Catalyst"
"platform=macOS"
"generic/platform=iOS;generic/platform=iOS Simulator"
"generic/platform=watchOS;generic/platform=watchOS Simulator"
"generic/platform=tvOS;generic/platform=tvOS Simulator"
)
ARCHIVES=(
"$LIB_NAME.macCatalyst.xcarchive"
"$LIB_NAME.macos.xcarchive"
"$LIB_NAME.iOS.xcarchive;$LIB_NAME.iOS-simulator.xcarchive"
"$LIB_NAME.watchOS.xcarchive;$LIB_NAME.watchOS-simulator.xcarchive"
"$LIB_NAME.tvOS.xcarchive;$LIB_NAME.tvOS-simulator.xcarchive"
)

COMMAND="xcodebuild -create-xcframework "
xcodebuild clean -project $PROJ_PATH
for i in ${!SCHEMES[@]}; do
IFS=";" read -r -a PLATFORM <<< "${PLATFORMS[i]}"
IFS=";" read -r -a ARCHIVE <<< "${ARCHIVES[i]}"

for j in ${!PLATFORM[@]}; do
ARCHIVE_PATH="$FRAMEWORKS_PATH/${ARCHIVE[$j]}"
xcodebuild archive -scheme ${SCHEMES[$i]} \
-project $PROJ_PATH \
-destination "${PLATFORM[$j]}" \
-archivePath $ARCHIVE_PATH \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES | xcpretty

COMMAND="$COMMAND -framework $ARCHIVE_PATH/Products/Library/Frameworks/$LIB_NAME.framework"
done

done
COMMAND="$COMMAND -output $XCFRAMEWORK_PATH"
$COMMAND | xcpretty
rm -rd $FRAMEWORKS_PATH
cd $BUILD_PATH
zip -r -X $XCFRAMEWORK_ZIP $XCFRAMEWORK_NAME
rm -rd $XCFRAMEWORK_NAME
cd ..
echo ::set-output name=path::$XCFRAMEWORK_ZIP_PATH
29 changes: 29 additions & 0 deletions scripts/rebase.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FOLDER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f2)
TEMP_DIR=".tmp"

mkdir $TEMP_DIR
cd $TEMP_DIR

git clone https://x-access-token:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git
cd $FOLDER
git checkout $OUTDATED_BRANCH

echo Adding origin as $GITHUB_REPOSITORY
git remote set-url origin https://x-access-token:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git
git config --global user.email "$USER_EMAIL"
git config --global user.name "$USER_NAME"

git fetch origin $BASE_BRANCH

echo git pull --rebase origin $OUTDATED_BRANCH
git pull --rebase origin $OUTDATED_BRANCH

echo Rebasing $BASE_BRANCH onto $OUTDATED_BRANCH
echo git rebase origin/$BASE_BRANCH
git rebase origin/$BASE_BRANCH

echo git push --force-with-lease origin $OUTDATED_BRANCH
git push --force-with-lease origin $OUTDATED_BRANCH

cd ../..
rm -rf $TEMP_DIR

0 comments on commit 2c7816c

Please sign in to comment.