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 fileName: String = "TokenExtension.swift" | |
let destinationUrl = "\(FileManager.default.currentDirectoryPath)/\(fileName)" | |
do { | |
try tokenExtension.write(toFile: destinationUrl, atomically: true, encoding: .utf8) | |
print("Token Extension is successfully generated:\n \(destinationUrl)\n") | |
} catch { | |
print(error) | |
} |
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
func traverse(dictionary: [String : Any], parent: String) -> String { | |
if dictionary.keys.contains("type") { | |
let type = dictionary["type"] as! String | |
let tokenType: TokenType = TokenType(value: type) | |
switch tokenType { | |
case .color: | |
let value = dictionary["value"] as! String | |
let variableValue = "UIColor.hexColor(\"\(value)\") ?? .black" | |
return createVariable(dataType: tokenType.dataType, variableName: parent.camelCased(with: "."), value: variableValue) | |
case .typography: |
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
{ | |
"Color": { | |
"red": { | |
"light": { | |
"value": "#FFCCCB", | |
"type": "color" | |
}, | |
"regular": { | |
"value": "#880808", | |
"type": "color" |
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
guard let fileUrl = Bundle.main.url(forResource: "Token", withExtension: "json") else { | |
return | |
} | |
guard let jsonData = try? Data(contentsOf: fileUrl) else { | |
return | |
} | |
guard let object = try? JSONSerialization.jsonObject(with: jsonData, options: .fragmentsAllowed), | |
let dictionary = object as? [String : Any] else { |
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 Foundation | |
@main | |
struct SampleScript { | |
static func main() { | |
print("execute script! ") | |
} | |
} |
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 SomeViewController: UIViewController { | |
typealias GetCardModelsCompletion = (Result<[CardModel], Error>) -> Void | |
typealias GetCardModels = (@escaping GetCardModelsCompletion) -> Void | |
private var cards: [CardModel] = [] | |
private let getCardModels: GetCardModels | |
init(getCardModels: @escaping GetCardModels) { | |
self.getCardModels = getCardModels |
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 SomeViewController: UIViewController { | |
private var cards: [CardModel] = [] | |
private let cardService: CardModelService | |
init(cardService: CardModelService) { | |
self.cardService = cardService | |
super.init(nibName: nil, bundle: .main) | |
} | |
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
struct CardModel {} | |
protocol CardModelService { | |
func fetchCardModels(completion: @escaping (Result<[CardModel], Error>) -> Void) | |
} | |
class HomeService: CardModelService { | |
static let shared = HomeService() | |
private init() {} | |
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
struct CardModel {} | |
class HomeService { | |
static let shared = HomeService() | |
private init() {} | |
func fetchHomeCardModels(completion: @escaping (Result<[CardModel], Error>) -> Void) { | |
// ... | |
} |
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 SomeViewController: UIViewController { | |
var isFromHome = false | |
var isFromCart = false | |
var isFromProfile = false | |
var homeService: HomeService = .shared | |
var cartService: CartService = .shared | |
var profileService: ProfileService = .shared | |
NewerOlder