Giter Club home page Giter Club logo

taglistview's Introduction

TagListView

Travis CI Version License Carthage compatible

Simple and highly customizable iOS tag list view, in Swift.

Supports Storyboard, Auto Layout, and @IBDesignable.

Screenshot

Usage

The most convinient way is to use Storyboard. Drag a view to Storyboard and set Class to TagListView (if you use CocoaPods, also set Module to TagListView). Then you can play with the attributes in the right pane, and see the preview in real time thanks to @IBDesignable.

Interface Builder

You can add tag to the tag list view, or set custom font and alignment through code:

tagListView.textFont = UIFont.systemFontOfSize(24)
tagListView.alignment = .Center // possible values are .Left, .Center, and .Right

tagListView.addTag("TagListView")
tagListView.insertTag("This should be the second tag", at: 1)

tagListView.removeTag("meow") // all tags with title “meow” will be removed
tagListView.removeAllTags()

You can implement TagListViewDelegate to receive tag pressed event:

// ...
{
    // ...
    tagListView.delegate = self
    // ...
}

func tagPressed(title: String, tagView: TagView, sender: TagListView) {
    print("Tag pressed: \(title), \(sender)")
}

You can also customize a particular tag, or set tap handler for it by manipulating the TagView object returned by addTag(_:):

let tagView = tagListView.addTag("blue")
tagView.tagBackgroundColor = UIColor.blueColor()
tagView.onTap = { tagView in
    print("Don’t tap me!")
}

Be aware that if you update a property (e.g. tagBackgroundColor) for a TagListView, all the inner TagViews will be updated.

Installation

Use CocoaPods:

pod 'TagListView', '~> 1.0'

Or Carthage:

github "ElaWorkshop/TagListView" ~> 1.0

Or drag TagListView folder into your project.

Older Swift Versions?

Currently, the master branch is using Swift 3.0.

For Swift 2, use version 1.0.1 or swift-2.3 branch. For Swift 1.2, use version 0.2.

Contribution

Pull requests are welcome! If you want to do something big, please open an issue to let me know first.

License

MIT

taglistview's People

Contributors

aaronpearce avatar aleene avatar benuuu avatar cee avatar kitasuke avatar marcelofabri avatar migfabio avatar morizotter avatar nick-the-uncharted avatar nrewik avatar philipheinser avatar redent avatar rolandasrazma avatar ronkliffer avatar takuoka avatar xbeg9 avatar xhacker avatar

Watchers

 avatar  avatar  avatar

taglistview's Issues

Clear button.

It would be nice to have clear button in a TagListField similar to a UITextField. This clear button, when present should remove all tags.
This can work similar to UITextField, i.e. either it is always visible. Or it depends isEditable, i.e. visible when isEditable or visible when !isEditable.
#8

Tag granularity

The layout of the tags is mainly governed by the layout details of the TagListView. However it is possible to set the layout of individual tags by accessing their TagViews.

Accessing TagViews can be done while setting up the TagListView. And if needed can be changed later. Or when selecting or editing a tag.

Do we need something like willDisplayTag(atIndex:), so the user can setup things? Seems a very heavy function if this must be called for each tag.
#8

Drag&drop support

Drag&drop allows the user to rearrange tags

  • With a long press a tag can be selected, it will then hover above the tag list and can be dropped between two other tags;
  • Drag&drop is only possible when the TagViewList isEditable;
  • A delegate asks the user if a tag may be dragged. So you can deny certain tags to be dragged;
  • A delegate informs the user that a tag has been dragged to a new position. This allows the user to adapt his data;
  • The demo should show dragging and denying;
  • Can we keep the original longPress function?

Managed TagListView

A version og TagListView without direct access to TagViews. Everything is handled through delegates.

To-field?

I could use the to-field to make the interface compacter.

Removal animation

A question was asked whether it was possible to add a removal animation.

I might use the drag&drop approach for this. On removal, dim the tag to fully hidden and the make the width of the tag smaller, which should move all the other tags.

removeAllTags()

Should have another look at the implementation of this function.

  • What is the relation with the edit-delegates and -datasources;
  • Is there a relation with a clear-button ( #9 )?
    #8

Delete and d&d

I am warming to the use of a delete button. If you make a mistake now with d&d, you might delete an item. So somekind of brake on this is usefull.
This can be a delete button, so you need to hit a specific area.
Or it can be a two-phase delete, as seems that is used by TokenField. First you highlight and then you tap delete on the keyboard. And you can not delete by tapping.

ScrollView

Do I need the scrollView? Or can I do without?

The TagListView consists now of a PrefixLabel + a list if TagView's + an InputTextView.

Suggestions

The tokenfield implementation has a delegate that starts as soon as the user types. This can be used to present suggestions in a TableView for instance. As the user continues typing, the suggestions are finetuned. Tapping a suggstion could for the setting of a tag.

I did not yet find an implementation for this.

EditAccessory demo

Add the editAccessory to the demo. Use something similar as the UITextField clear button..

#8

Documentation section on basic usage

The user does not have to use all the delegates and datasource protocols. Neither is it necessary to access tags by index. These functions are only necessary if you need to keep data and interface in sync.

The original set of functions of TagListView will be sufficient for some users. The difference between these two approaches should be made clear in the documentation.
#8

Removal legacy support

Is legacy support for the removal button still wanted? Can we leave it? Does it harm or interfer with other functions?
#8 and #10

EditModes

How can I specify the various editModes? We have:

  • TagListViewEditingStyleDelete
  • TagListViewEditingStyleInsert
  • TagListViewEditingStyleMove

There should be a corresponding delegate function:

  • tagListView(_ tagListView: TagListView, editingStyleForTagAt: index) -> TagListViewEditingStyle

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.