This file contains hidden or 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
func setCardChildViewController(_ viewController: UIViewController, hostView: CardView) { | |
add(viewController) | |
hostView.addSubview(viewController.view) | |
hostView.backgroundColor = viewController.view.backgroundColor | |
viewController.view.frame = CGRect(origin: hostView.bounds.origin, size: CGSize(width: hostView.bounds.size.width, height: hostView.bounds.size.height - CardsHolderView.Constants.subviewBottomOffset)) | |
} | |
func setTopChildViewController(_ viewController: UIViewController) { | |
add(viewController) | |
customView.topView.addSubview(viewController.view) |
This file contains hidden or 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
private func setChildViewControllers() { | |
let topViewController = ProfileShortInfoViewController() | |
view.backgroundColor = topViewController.view.backgroundColor | |
let card1ViewController = ProfileActivityViewController() | |
let card2ViewController = RecommendationsViewController() | |
setTopChildViewController(topViewController) | |
setCard1ChildViewController(card1ViewController) | |
setCard2ChildViewController(card2ViewController) | |
self.topViewController = topViewController | |
self.activityViewController = card1ViewController |
This file contains hidden or 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 view is a root view inside CardsHolderViewController | |
class CardsHolderView: UIView { | |
let topView = UIView() | |
let cardView1 = CardView() | |
let cardView2 = CardView() | |
/// | |
/// some other code here | |
/// |
This file contains hidden or 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
func add(_ child: UIViewController, shouldAddView: Bool = false) { | |
addChild(child) | |
if shouldAddView { | |
view.addSubview(child.view) | |
} | |
child.didMove(toParent: self) | |
} | |
func remove(shouldRemoveView: Bool = false) { | |
guard parent != nil else { |
This file contains hidden or 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
struct ScreenSize { | |
static let screenWidth = UIScreen.main.bounds.size.width | |
static let screenHeight = UIScreen.main.bounds.size.height | |
static let screenMaxLength = max(ScreenSize.screenWidth, ScreenSize.screenHeight) | |
static let screenMinLength = min(ScreenSize.screenWidth, ScreenSize.screenHeight) | |
} | |
/// Type of device, based on screen size. | |
struct DeviceType { |
This file contains hidden or 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
import UIKit | |
class ProfileView: UIView { | |
// Some properties | |
var titleLabel: UILabel | |
var profileImageView: UIImageVew | |
var profileImageViewTopConstraint: NSLayoutConstraint | |
var titleLabelLeadingConstraint: NSLayoutConstraint |
This file contains hidden or 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
import Foundation | |
/// SB - screen based | |
/// Use `definedValue` to get value, depending on the screen of device. | |
struct SBValue<T> { | |
/// Corresponds to 4" screen | |
let iPhoneSE: T | |
/// Corresponds to 4.7" screen | |
let iPhone8: T | |
/// Corresponds to 5.5" screen |
This file contains hidden or 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
import UIKit | |
class ProfileView: UIView { | |
// Some properties | |
var titleLabel: UILabel | |
var profileImageView: UIImageVew | |
var profileImageViewTopConstraint: NSLayoutConstraint | |
var titleLabelLeadingConstraint: NSLayoutConstraint |
This file contains hidden or 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
import Photos | |
extension PHPhotoLibrary { | |
typealias PhotoAsset = PHAsset | |
typealias PhotoAlbum = PHAssetCollection | |
static func saveAssets(_ assets: [Any], albumName: String, completion: @escaping ([PHAsset]?)->()) { | |
if let album = self.findAlbum(albumName: albumName) { | |
saveAssets(assets, album: album, completion: completion) |
This file contains hidden or 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
extension SwipingCollectionViewCell: UIGestureRecognizerDelegate { | |
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool { | |
return true | |
} | |
} |
NewerOlder