Skip to content

Instantly share code, notes, and snippets.

Avatar

Paul Stamatiou stammy

View GitHub Profile
View Wallet.swift
import SwiftUI
import PlaygroundSupport
// constants
let cardWidth: CGFloat = 343
let cardHeight: CGFloat = 212
let spacing = 36
let animation = Animation.spring()
let cardColors = [
Color(UIColor.systemRed),
@LeeKahSeng
LeeKahSeng / Decode-Dynamic-Keys-JSON-Final.swift
Last active Nov 14, 2020
Decode and Flatten JSON with Dynamic Keys Using Swift Decodable (https://swiftsenpai.com/swift/decode-dynamic-keys-json/)
View Decode-Dynamic-Keys-JSON-Final.swift
let jsonString = """
{
"S001": {
"firstName": "Tony",
"lastName": "Stark"
},
"S002": {
"firstName": "Peter",
"lastName": "Parker"
},
@frankfka
frankfka / iOSCustomSegmentedControlSwiftUI.swift
Created May 17, 2020
Custom Segmented Picker / Segmented Control in SwiftUI
View iOSCustomSegmentedControlSwiftUI.swift
import SwiftUI
extension View {
func eraseToAnyView() -> AnyView {
AnyView(self)
}
}
struct SizePreferenceKey: PreferenceKey {
typealias Value = CGSize
@mecid
mecid / PagerView.swift
Last active Nov 24, 2020
PagerView in SwiftUI
View PagerView.swift
//
// PagerView.swift
//
// Created by Majid Jabrayilov on 12/5/19.
// Copyright © 2019 Majid Jabrayilov. All rights reserved.
//
import SwiftUI
struct PagerView<Content: View>: View {
let pageCount: Int
@stinger
stinger / CombineFetcherAndDecoder.swift
Last active Nov 1, 2020
Combine - fetching and decoding JSON data
View CombineFetcherAndDecoder.swift
import Foundation
import Combine
enum APIError: Error, LocalizedError {
case unknown, apiError(reason: String), parserError(reason: String)
var errorDescription: String? {
switch self {
case .unknown:
return "Unknown error"
@samwize
samwize / DynamicKey.swift
Created Sep 28, 2017
A CodingKey that is dynamic -- it can be any string! Encode/decode with a Dictionary of `[String : Any]` in the model.
View DynamicKey.swift
/**
```
// Encode a model with properties of type [String : Any]
var propertiesContainer = container.nestedContainer(keyedBy: DynamicKey.self, forKey: .properties)
if let properties = properties {
try propertiesContainer.encodeDynamicKeyValues(withDictionary: properties)
}
```
*/
struct DynamicKey: CodingKey {
@uqmessias
uqmessias / devices-model-resolution.md
Last active Aug 11, 2020
Some Android devices dimensions
View devices-model-resolution.md
@niw
niw / .slate
Created Oct 17, 2013
My current settings for Slate
View .slate
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
# Shift + Command
bind up:shift;cmd move screenSizeX/5;0 screenSizeX/5*3;screenSizeY
bind down:shift;cmd push down bar-resize:screenSizeY
bind right:shift;cmd move screenSizeX-320;screenSizeY/2 300;screenSizeY/2
bind left:shift;cmd move 20;screenSizeY/2 700;screenSizeY/2
View _media-queries.scss
// Media Queries in Sass 3.2
//
// These mixins make media queries a breeze with Sass.
// The media queries from mobile up until desktop all
// trigger at different points along the way
//
// And important point to remember is that and width
// over the portrait width is considered to be part of the
// landscape width. This allows us to capture widths of devices
// that might not fit the dimensions exactly. This means the break
@kimroen
kimroen / high-dpi-media.scss
Created Nov 20, 2012 — forked from marcedwards/high-dpi-media.css
A Sass media query mixin that captures almost all high DPI aware devices.
View high-dpi-media.scss
/* ----------------------------------------------------------------------- */
/* */
/* Improved upon a mixin from 37signals and combined */
/* with these numbers from marc. */
/* */
/* 37signals-version: */
/* http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss */
/* */
/* @kimroen */
/* */
You can’t perform that action at this time.