Skip to content

Commit

Permalink
BottomSheet v3 (#79)
Browse files Browse the repository at this point in the history
- 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
lucaszischka authored Aug 7, 2022
1 parent 23f37fd commit 75b0143
Show file tree
Hide file tree
Showing 48 changed files with 3,789 additions and 1,349 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/CI.yml
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'
2 changes: 2 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
disabled_rules:
- trailing_whitespace
4 changes: 2 additions & 2 deletions BottomSheetSwiftUI.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'BottomSheetSwiftUI'
s.version = '2.8.0'
s.version = '3.0.0'
s.summary = 'A sliding sheet from the bottom of the screen with custom states build with SwiftUI.'

s.homepage = 'https://github.com/lucaszischka/BottomSheet'
Expand All @@ -9,7 +9,7 @@ Pod::Spec.new do |s|
s.source = { :git => 'https://github.com/lucaszischka/BottomSheet.git', :tag => s.version.to_s }

s.ios.deployment_target = '13.0'
s.swift_version = '5.1'
s.swift_version = '5.5'

s.weak_frameworks = 'SwiftUI'
s.source_files = 'Sources/BottomSheet/**/*'
Expand Down
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
BottomSheet Changelog
==================

#### v3.0.0
- 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

#### v2.8.0
- Add `disableBottomSafeAreaInsets` option #63
- Add `disableFlickThrough` option #61
Expand All @@ -13,7 +28,7 @@ BottomSheet Changelog

#### v2.6.0
- Fix critical bug with `.appleScrollBehavior` #40
- Update codestyle
- Update code-style
- Remove not used file
- Update Readme
- Renamed tapToDissmiss option tapToDismiss #43
Expand Down
8 changes: 5 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
// swift-tools-version:5.1
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "BottomSheet",
platforms: [
.iOS(.v13)
.iOS(.v13),
.macCatalyst(.v13),
.macOS(.v10_15)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "BottomSheet",
targets: ["BottomSheet"]),
targets: ["BottomSheet"])
],
dependencies: [
// Dependencies declare other packages that this package depends on.
Expand Down
332 changes: 213 additions & 119 deletions README.md

Large diffs are not rendered by default.

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
}
}
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
}
}
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
}
}
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
}
}
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
}
}
Loading

0 comments on commit 75b0143

Please sign in to comment.