-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ticketmaster/vreddy-MA-10855-updategithubs…
…ampleapp Add marektDomain to sample app for PrePurchase
- Loading branch information
Showing
12 changed files
with
310 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...ntegration/Menus/MenuBuilder/MenuCells/MenuButtonWithTitleAndPopupMenuTableViewCell.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// | ||
// MenuButtonWithTitleAndPopupMenuTableViewCell.swift | ||
// RetailDevApp | ||
// | ||
// Created by Vishwak Reddy on 09/11/2024. | ||
// | ||
|
||
import UIKit | ||
|
||
protocol PopupMenuTableviewCellDelegate: AnyObject { | ||
func valueChanged(_ cell: MenuButtonWithTitleAndPopupTableViewCell, value: String) | ||
} | ||
|
||
class MenuButtonWithTitleAndPopupTableViewCell: MenuBuilderTableViewCell { | ||
|
||
@IBOutlet weak var titleLabel: UILabel! | ||
@IBOutlet weak var valueButton: UIButton! | ||
|
||
weak var delegate: PopupMenuTableviewCellDelegate? | ||
|
||
// MARK: Constructors | ||
func configure(withCellInfo cellInfo: MenuBuilderCellInfo) { | ||
guard cellInfo.cellType == .buttonWithTitleAndPopupMenu else { return } | ||
self.cellInfo = cellInfo | ||
self.accessoryType = cellInfo.accessoryType | ||
|
||
titleLabel.text = cellInfo.titleText | ||
valueButton.setTitle(cellInfo.valueText, for: .normal) | ||
|
||
titleLabel.textColor = cellInfo.titleColor ?? .label | ||
valueButton.tintColor = cellInfo.valueColor ?? contentView.tintColor | ||
contentView.backgroundColor = cellInfo.backgroundColor | ||
|
||
valueButton.menu = UIMenu(title: "", children: menuActions()) | ||
valueButton.showsMenuAsPrimaryAction = true | ||
|
||
} | ||
|
||
// MARK: Updates | ||
func update(title: String) { | ||
titleLabel.text = title | ||
} | ||
|
||
func update(buttonTitle: String) { | ||
valueButton.setTitle(buttonTitle, for: .normal) | ||
} | ||
|
||
} | ||
|
||
extension MenuButtonWithTitleAndPopupTableViewCell { | ||
func menuActions() -> [UIMenuElement] { | ||
guard let valueArray = cellInfo.valueArray else { return []} | ||
var actions = [UIMenuElement]() | ||
for (index, value) in valueArray.enumerated() { | ||
var title: String | ||
if let titlesArray = cellInfo.segmentTextArray, | ||
index < titlesArray.count | ||
{ | ||
title = titlesArray[index] | ||
} else { | ||
title = value | ||
} | ||
|
||
actions.append( | ||
UIAction(title: title) { [weak self] action in | ||
guard let self else { return } | ||
self.delegate?.valueChanged(self, value: value) | ||
} | ||
) | ||
} | ||
return actions | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...oIntegration/Menus/MenuBuilder/MenuCells/MenuButtonWithTitleAndPopupMenuTableViewCell.xib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="22505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> | ||
<device id="retina6_1" orientation="portrait" appearance="light"/> | ||
<dependencies> | ||
<deployment identifier="iOS"/> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/> | ||
<capability name="Safe area layout guides" minToolsVersion="9.0"/> | ||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | ||
</dependencies> | ||
<objects> | ||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> | ||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="KGk-i7-Jjw" customClass="MenuButtonWithTitleAndPopupTableViewCell" customModule="RetailDevAppNav" customModuleProvider="target"> | ||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/> | ||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> | ||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM"> | ||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/> | ||
<autoresizingMask key="autoresizingMask"/> | ||
<subviews> | ||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Title Text" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="oXr-G1-O1Z"> | ||
<rect key="frame" x="10" y="7" width="62.5" height="30"/> | ||
<fontDescription key="fontDescription" type="system" pointSize="15"/> | ||
<nil key="textColor"/> | ||
<nil key="highlightedColor"/> | ||
</label> | ||
<button opaque="NO" contentMode="scaleToFill" horizontalCompressionResistancePriority="751" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="l7s-uh-4La"> | ||
<rect key="frame" x="222" y="7" width="88" height="30"/> | ||
<state key="normal" title="Value Button"/> | ||
</button> | ||
</subviews> | ||
<constraints> | ||
<constraint firstItem="oXr-G1-O1Z" firstAttribute="bottom" secondItem="H2p-sc-9uM" secondAttribute="bottom" constant="-7" id="Gx3-t5-yvp"/> | ||
<constraint firstItem="oXr-G1-O1Z" firstAttribute="trailing" relation="lessThanOrEqual" secondItem="l7s-uh-4La" secondAttribute="leading" constant="-10" id="SGR-xO-NUb"/> | ||
<constraint firstItem="l7s-uh-4La" firstAttribute="trailing" secondItem="H2p-sc-9uM" secondAttribute="trailing" constant="-10" id="Vva-ha-2n5"/> | ||
<constraint firstItem="oXr-G1-O1Z" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="10" id="cCg-rm-gJ6"/> | ||
<constraint firstItem="l7s-uh-4La" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="7" id="dzx-Vy-AwF"/> | ||
<constraint firstItem="l7s-uh-4La" firstAttribute="bottom" secondItem="H2p-sc-9uM" secondAttribute="bottom" constant="-7" id="g1w-1l-xck"/> | ||
<constraint firstItem="oXr-G1-O1Z" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="7" id="wqR-1l-ki3"/> | ||
</constraints> | ||
</tableViewCellContentView> | ||
<viewLayoutGuide key="safeArea" id="njF-e1-oar"/> | ||
<connections> | ||
<outlet property="titleLabel" destination="oXr-G1-O1Z" id="XNd-ui-ZL5"/> | ||
<outlet property="valueButton" destination="l7s-uh-4La" id="E05-1i-CHX"/> | ||
</connections> | ||
<point key="canvasLocation" x="123" y="154"/> | ||
</tableViewCell> | ||
</objects> | ||
</document> |
77 changes: 77 additions & 0 deletions
77
TMSDKDemoIntegration/Menus/PrePurchase/MarketLocation+AdditionalMarkets.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// | ||
// MarketLocation+Extensions.swift | ||
// RetailDevApp | ||
// | ||
// Created by Andrew Rennard on 12/02/2024. | ||
// | ||
|
||
import Foundation | ||
import CoreLocation | ||
import TicketmasterFoundation | ||
|
||
extension MarketLocation { | ||
static func defaultLocationFor(market: MarketDomain) -> MarketLocation { | ||
switch market { | ||
case .CA: MarketLocation.Canada_BritishColumbia_Vancouver() | ||
case .AU: MarketLocation.Australia_Sydney() | ||
case .MX: MarketLocation.Mexico_MexicoCity() | ||
case .NZ: MarketLocation.NewZealand_Auckland() | ||
case .UK: MarketLocation.UK_London() | ||
case .IE: MarketLocation.IE_Dublin() | ||
default: MarketLocation.California_LosAngeles() | ||
} | ||
} | ||
} | ||
|
||
extension MarketLocation { | ||
|
||
static func Australia_Sydney() -> MarketLocation { | ||
let domain: MarketDomain = .AU | ||
let marketID: Int = 307 | ||
let marketName: String = "Sydney" | ||
let description: String = "Sydney, AU" | ||
let clLocation: CLLocation = CLLocation(latitude: -33.87271, longitude: 151.20569) | ||
|
||
return MarketLocation(domain: domain, identifier: "\(marketID)", name: marketName, localizedName: description, dmaId: nil, countryCode: domain.countryCode, userLocation: UserLocation(location: clLocation, source: .appMarketList), source: .appMarketList) | ||
} | ||
|
||
static func Mexico_MexicoCity() -> MarketLocation { | ||
let domain: MarketDomain = .MX | ||
let marketID: Int = 402 | ||
let marketName: String = "Mexico City" | ||
let description: String = "Mexico City, MX" | ||
let clLocation: CLLocation = CLLocation(latitude: 19.43011, longitude: 99.13361) | ||
|
||
return MarketLocation(domain: domain, identifier: "\(marketID)", name: marketName, localizedName: description, dmaId: nil, countryCode: domain.countryCode, userLocation: UserLocation(location: clLocation, source: .appMarketList), source: .appMarketList) | ||
} | ||
|
||
static func NewZealand_Auckland() -> MarketLocation { | ||
let domain: MarketDomain = .NZ | ||
let marketID: Int = 351 | ||
let marketName: String = "Auckland" | ||
let description: String = "Auckland, NZ" | ||
let clLocation: CLLocation = CLLocation(latitude: -36.85307, longitude: 174.76358) | ||
|
||
return MarketLocation(domain: domain, identifier: "\(marketID)", name: marketName, localizedName: description, dmaId: nil, countryCode: domain.countryCode, userLocation: UserLocation(location: clLocation, source: .appMarketList), source: .appMarketList) | ||
} | ||
|
||
static func UK_London() -> MarketLocation { | ||
let domain: MarketDomain = .UK | ||
let marketID: Int = 202 | ||
let marketName: String = "London" | ||
let description: String = "London, UK" | ||
let clLocation: CLLocation = CLLocation(latitude: 51.51, longitude: -0.12) | ||
|
||
return MarketLocation(domain: domain, identifier: "\(marketID)", name: marketName, localizedName: description, dmaId: nil, countryCode: domain.countryCode, userLocation: UserLocation(location: clLocation, source: .appMarketList), source: .appMarketList) | ||
} | ||
|
||
static func IE_Dublin() -> MarketLocation { | ||
let domain: MarketDomain = .IE | ||
let marketID: Int = 208 | ||
let marketName: String = "Dublin" | ||
let description: String = "Dublin, IE" | ||
let clLocation: CLLocation = CLLocation(latitude: 53.35, longitude: -6.27) | ||
|
||
return MarketLocation(domain: domain, identifier: "\(marketID)", name: marketName, localizedName: description, dmaId: nil, countryCode: domain.countryCode, userLocation: UserLocation(location: clLocation, source: .appMarketList), source: .appMarketList) | ||
} | ||
} |
Oops, something went wrong.