Latest0.9.7
Homepagehttps://github.com/mohsenShakiba/CUITools
LicenseMIT
Platformsios 9.0
DependenciesSnapKit, DKImagePickerController, ImageViewer, Kingfisher
Authors

Common UI Tools for personal use

Table Of Contents

AlertView

Notifies user of an action that just happened.

Usage

let alertViewProvider = AlertViewProvider(title: String, detail: String, actionTitle: String, type: FlashViewType)
bulletinProvider.present(in: myViewController)

Bulletin

Shows a message with action and cancel button
suitable for notifying the user that something happens which needs an action to be performed or be canceled

Usage

let bulletinProvider = BulletinProvider(title: String, detail: String, image: UIImage? = nil, actionTitle: String?, cancelTitle: String?)
bulletinProvider.delegate = self
bulletinProvider.present(in: myViewController)
bulletinProvider.dismiss() // will dismiss the controller
// delegate
func bulletin(actionClicked provider: BulletinAlertProvider)
func bulletin(cancelClicked provider: BulletinAlertProvider)

ErrorView

Simple view for showing error message
Suitable for when internet is disconnected
Used in the MSTableViewController as the showError view

let errorView = ErrorView(message: String, image: UIImage?)
// add to msView or subView of UIViewController

Notification

Notification allows you to show a message on top of the window for a short period of time

Usage

let notificationProvider = NotificationProvider(text: "this is a simple notification", type: .sucess)
// will show the notification in the top most window
notificationProvider.presentInWindow()
// will show the notification in the current controller
notificationProvider.present(in: myViewController)

FlashView

FlashView shows an animated view, which can be of success, error or custom
The animationDuration and edgeInsets can be configured BEFORE callling the present method

Usage

let flashProvider = FlashProvider(type: FlashViewType)
flashProvider.present()

ImageViewerExtension

Extend the UIViewController from ImageViewerExtension and then call the following method

  • presentImage(image: UIImage) which will show the gallery with the provided image

LoadingButton

View for showing a button that can transform into loading state.

IMPORTANT: it’s best to not set height and width constraint since the loading animation relies on intrinsic content size

let loadingButton = LoadingButton(title: String, type: LoadingButtonType)

LoadingImageView

This extension enables the UIImageView to load a URL async
The image is then resized and shrinked to the bounds size

imageView.url = "http://test.com/image.jpg"
imageView.cornerToBounds = true // set the radius accordning to bounds
imageView.defaultImage = my_playholder_img // set image for when the UIImageView is empty

LoadingView

Displays a loading indicator.
The width and height constrainsts aren’t needed since the intrinsic content size is provided

let loadingView = LoadingView(type: LoadingViewType, color: LoadingViewColorType)

LoadingViewType.normal // size is 40
LoadingViewType.small // size is 25
LoadingViewColorType.default // #CCCCCC
LoadingViewColorType.accent // the accent
LoadingViewColorType.white // #FFFFFF

MSView & MSViewController

This view enabled multiple views to be displayed with fadein/fadeout transition

let msView = MSView()
msView.animationDuration = 0.5 // duration of animation, default: 0.15
msView.currentView // returns the current visible view
msView.animate(to: nextView)
class MyMSViewControler: MSViewController {

    override viewDidLoad() {
        super.viewDidLoad()
        animate(to: nextView)
    }

}

SelectController

Allows the user to select one or many items from the provided view

SelectOption

The user can only select one option

let provider = SelectOptionProvider<Int>(headerTitle: String? = nil, cancelTitle: String)
provider.appendItem(title: "first option", value: 1)
provider.insertItem(title: "second option", value: 2, at: 1)
provider.present(in: myViewController)
provider.onResult { result in
    switch result {
        case .cancel: break
        case .value(let value): // value is same type as T
        print(value)
    }

Picker

The user can pick one or multiple values from the picker view

let provider = SelectOptionProvider<Int>(headerTitle: String? = nil, cancelTitle: String)
provider.addItem("one", value: 1, component: 0)
provider.addItem("two", value: 2, component: 0)
provider.addItem("three", value: 3, component: 0)
provider.present(in: myViewController)
provider.onResult { result in
    switch result {
        case .cancel: break
        case .value(let value):
            // array containing dictionary [Component: Valye]
            let valueForComponent = value[0]
    }
}

SelectController

extend view controller to implement the SelectImageProtocol, then implement the following method

  • func imageSelectionSucceed(images: [UIImage])
  • func imageSelectionCanceled()
    to call the selectImageController call presentSelectImage(config) and pass the config

    let config = SelectImageConfig()
    config.selectionCount = 1 //default
    config.sourceType: DKImagePickerControllerSourceType = .both // default, means both camera and gallery
    config.showCancelButton = true // default
    self.presentSelectImage(config: config)

Styles

Gloabl styles

Known Bugs And Limitations

  • cannot change the size of image in the BulletinAlert
  • ErrorView does not have an action

Author

mohsenShakiba, [email protected]

License

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

Latest podspec

{
    "name": "CUITools",
    "version": "0.9.7",
    "summary": "UI tools for internal usage",
    "description": "UI tools for usage in internal apps.nincluding loading, select and more",
    "homepage": "https://github.com/mohsenShakiba/CUITools",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "mohsenShakiba": "[email protected]"
    },
    "source": {
        "git": "https://github.com/mohsenShakiba/CUITools.git",
        "tag": "0.9.7"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "CUITools/Classes/**/*",
    "resource_bundles": {
        "CUITools": [
            "CUITools/Assets/*.ttf"
        ]
    },
    "dependencies": {
        "SnapKit": [
            "< 4.0.0"
        ],
        "DKImagePickerController": [
            "< 3.8.0"
        ],
        "ImageViewer": [
            "~> 4.0"
        ],
        "Kingfisher": [
            "~> 4.6"
        ]
    },
    "pushed_with_swift_version": "3.2"
}

Pin It on Pinterest

Share This