-
-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Recoded the project - Added iPhone landscape support - Added iPad support - Added MacOS support - Changed from options to view modifiers - Cleaned up the code (swiftLint and splitting it up) - Added dynamic size support - Added onDismiss modifier - Added dragIndicatorAction modifier - Added dragPositionSwitchAction modifier - Added dragGesture listener - Changed customBackground to not rely on AnyView - Fixed onAppear only called once #65
- Loading branch information
1 parent
23f37fd
commit 75b0143
Showing
48 changed files
with
3,789 additions
and
1,349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
paths: | ||
- '.github/workflows/swiftlint.yml' | ||
- '.swiftlint.yml' | ||
- '**/*.swift' | ||
pull_request: | ||
paths: | ||
- '.github/workflows/swiftlint.yml' | ||
- '.swiftlint.yml' | ||
- '**/*.swift' | ||
|
||
jobs: | ||
SwiftLint: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: GitHub Action for SwiftLint | ||
uses: norio-nomura/action-swiftlint@3.2.1 | ||
|
||
Build: | ||
|
||
runs-on: macos-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Build iOS | ||
run: xcodebuild -scheme BottomSheet -destination 'generic/platform=iOS' | ||
|
||
- name: Build macOS | ||
run: xcodebuild -scheme BottomSheet -destination 'generic/platform=macOS' | ||
|
||
- name: Build mac Catalyst | ||
run: xcodebuild -scheme BottomSheet -destination 'generic/platform=macOS,variant=Mac Catalyst' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
disabled_rules: | ||
- trailing_whitespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
Sources/BottomSheet/BottomSheet+ViewModifiers/BottomSheet+AppleScrollBehavior.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// BottomSheet+AppleScrollBehavior.swift | ||
// | ||
// Created by Lucas Zischka. | ||
// Copyright © 2022 Lucas Zischka. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public extension BottomSheet { | ||
|
||
/// Packs the mainContent into a ScrollView. | ||
/// | ||
/// Behaviour on the iPhone: | ||
/// - The ScrollView is only enabled (scrollable) when the BottomSheet is in a `...Top` position. | ||
/// - If the offset of the ScrollView becomes less than or equal to 0, | ||
/// the BottomSheet is pulled down instead of scrolling. | ||
/// - In every other position the BottomSheet will be dragged instead | ||
/// | ||
/// This behaviour is not active on Mac and iPad, because it would not make sense there. | ||
/// | ||
/// Please note, that this feature has sometimes weird flickering, | ||
/// when the content of the ScrollView is smaller than itself. | ||
/// If you have experience with UIKit and UIScrollViews, you are welcome to open a pull request to fix this. | ||
/// | ||
/// - Parameters: | ||
/// - bool: A boolean whether the option is enabled. | ||
/// | ||
/// - Returns: A BottomSheet where the mainContent is packed inside a ScrollView. | ||
func enableAppleScrollBehavior(_ bool: Bool = true) -> BottomSheet { | ||
self.configuration.isAppleScrollBehaviorEnabled = bool | ||
return self | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
Sources/BottomSheet/BottomSheet+ViewModifiers/BottomSheet+BackgroundBlur.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// BottomSheet+BackgroundBlur.swift | ||
// | ||
// Created by Lucas Zischka. | ||
// Copyright © 2022 Lucas Zischka. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
public extension BottomSheet { | ||
|
||
/// Adds a fullscreen blur layer below the BottomSheet. | ||
/// | ||
/// The opacity of the layer is proportional to the height of the BottomSheet. | ||
/// The material can be changed using the `.backgroundBlurMaterial()` modifier. | ||
/// | ||
/// - Parameters: | ||
/// - bool: A boolean whether the option is enabled. | ||
/// | ||
/// - Returns: A view that has a blur layer below the BottomSheet. | ||
func enableBackgroundBlur(_ bool: Bool = true) -> BottomSheet { | ||
self.configuration.isBackgroundBlurEnabled = bool | ||
return self | ||
} | ||
|
||
/// Changes the material of the blur layer. | ||
/// | ||
/// Changing the material does not affect whether the blur layer is shown. | ||
/// To toggle the blur layer please use the `.enableBackgroundBlur()` modifier. | ||
/// | ||
/// - Parameters: | ||
/// - material: The new material. | ||
/// | ||
/// - Returns: A view with a different material of the blur layer. | ||
func backgroundBlurMaterial(_ material: VisualEffect) -> BottomSheet { | ||
self.configuration.backgroundBlurMaterial = material | ||
return self | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
Sources/BottomSheet/BottomSheet+ViewModifiers/BottomSheet+CloseButton.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// BottomSheet+CloseButton.swift | ||
// | ||
// Created by Lucas Zischka. | ||
// Copyright © 2022 Lucas Zischka. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public extension BottomSheet { | ||
|
||
/// Adds a close button to the headerContent on the trailing side. | ||
/// | ||
/// To perform a custom action when the BottomSheet is closed (not only via the close button), | ||
/// please use the `.onDismiss()` option. | ||
/// | ||
/// - Parameters: | ||
/// - bool: A boolean whether the option is enabled. | ||
/// | ||
/// - Returns: A BottomSheet with a close button. | ||
func showCloseButton(_ bool: Bool = true) -> BottomSheet { | ||
self.configuration.isCloseButtonShown = bool | ||
return self | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
Sources/BottomSheet/BottomSheet+ViewModifiers/BottomSheet+ContentDrag.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// BottomSheet+ContentDrag.swift | ||
// | ||
// Created by Lucas Zischka. | ||
// Copyright © 2022 Lucas Zischka. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public extension BottomSheet { | ||
|
||
/// Makes it possible to resize the BottomSheet by dragging the mainContent. | ||
/// | ||
/// Due to imitations in the SwiftUI framework, | ||
/// this option has no effect or even makes the BottomSheet glitch | ||
/// if the mainContent is packed into a ScrollView or a List. | ||
/// | ||
/// - Parameters: | ||
/// - bool: A boolean whether the option is enabled. | ||
/// | ||
/// - Returns: A BottomSheet where the mainContent can be used for resizing. | ||
func enableContentDrag(_ bool: Bool = true) -> BottomSheet { | ||
self.configuration.isContentDragEnabled = bool | ||
return self | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
Sources/BottomSheet/BottomSheet+ViewModifiers/BottomSheet+CustomAnimation.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// BottomSheet+CustomAnimation.swift | ||
// | ||
// Created by Lucas Zischka. | ||
// Copyright © 2022 Lucas Zischka. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
public extension BottomSheet { | ||
|
||
/// Applies the given animation to the BottomSheet when any value changes. | ||
/// | ||
/// - Parameters: | ||
/// - animation: The animation to apply. If animation is nil, the view doesn’t animate. | ||
/// | ||
/// - Returns: A view that applies `animation` to the BottomSheet. | ||
func customAnimation(_ animation: Animation?) -> BottomSheet { | ||
self.configuration.animation = animation | ||
return self | ||
} | ||
} |
Oops, something went wrong.