Skip to content

Commit f34f475

Browse files
Interactive Media Ads Developer RelationsIMA Developer Relations
authored andcommitted
No public description
PiperOrigin-RevId: 800571237
1 parent 43680ab commit f34f475

File tree

14 files changed

+1348
-0
lines changed

14 files changed

+1348
-0
lines changed

Swift/prerelease/CustomUIExample/CustomUIExample.xcodeproj/project.pbxproj

Lines changed: 382 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1530"
4+
version = "1.7">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES"
8+
buildArchitectures = "Automatic">
9+
<BuildActionEntries>
10+
<BuildActionEntry
11+
buildForTesting = "YES"
12+
buildForRunning = "YES"
13+
buildForProfiling = "YES"
14+
buildForArchiving = "YES"
15+
buildForAnalyzing = "YES">
16+
<BuildableReference
17+
BuildableIdentifier = "primary"
18+
BlueprintIdentifier = "D216278F2C165053004B08EF"
19+
BuildableName = "CustomUIExample.app"
20+
BlueprintName = "CustomUIExample"
21+
ReferencedContainer = "container:CustomUIExample.xcodeproj">
22+
</BuildableReference>
23+
</BuildActionEntry>
24+
</BuildActionEntries>
25+
</BuildAction>
26+
<TestAction
27+
buildConfiguration = "Debug"
28+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
29+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
30+
shouldUseLaunchSchemeArgsEnv = "YES"
31+
shouldAutocreateTestPlan = "YES">
32+
</TestAction>
33+
<LaunchAction
34+
buildConfiguration = "Debug"
35+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37+
launchStyle = "0"
38+
useCustomWorkingDirectory = "NO"
39+
ignoresPersistentStateOnLaunch = "NO"
40+
debugDocumentVersioning = "YES"
41+
debugServiceExtension = "internal"
42+
allowLocationSimulation = "YES">
43+
<BuildableProductRunnable
44+
runnableDebuggingMode = "0">
45+
<BuildableReference
46+
BuildableIdentifier = "primary"
47+
BlueprintIdentifier = "D216278F2C165053004B08EF"
48+
BuildableName = "CustomUIExample.app"
49+
BlueprintName = "CustomUIExample"
50+
ReferencedContainer = "container:CustomUIExample.xcodeproj">
51+
</BuildableReference>
52+
</BuildableProductRunnable>
53+
<EnvironmentVariables>
54+
<EnvironmentVariable
55+
key = "IDEPreferLogStreaming"
56+
value = "YES"
57+
isEnabled = "YES">
58+
</EnvironmentVariable>
59+
</EnvironmentVariables>
60+
</LaunchAction>
61+
<ProfileAction
62+
buildConfiguration = "Release"
63+
shouldUseLaunchSchemeArgsEnv = "YES"
64+
savedToolIdentifier = ""
65+
useCustomWorkingDirectory = "NO"
66+
debugDocumentVersioning = "YES">
67+
<BuildableProductRunnable
68+
runnableDebuggingMode = "0">
69+
<BuildableReference
70+
BuildableIdentifier = "primary"
71+
BlueprintIdentifier = "D216278F2C165053004B08EF"
72+
BuildableName = "CustomUIExample.app"
73+
BlueprintName = "CustomUIExample"
74+
ReferencedContainer = "container:CustomUIExample.xcodeproj">
75+
</BuildableReference>
76+
</BuildableProductRunnable>
77+
</ProfileAction>
78+
<AnalyzeAction
79+
buildConfiguration = "Debug">
80+
</AnalyzeAction>
81+
<ArchiveAction
82+
buildConfiguration = "Release"
83+
revealArchiveInOrganizer = "YES">
84+
</ArchiveAction>
85+
</Scheme>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
source 'https://github.com/CocoaPods/Specs.git'
2+
3+
platform :ios, '17'
4+
project 'CustomUIExample.xcodeproj'
5+
6+
target 'CustomUIExample' do
7+
pod 'GoogleAds-IMA-iOS-SDK', '~> 3.27.4'
8+
end
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2024 Google LLC. All rights reserved.
2+
//
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
5+
// file except in compliance with the License. You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software distributed under
10+
// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
// ANY KIND, either express or implied. See the License for the specific language governing
12+
// permissions and limitations under the License.
13+
14+
import CoreData
15+
import UIKit
16+
17+
@main class AppDelegate: UIResponder, UIApplicationDelegate {
18+
19+
var window: UIWindow?
20+
21+
func application(
22+
_ application: UIApplication,
23+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
24+
) -> Bool {
25+
// Override point for customization after application launch.
26+
return true
27+
}
28+
29+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors" : [
3+
{
4+
"idiom" : "universal"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"platform" : "ios",
6+
"size" : "1024x1024"
7+
}
8+
],
9+
"info" : {
10+
"author" : "xcode",
11+
"version" : 1
12+
}
13+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import GoogleInteractiveMediaAds
2+
import SwiftUI
3+
4+
/// A button that represents a link with custom UI.
5+
public struct CustomUILink: View {
6+
7+
let link: IMAUILink
8+
let customUI: IMACustomUI
9+
10+
/// - Parameters:
11+
/// - link: Data for rendering the link and performing the click action.
12+
/// - customUI: Provider for SDK interactions.
13+
init(link: IMAUILink, customUI: IMACustomUI) {
14+
self.link = link
15+
self.customUI = customUI
16+
}
17+
18+
public var body: some View {
19+
Button(
20+
action: {
21+
self.customUI.uiElement(self.link.id, didClickWith: nil)
22+
UIApplication.shared.open(self.link.clickURL, options: [:], completionHandler: nil)
23+
},
24+
label: {
25+
Text(self.link.text)
26+
})
27+
}
28+
}
29+
30+
/// A button that represents an icon with custom UI.
31+
public struct CustomUIIcon: View {
32+
33+
let icon: IMAUIIcon
34+
let action: () -> Void
35+
36+
/// - Parameters:
37+
/// - icon: Data for rendering the icon including the image URL and width/height.
38+
/// - action: The action to perform when the icon is clicked.
39+
init(icon: IMAUIIcon, action: @escaping () -> Void) {
40+
self.icon = icon
41+
self.action = action
42+
}
43+
44+
public var body: some View {
45+
HStack {
46+
Spacer()
47+
VStack {
48+
Spacer()
49+
ZStack {
50+
Button(
51+
action: {
52+
self.action()
53+
},
54+
) {
55+
AsyncImage(url: self.icon.image.url) { image in
56+
image.resizable().scaledToFit()
57+
} placeholder: {
58+
Color.clear
59+
}
60+
.allowsHitTesting(false)
61+
}
62+
}
63+
.frame(width: CGFloat(self.icon.image.width), height: CGFloat(self.icon.image.height))
64+
.background(Color.blue)
65+
}
66+
}
67+
}
68+
}
69+
70+
/// A dialog displaying the fallback image with a close button.
71+
public struct CustomUIFallbackImage: View {
72+
73+
let fallbackImage: IMAUIFallbackImage
74+
let action: () -> Void
75+
76+
/// - Parameters:
77+
/// - fallbackImage: Data for rendering the fallback image including the image URL.
78+
/// - action: The action to perform when the dialog is closed.
79+
init(fallbackImage: IMAUIFallbackImage, action: @escaping () -> Void) {
80+
self.fallbackImage = fallbackImage
81+
self.action = action
82+
}
83+
84+
public var body: some View {
85+
ZStack {
86+
Color.black.opacity(0.7).edgesIgnoringSafeArea(.all)
87+
AsyncImage(url: self.fallbackImage.url) { image in
88+
image.resizable().scaledToFill()
89+
} placeholder: {
90+
Color.clear
91+
}
92+
.edgesIgnoringSafeArea(.all)
93+
VStack {
94+
HStack {
95+
Spacer()
96+
Button(
97+
action: {
98+
self.action()
99+
},
100+
label: {
101+
Text("x")
102+
})
103+
}
104+
Spacer()
105+
}
106+
}
107+
}
108+
}

0 commit comments

Comments
 (0)