Skip to content

Instantly share code, notes, and snippets.

View Stickerbox's full-sized avatar

Jordan Dixon Stickerbox

View GitHub Profile
extension UIWindow {
open override func motionEnded(_ motion: UIEventSubtype, with event: UIEvent?) {
super.motionEnded(motion, with: event)
guard motion == .motionShake else { return }
let version = Bundle.main.versionNumber ?? ""
let build = Bundle.main.buildNumber ?? ""
{% for struct in types.all.implementing.Codable|struct %}
{% ifnot struct.annotations.ignore %}
extension {{ struct.name }} {
enum CodingKeys: String, CodingKey {
{% for var in struct.storedVariables %}
{% if var.annotations.key %}
case {{ var.name }} = "{{ var.annotations.key }}"
{% endif %}
{% ifnot var.annotations.key %}
import Foundation
// MARK: - Localisation
struct Localised {
{% for enum in types.implementing.Localisable %}
struct {{ enum.name|replace:"SourceryLocaliser.",""|replace:".","_" }} {
{% for case in enum.cases %}
static var {{ case.name }}: String { return NSLocalizedString("{{ enum.name|replace:"SourceryLocaliser.",""}}.{{case.name|capitalize}}", comment: "") }
import Foundation
// MARK: - Localisation
struct Localised {
{% for enum in types.implementing.Localisable %}
struct {{ enum.name|replace:"SourceryLocaliser.",""|replace:".","_" }} {
{% for case in enum.cases %}
static var {{ case.name }}: String { return NSLocalizedString("{{ enum.name|replace:"SourceryLocaliser.",""}}.{{case.name|capitalize}}", comment: "") }
$PODS_ROOT/Sourcery/bin/sourcery --sources ./YourProjectName --templates ./Templates --output ./GeneratedCode/SourceryGenerated.swift
@Stickerbox
Stickerbox / build.gradle
Last active January 2, 2018 12:30
The app gradle file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion(compileSdk)
buildToolsVersion(buildTools)
defaultConfig {
minSdkVersion(minSdk)
targetSdkVersion(targetSdk)
@Stickerbox
Stickerbox / build.gradle
Created January 2, 2018 12:12
The project gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
// This is the project gradle file
buildscript {
ext.kotlin_version = '1.2.10'
repositories {
google()
jcenter()
}
dependencies {
ext.internalProject = { code ->
dependencies {
implementation project(":$code")
}
}
ext.exposedProject = { code ->
dependencies {
api project(":$code")
}
import android.animation.Animator
import android.animation.ValueAnimator
import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.graphics.RectF
import android.support.annotation.ColorRes
import android.util.AttributeSet
import android.util.TypedValue
import UIKit
@IBDesignable
class ActivityIndicatorView: UIView {
enum AnimationStyle {
case linear, extendable
}
@IBInspectable var trackColor: UIColor = .clear { didSet { setNeedsDisplay() } }