Skip to content

Instantly share code, notes, and snippets.

Avatar
🕵️‍♂️
debugging

Yonathan Goriachnick yoni-g

🕵️‍♂️
debugging
View GitHub Profile
@yoni-g
yoni-g / Coordinator.swift
Last active Nov 15, 2020
A coordinator implementation I use In my projects [Used for one main coordinator, you can change it to work with multiple coordinators]
View Coordinator.swift
import UIKit
protocol Coordinator {
var navigationController: UINavigationController? { get set }
// config funcs
func setNavControler(_ navCtrl: UINavigationController) -> Self
func start()
// display funcs
func show(view: AppScreen)
@yoni-g
yoni-g / MenuOption.swift
Last active Jul 27, 2020
How to present a popup menu in iOS?
View MenuOption.swift
//
// MenuOption.swift
//
struct MenuOption {
var title: String = ""
var image: UIImage
var action: (()->())
init(title: String, image: UIImage, action: @escaping (()->())) {
@yoni-g
yoni-g / AnalyticsManager.swift
Last active May 2, 2021
AnalyticsManager class to easily log and manage events in iOS apps
View AnalyticsManager.swift
import FirebaseAnalytics
import Crashlytics
enum AnalyticsEvent {
case materialDetails(matName: String?, matNumber: String?)
case addMaterialInTab(tabName: String)
case tabPressed(tabName: String)
case sendOrder(agentCode: String?, customerNumber: String?, totalAmount: NSNumber?, userCurrency: String?, itemsQty: Int?)
case loggedUserInfo(customerNumber: String?, contactEmail: String?, userMobile: String?)
View Post on chatter with apex
FeedItem postItem = new FeedItem();
postItem.ParentId = 'SOME_TEST_ID';
postItem.Type = 'TextPost';
postItem.Title = 'Hello World! ';
postItem.Body = 'This is my test';
insert postItem;
@yoni-g
yoni-g / CloseAfterDownload.js
Last active Mar 3, 2021
How to force close an opened download file (pdf) tab or page that opened by a link?
View CloseAfterDownload.js
function openPage(url) {
window.setTimeout(function () {
openWindow(url);
} ,500);
}
function openWindow(url) {
var tab = window.open(url);
if (!url.location.pathname.includes('pdf')){
setTimeout(function () {
@yoni-g
yoni-g / closeAppElegantly.swift
Last active Jul 22, 2021
How to exit an iOS app without it looking like a crash? - Swift
View closeAppElegantly.swift
func showMessageResetApp(){
let exitAppAlert = UIAlertController(title: "Restart is needed",
message: "We need to restart the app on your first login to the app.\n Please reopen the app after this.",
preferredStyle: .alert)
let resetApp = UIAlertAction(title: "Close Now", style: .destructive) {
(alert) -> Void in
// home button pressed programmatically - to thorw app to background
UIControl().sendAction(#selector(URLSessionTask.suspend), to: UIApplication.shared, for: nil)
// terminaing app in background