Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch 4.0.1 #168

Merged
merged 17 commits into from
Dec 19, 2024
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 solves two seemingly contradictory problems - to allow developers to create fully customizable popup, and to make the process as simple as possible.
DESC

s.version = '4.0.0'
s.version = '4.0.1'
s.ios.deployment_target = '14.0'
s.osx.deployment_target = '12.0'
s.tvos.deployment_target = '15.0'
Expand Down
69 changes: 63 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,83 @@
<p>
<!--Discord-->
<a href="https://link.mijick.com/discord">
<img alt="Join us on Discord" src="https://github.com/Mijick/Assets/blob/main/Popups/Buttons/discord.png" height="40px">
<img alt="Join us on Discord" src="https://github.com/Mijick/Assets/blob/main/Common/Buttons/discord.png" height="40px">
</a>
<!--Linkedin-->
<a href="https://link.mijick.com/linkedin">
<img alt="Follow us on LinkedIn" src="https://github.com/Mijick/Assets/blob/main/Popups/Buttons/linkedin.png" height="40px">
<img alt="Follow us on LinkedIn" src="https://github.com/Mijick/Assets/blob/main/Common/Buttons/linkedin.png" height="40px">
</a>
<!--GitHub-->
<a href="https://link.mijick.com/github">
<img alt="See our other frameworks" src="https://github.com/Mijick/Assets/blob/main/Popups/Buttons/github.png" height="40px">
<img alt="See our other frameworks" src="https://github.com/Mijick/Assets/blob/main/Common/Buttons/github.png" height="40px">
</a>
<!--Medium-->
<a href="https://link.mijick.com/medium">
<img alt="Read us on Medium" src="https://github.com/Mijick/Assets/blob/main/Popups/Buttons/medium.png" height="40px">
<img alt="Read us on Medium" src="https://github.com/Mijick/Assets/blob/main/Common/Buttons/medium.png" height="40px">
</a>
<!--Buymeacoffee-->
<a href="https://link.mijick.com/buymeacoffee">
<img alt="Buy us a coffee" src="https://github.com/Mijick/Assets/blob/main/Popups/Buttons/buymeacoffee.png" height="40px">
<img alt="Buy us a coffee" src="https://github.com/Mijick/Assets/blob/main/Common/Buttons/buymeacoffee.png" height="40px">
</a>
</p>

<!--Features-->
# ✨ Features
<table><tbody>
<tr>
<td>📱</td>
<td>Three positions for the popups: Top, Center or Bottom</td>
</tr>
<tr>
<td>🎁</td>
<td>Stackable popups</td>
</tr>
<tr>
<td>🐫</td>
<td>Three height modes: Automatic, Large or Fullscreen</td>
</tr>
<tr>
<td>⛹️</td>
<td>Resizable popups</td>
</tr>
<tr>
<td>🍃</td>
<td>Automatic dismissal</td>
</tr>
<tr>
<td>🖖</td>
<td>Super easy to use from any place in the code</td>
</tr>
<tr>
<td>🚧</td>
<td>Fully customizable</td>
</tr>
<tr>
<td>🕺</td>
<td>Beautiful animations</td>
</tr>
<tr>
<td>🤏🏼</td>
<td>Gestures support</td>
</tr>
<tr>
<td>🍏</td>
<td>Works with SwiftUI sheets</td>
</tr>
<tr>
<td>🖥️</td>
<td>Supports iOS, macOS, tvOS, watchOS and visionOS</td>
</tr>
<tr>
<td>⚡️</td>
<td>Supports Swift 6</td>
</tr>
<tr>
<td>🚀</td>
<td>... and others</td>
</tr>
</tbody></table>

