• Stars
    star
    330
  • Rank 127,657 (Top 3 %)
  • Language
    Swift
  • License
    MIT License
  • Created about 9 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Custom view for writing tags, contacts and etc. - written in Swift

TFBubbleItUp logo

TFBubbleItUp

Version License Platform

preview

Usage

Just place UIView in your controller wherever you want and make it as TFBubbleItUpView subclass. It is configured as IBDesignable, so it will show up. The content size is calculated by the view itself, no need to use height constraint. Just set in the Interface builder Intrinsic size to placeholder - width check None and for height choose what suits you best.

Intrinsic size

There is also a delegate available (named bubbleItUpDelegate, because TFBubbleItUpView is in fact a subclass of UICollectionView) with currently one method func bubbleItUpViewDidFinishEditingBubble(view: TFBubbleItUpView, text: String).

You can preset values with setItem([TFBubbleItem]) where TFBubbleItem is a struct whose initializer takes string (TFBubbleItem(text: "Hullo!")).

If you want to access all items from view, there is method for that validStrings() -> [String]. That's because sometimes there are empty items, this method will filter it for you a send you only valid strings.

Validation

Among all the configuration, there is an ability to validate items before they can be bubbled. There is typealias named Validation which is just a function definition:

public typealias Validation = String -> Bool

Verification function takes a string and returns Bool indicates whether the string is valid or not. These methods should be elementary. There are already two of them available as public classes of TFBubbleItUpValidation - testEmptiness() and testEmailAddress(). These methods returns Validation function and the validation can be called like testEmptiness()("a text"). This technique of translating the evaluation of a function is called Currying. You can provide your own Validation:

func testSomething() -> Validation {
  return { text in
    return text == "something"
  }
}

This allows us to easily combine validation by function TFBubbleItUpValidation.combine(v1: Validation, v2: Validation) or even better with provided operator |>>

let validation = TFBubbleItUpValidation.testEmptiness() |>> TFBubbleItUpValidation.testEmailAddress()

The validation can be applied to TFBubbleItUpView via configuration

TFBubbleItUpViewConfiguration.itemValidation = validation

And we can also validate the maximum number of items user can type in by

TFBubbleItUpViewConfiguration.numberOfItems = .Quantity(5) // default .Unlimited

Configuration

BubbleItUp is highly configurable. There is configuration file called TFBubbleItUpViewConfiguration with class variables for configuration.

It is a mix of appearance and functional stuff. I would like to point out skipOnWhitespace and skipOnReturnKey properties, by them you can change the behaviour of bubble creation around text (see documentation comments bellow).

/// Background color for cell in normal state
public static var viewBackgroundColor: UIColor = UIColor(red: 0.918, green: 0.933, blue: 0.949, alpha: 1.00)

/// Background color for cell in edit state
public static var editBackgroundColor: UIColor = UIColor.whiteColor()

/// Background color for cell in invalid state
public static var invalidBackgroundColor: UIColor = UIColor.whiteColor()

/// Font for cell in normal state
public static var viewFont: UIFont = UIFont.systemFontOfSize(12.0)

/// Font for cell in edit state
public static var editFont: UIFont = UIFont.systemFontOfSize(12.0)

/// Font for cell in invalid state
public static var invalidFont: UIFont = UIFont.systemFontOfSize(12.0)

/// Font color for cell in view state
public static var viewFontColor: UIColor = UIColor(red: 0.353, green: 0.388, blue: 0.431, alpha: 1.00)

/// Font color for cell in edit state
public static var editFontColor: UIColor = UIColor(red: 0.510, green: 0.553, blue: 0.596, alpha: 1.00)

/// Font color for cell in invalid state
public static var invalidFontColor: UIColor = UIColor(red: 0.510, green: 0.553, blue: 0.596, alpha: 1.00)

/// Corner radius for cell in view state
public static var viewCornerRadius: Float = 2.0

/// Corner radius for cell in edit state
public static var editCornerRadius: Float = 2.0

/// Corner radius for cell in invalid state
public static var invalidCornerRadius: Float = 2.0

/// Height for item
public static var cellHeight: Float = 25.0

/// View insets
public static var inset: UIEdgeInsets = UIEdgeInsetsMake(5, 5, 5, 5)

/// Interitem spacing
public static var interitemSpacing: CGFloat = 5.0

/// Line spacing
public static var lineSpacing: CGFloat = 5.0

/// Keyboard type
public static var keyboardType: UIKeyboardType = UIKeyboardType.EmailAddress

/// Keyboard return key
public static var returnKey: UIReturnKeyType = UIReturnKeyType.Done

