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

feat: add standalone modal #38

Draft
wants to merge 9 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 135 additions & 1 deletion Demo/Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
30ED62152C73B86E007F68D0 /* DemoUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30ED62142C73B86E007F68D0 /* DemoUITests.swift */; };
30ED62172C73B86E007F68D0 /* DemoUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30ED62162C73B86E007F68D0 /* DemoUITestsLaunchTests.swift */; };
C67A5ACA2B2A5FE700BBF5F7 /* PayPalMessages.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C67A5AC92B2A5FE700BBF5F7 /* PayPalMessages.framework */; };
C67A5ACB2B2A5FE700BBF5F7 /* PayPalMessages.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C67A5AC92B2A5FE700BBF5F7 /* PayPalMessages.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
C6E7C4922A38AC56003C05E4 /* DemoApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6E7C4912A38AC56003C05E4 /* DemoApp.swift */; };
Expand All @@ -27,6 +29,16 @@
F200FF1C2A94E8A20002DE25 /* DefaultMessageConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = F200FF1B2A94E8A20002DE25 /* DefaultMessageConfig.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
30ED62182C73B86E007F68D0 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = C6E7C4862A38AC56003C05E4 /* Project object */;
proxyType = 1;
remoteGlobalIDString = C6E7C48D2A38AC56003C05E4;
remoteInfo = Demo;
};
/* End PBXContainerItemProxy section */

