Skip to content

Bottom view with infinity actions

License

Notifications You must be signed in to change notification settings

VladK9/UIControlView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

About

Bottom view with infinity actions

Navigate

Features

  • Highly customizable

    • cornerRadius
    • view width/height
    • show/hide indicator
    • show with slide/fade animation
    • close button title
    • close button background color
    .theme(light: .black, dark: .white, any: .white)
    .color(.black)
    • close button tint color
    .theme(light: .black, dark: .white, any: .white)
    .color(.black)
    .auto - Color depends on closeBackColor (dark or light)

    Each item config

    Item

    - onlyTitle(_ title: String)
    - onlyIcon(_ icon: UIImage)
    - TitleWithIcon(_ title: String, _ icon: UIImage)

    Tint color

    - standard
    - custom(_ color: UIColor)
    - customHEX(_ hex: String)
    - coloredImage(_ tintColor: UIColor) // If a multi-color image is used, only the text color changes

    Background color

    - standard
    - clear
    - custom(_ color: UIColor)
    - customHEX(_ hex: String)

    Item action

    Single action

    .init(item: .onlyTitle("Item with single action"), tintColor: .customHEX("#0C5AA9"), backColor: .custom(.blue), handler: { _ in
    }),

    Double action

    .init(item: .onlyTitle("Item with double action"),
          selectionConfig: .backWithBorder(.systemPurple),
          isPreselected: true,
          isSelected: { _ in
             //Selected
          }, isUnselected: { _ in
             //Unselected
          }),
  • The ability to show one above the other view's

  • Swipe to hide or press button
  • Support dark/light theme

Installation

Put Sources folder in your Xcode project. Make sure to enable Copy items if needed.

Usage

Actions

let view = UIControlView.self
let actions: [UIControlViewAction] = [
    .init(item: .TitleWithIcon("Item 1", UIImage(systemName: "highlighter")!), tintColor: .customHEX("890596"), backColor: .custom(.purple), handler: { _ in
    }),
    .init(item: .onlyTitle("Item 2"), tintColor: .customHEX("#0C5AA9"), backColor: .custom(.blue), handler: { _ in
    }),
    .init(item: .onlyTitle("Item with double action"),
          selectionConfig: .backWithBorder(.systemPurple),
          isPreselected: true,
          isSelected: { _ in
              //Selected
          }, isUnselected: { _ in
              //Unselected
          })
]
      
view.showHideIndicator = false
view.closeButton.title = "Close"
view.closeButton.tintColor = .auto
view.closeButton.backColor = .theme(light: .black, dark: .white, any: .white) // .color(.black)
view.showWithSlideAnimation = true
view.delegate = self
view.show(self, type: .actions(actions))

Color

let view = UIControlView.self
let colors: [UIColor] = [.gray, .systemBlue, .brown, .systemTeal, .systemCyan, .systemPink, .systemRed, .systemMint]
      
view.showHideIndicator = false
view.closeButton.title = "Close"
view.closeButton.tintColor = .auto
view.closeButton.backColor = .theme(light: .black, dark: .white, any: .white) // .color(.black)
view.showWithSlideAnimation = true
view.delegate = self
view.colorDelegate = self
view.show(self, type: .color(colors, selected: .none)) // selected: .selected(top: Int, bottom: Int) - Selected item on start

Delegate

To get hide method or order, set the delegate with protocol UIControlViewDelegate:

func didHideView(_ method: HideMethod, _ order: HideOrder) {
    if method == .isSwipe {
        print("isSwipe")
    } else if method == .isButton {
        print("isButton")
    }
        
    if order == .isMain {
        print("isMain")
    } else if order == .isSubview {
        print("isSubview")
    } else if order == .isAllClosed {
        print("isAllClosed")
    }
}

To get selected color, set the delegate with protocol UIControlViewColorDelegate:

func didSelectColor(_ color: UIColor) {
    ... = color
}