Coder Social home page Coder Social logo

charliescheer / mediapicker-ios Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wordpress-mobile/mediapicker-ios

0.0 1.0 0.0 1.9 MB

WPMediaPicker is an iOS controller that allows capture and picking of media assets.

License: GNU General Public License v2.0

Ruby 1.37% Objective-C 98.63%

mediapicker-ios's Introduction

WPMediaPicker

CircleCI Version License Platform

WPMediaPicker is an iOS controller that allows capture and picking of media assets. It allows:

  • Allows selection of multiple media objects in one go.
  • Capture of new media while inside the picker.
  • Use different data sources for the media library.
  • Switch between different albums.
  • Filtering by media types.
  • Preview of media (images and video) in full screen.
  • Show the media picker inside as a keyboard input view.
  • Super quick and memory optimized.
  • Allows horizontal and vertical scroll of assets.
  • Allows custom searching/filtering of assets.

Screenshot

Installation

WPMediaPicker is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "WPMediaPicker"

Usage

To use the picker do the following:

Import header

#import <WPMediaPicker/WPMediaPicker.h>

Create and present the picker in modal mode

WPNavigationMediaPickerViewController * mediaPicker = [[WPNavigationMediaPickerViewController alloc] init];
mediaPicker.delegate = self;
[self presentViewController:mediaPicker animated:YES completion:nil];

Implement didFinishPickingAssets delegate

The delegate is responsible for dismissing the picker when the operation completes. To dismiss the picker, call the dismissViewControllerAnimated:completion: method of the presenting controller responsible for displaying the WPNavigationMediaPickerController object. Please refer to the demo app.

- (void)mediaPickerController:(WPMediaPickerViewController *)picker didFinishPickingAssets:(NSArray<WPMediaAsset> *)assets
{
  [self dismissViewControllerAnimated:YES completion:nil];    
}

Other methods to display the picker

The example above shows the recommended way to show the picker in a modal. There are currently three available controllers to show the picker depending on your application needs:

How to configure the appearance of the picker

Just use the standard appearance methods from UIKit. Here is an example how to configure the main components

//Configure navigation bar background color
[[UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[[WPNavigationMediaPickerViewController class]]] setBarTintColor:[UIColor colorWithRed:0/255.0f green:135/255.0f blue:190/255.0f alpha:1.0f]];
//Configure navigation bar items text color
[[UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[[WPNavigationMediaPickerViewController class]]] setTintColor:[UIColor whiteColor]];
//Configure navigation bar title text color
[[UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[[WPNavigationMediaPickerViewController class]]] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]} ];
//Configure background color for media scroll view
[[UICollectionView appearanceWhenContainedInInstancesOfClasses:@[[WPMediaCollectionViewController class]]] setBackgroundColor:[UIColor colorWithRed:233/255.0f green:239/255.0f blue:243/255.0f alpha:1.0f]];
//Configure background color for media cell while loading image.
[[WPMediaCollectionViewCell appearanceWhenContainedInInstancesOfClasses:@[[WPMediaCollectionViewController class]]] setBackgroundColor:[UIColor colorWithRed:243/255.0f green:246/255.0f blue:248/255.0f alpha:1.0f]];
//Configure color for activity indicator while loading media collection
[[UIActivityIndicatorView appearanceWhenContainedInInstancesOfClasses:@[[WPMediaCollectionViewController class]]] setColor:[UIColor grayColor]];

How to use a custom data source for the picker

If you have a custom database of media and you want to display it using the WPMediaPicker you need to implement the following protocols around your data:

You can view the protocols documentation for more implementation details. After you have implemented it you can use it by simple doing the following:

self.customDataSource = [[WPCustomAssetDataSource alloc] init];
mediaPicker.dataSource = self.customDataSource;

Sample Project

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • ARC
  • Photos, AVFoundation, ImageIO
  • XCode 10 or above
  • iOS 11 or above

Contributing

Read our Contributing Guide to learn about reporting issues, contributing code, and more ways to contribute.

Getting in Touch

If you have questions about getting setup or just want to say hi, join the WordPress Slack and drop a message on the #mobile channel.

Author

WordPress, [email protected]

License

WPMediaPicker is available under the GPL license. See the LICENSE file for more info.

mediapicker-ios's People

Contributors

aerych avatar astralbodies avatar ay8s avatar bummytime avatar ctarda avatar cyhsutw avatar etoledom avatar eugene-polyakov avatar frosty avatar jkmassel avatar jleandroperez avatar jtreanor avatar kant avatar koke avatar kurzee avatar kwonye avatar leandroalonso avatar loremattei avatar mindgraffiti avatar pinarol avatar rachelmcr avatar scoutharris avatar sendhil avatar sergioestevao avatar shiki avatar

Watchers

 avatar

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.