Skip to content

Instantly share code, notes, and snippets.

Avatar

Jordan Dixon Stickerbox

View GitHub Profile
View Logger+Extensions.swift
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 ?? ""
View Codable+CodingKeys.stencil
{% 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 %}
View localised+string.stencil
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: "") }
View localised+string.stencil
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: "") }
View sourcery_command
$PODS_ROOT/Sourcery/bin/sourcery --sources ./YourProjectName --templates ./Templates --output ./GeneratedCode/SourceryGenerated.swift
@Stickerbox
Stickerbox / build.gradle
Last active Jan 2, 2018
The app gradle file
View build.gradle
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 Jan 2, 2018
The project gradle file
View build.gradle
// 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 {
View Gradle Functions
ext.internalProject = { code ->
dependencies {
implementation project(":$code")
}
}
ext.exposedProject = { code ->
dependencies {
api project(":$code")
}
View ProgressView.kt
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
View ActivityIndicatorView.swift
import UIKit
@IBDesignable
class ActivityIndicatorView: UIView {
enum AnimationStyle {
case linear, extendable
}
@IBInspectable var trackColor: UIColor = .clear { didSet { setNeedsDisplay() } }