Skip to content

Commit

Permalink
Only require popup bar layout fixes only when a SwiftUI view is used …
Browse files Browse the repository at this point in the history
…as popup content

Demo project improvements
  • Loading branch information
LeoNatan committed Oct 14, 2020
1 parent 32b4453 commit 26cc0ee
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 25 deletions.
12 changes: 12 additions & 0 deletions LNPopupUIExample/LNPopupUIExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
396B439624DC8EF100D84FC7 /* LoremIpsum in Frameworks */ = {isa = PBXBuildFile; productRef = 396B439524DC8EF100D84FC7 /* LoremIpsum */; };
398404EA25003925006C9011 /* SceneSelection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 398404E925003925006C9011 /* SceneSelection.swift */; };
398404EE2500451E006C9011 /* MapView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 398404ED2500451E006C9011 /* MapView.swift */; };
3985A1E525378E73004AA4D7 /* WebController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3985A1E425378E73004AA4D7 /* WebController.swift */; };
398DB7AD250400BE00CD89DB /* NavDemoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 398DB7AC250400BE00CD89DB /* NavDemoView.swift */; };
39AAAA6C25040FA900E5FD41 /* TabNavView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39AAAA6B25040FA900E5FD41 /* TabNavView.swift */; };
39AAAA6E25040FF400E5FD41 /* ConstraintsDemoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39AAAA6D25040FF400E5FD41 /* ConstraintsDemoView.swift */; };
Expand Down Expand Up @@ -54,6 +55,7 @@
395781F224DC692300A604D1 /* PlayerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerView.swift; sourceTree = "<group>"; };
398404E925003925006C9011 /* SceneSelection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneSelection.swift; sourceTree = "<group>"; };
398404ED2500451E006C9011 /* MapView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapView.swift; sourceTree = "<group>"; };
3985A1E425378E73004AA4D7 /* WebController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebController.swift; sourceTree = "<group>"; };
398DB7AC250400BE00CD89DB /* NavDemoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavDemoView.swift; sourceTree = "<group>"; };
39AAAA6B25040FA900E5FD41 /* TabNavView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabNavView.swift; sourceTree = "<group>"; };
39AAAA6D25040FF400E5FD41 /* ConstraintsDemoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstraintsDemoView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -99,6 +101,7 @@
398DB7AF250401DB00CD89DB /* DemoScenes */,
398DB7B0250401E300CD89DB /* MusicScene */,
398DB7B1250401F800CD89DB /* MapScene */,
3985A1E325378E57004AA4D7 /* IntroWebView */,
395781D424DC5D2700A604D1 /* AppDelegate.swift */,
395781D624DC5D2700A604D1 /* SceneDelegate.swift */,
398404E925003925006C9011 /* SceneSelection.swift */,
Expand All @@ -125,6 +128,14 @@
name = Frameworks;
sourceTree = "<group>";
};
3985A1E325378E57004AA4D7 /* IntroWebView */ = {
isa = PBXGroup;
children = (
3985A1E425378E73004AA4D7 /* WebController.swift */,
);
path = IntroWebView;
sourceTree = "<group>";
};
398DB7AF250401DB00CD89DB /* DemoScenes */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -233,6 +244,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
3985A1E525378E73004AA4D7 /* WebController.swift in Sources */,
395781D524DC5D2700A604D1 /* AppDelegate.swift in Sources */,
398404EE2500451E006C9011 /* MapView.swift in Sources */,
39AAAA72250415E800E5FD41 /* ViewDemoView.swift in Sources */,
Expand Down
5 changes: 5 additions & 0 deletions LNPopupUIExample/LNPopupUIExample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
Expand Down
34 changes: 34 additions & 0 deletions LNPopupUIExample/LNPopupUIExample/IntroWebView/WebController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// WebController.swift
// LNPopupUIExample
//
// Created by Leo Natan on 10/14/20.
//

import UIKit
import WebKit

class WebController: UIViewController {
private let webView = WKWebView()

override func viewDidLoad() {
super.viewDidLoad()

webView.load(URLRequest(url: URL(string: "https://github.com/LeoNatan/LNPopupUI")!))
webView.translatesAutoresizingMaskIntoConstraints = false

view.addSubview(webView)
NSLayoutConstraint.activate([
view.topAnchor.constraint(equalTo: webView.topAnchor),
view.bottomAnchor.constraint(equalTo: webView.bottomAnchor),
view.leadingAnchor.constraint(equalTo: webView.leadingAnchor),
view.trailingAnchor.constraint(equalTo: webView.trailingAnchor),
])

popupItem.title = "Welcome to LNPopupUI"
popupItem.image = UIImage(named: "genre10")
popupItem.barButtonItems = [
UIBarButtonItem(image: UIImage(systemName: "suit.heart.fill"), style: .done, target: nil, action: nil)
]
}
}
25 changes: 4 additions & 21 deletions LNPopupUIExample/LNPopupUIExample/SceneSelection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import SwiftUI
import LNPopupUI

fileprivate let introWebController = WebController()

struct SceneSelection: View {
@State var tabnavPresented: Bool = false
@State var tabPresented: Bool = false
Expand Down Expand Up @@ -96,27 +98,8 @@ struct SceneSelection: View {
}
.navigationViewStyle(StackNavigationViewStyle())
.ignoresSafeArea()
.popup(isBarPresented: Binding.constant(true)) {
SafeAreaDemoView(offset: true)
.popupTitle("Welcome to LNPopupUI!")
.popupImage(Image("genre10"))
.popupBarItems({
HStack(spacing: 20) {
Button(action: {
print("Play")
}) {
Image(systemName: "play.fill")
}

Button(action: {
print("Next")
}) {
Image(systemName: "forward.fill")
}
}
.font(.system(size: 20))
})
}
.popup(isBarPresented: Binding.constant(true), popupContentController: introWebController)
.popupCloseButtonStyle(.round)
.popupBarMarqueeScrollEnabled(true)
}
}
Expand Down
7 changes: 4 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

Expand All @@ -21,12 +20,14 @@ let package = Package(
],
dependencies: [
// .package(path: "../LNPopupController")
.package(url: "https://github.com/LeoNatan/LNPopupController.git", from: Version(stringLiteral: "2.10.16"))
.package(url: "https://github.com/LeoNatan/LNPopupController.git", from: Version(stringLiteral: "2.10.20"))
],
targets: [
.target(
name: "LNPopupUI",
dependencies: ["LNPopupController-Static"],
dependencies: [
.product(name: "LNPopupController-Static", package: "LNPopupController")
],
exclude: [
"LNPopupUIExample",
"Supplements"
Expand Down
4 changes: 3 additions & 1 deletion Sources/LNPopupUI/Private/LNPopupProxyViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ internal class LNPopupProxyViewController<Content, PopupContent> : UIHostingCont
let popupContentHandler = state.content != nil ? viewHandler(state) : viewControllerHandler(state)

let handler : (Bool) -> Void = { animated in
self.target.popupBar.setValue(true, forKey: "_applySwiftUILayoutFixes")
if state.content != nil {
self.target.popupBar.setValue(true, forKey: "_applySwiftUILayoutFixes")
}
self.target.popupContentView.popupCloseButtonStyle = self.currentPopupState.closeButtonStyle
self.target.popupPresentationDelegate = self
self.target.popupInteractionStyle = self.currentPopupState.interactionStyle
Expand Down

0 comments on commit 26cc0ee

Please sign in to comment.