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
@dynamicMemberLookup | |
struct Template { | |
var template : String | |
private var data : [String:String] | |
var populatedTemplate : String { data.reduce(template) { $0.replacingOccurrences(of: "${\($1.key)}", with: $1.value) } } | |
init(template: String, data: [String:String] = [:]) { | |
self.template = template | |
self.data = data | |
} |
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
// | |
// NibWrapped.swift | |
// ReusableXibViews | |
// | |
// Created by Matthias Lamoureux on 13/01/2020. | |
// Copyright © 2020 QSC. All rights reserved. | |
// | |
import UIKit |
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
/// Property wrapper used to wrapp a view instanciated from a Nib | |
@propertyWrapper public struct NibWrapped<T: UIView> { | |
/// Initializer | |
/// | |
/// - Parameter type: Type of the wrapped view | |
public init(_ type: T.Type) { } | |
/// The wrapped value | |
public var wrappedValue: UIView! |
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 | |
@IBDesignable class MessageViewWrapper : NibWrapperView<MessageView> { } | |
class MessageView: UIView { | |
... |
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
// | |
// NibWrapperView.swift | |
// ReusableXibViews | |
// | |
// Created by Matthias Lamoureux on 13/01/2020. | |
// Copyright © 2020 QSC. All rights reserved. | |
// | |
import UIKit |
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
// | |
// UIView+Nib.swift | |
// ReusableXibViews | |
// | |
// Created by Matthias Lamoureux on 13/01/2020. | |
// Copyright © 2020 QSC. All rights reserved. | |
// | |
import UIKit |
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
// | |
// MessageView.swift | |
// ReusableXibViews | |
// | |
// Created by Matthias Lamoureux on 13/01/2020. | |
// Copyright © 2020 QSC. All rights reserved. | |
// | |
import UIKit |
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
#!/usr/bin/swift | |
import Foundation | |
guard CommandLine.arguments.count == 3 else { | |
print("Usage:\n\t\(CommandLine.arguments[0]) <STRINGS_TO_TRANSFER_FILE> <STRING_FILE_ON_WHICH_TRANSFER_STRINGS>\n") | |
exit(1) | |
} | |
let source = CommandLine.arguments[1] |
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
#!/bin/sh | |
set -e | |
if [[ -z "$1" ]]; then | |
echo "Usage:\n\t$0 <FILE>\n" | |
exit 1 | |
fi | |
echo "👍 Processing $1" |
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 | |
extension UIColor { | |
static func defaultColor(named name: String, default defaultColor: UIColor = .black) -> UIColor { | |
if #available(iOS 11, *) { | |
return UIColor(named: name) ?? defaultColor | |
} | |
else { | |
return _defaultColors[name] ?? defaultColor | |
} |
NewerOlder