Skip to content

Commit

Permalink
ref/apply_swift_formatting (#271)
Browse files Browse the repository at this point in the history
  • Loading branch information
alacau authored Nov 9, 2023
1 parent 811cedc commit b66868e
Show file tree
Hide file tree
Showing 29 changed files with 105 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
// Copyright © 2019 AppLovin. All rights reserved.
//

import UIKit
import Adjust
import AppLovinSDK
import UIKit

class ALAppDelegate: UIResponder, UIApplicationDelegate
{
Expand All @@ -28,14 +28,14 @@ class ALAppDelegate: UIResponder, UIApplicationDelegate
Adjust.appDidLaunch(adjustConfig)
})

let barTintColor = UIColor.init(red: 10/255.0, green: 131/255.0, blue: 170/255.0, alpha: 1.0)
let barTintColor = UIColor.init(red: 10 / 255.0, green: 131 / 255.0, blue: 170 / 255.0, alpha: 1.0)
let navigationBarAppearance = UINavigationBar.appearance()
if #available(iOS 15.0, *)
{
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = barTintColor
appearance.titleTextAttributes = [.foregroundColor : UIColor.white]
appearance.titleTextAttributes = [.foregroundColor: UIColor.white]
navigationBarAppearance.standardAppearance = appearance
navigationBarAppearance.scrollEdgeAppearance = appearance
navigationBarAppearance.tintColor = .white
Expand All @@ -45,7 +45,7 @@ class ALAppDelegate: UIResponder, UIApplicationDelegate
// Fallback on earlier versions
navigationBarAppearance.isTranslucent = false
navigationBarAppearance.barTintColor = barTintColor
navigationBarAppearance.titleTextAttributes = [.foregroundColor : UIColor.white]
navigationBarAppearance.titleTextAttributes = [.foregroundColor: UIColor.white]
navigationBarAppearance.tintColor = .white
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// Copyright © 2023 AppLovin. All rights reserved.
//

import SwiftUI
import AppLovinSDK
import SwiftUI

@available(iOS 13.0, *)
struct ALAdViewSwiftUIWrapper: UIViewRepresentable
Expand All @@ -18,21 +18,21 @@ struct ALAdViewSwiftUIWrapper: UIViewRepresentable
let adFormat: ALAdSize

// ALAdLoadDelegate methods
var didLoad: ((ALAdService, ALAd) -> Void)? = nil
var didFailToLoadAdWithError: ((ALAdService, Int32) -> Void)? = nil
var didLoad: ((ALAdService, ALAd) -> ())? = nil
var didFailToLoadAdWithError: ((ALAdService, Int32) -> ())? = nil

// ALAdDisplayDelegate methods
var wasDisplayedIn: ((ALAd, UIView) -> Void)? = nil
var wasHiddenIn: ((ALAd, UIView) -> Void)? = nil
var wasClickedIn: ((ALAd, UIView) -> Void)? = nil
var wasDisplayedIn: ((ALAd, UIView) -> ())? = nil
var wasHiddenIn: ((ALAd, UIView) -> ())? = nil
var wasClickedIn: ((ALAd, UIView) -> ())? = nil

// ALAdViewEventDelegate methods
var didPresentFullscreenFor: ((ALAd, ALAdView) -> Void)? = nil
var willDismissFullscreenFor: ((ALAd, ALAdView) -> Void)? = nil
var didDismissFullscreenFor: ((ALAd, ALAdView) -> Void)? = nil
var willLeaveApplicationFor: ((ALAd, ALAdView) -> Void)? = nil
var didReturnToApplicationFor: ((ALAd, ALAdView) -> Void)? = nil
var didFailToDisplayIn: ((ALAd, ALAdView, ALAdViewDisplayErrorCode) -> Void)? = nil
var didPresentFullscreenFor: ((ALAd, ALAdView) -> ())? = nil
var willDismissFullscreenFor: ((ALAd, ALAdView) -> ())? = nil
var didDismissFullscreenFor: ((ALAd, ALAdView) -> ())? = nil
var willLeaveApplicationFor: ((ALAd, ALAdView) -> ())? = nil
var didReturnToApplicationFor: ((ALAd, ALAdView) -> ())? = nil
var didFailToDisplayIn: ((ALAd, ALAdView, ALAdViewDisplayErrorCode) -> ())? = nil

func makeUIView(context: Context) -> ALAdView
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ class ALBaseAdViewController: UIViewController
override func viewDidAppear(_ animated: Bool)
{
super.viewDidAppear(animated)
self.navigationController?.setToolbarHidden(self.hidesBottomBarWhenPushed, animated: true)
navigationController?.setToolbarHidden(hidesBottomBarWhenPushed, animated: true)
}

override func viewWillDisappear(_ animated: Bool)
{
self.navigationController?.setToolbarHidden(true, animated: false)
navigationController?.setToolbarHidden(true, animated: false)
super.viewWillDisappear(animated)
}

internal func logCallback(functionName: String = #function)
func logCallback(functionName: String = #function)
{
callbacks.append(functionName)
callbackTableView.insertRows(at: [IndexPath(row: callbacks.count - 1, section: 0)], with: .automatic)
Expand All @@ -46,6 +46,6 @@ extension ALBaseAdViewController: UITableViewDataSource

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return callbacks.count
callbacks.count
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// Copyright © 2023 AppLovin. All rights reserved.
//

import SwiftUI
import AppLovinSDK
import SwiftUI

@available(iOS 13.0, *)
class ALDemoAdViewSwiftUIViewModel: NSObject, ObservableObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
// Copyright © 2019 AppLovin. All rights reserved.
//

import UIKit
import AppLovinSDK
import MessageUI
import SafariServices
import UIKit

class ALHomeViewController: UITableViewController
{
Expand All @@ -21,20 +21,20 @@ class ALHomeViewController: UITableViewController

override var preferredStatusBarStyle: UIStatusBarStyle
{
return .lightContent
.lightContent
}

override func viewDidLoad()
{
super.viewDidLoad()
self.navigationController?.setToolbarHidden(self.hidesBottomBarWhenPushed, animated: true)
navigationController?.setToolbarHidden(hidesBottomBarWhenPushed, animated: true)
addFooterLabel()
muteToggle.image = muteIconForCurrentSdkMuteSetting()
}

override func viewWillDisappear(_ animated: Bool)
{
self.navigationController?.setToolbarHidden(true, animated: false)
navigationController?.setToolbarHidden(true, animated: false)
super.viewWillDisappear(animated)
}

Expand All @@ -60,17 +60,17 @@ class ALHomeViewController: UITableViewController

override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath)
{
if UIDevice.current.userInterfaceIdiom == .phone && indexPath.section == 0 && indexPath.row == Self.kRowIndexToHideForPhones
if UIDevice.current.userInterfaceIdiom == .phone && indexPath.section == 0 && indexPath.row == Self.kRowIndexToHideForPhones
{
cell.isHidden = true;
cell.isHidden = true
}
}

override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
{
if UIDevice.current.userInterfaceIdiom == .phone && indexPath.section == 0 && indexPath.row == Self.kRowIndexToHideForPhones
if UIDevice.current.userInterfaceIdiom == .phone && indexPath.section == 0 && indexPath.row == Self.kRowIndexToHideForPhones
{
return 0;
return 0
}

return super.tableView(tableView, heightForRowAt: indexPath)
Expand All @@ -89,7 +89,7 @@ class ALHomeViewController: UITableViewController
let style = NSMutableParagraphStyle()
style.alignment = .center
style.minimumLineHeight = 20
footer.attributedText = NSAttributedString(string: text, attributes: [NSAttributedString.Key.paragraphStyle : style])
footer.attributedText = NSAttributedString(string: text, attributes: [NSAttributedString.Key.paragraphStyle: style])

var frame = footer.frame
frame.size.height = footer.sizeThatFits(CGSize(width: footer.frame.width, height: CGFloat.greatestFiniteMagnitude)).height + 60
Expand All @@ -111,7 +111,7 @@ class ALHomeViewController: UITableViewController

func muteIconForCurrentSdkMuteSetting() -> UIImage!
{
return ALSdk.shared()!.settings.isMuted ? UIImage(named: "mute") : UIImage(named: "unmute")
ALSdk.shared()!.settings.isMuted ? UIImage(named: "mute") : UIImage(named: "unmute")
}

// MARK: Table View Actions
Expand All @@ -132,4 +132,3 @@ class ALHomeViewController: UITableViewController
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// Copyright © 2023 AppLovin. All rights reserved.
//

import SwiftUI
import AppLovinSDK
import SwiftUI

@available(iOS 13.0, *)
struct ALMAXNativeTemplateAdViewSwiftUIWrapper: UIViewRepresentable
Expand All @@ -18,13 +18,13 @@ struct ALMAXNativeTemplateAdViewSwiftUIWrapper: UIViewRepresentable
let containerView: UIView

// MANativeAdDelegate methods
var didLoadNativeAd: ((MANativeAdView?, MAAd) -> Void)? = nil
var didFailToLoadNativeAd: ((String, MAError) -> Void)? = nil
var didClickNativeAd: ((MAAd) -> Void)? = nil
var didExpireNativeAd: ((MAAd) -> Void)? = nil
var didLoadNativeAd: ((MANativeAdView?, MAAd) -> ())? = nil
var didFailToLoadNativeAd: ((String, MAError) -> ())? = nil
var didClickNativeAd: ((MAAd) -> ())? = nil
var didExpireNativeAd: ((MAAd) -> ())? = nil

// MAAdRevenueDelegate methods
var didPayRevenue: ((MAAd) -> Void)? = nil
var didPayRevenue: ((MAAd) -> ())? = nil

func makeUIView(context: Context) -> UIView
{
Expand Down Expand Up @@ -101,7 +101,7 @@ class ALMAXNativeSwiftUIAdLoader
{
self.containerView = containerView

nativeAdLoader = MANativeAdLoader(adUnitIdentifier: adUnitIdentifier)
self.nativeAdLoader = MANativeAdLoader(adUnitIdentifier: adUnitIdentifier)
}

func setNativeAdDelegate(_ context: UIViewRepresentableContext<ALMAXNativeTemplateAdViewSwiftUIWrapper>)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// Copyright © 2023 AppLovin. All rights reserved.
//

import SwiftUI
import AppLovinSDK
import SwiftUI

@available(iOS 13.0, *)
struct MAAdViewSwiftUIWrapper: UIViewRepresentable
Expand All @@ -17,20 +17,20 @@ struct MAAdViewSwiftUIWrapper: UIViewRepresentable
let sdk: ALSdk

// MAAdViewAdDelegate methods
var didLoad: ((MAAd) -> Void)? = nil
var didFailToLoadAd: ((String, MAError) -> Void)? = nil
var didDisplay: ((MAAd) -> Void)? = nil
var didFailToDisplayAd: ((MAAd, MAError) -> Void)? = nil
var didClick: ((MAAd) -> Void)? = nil
var didExpand: ((MAAd) -> Void)? = nil
var didCollapse: ((MAAd) -> Void)? = nil
var didHide: ((MAAd) -> Void)? = nil
var didLoad: ((MAAd) -> ())? = nil
var didFailToLoadAd: ((String, MAError) -> ())? = nil
var didDisplay: ((MAAd) -> ())? = nil
var didFailToDisplayAd: ((MAAd, MAError) -> ())? = nil
var didClick: ((MAAd) -> ())? = nil
var didExpand: ((MAAd) -> ())? = nil
var didCollapse: ((MAAd) -> ())? = nil
var didHide: ((MAAd) -> ())? = nil

// MAAdRequestDelegate method
var didStartAdRequest: ((String) -> Void)? = nil
var didStartAdRequest: ((String) -> ())? = nil

// MAAdRevenueDelegate method
var didPayRevenue: ((MAAd) -> Void)? = nil
var didPayRevenue: ((MAAd) -> ())? = nil

func makeUIView(context: Context) -> MAAdView
{
Expand Down Expand Up @@ -137,7 +137,7 @@ struct MAAdViewFrame: ViewModifier

func body(content: Content) -> some View
{
if ( adFormat == .banner || adFormat == .leader )
if adFormat == .banner || adFormat == .leader
{
// Stretch to the width of the screen for banners to be fully functional
// Banner height on iPhone and iPad is 50 and 90, respectively
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
// Copyright © 2023 AppLovin. All rights reserved.
//

import UIKit
import Adjust
import AppLovinSDK
import UIKit

class ALMAXAppOpenAdViewController: ALBaseAdViewController, MAAdViewAdDelegate, MAAdRevenueDelegate
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
// Copyright © 2019 AppLovin. All rights reserved.
//

import UIKit
import Adjust
import AppLovinSDK
import UIKit

class ALMAXAutoLayoutBannerAdViewController: ALBaseAdViewController, MAAdViewAdDelegate, MAAdRevenueDelegate
{
Expand All @@ -31,11 +31,11 @@ class ALMAXAutoLayoutBannerAdViewController: ALBaseAdViewController, MAAdViewAdD
view.addSubview(adView)

// Anchor the banner to the left, right, and top of the screen.
adView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true;
adView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true;
adView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true;
adView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
adView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
adView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true

adView.widthAnchor.constraint(equalTo: view.widthAnchor).isActive = true;
adView.widthAnchor.constraint(equalTo: view.widthAnchor).isActive = true
adView.heightAnchor.constraint(equalToConstant: (UIDevice.current.userInterfaceIdiom == .pad) ? 90 : 50).isActive = true // Banner height on iPhone and iPad is 50 and 90, respectively

// Load the first ad
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
// Copyright © 2019 AppLovin. All rights reserved.
//

import UIKit
import Adjust
import AppLovinSDK
import UIKit

class ALMAXFrameLayoutBannerAdViewController: ALBaseAdViewController, MAAdViewAdDelegate, MAAdRevenueDelegate
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
// Copyright © 2019 AppLovin. All rights reserved.
//

import UIKit
import Adjust
import AppLovinSDK
import UIKit

class ALMAXInterfaceBuilderBannerAdViewController: ALBaseAdViewController, MAAdViewAdDelegate, MAAdRevenueDelegate
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
// Copyright © 2023 AppLovin. All rights reserved.
//

import AppLovinSDK
import SwiftUI
import UIKit
import AppLovinSDK

@available(iOS 13.0, *)
class ALMAXSwiftUIBannerAdViewController: UIHostingController<ALMAXSwiftUIBannerAdView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
// Copyright © 2023 AppLovin. All rights reserved.
//

import SwiftUI
import Adjust
import AppLovinSDK
import SwiftUI

@available(iOS 13.0, *)
struct ALMAXSwiftUIBannerAdView: View
{
@ObservedObject private var viewModel = ALMAXSwiftUIBannerAdViewModel()

var body: some View {
var body: some View
{
VStack {
MAAdViewSwiftUIWrapper(adUnitIdentifier: "YOUR_AD_UNIT_ID",
adFormat: .banner,
Expand All @@ -29,14 +30,15 @@ struct ALMAXSwiftUIBannerAdView: View
didCollapse: viewModel.didCollapse,
didHide: viewModel.didHide,
didPayRevenue: viewModel.didPayRevenue)
.deviceSpecificFrame()
.deviceSpecificFrame()

callbacksTable
.frame(maxHeight: .infinity)
}
}

var callbacksTable: some View {
var callbacksTable: some View
{
List(viewModel.callbacks) {
Text($0.callback)
}
Expand Down
Loading

0 comments on commit b66868e

Please sign in to comment.