Skip to content

Instantly share code, notes, and snippets.

@likil33
likil33 / gist:7598c1d875abec66bfb9198406094bfc
Created July 2, 2024 18:28
Loading indicator - default and. third party lib. NVActivityIndicatorView
//Default
import Foundation
import UIKit
class LoaingView:UIView {
public static let shared = LoaingView()
private var indicator:UIActivityIndicatorView = {
@likil33
likil33 / Okta-customLogin-refreshToken
Created June 27, 2024 08:33
Okta-customLogin-refreshToken
// 1 - (At webservice - refreshTOken)
OktaAuthManager.shared.renewTokens { stateManager, error in
if let error = error {
print("Renew token error: \(error)")
return
}
// Successfully renewed token
let appearance = UINavigationBarAppearance()
let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
appearance.backgroundColor = .systemGreen
appearance.titleTextAttributes = textAttributes
self.navigationController?.navigationBar.standardAppearance = appearance
self.navigationController?.navigationBar.scrollEdgeAppearance = appearance
self.title = "USA Coastal Boat Ramps"
other stuff
@likil33
likil33 / DateFormat
Created March 16, 2023 10:08
DateFormat
func dateSetup(_ dateStr:String) -> String {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
let dateString = formatter.date(from: dateStr)
formatter.dateFormat = "MM-dd-yyyy"
return formatter.string(from: dateString ?? Date())
}
@likil33
likil33 / SwiftStandardShortCodesMVVM
Last active December 13, 2022 12:54
Swift Standard Short help for base setup
Notification bar
====================
=> Navigation bar color and title color and text change and status bar:
AppDelegate
UINavigationBar.appearance().barTintColor = UIColor(displayP3Red: 47/255, green: 54/255, blue: 64/255, alpha: 1.0)
UINavigationBar.appearance().largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
@likil33
likil33 / Framework Run script
Created October 11, 2022 13:55
Framework Run script at build phases
#Gerenare device framework
xcodebuild archive -scheme ${PROJECT_NAME} -archivePath "${PROJECT_DIR}/build/${PROJECT_NAME}-iphoneos.xcarchive" -sdk iphoneos SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
#Generate simulator framework
xcodebuild archive -scheme ${PROJECT_NAME} -archivePath "${PROJECT_DIR}/build/${PROJECT_NAME}-iossimulator.xcarchive" -sdk iphonesimulator SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
#Generate xcframework for both arches
xcodebuild -create-xcframework -framework "${PROJECT_DIR}/build/${PROJECT_NAME}-iphoneos.xcarchive/Products/Library/Frameworks/${PROJECT_NAME}.framework" -framework "${PROJECT_DIR}/build/${PROJECT_NAME}-iossimulator.xcarchive/Products/Library/Frameworks/${PROJECT_NAME}.framework" -output "${PROJECT_DIR}/build/${PROJECT_NAME}.xcframework"
#Open directory where xcframework were generate
@likil33
likil33 / All Extra
Last active November 5, 2024 16:13
All - Simple stuff - code
=========================== UIView - Placed on VC =======================
UIApplication.shared.keyWindow?.addSubview(self.resetView)
self.resetView.frame.size.height = (self.navigationController?.view.bounds.height)!
self.resetView.frame.size.width = self.view.bounds.width
self.resetView.alpha = 0.0
@likil33
likil33 / UICollectionviewSwift
Created September 21, 2022 13:41
UICollectionviewSwift
@IBOutlet weak var collectionviewList: UICollectionView!
func baseSetup() {
self.headerTitles.removeAll()
collectionviewList.register(UINib(nibName: "TitleCollectionViewCell", bundle: nil), forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "TitleCollectionViewCell")
collectionviewList.delegate = self
collectionviewList.dataSource = self
let layout = UICollectionViewFlowLayout()
layout.sectionInset = UIEdgeInsets(top: 5, left: 0, bottom: 5, right: 15)
layout.minimumInteritemSpacing = 0
@likil33
likil33 / Firebase Push
Last active September 19, 2022 12:53
Firebase push notification
pod 'Firebase/Analytics'
pod 'Firebase/Messaging'
import UserNotifications
import UserNotificationsUI
import Firebase
import FirebaseMessaging
@likil33
likil33 / RootViewController
Created September 16, 2022 10:57
Root View controller swift
import Foundation
import UIKit
// MARK: Switcher class
enum RootVC:String {
case LoginViewController, TabBarVC
}
class Switcher {
static let shared = Switcher()