Skip to content

Commit

Permalink
Patch 3.0.1
Browse files Browse the repository at this point in the history
fix:
- Fixed the problem with a drag gesture

docs:            
- Updated in-app documentation
  • Loading branch information
jay-jay-lama authored Nov 4, 2024
1 parent 296942c commit ce72aa9
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 13 deletions.
2 changes: 1 addition & 1 deletion MijickPopups.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Pod::Spec.new do |s|
MijickPopups is a free and open-source library dedicated for SwiftUI that makes the process of presenting popups easier and much cleaner.
DESC

s.version = '3.0.0'
s.version = '3.0.1'
s.ios.deployment_target = '14.0'
s.osx.deployment_target = '12.0'
s.tvos.deployment_target = '15.0'
Expand Down
6 changes: 6 additions & 0 deletions Sources/Internal/Configurables/Local/LocalConfig+Centre.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ public extension LocalConfig { class Centre: LocalConfig {
}}

// MARK: Typealias
/**
Configures the popup.
See the list of available methods in ``LocalConfig``.

- important: If a certain method is not called here, the popup inherits the configuration from ``GlobalConfigContainer``.
*/
public typealias CentrePopupConfig = LocalConfig.Centre


Expand Down
13 changes: 13 additions & 0 deletions Sources/Internal/Configurables/Local/LocalConfig+Vertical.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,20 @@ public extension LocalConfig { class Vertical: LocalConfig {
}}

// MARK: Subclasses & Typealiases
/**
Configures the popup.
See the list of available methods in ``LocalConfig`` and ``LocalConfig/Vertical``.

- important: If a certain method is not called here, the popup inherits the configuration from ``GlobalConfigContainer``.
*/
public typealias TopPopupConfig = LocalConfig.Vertical.Top

