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 SwiftUI | |
extension View where Self: Shape { | |
func glow( | |
fill: some ShapeStyle, | |
lineWidth: Double, | |
blurRadius: Double = 8.0, | |
lineCap: CGLineCap = .round | |
) -> some View { | |
self |
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 Foundation | |
import Combine | |
public struct ResultPublisher<Success, Failure>: Publisher where Failure: Error { | |
public typealias Output = Success | |
public typealias Failure = Failure | |
public typealias ResultCallback = (Result<Success, Failure>) -> Void | |
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
/// | |
/// https://stackoverflow.com/a/29741007 | |
/// | |
let s = Struct() // Struct | |
withUnsafePointer(to: s) { | |
print(String(format: "%p", $0) | |
} | |
/// | |
/// http://stackoverflow.com/a/36539213/226791 |
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 SwiftUI | |
struct ContentView : View { | |
var body: some View { | |
ZStack(alignment: Alignment.top) { | |
MapView() | |
SlideOverCard { | |
VStack { | |
CoverImage(imageName: "maitlandbay") | |
Text("Maitland Bay") |
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
/// Source | |
/// https://github.com/wendyliga/SwiftKit/blob/master/Sources/SwiftKit/Array%2BExtension.swift | |
/// Article | |
/// https://medium.com/flawless-app-stories/say-goodbye-to-index-out-of-range-swift-eca7c4c7b6ca | |
import Foundation | |
extension Array { | |
/** |
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
extension ObservableType { | |
func flatMap<A: AnyObject, O: ObservableType>(weak obj: A, selector: @escaping (A, Self.E) throws -> O) -> Observable<O.E> { | |
return flatMap { [weak obj] value -> Observable<O.E> in | |
try obj.map { try selector($0, value).asObservable() } ?? .empty() | |
} | |
} | |
func flatMapFirst<A: AnyObject, O: ObservableType>(weak obj: A, selector: @escaping (A, Self.E) throws -> O) -> Observable<O.E> { | |
return flatMapFirst { [weak obj] value -> Observable<O.E> in |
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
// In Swift a method can be marked with rethrows keyword. It means that it throws an error only if one of its arguments throws an error. | |
func bar(callback: () throws -> Void) rethrows { | |
try callback() | |
} | |
//using String to throw an error. | |
extension String: Error {} | |
func bar() throws { |
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
// | |
// CGRect+Geometry.swift | |
// | |
// Created by Artem Krachulov. | |
// Copyright (c) 2016 Artem Krachulov. All rights reserved. | |
// http://www.artemkrachulov.com | |
// | |
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
// | |
// CGSize+Geometry.swiftt | |
// | |
// Created by Artem Krachulov. | |
// Copyright (c) 2016 Artem Krachulov. All rights reserved. | |
// http://www.artemkrachulov.com | |
// | |
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
// | |
// Double-Float+Rounding.swift | |
// Extension for Ceil, Floor and Round methods. | |
// | |
// Created by Artem Krachulov. | |
// Copyright (c) 2016 Artem Krachulov. All rights reserved. | |
// Website: http://www.artemkrachulov.com/ | |
// | |
import UIKit |
NewerOlder