Coder Social home page Coder Social logo

chafu's Introduction

Chafu

Continuous Integration

Build Server Platform Build Status
AppVeyor Windows AppVeyor Build status
Bitrise macOS Bitrise
VSTS Windows Visual Studio Team services
MyGet Windows chafu MyGet Build Status

Packages

NuGet

Description

Chafu is a photo browser and camera library for Xamarin.iOS. It is heavily inspired from Fusuma, which is a Swift library written by ytakzk.

It has been tweaked for ease of use in a C# environment, all xibs converted to C# code and unnecessary wrapper views have been removed. The library has been simplified and loads of unfixed Fusuma bugs and features have been fixed in this library.

Preview

Features

  • UIImagePickerController alternative
  • Camera roll (images and video)
  • Album view to show images and video from folder
  • Camera for capturing both photos and video
  • Cropping of photos into squares
  • Toggling of flash when capturing photos and video
  • Supports front and back cameras
  • Face detection
  • Customizable

Installation

Install from NuGet

Install-Package Chafu

Note: iOS 10 requires the developer to provide usage descriptions in the info.plist. Otherwise, the application will crash, when requesting permissions to camera, photo library or microphone.

<key>NSPhotoLibraryUsageDescription</key>
<string>Describe what photo library is used for</string>
<key>NSCameraUsageDescription</key>
<string>Describe what camera is used for</string>
<key>NSMicrophoneUsageDescription</key>
<string>Describe what microphone is used for</string>

Usage

Add a using chafu; in the top of your class.

var chafu = new ChafuViewController();
chafu.HasVideo = true; // add video tab
chafu.MediaTypes = MediaType.Image | MediaType.Video // customize what to show
PresentViewController(chafu, true);

or if you only want to show gallery:

var gallery = new AlbumViewController();
gallery.MediaTypes = MediaType.Image | MediaType.Video // customize what to show
PresentViewController(gallery, true);

Both accept custom data source which will be instantiated lazily:

var chafu = new AlbumViewController {
    LazyDataSource = (view, size, mediaTypes) => 
        new LocalFilesDataSource(view, size, mediaTypes) {ImagesPath = path},
    LazyDelegate = (view, source) => new LocalFilesDelegate(view, (LocalFilesDataSource) source),
};

where path is a directory the App has access to.

Events

// When image is selected or captured with camera
chafu.ImageSelected += (sender, image) => imageView.Image = image;

// When video is captured with camera
chafu.VideoSelected += (sender, videoUrl) => urlLabel.Text = videoUrl.AbsoluteString;

// When ViewController is dismissed
chafu.Closed += (sender, e) => { /* do stuff on closed */ };

// When permissions to access camera roll are denied by the user
chafu.CameraRollUnauthorized += (s, e) => { /* do stuff when Camera Roll is unauthorized */ };

// when permissions to access camera are denied by the user
chafu.CameraUnauthorized += (s, e) => { /* do stuff when Camera is unauthorized */ };

Customization

All customization happens through the static Configuration class.

Configuration.BaseTintColor = UIColor.White;
Configuration.TintColor = UIColor.Red;
Configuration.BackgroundColor = UIColor.Cyan;
Configuration.CropImage = false;
Configuration.TintIcons = true;
// etc...

Explore the class for more configuration.

Thanks to

Many thanks to ytakzk for his initial Fusuma implementation, which this library started as.

What does Chafu mean?

Fusuma means bran in Japanese, Chafu in Japanese means chaff. Chaff is sometimes confused with bran.

License

Chafu is licensed under the MIT License, see the LICENSE file for more information.

chafu's People

Contributors

cheesebaron avatar mihaicph 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

Watchers

 avatar  avatar  avatar  avatar

chafu's Issues

Picking video or image externally crashes app

After having added Video preview support, the observer does not correctly take in account videos when reordering the collection, when a picture/video is taken or deleted outside of the app and app is brought into foreground again.

Blank icons on buttons

A bug for this is logged here: https://bugzilla.xamarin.com/show_bug.cgi?id=34762

Windows builds apparently don't work properly with assets in libraries, so the bundled assets unfortunately don't show up on buttons.

This means you have to supply your own icons currently.

These can be set using the Configuration class like so:

Configuration.AlbumImage = UIImage.FromBundle("album");
Configuration.CameraImage = UIImage.FromBundle("camera");
Configuration.VideoImage = UIImage.FromBundle("video");
Configuration.CheckImage = UIImage.FromBundle("check");
Configuration.CloseImage = UIImage.FromBundle("close");

Image with zooming issue on first load

I am facing the issue on first load of view the preview image is getting zoomed (higher scaling ratio)
and I am not able to do anything with that. When I clicked on the same image from photo library preview shows me expected image and works normally.

On first load:
onfirstload

Selected the same image:
after selecting the same image

New logo for Chafu

Hi, I designed a logo for Chafu. How do these look? If you have an idea, you can tell me. Also, If you like it, I will send you a pr.

chafu

Improve swipe gestures on AlbumView

Gestures on the AlbumView feel a little strange in some cases. I.e. when you scroll upwards to reveal images in the bottom pushes the big preview image up. But you can't swipe down to move it down again. Only switching the image moves it down.

Default Images Not Shown

screenshot

Steps to reproduce:

  1. Remove library reference from sample.
  2. Add Chafu package to the sample.
  3. Run.

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.