Skip to content

Instantly share code, notes, and snippets.

View yoni-g's full-sized avatar

Yonathan Goriachnick yoni-g

  • BA-link
  • Israel
View GitHub Profile
yoni-g / Coordinator.swift
Last active November 15, 2020 16:11
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 / MenuOption.swift
Last active July 27, 2020 06:55
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 / AnalyticsManager.swift
Last active May 2, 2021 09:07
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 / CloseAfterDownload.js
Last active March 3, 2021 13:06
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 () {
} ,500);
function openWindow(url) {
var tab =;
if (!url.location.pathname.includes('pdf')){
setTimeout(function () {
yoni-g / closeAppElegantly.swift
Last active March 30, 2023 02:08
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