Skip to content

Instantly share code, notes, and snippets.

View Angeloffury7's full-sized avatar

Angeloffury7(Naver) Angeloffury7

View GitHub Profile
@Angeloffury7
Angeloffury7 / PHImageManager-requestImage-async.swift
Created October 2, 2024 01:27 — forked from sindresorhus/PHImageManager-requestImage-async.swift
How to use `PHImageManager#requestImage` with async/await in Swift.
import Photos
struct UnexpectedNilError: Error {}
extension PHImageManager {
func requestImage(
for asset: PHAsset,
targetSize: CGSize,
contentMode: PHImageContentMode,
options: PHImageRequestOptions?
@Angeloffury7
Angeloffury7 / PHImageManager-requestImage-async.swift
Created October 2, 2024 01:27 — forked from sindresorhus/PHImageManager-requestImage-async.swift
How to use `PHImageManager#requestImage` with async/await in Swift.
import Photos
struct UnexpectedNilError: Error {}
extension PHImageManager {
func requestImage(
for asset: PHAsset,
targetSize: CGSize,
contentMode: PHImageContentMode,
options: PHImageRequestOptions?
// Demonstrating a bug with what the table view reports as the destination index path when dragging within
// the same section
import UIKit
class TableViewController: UITableViewController, UITableViewDragDelegate, UITableViewDropDelegate {
var data: [(String, [String])] = [("One", ["A", "B", "C"]), ("Two", ["1", "2", "3"])]
override func viewDidLoad() {
super.viewDidLoad()
// Demonstrating a bug with what the table view reports as the destination index path when dragging within
// the same section
import UIKit
class TableViewController: UITableViewController, UITableViewDragDelegate, UITableViewDropDelegate {
var data: [(String, [String])] = [("One", ["A", "B", "C"]), ("Two", ["1", "2", "3"])]
override func viewDidLoad() {
super.viewDidLoad()
@Angeloffury7
Angeloffury7 / PlatformVisibility.swift
Created August 30, 2024 00:05
A Swift view modifier to handle visibility of views for specific platforms
import SwiftUI
public struct Platform: OptionSet {
public var rawValue: UInt8
public static let iOS = Platform(rawValue: 1 << 0)
public static let macOS = Platform(rawValue: 1 << 1)
public static let tvOS = Platform(rawValue: 1 << 2)
public static let watchOS = Platform(rawValue: 1 << 3)
public static let all: Platform = [.iOS, .macOS, .tvOS, .watchOS]
@Angeloffury7
Angeloffury7 / PlatformVisibility.swift
Created August 30, 2024 00:05
A Swift view modifier to handle visibility of views for specific platforms
import SwiftUI
public struct Platform: OptionSet {
public var rawValue: UInt8
public static let iOS = Platform(rawValue: 1 << 0)
public static let macOS = Platform(rawValue: 1 << 1)
public static let tvOS = Platform(rawValue: 1 << 2)
public static let watchOS = Platform(rawValue: 1 << 3)
public static let all: Platform = [.iOS, .macOS, .tvOS, .watchOS]
@Angeloffury7
Angeloffury7 / GoneView.swift
Created August 29, 2024 23:58 — forked from MohammedAlimoor/GoneView.swift
IOS # Swift3 , gone (hide view like android) by height or width with UpdateAutoLayoutConstraints when hidden
/* .
how to use :
view.hideByHeight(hidden: true)
view.hideByWidth(hidden: true)
add constraint to view :
view.setConstraintConstant(constant: CGFloat(50), forAttribute: .width)
*/
// Created by mohammed alimoor on 1/25/17.
import UIKit
@Angeloffury7
Angeloffury7 / Side-Menu
Created July 4, 2024 11:51 — forked from Bhargav-Agravat/Side-Menu
SWiftUi Simple side menu
//
// SideMenuItem.swift
// SideMenu
//
// Created by Bhargav Agravat on 29/03/23.
//
import SwiftUI
import SwiftUI
struct ContentView: View {
@State var isOpenSideMenu: Bool = false
@State var text = "Hello, World!"
var body: some View {
ZStack{
NavigationView {
Text(text)
.navigationBarTitle("メイン画面")
@Angeloffury7
Angeloffury7 / observer.swift
Created February 19, 2024 03:46 — forked from starhoshi/observer.swift
Swift observer pattern.
import Foundation
protocol Observer {
var id: String { get }
func update(_ string: String)
}
extension Observer {
func update(_ string: String) {
print("\(type(of: self)) に届いた新しい値は \(string) です。")