This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
/// Common aspect ratios | |
public enum AspectRatio: CGFloat { | |
case square = 1 | |
case threeToFour = 0.75 | |
case fourToThree = 1.75 | |
} | |
/// Fit an image to a certain aspect ratio while maintaining its aspect ratio |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIView { | |
open override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { | |
super.touchesBegan(touches, with: event) | |
UIApplication.shared.windows | |
.first { $0.isKeyWindow }? | |
.endEditing(true) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import PhotosUI | |
struct PhotoPicker: UIViewControllerRepresentable { | |
typealias UIViewControllerType = PHPickerViewController | |
@Binding var images: [UIImage] | |
var selectionLimit: Int | |
var filter: PHPickerFilter? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import Combine | |
struct AdaptsToSoftwareKeyboard: ViewModifier { | |
@State var currentHeight: CGFloat = 0 | |
func body(content: Content) -> some View { | |
content | |
.padding(.bottom, currentHeight) | |
.edgesIgnoringSafeArea(.bottom) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let attributedString = NSMutableAttributedString(string: "WhatEver text you want") | |
// *** Create instance of `NSMutableParagraphStyle` | |
let paragraphStyle = NSMutableParagraphStyle() | |
// *** set LineSpacing property in points *** | |
paragraphStyle.lineSpacing = 4 // Whatever line spacing you want in points | |
// *** Apply attribute to string *** | |
attributedString.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraphStyle, range: NSMakeRange(0, attributedString.length)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - Firebase Auth | |
extension Auth { | |
//Handle Firebase Auth Errors | |
static func handleFirebaseAuthErrorWith(errorCode: AuthErrorCode) -> [String] { | |
switch errorCode { | |
case .emailAlreadyInUse: | |
let title = "User Exist" | |
let message = "The email address provided already exist. Please login using your credentials." | |
return [title, message] | |
case .invalidEmail: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Here you can set View width and height as per your requirement for displaying supportView position in navigationbar | |
let supportView = UIView(frame: CGRect(x: 0, y: 0, width: 120, height: 40)) | |
//supportView.backgroundColor = UIColor.red | |
let logo = UIImageView(image: UIImage(named: "logo")) //UIImage(named: "SelectAnAlbumTitleLettering") | |
// customize the origin as (45,5) but can pass them as your requirement. | |
logo.frame = CGRect(x: 0, y: -5, width: supportView.frame.size.width, height: supportView.frame.size.height) | |
supportView.addSubview(logo) | |
supportView.contentMode = .center |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PdfTools { | |
func generatePdfFromCollectionView(_ collectionView: UICollectionView?, filename:String, success:(String) -> ()) { | |
guard let collectionView = collectionView else { | |
return | |
} | |
let pdfData = NSMutableData() | |
let contentArea = CGRect( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Only add the content below this line | |
add_filter('body_class','browser_body_class'); | |
/** | |
* | |
* Add browser class based on user browser | |
* | |
*/ | |
function browser_body_class($classes) { |
NewerOlder