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

Added SPM support #264

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ playground.xcworkspace
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
.build/
.swiftpm/

# CocoaPods
#
Expand Down
5 changes: 5 additions & 0 deletions CardParts/src/Classes/Card Parts/CardPartBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
// Copyright © 2017 Mint.com. All rights reserved.
//

#if SWIFT_PACKAGE
import UIKit
#else
import Foundation
#endif

import RxSwift
import RxCocoa

Expand Down
4 changes: 4 additions & 0 deletions CardParts/src/Classes/Card Parts/CardPartCenteredView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
// Created by Tumer, Deniz on 6/20/18.
//

#if SWIFT_PACKAGE
import UIKit
#else
import Foundation
#endif

public class CardPartCenteredView: UIView, CardPartView {
public var margins: UIEdgeInsets = CardParts.theme.cardPartMargins
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
// Created by Roossin, Chase on 3/7/18.
//

#if SWIFT_PACKAGE
import UIKit
#else
import Foundation
#endif

open class CardPartCollectionViewCardPartsCell : UICollectionViewCell {

Expand Down
20 changes: 16 additions & 4 deletions CardParts/src/Classes/Card Parts/CardPartConfettiView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class CardPartConfettiView: UIView, CardPartView {
}
}

public var confettiImages = [UIImage(named: "confetti", in: Bundle(for: CardPartConfettiView.self),compatibleWith: nil)] as? [UIImage]
public var confettiImages = [UIImage(named: "confetti", in: Bundle.confetti,compatibleWith: nil)] as? [UIImage]

//A layer that emits, animates, and renders a particle system.
var emitter: CAEmitterLayer = CAEmitterLayer()
Expand Down Expand Up @@ -127,15 +127,27 @@ public class CardPartConfettiView: UIView, CardPartView {
private func image(for type: ConfettiType, index: Int = 0) -> UIImage? {
switch type {
case .diamond:
return UIImage(named: "diamond", in: Bundle(for: CardPartConfettiView.self), compatibleWith: nil)
return UIImage(named: "diamond", in: Bundle.confetti, compatibleWith: nil)
case .star:
return UIImage(named: "star", in: Bundle(for: CardPartConfettiView.self), compatibleWith: nil)
return UIImage(named: "star", in: Bundle.confetti, compatibleWith: nil)
case let .image(customImage):
return customImage
case .mixed:
return confettiImages?[index]
case .confetti:
return UIImage(named: "confetti", in: Bundle(for: CardPartConfettiView.self), compatibleWith: nil)
return UIImage(named: "confetti", in: Bundle.confetti, compatibleWith: nil)
}
}
}

private extension Bundle {

/// Gets the correct Bundle for cenfetti images based on the environment.
static var confetti: Bundle {
#if SWIFT_PACKAGE
return Bundle.module
#else
return Bundle(for: CardPartConfettiView.self)
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
// Created by bcarreon1 on 1/30/20.
//

#if SWIFT_PACKAGE
import UIKit
#else
import Foundation
#endif

import RxSwift
import RxCocoa

Expand Down
4 changes: 4 additions & 0 deletions CardParts/src/Classes/Card Parts/CardPartOrientedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
// Created by Tumer, Deniz on 6/13/18.
//

#if SWIFT_PACKAGE
import UIKit
#else
import Foundation
#endif

public enum Orientation {
case top
Expand Down
5 changes: 5 additions & 0 deletions CardParts/src/Classes/Card Parts/CardPartSeparatorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
// Copyright © 2017 Mint.com. All rights reserved.
//

#if SWIFT_PACKAGE
import UIKit
#else
import Foundation
#endif

import RxSwift
import RxCocoa

Expand Down
5 changes: 5 additions & 0 deletions CardParts/src/Classes/Card Parts/CardPartSliderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
// Created by Kier, Tom on 12/9/17.
//

#if SWIFT_PACKAGE
import UIKit
#else
import Foundation
#endif

import RxSwift
import RxCocoa

Expand Down
5 changes: 5 additions & 0 deletions CardParts/src/Classes/Card Parts/CardPartSpacerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
// Copyright © 2017 Mint.com. All rights reserved.
//

#if SWIFT_PACKAGE
import UIKit
#else
import Foundation
#endif

import RxSwift
import RxCocoa

Expand Down
4 changes: 4 additions & 0 deletions CardParts/src/Classes/Card Parts/CardPartSwitchView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
// Created by bcarreon1 on 2/25/20.
//

#if SWIFT_PACKAGE
import UIKit
#endif

public class CardPartSwitchView: UISwitch, CardPartView {
public var margins: UIEdgeInsets = CardParts.theme.cardPartMargins
}
6 changes: 5 additions & 1 deletion CardParts/src/Classes/Card Parts/CardPartTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
// Created by Kier, Tom on 12/14/17.
//

#if SWIFT_PACKAGE
import UIKit
#else
import Foundation
import Foundation
#endif

import RxSwift
import RxCocoa

Expand Down
18 changes: 15 additions & 3 deletions CardParts/src/Classes/Card Parts/CardPartTitleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class CardPartTitleView : UIView, CardPartView {
public var menuButtonImageName: String = "arrowdown" {
didSet {
if type == .titleWithMenu || type == .titleWithActionableButton {
menuButtonImage = UIImage(named: menuButtonImageName, in: Bundle(for: CardPartTitleView.self), compatibleWith: nil)
menuButtonImage = UIImage(named: menuButtonImageName, in: Bundle.title, compatibleWith: nil)
}
}
}
Expand Down Expand Up @@ -80,7 +80,7 @@ public class CardPartTitleView : UIView, CardPartView {
if let image = menuButtonImage {
button.setImage(image, for: .normal)
} else {
button.setImage(UIImage(named: menuButtonImageName, in: Bundle(for: CardPartTitleView.self), compatibleWith: nil), for: .normal)
button.setImage(UIImage(named: menuButtonImageName, in: Bundle.title, compatibleWith: nil), for: .normal)
}
button.addTarget(self, action: #selector(menuButtonTapped), for: UIControl.Event.touchUpInside)
addSubview(button)
Expand All @@ -92,7 +92,7 @@ public class CardPartTitleView : UIView, CardPartView {
if let image = menuButtonImage {
button.setImage(image, for: .normal)
} else {
button.setImage(UIImage(named: menuButtonImageName, in: Bundle(for: CardPartTitleView.self), compatibleWith: nil), for: .normal)
button.setImage(UIImage(named: menuButtonImageName, in: Bundle.title, compatibleWith: nil), for: .normal)
}
button.addTarget(self, action: #selector(actionableMenuTapped), for: UIControl.Event.touchUpInside)
addSubview(button)
Expand Down Expand Up @@ -203,3 +203,15 @@ extension Reactive where Base: CardPartTitleView {
}
}
}

private extension Bundle {

/// Gets the correct Bundle for the `arrowdown` image based on the environment.
static var title: Bundle {
#if SWIFT_PACKAGE
return Bundle.module
#else
return Bundle(for: CardPartTitleView.self)
#endif
}
}
4 changes: 4 additions & 0 deletions CardParts/src/Classes/Card Parts/CardPartTriangleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
// Created by Venkatnarayansetty, Badarinath on 9/19/19.
//

#if SWIFT_PACKAGE
import UIKit
#else
import Foundation
#endif

class CardPartTriangleView: UIView,CardPartView {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
// Copyright © 2017 Mint.com. All rights reserved.
//

#if SWIFT_PACKAGE
import UIKit
#else
import Foundation
#endif

import RxSwift
import RxCocoa

Expand Down
4 changes: 4 additions & 0 deletions CardParts/src/Classes/CardPartTableViewCardPartsCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
// Copyright © 2017 Mint.com. All rights reserved.
//

#if SWIFT_PACKAGE
import UIKit
#else
import Foundation
#endif

open class CardPartTableViewCardPartsCell : UITableViewCell {

Expand Down
4 changes: 4 additions & 0 deletions CardParts/src/Classes/CardPartsFullScreenViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
// Copyright © 2017 Mint.com. All rights reserved.
//

#if SWIFT_PACKAGE
import UIKit
#else
import Foundation
#endif

open class CardPartsFullScreenViewController: CardPartsViewController {

Expand Down
4 changes: 4 additions & 0 deletions CardParts/src/Classes/CardPartsTheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
// Created by Kier, Tom on 12/7/17.
//

#if SWIFT_PACKAGE
import UIKit
#else
import Foundation
#endif

public protocol CardPartsTheme {

Expand Down
14 changes: 13 additions & 1 deletion CardParts/src/Classes/CardsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ open class CardsViewController : UIViewController, UICollectionViewDataSource, U
}.disposed(by: bag)
if getEditModeForIndexPath(indexPath: indexPath) {
let editButton = UIButton(frame: CGRect(x: view.bounds.size.width - editButtonOffset - editButtonWidth, y: 0, width: editButtonWidth, height: editButtonHeight))
editButton.setImage(UIImage(named: editButtonImage, in: Bundle(for: CardsViewController.self), compatibleWith: nil), for: .normal)
editButton.setImage(UIImage(named: editButtonImage, in: Bundle.controller, compatibleWith: nil), for: .normal)
editButton.addTargetClosure { _ in
if let editibalCardTrait = cardController as? EditableCardTrait {
editibalCardTrait.onEditButtonTap()
Expand Down Expand Up @@ -471,3 +471,15 @@ extension CardsViewController {
notifyCardsVisibility()
}
}

private extension Bundle {

/// Gets the correct Bundle for the `budgets_disclosure_icon` image based on the environment.
static var controller: Bundle {
#if SWIFT_PACKAGE
return Bundle.module
#else
return Bundle(for: CardsViewController.self)
#endif
}
}
4 changes: 4 additions & 0 deletions CardParts/src/Delegates/CardVisibilityDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
// Created by Tumer, Deniz on 5/23/18.
//

#if SWIFT_PACKAGE
import UIKit
#endif

/*
* This protocol handles passing data about the visibility of a card
* from an instance of a CardsViewController to the card itself
Expand Down
4 changes: 4 additions & 0 deletions CardParts/src/Extensions/Date.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
// Copyright © 2017 Intuit, Inc. All rights reserved.
//

#if SWIFT_PACKAGE
import Foundation
#endif

enum DateFormat : String {
case Date = "yyyy'-'MM'-'dd'", DateAndTime = "yyyy'-'MM'-'dd'T'HH':'mm':'ssZ", CreditDateAndTime = "yyyy-MM-dd'T'HH:mm:ss.sssZ", CreditShortDateAndTime = "MMMM yyyy", DateSlashes = "MM/dd/yyyy", abbreviatedMonth = "MMM YYYY", abbreviatedMonthIncludeDate = "MMM d, YYYY"
}
Expand Down
4 changes: 4 additions & 0 deletions CardParts/src/Extensions/NSObjectProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
// Copyright © 2017 Intuit, Inc. All rights reserved.
//

#if SWIFT_PACKAGE
import Foundation
#endif

extension NSObjectProtocol {
var className: String {
return String(describing: type(of: self))
Expand Down
4 changes: 4 additions & 0 deletions CardParts/src/Extensions/UIButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
// Copyright © 2017 Intuit, Inc. All rights reserved.
//

#if SWIFT_PACKAGE
import UIKit
#endif

typealias UIButtonTargetClosure = (UIButton) -> ()

extension UIButton {
Expand Down
4 changes: 4 additions & 0 deletions CardParts/src/Extensions/UIColor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
// Copyright © 2017 Intuit, Inc. All rights reserved.
//

#if SWIFT_PACKAGE
import UIKit
#endif

extension UIColor {

static var turboGenericGreyTextColor : UIColor {get{return UIColor.color(169, green: 169, blue: 169)}}
Expand Down
4 changes: 4 additions & 0 deletions CardParts/src/Extensions/UIFont.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
// Copyright © 2017 Intuit, Inc. All rights reserved.
//

#if SWIFT_PACKAGE
import UIKit
#endif

enum FontSize: Int {
case ultrabig = 48, header = 36, xx_Large = 28, x_Large = 24, large = 17, medium = 16, normal = 14, small = 12, x_Small = 10
}
Expand Down
4 changes: 4 additions & 0 deletions CardParts/src/Extensions/UIView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
// Created by bcarreon1 on 1/30/20.
//

#if SWIFT_PACKAGE
import UIKit
#endif

extension UIView {
func roundCorners(_ corners: CACornerMask, radius: CGFloat){
if #available(iOS 11.0, *) {
Expand Down
4 changes: 4 additions & 0 deletions CardParts/src/Utilities/CardUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
// Created by Tumer, Deniz on 5/23/18.
//

#if SWIFT_PACKAGE
import UIKit
#else
import Foundation
#endif

/*
* Defines utility methods for cards.
Expand Down
Loading