Giter Site home page Giter Site logo

naturaln0va / visualactivityviewcontroller Goto Github PK

View Code? Open in Web Editor NEW
757.0 13.0 29.0 647 KB

A way to represent what you’re sharing.

Home Page: https://ackermann.io/posts/previewing-the-system-share-sheet

License: MIT License

Swift 100.00%
swift4 uiactivityviewcontroller sharing preview customization ios

visualactivityviewcontroller's Introduction

VisualActivityViewController

Swift
Twitter

VisualActivityViewController Preview

About

This project provides a preview of items being shared via UIActivityViewController. Example:

// standard activity view controller
let vc = UIActivityViewController(activityItems: [shareText])

// custom activity view controller with a preview 
let vc = VisualActivityViewController(text: shareText)

Features

  • Text, Image, and URL previewing
  • Swipe gesture to dismiss the share sheet
  • Easy customization (match your app’s style)

Requirements

  • iOS 9.0+
  • Xcode 9.0+

Installation

To install, simply add the VisualActivityViewController.swift file to your project.

Advanced Usage

There are quite a few different options to customize the appearance of the preview. Check out the example project to see how some of these options work.

/// The duration for the preview fading in
var fadeInDuration: TimeInterval = 0.3

/// The duration for the preview fading out
var fadeOutDuration: TimeInterval = 0.3

/// The corner radius of the preview
var previewCornerRadius: CGFloat = 12

/// The corner radius of the preview image
var previewImageCornerRadius: CGFloat = 3

/// The side length of the preview image
var previewImageSideLength: CGFloat = 80

/// The padding around the preview
var previewPadding: CGFloat = 12

/// The number of lines to preview
var previewNumberOfLines: Int = 5

/// The preview color for URL activity items
var previewLinkColor: UIColor = UIColor(red: 0, green: 0.47, blue: 1, alpha: 1)

/// The font for the preview label
var previewFont: UIFont = UIFont.systemFont(ofSize: 18)

/// The margin from the top of the viewController's window
var previewTopMargin: CGFloat = 8

/// The margin from the top of the viewController's view
var previewBottomMargin: CGFloat = 8

License

This project is available under the MIT license. See the LICENSE file for more info.

visualactivityviewcontroller's People

Contributors

naturaln0va avatar neilmorton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

visualactivityviewcontroller's Issues

preview don't remove from window

preview don't remove from window, will create constraint bug, I think you should remove it by this code;

 override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        UIView.animate(withDuration: fadeOutDuration) {
            self.preview?.alpha = 0
            if let window = self.view.window,
                window.subviews.contains(self.preview) {
                self.preview.removeFromSuperview()
            }
        }
    }

Whatsapp share

Hello,
Its not sharing image in the whatsapp. How can I handle it?

applicationActivities

Please add applicationActivities to VisualActivityViewController
example : VisualActivityViewController(text: "", applicationActivities: Freedom.browsers())

Expose all variables in Objective C

It would be extremely useful to expose all the variables to Objective C, as they are in Swift.

Could be done using @objcMembers prefix to the VisualActivityViewController class.

Does not work on iOS 13

VisualActivityViewController doesn't show a UIView on iOS 13. This version is working fine till iOS 12.4. What is the possible fix.

Thank You

Autoresizing Mask Autolayout error hides the Preview on iPad (works as expected on iPhone)

Hello! I updated to the latest version, I'm getting a layout constraints error on iPad. The preview view doesn't display at all on iPad, and I'm guessing it's related to this error.

My share items are a String and an URL.

It works fine as expected on iPhone. Yes, I'm setting sourceRect and sourceView

Here is the error:

[LayoutConstraints] Unable to simultaneously satisfy constraints.
	Probably at least one of the constraints in the following list is one you don't want. 
	Try this: 
		(1) look at each constraint and try to figure out which you don't expect; 
		(2) find the code that added the unwanted constraint or constraints and fix it. 
	(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSAutoresizingMaskLayoutConstraint:0x600001516620 h=--& v=--& UIView:0x7fbe60d56940.midY == 146   (active)>",
    "<NSAutoresizingMaskLayoutConstraint:0x60000150dae0 h=--& v=--& UIView:0x7fbe60d56940.height == 292   (active)>",
    "<NSLayoutConstraint:0x600001516080 UIVisualEffectView:0x7fbe60d56d40.top >= UILayoutGuide:0x600004f902a0'UIViewSafeAreaLayoutGuide'.top + 8   (active)>",
    "<NSLayoutConstraint:0x600001516cb0 UIVisualEffectView:0x7fbe60d56d40.bottom == UIView:0x7fbe60d56940.top - 8   (active)>",
    "<NSLayoutConstraint:0x6000015171b0 'UIViewSafeAreaLayoutGuide-top' V:|-(0)-[UILayoutGuide:0x600004f902a0'UIViewSafeAreaLayoutGuide']   (active, names: '|':UIView:0x7fbe6285b5c0 )>"
)

and here is my call

let vc = VisualActivityViewController(activityItems: [shareText, url], applicationActivities: nil)
                            
if let popoverPresentationController = vc.popoverPresentationController {
   popoverPresentationController.sourceRect = cell.bounds
   popoverPresentationController.sourceView = cell
}
                            
self.present(vc, animated: true, completion: nil)

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.