<!--Description-->
# ☀️ Why MijickPopups?
MijickPopups library solves two seemingly contradictory problems - to allow developers to create fully customizable popup views, and to make the process as simple as possible. Here is why we think we have successfully met these objectives:
Expand Down Expand Up @@ -145,7 +202,7 @@ Join the welcoming community of developers on [Discord](https://link.mijick.com/
# 🌼 Contribute
To contribute a feature or idea to **MijickPopups**, create an [issue](https://github.com/Mijick/Popups/issues/new?assignees=FulcrumOne&labels=state%3A+inactive%2C+type%3A+feature&projects=&template=🚀-feature-request.md&title=%5BFREQ%5D) explaining your idea or bring it up on [Discord](https://discord.com/invite/dT5V7nm5SC). <br>
If you find a bug, please create an [issue](https://github.com/Mijick/Popups/issues/new?assignees=FulcrumOne%2C+jay-jay-lama&labels=state%3A+inactive%2C+type%3A+bug&projects=&template=🦟-bug-report.md&title=%5BBUG%5D). <br>
If you would like to contribute, please refer to the [Contribution Guidelines](https://link.mijick.com/contribution-guidelines).
If you would like to contribute, please refer to the [Contribution Guidelines](https://github.com/Mijick/Popups/blob/main/.github/CONTRIBUTING.md).

<!--Sponsorship-->
# 💜 Sponsor our work
Expand Down
2 changes: 0 additions & 2 deletions Sources/Internal/Containers/PopupStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ extension PopupStack {
}



// MARK: - STACK OPERATIONS


Expand Down Expand Up @@ -96,7 +95,6 @@ private extension PopupStack {
}



// MARK: - STACK CONTAINER OPERATIONS


Expand Down
2 changes: 0 additions & 2 deletions Sources/Internal/Models/AnyPopup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ struct AnyPopup: Popup {
}



// MARK: - INITIALIZE & UPDATE


Expand Down Expand Up @@ -70,7 +69,6 @@ private extension AnyPopup {
}



// MARK: - PROTOCOLS CONFORMANCE


Expand Down
1 change: 0 additions & 1 deletion Sources/Internal/Models/ID+Popup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ extension PopupID {
}



// MARK: - HELPERS


Expand Down
4 changes: 2 additions & 2 deletions Sources/Internal/UI/PopupCenterStackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ struct PopupCenterStackView: View {
@ObservedObject var viewModel: VM.CenterStack


var body: some View {
var body: some View { if viewModel.screen.height > 0 {
ZStack(content: createPopupStack)
.id(viewModel.popups.isEmpty)
.transition(transition)
.frame(maxWidth: .infinity, maxHeight: viewModel.screen.height)
}
}}
}
private extension PopupCenterStackView {
func createPopupStack() -> some View {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Internal/UI/PopupVerticalStackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ struct PopupVerticalStackView: View {
@ObservedObject var viewModel: VM.VerticalStack


var body: some View {
var body: some View { if viewModel.screen.height > 0 {
ZStack(alignment: (!viewModel.alignment).toAlignment(), content: createPopupStack)
.frame(height: viewModel.screen.height, alignment: viewModel.alignment.toAlignment())
.onDragGesture(onChanged: viewModel.onPopupDragGestureChanged, onEnded: viewModel.onPopupDragGestureEnded, isEnabled: viewModel.dragGestureEnabled)
}
}}
}
private extension PopupVerticalStackView {
func createPopupStack() -> some View {
Expand Down
8 changes: 8 additions & 0 deletions Sources/Internal/UI/PopupView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ struct PopupView: View {
private let bottomStackViewModel: VM.VerticalStack = .init(BottomPopupConfig.self)


init(rootView: any View, popupStack: PopupStack) {
#if os(tvOS)
self.rootView = rootView
#endif
self.stack = popupStack

Task { [self] in await updateViewModels { await $0.updatePopups(stack.popups) } }
}
var body: some View {
#if os(tvOS)
AnyView(rootView)
Expand Down
7 changes: 2 additions & 5 deletions Sources/Internal/View Models/ViewModel+CentreStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ extension VM { class CenterStack: ViewModel { required init() {}
var popups: [AnyPopup] = []
var activePopupProperties: ActivePopupProperties = .init()
var screen: Screen = .init()
var updatePopupAction: ((AnyPopup) async -> ())!
var closePopupAction: ((AnyPopup) async -> ())!
var updatePopupAction: ((AnyPopup) async -> ())?
var closePopupAction: ((AnyPopup) async -> ())?
}}



// MARK: - METHODS / VIEW MODEL / ACTIVE POPUP


Expand Down Expand Up @@ -84,7 +83,6 @@ extension VM.CenterStack {
}



// MARK: - METHODS / VIEW MODEL / SELECTED POPUP


Expand All @@ -104,7 +102,6 @@ private extension VM.CenterStack {
}



// MARK: - METHODS / VIEW


Expand Down
10 changes: 3 additions & 7 deletions Sources/Internal/View Models/ViewModel+VerticalStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ extension VM { class VerticalStack: ViewModel { required init() {}
var popups: [AnyPopup] = []
var activePopupProperties: ActivePopupProperties = .init()
var screen: Screen = .init()
var updatePopupAction: ((AnyPopup) async -> ())!
var closePopupAction: ((AnyPopup) async -> ())!
var updatePopupAction: ((AnyPopup) async -> ())?
var closePopupAction: ((AnyPopup) async -> ())?
}}



// MARK: - METHODS / VIEW MODEL / ACTIVE POPUP


Expand Down Expand Up @@ -171,7 +170,6 @@ extension VM.VerticalStack {
}



// MARK: - METHODS / VIEW MODEL / SELECTED POPUP


Expand Down Expand Up @@ -214,7 +212,6 @@ private extension VM.VerticalStack {
}



// MARK: - METHODS / VIEW


Expand Down Expand Up @@ -307,7 +304,6 @@ extension VM.VerticalStack {
}



// MARK: - GESTURES


Expand Down Expand Up @@ -371,7 +367,7 @@ extension VM.VerticalStack {
}
private extension VM.VerticalStack {
func dismissLastPopupIfNeeded(_ popup: AnyPopup) async { switch activePopupProperties.translationProgress >= dragThreshold {
case true: await closePopupAction(popup)
case true: await closePopupAction?(popup)
case false: return
}}
func calculateTargetDragHeight(_ activePopup: AnyPopup) async -> CGFloat {
Expand Down
10 changes: 4 additions & 6 deletions Sources/Internal/View Models/ViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ enum VM {}
var screen: Screen { get set }

// MARK: Actions
var updatePopupAction: ((AnyPopup) async -> ())! { get set }
var closePopupAction: ((AnyPopup) async -> ())! { get set }
var updatePopupAction: ((AnyPopup) async -> ())? { get set }
var closePopupAction: ((AnyPopup) async -> ())? { get set }

// MARK: Methods
func calculateActivePopupHeight() async -> CGFloat?
Expand All @@ -35,7 +35,6 @@ enum VM {}
}



// MARK: - INITIALIZE & SETUP


Expand All @@ -54,7 +53,6 @@ extension ViewModel {
}



// MARK: UPDATE


Expand Down Expand Up @@ -95,15 +93,15 @@ extension ViewModel {

let newHeight = await calculatePopupHeight(heightCandidate, popup)
if newHeight != popup.height {
await updatePopupAction(popup.updatedHeight(newHeight))
await updatePopupAction?(popup.updatedHeight(newHeight))
}
}
}

// MARK: Popup Drag Height
extension ViewModel {
func updatePopupDragHeight(_ targetDragHeight: CGFloat, _ popup: AnyPopup) async {
await updatePopupAction(popup.updatedDragHeight(targetDragHeight))
await updatePopupAction?(popup.updatedDragHeight(targetDragHeight))
}
}

Expand Down
1 change: 0 additions & 1 deletion Sources/Public/Setup/Public+Setup+SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ extension PopupSceneDelegate {
}



// MARK: - WINDOW


Expand Down
4 changes: 2 additions & 2 deletions Sources/Public/Setup/Public+Setup+View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ public extension View {
*/
func registerPopups(id: PopupStackID = .shared, configBuilder: @escaping (GlobalConfigContainer) -> GlobalConfigContainer = { $0 }) -> some View {
#if os(tvOS)
PopupView(rootView: self, stack: .registerStack(id: id)).onAppear { _ = configBuilder(.init()) }
PopupView(rootView: self, popupStack: .registerStack(id: id)).onAppear { _ = configBuilder(.init()) }
#else
self
.frame(maxWidth: .infinity, maxHeight: .infinity)
.overlay(PopupView(stack: .registerStack(id: id)), alignment: .top)
.overlay(PopupView(rootView: self, popupStack: .registerStack(id: id)), alignment: .top)
.onAppear { _ = configBuilder(.init()) }
#endif
}
Expand Down
2 changes: 0 additions & 2 deletions Tests/Tests+PopupID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import SwiftUI
@MainActor final class PopupIDTests: XCTestCase {}



// MARK: - TEST CASES


Expand Down Expand Up @@ -119,7 +118,6 @@ extension PopupIDTests {
}



// MARK: - HELPERS


Expand Down
2 changes: 0 additions & 2 deletions Tests/Tests+PopupStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import SwiftUI
}



// MARK: - TEST CASES


Expand Down Expand Up @@ -241,7 +240,6 @@ extension PopupStackTests {
}



// MARK: - HELPERS


Expand Down
2 changes: 0 additions & 2 deletions Tests/Tests+ViewModel+PopupCenterStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ private extension PopupCenterStackViewModelTests {
}



// MARK: - TEST CASES


Expand Down Expand Up @@ -223,7 +222,6 @@ private extension PopupCenterStackViewModelTests {
}



// MARK: - HELPERS


Expand Down
Loading