Skip to content

This PR applies the swift-format default config to all .swift files in the repo #672

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

Merged
merged 1 commit into from
May 30, 2025
Merged
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
46 changes: 23 additions & 23 deletions MixpanelDemo/MixpanelDemo/ActionCompleteViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,35 @@
import UIKit

class ActionCompleteViewController: UIViewController {
@IBOutlet weak var popupView: UIView!
@IBOutlet weak var actionLabel: UILabel!
@IBOutlet weak var descLabel: UILabel!
var actionStr: String?
var descStr: String?
@IBOutlet weak var popupView: UIView!
@IBOutlet weak var actionLabel: UILabel!
@IBOutlet weak var descLabel: UILabel!
var actionStr: String?
var descStr: String?

override func viewDidLoad() {
super.viewDidLoad()
override func viewDidLoad() {
super.viewDidLoad()

popupView.clipsToBounds = true
popupView.layer.cornerRadius = 6
popupView.clipsToBounds = true
popupView.layer.cornerRadius = 6

let tap = UITapGestureRecognizer(target: self, action: #selector(handleTap))
view.addGestureRecognizer(tap)
let tap = UITapGestureRecognizer(target: self, action: #selector(handleTap))
view.addGestureRecognizer(tap)

actionLabel.text = actionStr
descLabel.text = descStr
}
actionLabel.text = actionStr
descLabel.text = descStr
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
self.dismiss(animated: true, completion: nil)
}
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

@objc func handleTap(gesture: UITapGestureRecognizer) {
dismiss(animated: true, completion: nil)
DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
self.dismiss(animated: true, completion: nil)
}
}

@objc func handleTap(gesture: UITapGestureRecognizer) {
dismiss(animated: true, completion: nil)
}

}
27 changes: 14 additions & 13 deletions MixpanelDemo/MixpanelDemo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@
// Copyright © 2016 Mixpanel. All rights reserved.
//

import UIKit
import Mixpanel
import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
var ADD_YOUR_MIXPANEL_TOKEN_BELOW_🛠🛠🛠🛠🛠🛠: String
let mixpanelOptions = MixpanelOptions(token: "MIXPANEL_TOKEN", trackAutomaticEvents: true)
Mixpanel.initialize(options: mixpanelOptions)
Mixpanel.mainInstance().loggingEnabled = true

return true
}
}
var window: UIWindow?

func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
var ADD_YOUR_MIXPANEL_TOKEN_BELOW_🛠🛠🛠🛠🛠🛠: String
let mixpanelOptions = MixpanelOptions(token: "MIXPANEL_TOKEN", trackAutomaticEvents: true)
Mixpanel.initialize(options: mixpanelOptions)
Mixpanel.mainInstance().loggingEnabled = true

return true
}
}
154 changes: 82 additions & 72 deletions MixpanelDemo/MixpanelDemo/GDPRViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,80 +6,90 @@
// Copyright © 2018 Mixpanel. All rights reserved.
//

import UIKit
import Mixpanel
import UIKit

class GDPRViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

@IBOutlet weak var tableView: UITableView!
var tableViewItems = ["Opt Out",
"Check Opted Out Flag",
"Opt In",
"Opt In w DistinctId",
"Opt In w DistinctId & Properties",
"Init with default opt-out",
"Init with default opt-in"
]

override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = self.tableView.dequeueReusableCell(withIdentifier: "cell")! as UITableViewCell
cell.textLabel?.text = tableViewItems[indexPath.item]
cell.textLabel?.textColor = #colorLiteral(red: 0.200000003, green: 0.200000003, blue: 0.200000003, alpha: 1)
return cell
}

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)

let actionStr = tableViewItems[indexPath.item]
var descStr = ""

