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 | |
import UIKit | |
/// A ViewModifier that re-enables the default iOS edge-swipe back gesture in a SwiftUI NavigationStack. | |
struct SwipeBackModifier: ViewModifier { | |
func body(content: Content) -> some View { | |
content | |
.background(SwipeBackEnabler().frame(width: 0, height: 0).allowsHitTesting(false)) | |
} | |
} |
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 | |
/// Usage: | |
/// .fullScreenOverlay(isPresented: $showAttachmentsMenu) { | |
/// SomeView() | |
/// .background(BackgroundClearView()) | |
/// } | |
struct BackgroundClearView: UIViewRepresentable { | |
func makeUIView(context: Context) -> UIView { | |
let view = 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 SwiftUI | |
import UIKit | |
struct FullScreenPresenter<Overlay: View>: UIViewControllerRepresentable { | |
@Binding var isPresented: Bool | |
let overlay: () -> Overlay | |
func makeUIViewController(context: Context) -> UIViewController { | |
UIViewController() // container | |
} |
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 os.log | |
protocol Logger { | |
func error(_ error: String) | |
func warning(_ warning: String) | |
func event(_ event: String) | |
func message(_ message: String) | |
} |
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 | |
extension Float { | |
var toOneDecimalPlace: String { String(format: "%.1f", 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 | |
extension DateFormatter { | |
static let mediumDateTimeFormatter: DateFormatter = { | |
let formatter = DateFormatter() | |
formatter.timeZone = TimeZone.current | |
formatter.dateStyle = .medium | |
formatter.timeStyle = .medium | |
return formatter |
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 Combine | |
import Foundation | |
// MARK: - Supporting Models: Once per codebase | |
enum HTTPMethod: String { | |
case delete | |
case get | |
case post |
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 OverlayView<OverlayContent: View>: ViewModifier { | |
@Binding var isPresented: Bool | |
var modalContent: OverlayContent | |
var transition: AnyTransition = .move(edge: .bottom) | |
var animation: Animation = .easeInOut | |
func body(content: Content) -> some View { |
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 Combine | |
import SwiftUI | |
struct IfNotNil<Value, Content>: View where Content: View { | |
private let value: Value? | |
private let content: (Value) -> Content | |
init(_ value: Value?, | |
@ViewBuilder show content: @escaping (Value) -> Content) { |
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 XCTest | |
import Realm | |
import RealmSwift | |
class ProofOfConceptTests: RealmTestCase { | |
// NOTE this is for objects with 1-to-1 relationships | |
func testUpdateAsset() { | |
// 1. make a full object | |
let city = City() |
NewerOlder