/**
Configures the popup.
See the list of available methods in ``LocalConfig`` and ``LocalConfig/Vertical``.

- important: If a certain method is not called here, the popup inherits the configuration from ``GlobalConfigContainer``.
*/
public typealias BottomPopupConfig = LocalConfig.Vertical.Bottom
public extension LocalConfig.Vertical {
class Top: LocalConfig.Vertical {}
Expand Down
22 changes: 12 additions & 10 deletions Sources/Internal/Extensions/View+Gestures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,26 @@ import SwiftUI
// MARK: On Tap Gesture
extension View {
func onTapGesture(perform action: @escaping () -> ()) -> some View {
#if os(iOS) || os(macOS) || os(visionOS) || os(watchOS)
onTapGesture(count: 1, perform: action)
#elseif os(tvOS)
#if os(tvOS)
self
#else
onTapGesture(count: 1, perform: action)
#endif
}
}

// MARK: On Drag Gesture
extension View {
func onDragGesture(onChanged actionOnChanged: @escaping (CGFloat) -> (), onEnded actionOnEnded: @escaping (CGFloat) -> ()) -> some View {
#if os(iOS) || os(macOS) || os(visionOS) || os(watchOS)
highPriorityGesture(DragGesture()
.onChanged { actionOnChanged($0.translation.height) }
.onEnded { actionOnEnded($0.translation.height) }
)
#elseif os(tvOS)
func onDragGesture(onChanged actionOnChanged: @escaping (CGFloat) -> (), onEnded actionOnEnded: @escaping (CGFloat) -> (), isEnabled: Bool) -> some View {
#if os(tvOS)
self
#else
highPriorityGesture(
DragGesture()
.onChanged { actionOnChanged($0.translation.height) }
.onEnded { actionOnEnded($0.translation.height) },
isEnabled: isEnabled
)
#endif
}
}
2 changes: 1 addition & 1 deletion Sources/Internal/UI/PopupVerticalStackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct PopupVerticalStackView<Config: LocalConfig.Vertical>: View {
var body: some View {
ZStack(alignment: (!viewModel.alignment).toAlignment(), content: createPopupStack)
.frame(height: viewModel.screen.height, alignment: viewModel.alignment.toAlignment())
.onDragGesture(onChanged: viewModel.onPopupDragGestureChanged, onEnded: viewModel.onPopupDragGestureEnded)
.onDragGesture(onChanged: viewModel.onPopupDragGestureChanged, onEnded: viewModel.onPopupDragGestureEnded, isEnabled: viewModel.dragGestureEnabled)
}
}
private extension PopupVerticalStackView {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Public/Popup/Public+Popup+Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public extension LocalConfig.Vertical {
func heightMode(_ value: HeightMode) -> Self { self.heightMode = value; return self }

/**
Sets the available detents for the popup.
Sets the available detents for the popup. Enables drag and drop functionality.

## Visualisation
![image](https://github.com/Mijick/Assets/blob/main/Framework%20Docs/Popups/drag-detent.png?raw=true)
Expand Down
82 changes: 82 additions & 0 deletions Sources/Public/Popup/Public+Popup+Main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,88 @@ public extension Popup {
}

// MARK: Available Types
/**
The view to be displayed as a Top popup.

# Optional Methods
- ``Popup/configurePopup(config:)-98ha0``
- ``Popup/onFocus()-6krqs``
- ``Popup/onDismiss()-3bufs``

# Usage Examples

## TopPopup
```swift
struct TopPopupExample: TopPopup {
func onFocus() { print("Popup is now active") }
func onDismiss() { print("Popup was dismissed") }
func configurePopup(config: TopPopupConfig) -> TopPopupConfig { config
.heightMode(.auto)
.cornerRadius(44)
.dragDetents([.fraction(1.2), .fraction(1.4), .large])
}
var body: some View {
Text("Hello Kitty")
}
}
```
![TopPopup](https://github.com/Mijick/Assets/blob/main/Framework%20Docs/Popups/top-popup.png?raw=true)
*/
public protocol TopPopup: Popup { associatedtype Config = TopPopupConfig }

/**
The view to be displayed as a Centre popup.

# Optional Methods
- ``Popup/configurePopup(config:)-3ze4``
- ``Popup/onFocus()-loq5``
- ``Popup/onDismiss()-3bufs``

# Usage Examples

## CentrePopup
```swift
struct CentrePopupExample: CentrePopup {
func onFocus() { print("Popup is now active") }
func onDismiss() { print("Popup was dismissed") }
func configurePopup(config: CentrePopupConfig) -> CentrePopupConfig { config
.cornerRadius(44)
.tapOutsideToDismissPopup(true)
}
var body: some View {
Text("Hello Kitty")
}
}
```
![CentrePopup](https://github.com/Mijick/Assets/blob/main/Framework%20Docs/Popups/centre-popup.png?raw=true)
*/
public protocol CentrePopup: Popup { associatedtype Config = CentrePopupConfig }

/**
The view to be displayed as a Bottom popup.

# Optional Methods
- ``Popup/configurePopup(config:)-98ha0``
- ``Popup/onFocus()-loq5``
- ``Popup/onDismiss()-254h8``

# Usage Examples

## BottomPopup
```swift
struct BottomPopupExample: BottomPopup {
func onFocus() { print("Popup is now active") }
func onDismiss() { print("Popup was dismissed") }
func configurePopup(config: BottomPopupConfig) -> BottomPopupConfig { config
.heightMode(.auto)
.cornerRadius(44)
.dragDetents([.fraction(1.2), .fraction(1.4), .large])
}
var body: some View {
Text("Hello Kitty")
}
}
```
![BottomPopup](https://github.com/Mijick/Assets/blob/main/Framework%20Docs/Popups/bottom-popup.png?raw=true)
*/
public protocol BottomPopup: Popup { associatedtype Config = BottomPopupConfig }
2 changes: 2 additions & 0 deletions Sources/Public/Present/Public+Present+Popup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public extension Popup {
``SwiftUICore/View/dismissPopup(_:popupManagerID:)-9mkd5``,
``SwiftUICore/View/dismissAllPopups(popupManagerID:)``
should be called with the same **popupManagerID** as the one used here.

- Warning: To present multiple popups of the same type, set a unique identifier using the method ``Popup/setCustomID(_:)``.
*/
func present(popupManagerID: PopupManagerID = .shared) { PopupManager.fetchInstance(id: popupManagerID)?.stack(.insertPopup(self)) }
}
Expand Down

0 comments on commit ce72aa9

Please sign in to comment.