switch indexPath.item {
case 0:
Mixpanel.mainInstance().optOutTracking()
descStr = "Opted out"
case 1:
descStr = "Opt-out flag is \(Mixpanel.mainInstance().hasOptedOutTracking())"
case 2:
Mixpanel.mainInstance().optInTracking()
descStr = "Opted In"
case 3:
Mixpanel.mainInstance().optInTracking(distinctId: "aDistinctIdForOptIn")
descStr = "Opt In with distinctId 'aDistinctIdForOptIn'"
case 4:
let p: Properties = ["a": 1,
"b": 2.3,
"c": ["4", 5] as [Any],
"d": URL(string:"https://mixpanel.com")!,
"e": NSNull(),
"f": Date()]
Mixpanel.mainInstance().optInTracking(distinctId: "aDistinctIdForOptIn", properties: p)
descStr = "Opt In with distinctId 'aDistinctIdForOptIn' and \(p)"
case 5:
Mixpanel.initialize(token: "testtoken", trackAutomaticEvents: true, optOutTrackingByDefault: true)
descStr = "Init Mixpanel with default opt-out(sample only), to make it work, place it in your startup stage of your app"
case 6:
Mixpanel.initialize(token: "testtoken", trackAutomaticEvents: true, optOutTrackingByDefault: false)
descStr = "Init Mixpanel with default opt-in(sample only), to make it work, place it in your startup stage of your app"
default:
break
}

let vc = storyboard!.instantiateViewController(withIdentifier: "ActionCompleteViewController") as! ActionCompleteViewController
vc.actionStr = actionStr
vc.descStr = descStr
vc.modalTransitionStyle = UIModalTransitionStyle.crossDissolve
vc.modalPresentationStyle = UIModalPresentationStyle.overFullScreen
present(vc, animated: true, completion: nil)
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return tableViewItems.count

@IBOutlet weak var tableView: UITableView!
var tableViewItems = [
"Opt Out",
"Check Opted Out Flag",
"Opt In",
"Opt In w DistinctId",
"Opt In w DistinctId & Properties",
"Init with default opt-out",
"Init with default opt-in",
]

override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = self.tableView.dequeueReusableCell(withIdentifier: "cell")! as UITableViewCell
cell.textLabel?.text = tableViewItems[indexPath.item]
cell.textLabel?.textColor = #colorLiteral(
red: 0.200000003, green: 0.200000003, blue: 0.200000003, alpha: 1)
return cell
}

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)

let actionStr = tableViewItems[indexPath.item]
var descStr = ""

switch indexPath.item {
case 0:
Mixpanel.mainInstance().optOutTracking()
descStr = "Opted out"
case 1:
descStr = "Opt-out flag is \(Mixpanel.mainInstance().hasOptedOutTracking())"
case 2:
Mixpanel.mainInstance().optInTracking()
descStr = "Opted In"
case 3:
Mixpanel.mainInstance().optInTracking(distinctId: "aDistinctIdForOptIn")
descStr = "Opt In with distinctId 'aDistinctIdForOptIn'"
case 4:
let p: Properties = [
"a": 1,
"b": 2.3,
"c": ["4", 5] as [Any],
"d": URL(string: "https://mixpanel.com")!,
"e": NSNull(),
"f": Date(),
]
Mixpanel.mainInstance().optInTracking(distinctId: "aDistinctIdForOptIn", properties: p)
descStr = "Opt In with distinctId 'aDistinctIdForOptIn' and \(p)"
case 5:
Mixpanel.initialize(
token: "testtoken", trackAutomaticEvents: true, optOutTrackingByDefault: true)
descStr =
"Init Mixpanel with default opt-out(sample only), to make it work, place it in your startup stage of your app"
case 6:
Mixpanel.initialize(
token: "testtoken", trackAutomaticEvents: true, optOutTrackingByDefault: false)
descStr =
"Init Mixpanel with default opt-in(sample only), to make it work, place it in your startup stage of your app"
default:
break
}

let vc =
storyboard!.instantiateViewController(withIdentifier: "ActionCompleteViewController")
as! ActionCompleteViewController
vc.actionStr = actionStr
vc.descStr = descStr
vc.modalTransitionStyle = UIModalTransitionStyle.crossDissolve
vc.modalPresentationStyle = UIModalPresentationStyle.overFullScreen
present(vc, animated: true, completion: nil)
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return tableViewItems.count
}
}
Loading