/* Begin PBXCopyFilesBuildPhase section */
C67A5ACC2B2A5FE700BBF5F7 /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
Expand All @@ -42,6 +54,9 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
30ED62122C73B86E007F68D0 /* DemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
30ED62142C73B86E007F68D0 /* DemoUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoUITests.swift; sourceTree = "<group>"; };
30ED62162C73B86E007F68D0 /* DemoUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoUITestsLaunchTests.swift; sourceTree = "<group>"; };
C67A5AC52B2A5DA300BBF5F7 /* PayPalMessages.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = PayPalMessages.framework; sourceTree = BUILT_PRODUCTS_DIR; };
C67A5AC92B2A5FE700BBF5F7 /* PayPalMessages.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = PayPalMessages.framework; sourceTree = BUILT_PRODUCTS_DIR; };
C6CBCBDE2A4A14D200645B38 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
Expand All @@ -65,6 +80,13 @@
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
30ED620F2C73B86E007F68D0 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
C6E7C48B2A38AC56003C05E4 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
Expand All @@ -76,10 +98,20 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
30ED62132C73B86E007F68D0 /* DemoUITests */ = {
isa = PBXGroup;
children = (
30ED62142C73B86E007F68D0 /* DemoUITests.swift */,
30ED62162C73B86E007F68D0 /* DemoUITestsLaunchTests.swift */,
);
path = DemoUITests;
sourceTree = "<group>";
};
C6E7C4852A38AC56003C05E4 = {
isa = PBXGroup;
children = (
C6E7C4902A38AC56003C05E4 /* Demo */,
30ED62132C73B86E007F68D0 /* DemoUITests */,
C6E7C48F2A38AC56003C05E4 /* Products */,
C6E7C4A52A38ADC7003C05E4 /* Frameworks */,
);
Expand All @@ -89,6 +121,7 @@
isa = PBXGroup;
children = (
C6E7C48E2A38AC56003C05E4 /* Demo.app */,
30ED62122C73B86E007F68D0 /* DemoTests.xctest */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -153,6 +186,24 @@
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
30ED62112C73B86E007F68D0 /* DemoTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 30ED621A2C73B86E007F68D0 /* Build configuration list for PBXNativeTarget "DemoTests" */;
buildPhases = (
30ED620E2C73B86E007F68D0 /* Sources */,
30ED620F2C73B86E007F68D0 /* Frameworks */,
30ED62102C73B86E007F68D0 /* Resources */,
);
buildRules = (
);
dependencies = (
30ED62192C73B86E007F68D0 /* PBXTargetDependency */,
);
name = DemoTests;
productName = DemoTests;
productReference = 30ED62122C73B86E007F68D0 /* DemoTests.xctest */;
productType = "com.apple.product-type.bundle.ui-testing";
};
C6E7C48D2A38AC56003C05E4 /* Demo */ = {
isa = PBXNativeTarget;
buildConfigurationList = C6E7C49C2A38AC5D003C05E4 /* Build configuration list for PBXNativeTarget "Demo" */;
Expand Down Expand Up @@ -181,9 +232,13 @@
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1410;
LastSwiftUpdateCheck = 1540;
LastUpgradeCheck = 1410;
TargetAttributes = {
30ED62112C73B86E007F68D0 = {
CreatedOnToolsVersion = 15.4;
TestTargetID = C6E7C48D2A38AC56003C05E4;
};
C6E7C48D2A38AC56003C05E4 = {
CreatedOnToolsVersion = 14.1;
};
Expand All @@ -203,11 +258,19 @@
projectRoot = "";
targets = (
C6E7C48D2A38AC56003C05E4 /* Demo */,
30ED62112C73B86E007F68D0 /* DemoTests */,
);
};
/* End PBXProject section */

/* Begin PBXResourcesBuildPhase section */
30ED62102C73B86E007F68D0 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
C6E7C48C2A38AC56003C05E4 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -241,6 +304,15 @@
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
30ED620E2C73B86E007F68D0 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
30ED62152C73B86E007F68D0 /* DemoUITests.swift in Sources */,
30ED62172C73B86E007F68D0 /* DemoUITestsLaunchTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
C6E7C48A2A38AC56003C05E4 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
Expand All @@ -264,7 +336,58 @@
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
30ED62192C73B86E007F68D0 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = C6E7C48D2A38AC56003C05E4 /* Demo */;
targetProxy = 30ED62182C73B86E007F68D0 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */

/* Begin XCBuildConfiguration section */
30ED621B2C73B86E007F68D0 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu17;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 17.5;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = dzh.DemoTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = Demo;
};
name = Debug;
};
30ED621C2C73B86E007F68D0 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu17;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 17.5;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = dzh.DemoTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = Demo;
};
name = Release;
};
C6E7C49A2A38AC5D003C05E4 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
Expand Down Expand Up @@ -390,6 +513,7 @@
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"Demo/Preview Content\"";
ENABLE_PREVIEWS = YES;
ENABLE_TESTING_SEARCH_PATHS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Demo/Info.plist;
INFOPLIST_KEY_LSApplicationCategoryType = "";
Expand Down Expand Up @@ -420,6 +544,7 @@
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"Demo/Preview Content\"";
ENABLE_PREVIEWS = YES;
ENABLE_TESTING_SEARCH_PATHS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Demo/Info.plist;
INFOPLIST_KEY_LSApplicationCategoryType = "";
Expand All @@ -444,6 +569,15 @@
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
30ED621A2C73B86E007F68D0 /* Build configuration list for PBXNativeTarget "DemoTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
30ED621B2C73B86E007F68D0 /* Debug */,
30ED621C2C73B86E007F68D0 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
C6E7C4892A38AC56003C05E4 /* Build configuration list for PBXProject "Demo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
Expand Down
13 changes: 13 additions & 0 deletions Demo/Demo.xcodeproj/xcshareddata/xcschemes/Demo.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "30ED62112C73B86E007F68D0"
BuildableName = "DemoUITests.xctest"
BlueprintName = "DemoUITests"
ReferencedContainer = "container:Demo.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand Down
18 changes: 18 additions & 0 deletions Demo/Demo/SwiftUIContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ struct SwiftUIContentView: View {
PayPalMessageView.Representable(config: messageConfig, stateDelegate: messageStateDelegate, eventDelegate: messageEventDelegate)
.background(backgroundColor)

HStack {
Spacer()
Button("Show Standalone Modal", action: showStandaloneModal)
.foregroundColor(.blue)
Spacer()
}

HStack {
// Reset configuration
Button("Reset", action: loadDefaultSelections)
Expand Down Expand Up @@ -200,6 +207,17 @@ struct SwiftUIContentView: View {
clientID = defaultData.clientID
}

// MARK: - Open Standalone Modal
public func showStandaloneModal() {
let config = PayPalMessageModalConfig(data: .init(
clientID: clientID,
environment: defaultMessageConfig.data.environment
))

let modal = PayPalMessageModalViewController(config: config)
modal.show()
}

// MARK: - Delegates

class MessageViewStateDelegate: PayPalMessageViewStateDelegate {
Expand Down
18 changes: 17 additions & 1 deletion Demo/Demo/UIKitContentViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ class UIKitContentViewController: UIViewController {
getButton(title: "Reset", action: #selector(resetConfig(_:)))
}()

lazy var standaloneModalButton: UIButton = {
getButton(title: "Show Standalone Modal", action: #selector(showStandaloneModal(_:)))
}()

lazy var stackView: UIStackView = {
paypalMessage.translatesAutoresizingMaskIntoConstraints = false

Expand Down Expand Up @@ -139,7 +143,8 @@ class UIKitContentViewController: UIViewController {
axis: .horizontal
),
getSeparator(),
paypalMessage
paypalMessage,
standaloneModalButton
],
padding: 12
)
Expand Down Expand Up @@ -224,6 +229,17 @@ class UIKitContentViewController: UIViewController {
loadDefaultSelections()
}

@objc private func showStandaloneModal(_ sender: UIView) {
let config = PayPalMessageModalConfig(data: .init(
clientID: getCurrentClientID() ??
defaultMessageConfig.data.clientID,
environment: defaultMessageConfig.data.environment
))

let modal = PayPalMessageModalViewController(config: config)
modal.show()
}

// MARK: - Styling Helpers
private func getCurrentConfig() -> PayPalMessageConfig {
let config = PayPalMessageConfig(
Expand Down
36 changes: 36 additions & 0 deletions Demo/DemoUITests/DemoUITests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import XCTest

final class DemoUITests: XCTestCase {

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.

// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false

// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

func testModalViewIsOnScreen() throws {
let app = XCUIApplication()
app.launch()

let window = app.windows.element(boundBy: 0)
app.buttons["Show Standalone Modal"].tap()
let modalCloseButton = app.buttons["PayPal learn more modal close"]
XCTAssert(window.frame.contains(modalCloseButton.frame))
}

func testLaunchPerformance() throws {
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
// This measures how long it takes to launch your application.
measure(metrics: [XCTApplicationLaunchMetric()]) {
XCUIApplication().launch()
}
}
}
}
Loading
Loading