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
import SwiftUI | |
public extension Text { | |
init(_ attributedString: NSAttributedString) { | |
if #available(iOS 15.0, *) { | |
self.init(AttributedString(attributedString)) | |
} else { | |
self.init("") // initial, empty Text | |
// scan the attributed string for distinctly attributed regions |
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
import UIKit | |
import DataProvider | |
final class CurrentPlanDataSource: NSObject { | |
// MARK: - Cell - | |
enum Cell { | |
case daysLeft(daysLeft: Int, endDate: Date, newPlan: String?, currentPlanTitle: String) | |
case cancelDowngrade(previousPlanTitle: String) |
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
class BasicFlowLayoutViewModel { | |
var sectionAdata = [UIColor.green, UIColor.purple, UIColor.orange, UIColor.blue, UIColor.green, UIColor.blue, UIColor.green, UIColor.red, UIColor.green, UIColor.blue, UIColor.green, UIColor.purple, UIColor.orange, UIColor.blue, UIColor.green, UIColor.blue, UIColor.systemPink] | |
var sectionBdata = [UIColor.red, UIColor.green, UIColor.blue, UIColor.green, UIColor.purple, UIColor.orange, UIColor.blue, UIColor.green, UIColor.blue, UIColor.green, UIColor.red, UIColor.green, UIColor.blue, UIColor.green] | |
} |
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
class BasicFlowLayoutViewController: UIViewController { | |
enum Constants { | |
static let reuseCell = "subclassedcell" | |
static let reuseHeader = "header" | |
} | |
override func loadView() { | |
collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) | |
self.view = collectionView | |
} |
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
extension BasicFlowLayoutViewController: UICollectionViewDelegateFlowLayout { | |
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { | |
return UIEdgeInsets(top: 0, left: 15, bottom: 100, right: 15) | |
} | |
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { | |
let noOfCellsInRow = 2 | |
let flowLayout = collectionViewLayout as! UICollectionViewFlowLayout | |
let totalSpace = flowLayout.sectionInset.left | |
+ flowLayout.sectionInset.right |
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
final class BasicUICollectionViewModel { | |
var data = [UIColor.red, UIColor.green, UIColor.blue, UIColor.green, UIColor.purple, UIColor.orange, UIColor.blue, UIColor.green, UIColor.blue, UIColor.green, UIColor.red, UIColor.green, UIColor.blue, UIColor.green, UIColor.purple, UIColor.orange, UIColor.blue, UIColor.green, UIColor.blue, UIColor.green, UIColor.red, UIColor.green, UIColor.blue, UIColor.green, UIColor.purple, UIColor.orange, UIColor.blue, UIColor.green, UIColor.blue, UIColor.green, UIColor.red, UIColor.green, UIColor.blue, UIColor.green, UIColor.purple, UIColor.orange, UIColor.blue, UIColor.green, UIColor.blue, UIColor.systemPink, UIColor.green, UIColor.blue, UIColor.green, UIColor.red, UIColor.green, UIColor.blue, UIColor.green, UIColor.purple, UIColor.orange, UIColor.blue, UIColor.green, UIColor.blue, UIColor.green, UIColor.red, UIColor.green, UIColor.blue, UIColor.green, UIColor.purple, UIColor.orange, UIColor.blue, UIColor.green, UIColor.blue, UIColor.systemPink] | |
} |
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
final class BasicUICollectionViewController: UIViewController { | |
enum Constants { | |
static let reuseCell = "subclassedcell" | |
} | |
var collectionView: UICollectionView! | |
let viewModel: BasicUICollectionViewModel | |
override func loadView() { | |
collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) |
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
let dogHandler = DogHandler() | |
let wolfHandler = WolfHandler() | |
let elephantHandler = ElephantHandler() | |
dogHandler.next = wolfHandler | |
wolfHandler.next = elephantHandler | |
dogHandler.handle(request: Animal.cat) // handled by the dog handler | |
dogHandler.handle(request: Animal.elephant) // handled by the elephant handler |
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
class DogHandler: Handler { | |
func handle(request: Animal) { | |
if request > .dog { | |
next?.handle(request: request) | |
} else { | |
print ("Handled by the dog handler") | |
} | |
} | |
var next: Handler? |
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
protocol Handler { | |
var next: Handler? { get } | |
func handle(request: Animal) | |
} |
NewerOlder