Skip to content

Instantly share code, notes, and snippets.

View ihamadfuad's full-sized avatar
🧑‍💻
Coding

Hamad Fuad ihamadfuad

🧑‍💻
Coding
View GitHub Profile
struct DraggableScaleableRotatableModifier: ViewModifier {
@State private var showingAlert = false
@Binding var lastOffset: CGSize
@Binding var lastRotation: Angle
@Binding var offset: CGSize
@Binding var scale: CGFloat
@Binding var angle: Angle
typealias Value = T
let key: String
@State private var value: Value?
init(wrappedValue: Value? = nil, _ key: String) {
self.key = key
var wrappedValue: Value? {
get { value }
nonmutating set {
value = newValue
do {
import SwiftUI
import KeychainAccess
@propertyWrapper
struct KeychainStorage<T: Codable>: DynamicProperty {
// ...
}
@ihamadfuad
ihamadfuad / Logger++.swift
Created February 8, 2022 10:55
Logger Simplified
import Foundation
import OSLog
public class Log {
/// Show message while debugging
static func debug(category: String = "MyApp", _ message: String) {
Logger.message().debug("[Debug] \(message)")
}
@ihamadfuad
ihamadfuad / SheetViewPresenter.swift
Created January 24, 2022 07:02
SwiftUI: Present Sheet From Anywhere Using @Environment
// ºººº----------------------------------------------------------------------ºººº \\
//
// Credit Hamad Fuad.
//
// Author: Hamad Fuad
// Email: ihamadfouad@icloud.com
//
// Created At: 24/01/2022
// Last modified: 24/01/2022
//
@ihamadfuad
ihamadfuad / UniversalAlert.swift
Last active January 24, 2022 07:03
SwiftUI: Present Alert From Anywhere Using @Environment
// ºººº----------------------------------------------------------------------ºººº \\
//
// Credit Hamad Fuad.
//
// Author: Hamad Fuad
// Email: ihamadfouad@icloud.com
//
// Created At: 24/01/2022
// Last modified: 24/01/2022
//