Snippets Collections
//Don't Forget to add permissions in info.pList for camera and gallery

struct ImagePicker{
    static func callImagePicker(_ viewController: UIViewController){
        let imagePicker = UIImagePickerController()
        imagePicker.delegate = viewController as? any UIImagePickerControllerDelegate & UINavigationControllerDelegate
        imagePicker.allowsEditing = true
        
        let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
        
        alertController.addAction(UIAlertAction(title: "Photo Library", style: .default, handler: { (action) in
            imagePicker.sourceType = .photoLibrary
            viewController.present(imagePicker, animated: true, completion: nil)
        }))
        
        if UIImagePickerController.isSourceTypeAvailable(.camera) {
            alertController.addAction(UIAlertAction(title: "Camera", style: .default, handler: { (action) in
                imagePicker.sourceType = .camera
                viewController.present(imagePicker, animated: true, completion: nil)
            }))
        }
        
        alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
        
        viewController.present(alertController, animated: true, completion: nil)
    }
}

//Inside view Controller

extension Your_View_Controller: UIImagePickerControllerDelegate, UINavigationControllerDelegate{
    
    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
        if let image = info[UIImagePickerController.InfoKey(rawValue: "UIImagePickerControllerEditedImage")] as? UIImage{
            Your_Image_View.image = image
            picker.dismiss(animated: true, completion: nil)
        }
    }
    
    func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
        picker.dismiss(animated: true, completion: nil)
    }
    
}
<div class="avatar__basic-s border--rad-f">
    <img class="avatar__img" src="../assets/images/face_3.jpg" srcset="
                      ../assets/images/face_3.jpg 1x,
                      ../assets/images/face_3.jpg 2x
                    " alt="face demo" />
</div>
<div class="avatar__basic-m border--rad-f">
    <img class="avatar__img" src="../assets/images/face_5.jpg" srcset="
                      ../assets/images/face_5.jpg 1x,
                      ../assets/images/face_5.jpg 2x
                    " alt="face demo" />
</div>
<div class="avatar__basic-l border--rad-f">
    <img class="avatar__img" src="../assets/images/face_1.jpg" srcset="
                      ../assets/images/face_1.jpg 1x,
                      ../assets/images/face_1.jpg 2x
                    " alt="face demo" />
</div>
<div class="avatar__basic-xl border--rad-f">
    <img class="avatar__img" src="../assets/images/face_4.jpg" srcset="
                      ../assets/images/face_4.jpg 1x,
                      ../assets/images/face_4.jpg 2x
                    " alt="face demo" />
</div>
star

Sat Apr 06 2024 10:53:53 GMT+0000 (Coordinated Universal Time)

#component
star

Fri Feb 18 2022 19:10:18 GMT+0000 (Coordinated Universal Time) https://programmingwithmosh.com/javascript/create-modal-using-react/

#react #modal #component
star

Tue Feb 08 2022 19:50:23 GMT+0000 (Coordinated Universal Time)

#avatar #alphaui #component

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension