Skip to content

Instantly share code, notes, and snippets.

View alfian0's full-sized avatar
🎯
Focusing

Muhammad Alfiansyah alfian0

🎯
Focusing
View GitHub Profile
class ZoomAndSnapFlowLayout: UICollectionViewFlowLayout {
let activeDistance: CGFloat = 200
let zoomFactor: CGFloat = 0.3
override init() {
super.init()
scrollDirection = .horizontal
minimumLineSpacing = 8
minimumInteritemSpacing = 8
class ProgressButton: UIButton {
private var shapLayer: CAShapeLayer = CAShapeLayer()
private var closeImage: UIImage? = {
let image = UIImage(named: "close_reply_icon")?
.withRenderingMode(.alwaysTemplate)
return image
}()
enum State {
case initial
/// The Debouncer will delay work items until time limit for the preceding call is over.
public final class Debouncer {
// MARK: - Properties
private let limit: TimeInterval
private let queue: DispatchQueue
private var workItem: DispatchWorkItem?
private let syncQueue = DispatchQueue(label: "com.stackexchange.debounce", attributes: [])
import UIKit
import RxSwift
import RxCocoa
import MobileCoreServices
class FileListController: UITableViewController {
private lazy var segmentedControl: UISegmentedControl = {
let segmentedControl = UISegmentedControl(items: ["GAMBAR", "DOKUMEN"])
segmentedControl.selectedSegmentIndex = 0
segmentedControl.tintColor = UIColor.white
@alfian0
alfian0 / ChatMenu.swift
Created November 4, 2018 14:55
Simplify UIAlertController with RxSwift
enum ChatMenu: Int, CustomStringConvertible {
case image
case document
case gif
case location
case contact
var description: String {
switch self {
case .image:
@alfian0
alfian0 / CoreLocation+RxSwift.swift
Last active July 1, 2020 03:47
[Pure Swift Delegate] DelegateProxy<CLLocationManager, CLLocationManagerDelegate>
import Foundation
import CoreLocation
import RxSwift
import RxCocoa
class CLLocationManagerDelegateProxy: DelegateProxy<CLLocationManager, CLLocationManagerDelegate>, DelegateProxyType, CLLocationManagerDelegate {
public weak private(set) var locationManager: CLLocationManager?
public init(locationManager: CLLocationManager) {
self.locationManager = locationManager
@alfian0
alfian0 / FCM
Last active August 31, 2018 01:46
curl -i -H 'Content-type: application/json' -H 'Authorization: key=API_KEY' -XPOST https://fcm.googleapis.com/fcm/send -d '{
"registration_ids":["FCM_TOKEN"],
"notification": {
"title":"Title of your notification",
"body":"content of your notification"
},
"mutable_content": true,
"data": {
"paylod_type": "paylod_type",
"event_type": "event_type",
import UIKit
class LoginViewController: UIViewController {
var viewModel: UserViewModel
override func viewDidLoad() {
super.viewDidLoad()
}
}
struct LoginModel {
let username: String
let password: String
}
class Singleton {
static var shared: Singleton = {
return Singleton()
}
private init() {}
}