/// Field auto-capitalization type
public static var autoCapitalization: UITextAutocapitalizationType = UITextAutocapitalizationType.None

/// Field auto-correction type
public static var autoCorrection: UITextAutocorrectionType = UITextAutocorrectionType.No

/// If true it creates new item when user types whitespace
public static var skipOnWhitespace: Bool = true

/// If true it creates new item when user press the keyboards return key. Otherwise resigns first responder
public static var skipOnReturnKey: Bool = false

/// Number of items that could be written
public static var numberOfItems: NumberOfItems = .Unlimited

/// Item has to pass validation before it can be bubbled
public static var itemValidation: Validation? = nil

Requirements

TFBubbleItUp uses Swift 5.0. Target deployment iOS 10.0 and higher.

Installation

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

pod "TFBubbleItUp"

Author

Ales Kocur, [email protected]

License

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

More Repositories

1

donut

Doughnut-like graph view capable of displaying multiple datasets with assignable colors
Kotlin
541
star
2

hauler

Library with swipe to dismiss Activity gesture implementation
Kotlin
434
star
3

Sonar

Radar style view written in swift
Swift
129
star
4

arkitekt

Arkitekt is a set of architectural tools based on Android Architecture Components, which gives you a solid base to implement the concise, testable and solid application.
Kotlin
123
star
5

TFTransparentNavigationBar

Custom transition between controllers in UINavigationController that makes navigation bar transparent on specified controllers
Swift
46
star
6

sheet-happens

Gradle plugin for generating Android / KMP string resources from Google Spreadsheets.
Kotlin
45
star
7

arkitekt-kmm

KMM library for UseCase abstraction
Kotlin
44
star
8

iOS-templates

Templates for MVVM-C architecture
Makefile
32
star
9

FuntastyKit

A collection of Swift utilities and protocols used in our projects
Swift
30
star
10

MVVM-C-Example

Example project for MVVM-C architecture in Swift
Swift
29
star
11

infinity

[Deprecated] Infinite paginated RecyclerView scrolling
Java
27
star
12

kmp-futured-template

Template for creating Kotlin Multiplatform applications at Futured.
Kotlin
20
star
13

FTAPIKit

Declarative and generic REST API framework using Codable.
Swift
19
star
14

Engineering-Handbook

Best practices and guidelines for developing apps in Futured
15
star
15

Gutenberg

Tiny library for generating attributed string with emoticons as images
Shell
14
star
16

bitrise-step-apk-info

Ruby
11
star
17

CellKit

Table View and Collection View data source wrapper
Swift
10
star
18

FormStateKit

A Swift package for simple management of forms and their fields. Focused on SwiftUI.
Swift
9
star
19

FTPropertyWrappers

Property wrappers for User Defaults, Keychain, StoredSubject and synchronization.
Swift
8
star
20

TFTableDescriptor

iOS Library / Simple table descriptor with dynamic cell height support
Objective-C
6
star
21

taste

[Deprecated]
Java
6
star
22

LocationManager

Swift
6
star
23

danger

The Danger rules we use at @futuredapp
Ruby
6
star
24

tasting

Android UI Automator wrapper for human-like scenario testing
Kotlin
6
star
25

Monkey-Madness

Easy to use ADB monkey command line wrapper
Shell
6
star
26

bitrise-step-ipa-info

Ruby
5
star
27

Funtasty-iOS-Playbook

Conventions for writing iOS applications
4
star
28

Realm-Codegen

Code Generation of Realm model files in Swift using Sourcery
Swift
2
star
29

OpenAPI-Project-Template

Template for OpenAPI specifications
Makefile
2
star
30

android-project-template

Kotlin
2
star
31

dev-academy-ios

Swift
2
star
32

f-academy-project-android

Kotlin
2
star
33

android-project-template-compose

Kotlin
1
star
34

brmo2023-kmm-talk

Code for the "KMM: Shared Navigation -- Finding The Sweet Spot" talk presented at BrMo2023 & Betsys Mobile dev meetup 2023
Kotlin
1
star
35

FTLogKit

Yet another logging framework for Apple platforms
Swift
1
star
36

ui-test-examples

xcode ui test examples
Swift
1
star
37

SwiftMonkeys

Monkeys for UI automated testing. Also known as UI/Application Exerciser Monkey.
Objective-C
1
star
38

TFSlideControl

Swift
1
star
39

.github

1
star
40

FCodeWars

1
star
41

FTTestingKit

Mockups and async extension to XCTestCase
Swift
1
star
42

FuturedKit

SwiftUI state management tools, resources and views used by Futured.
Swift
1
star
43

iOS-project-template

Template for creating iOS projects we use @futuredapp.
Ruby
1
star