Library to help handle mentions

Related tags

Animation SZMentions
Overview

SZMentions is no longer being updated, please use SZMentionsSwift

CocoaPods Compatible Platform Twitter

SZMentions is a lightweight mentions library for iOS. This library was built to assist with the adding, removing and editing of a mention within a textview.

How To Get Started

Communication

  • If you need help, feel free to tweet @StevenZweier
  • If you found a bug, have a feature request, or have a general question open an issue.
  • If you want to contribute, submit a pull request.

Installation with CocoaPods

CocoaPods

Podfile

To integrate SZMentions into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

pod 'SZMentions'

Then, run the following command:

$ pod install

Requirements

| SZMentions Version | Minimum iOS Target | |:--------------------:|:---------------------------:|| | 0.0.x | iOS 8.1 |

Usage

Below is a quick run through of the objects used in this library but as always the best place to get an understanding of the current implementation of the SZMentions library is in the example code.

SZMentionsListener

This class manages the mention interaction.

Setup

Use one of the many initializers to setup your mentions listener. Parameters explained below:

textView : required The text view we are applying the mentions listener to. Note: it's delegate must be the mentions manager.

mentionsManager : required The class that will be handling the mention interaction.

delegate : optional If you would like to receive UITextView delegate methods set this and it will be passed through after processing view the mentions listener.

defaultTextAttributes : Attributes (see: SZAttribute) to apply to the textview for all text that is not a mention.

mentionTextAttributes : Attributes (see: SZAttribute) to apply to the textview for all mentions

spaceAfterMention : optional Whether or not you would like a space to be added to the end of your mentions. Default is NO

trigger : The string used to start a mention. Default is @

cooldownInterval : optional The amount of time to wait between calling showMentionsList. Default is 0.5

Properties

mentions : readonly Array of all mentions currently applied to the text view.

Methods

- (void)addMention:(NSObject<SZCreateMentionProtocol> *)mention; : Call this method while adding a mention to apply the mention to the current text.

SZCreateMentionProtocol

This required properties for a mention being sent to the mentions listener

SZMentionsManagerProtocol

The require methods for handling mention interaction.

- (void)showMentionsListWithString:(NSString *)mentionString; lets the delegate know to show a mentions list as well as provides the current string typed into the textview, allowing for filtering of the mentions list.

- (void)hideMentionsList; lets the delegate know we are no longer typing in a mention.

SZMention

This class is returned via the mentions method, it includes the range of the mention as well as object containing the object sent to the mentions listener via the addMention:(id)mention method.

SZAttribute

This class is used to pass attributes to apply mentions text as well as regular text.

Example:

SZAttribute *attribute = [[SZAttribute alloc] initWithAttributeName:NSForegroundColorAttributeName
attributeValue:[UIColor redColor]];

Unit Tests

SZMentions includes unit tests which can be run on the SZMentions framework

Credits

SZMentions was originally created by Steven Zweier

Comments
  • not found

    not found

    import <SZMentions/SZMentionsListener.h>

    /Users/me/Downloads/SZMentions-master/SZMentionsExample/SZMentionsExample/Classes/SZExampleMention.h:9:9: 'SZMentions/SZMentionsListener.h' file not found

    can you give me a suggestion?

    thanks

    julian

    opened by juliankauai 4
  • Bug in iOS 11

    Bug in iOS 11

    The swift version here is okey but this is wrong in iOS 11. Plz help me check this again. Plz refer image bellow: screen shot 2017-09-27 at 11 36 55

    According I'm trying to pod swift version to my Objective-C project but cannot run

    opened by nguyenvantrai2011 2
  • How to cancel search?

    How to cancel search?

    Is there a way to cancel searching and not resign the textView's firstResponder? I want to allow users to cancel searching by tapping a button or the textView.

    My mentions listener has spaceAfterMention, addMentionOnReturnKey, and searchSpaces all set to true.

    opened by camdengaba 0
  • Correct the spelling of CocoaPods in README

    Correct the spelling of CocoaPods in README

    This pull requests corrects the spelling of CocoaPods šŸ¤“ https://github.com/CocoaPods/shared_resources/tree/master/media

    Created with cocoapods-readme.

    opened by ReadmeCritic 0
  • [Question] Is there anything implemented to

    [Question] Is there anything implemented to "read back" mentions from TextView?

    Let's say I'm using your example and I type something like "A test with @Steven Zweier library"

    When reading back the textView.text, it would read back as "A test with Steven Zweier library".

    Is there anything implemented to return this String informing what was a mention and what is "plain text", for example, to be able to set differently in Labels later, identifying the mention? Or is this something that should be implemented at a high level?

    If so, do you recommend anything specific to be able to identify this?

    opened by alezoffoli 0
  • How to remove mention in one stroke while typing backspace

    How to remove mention in one stroke while typing backspace

    Hi @szweier , Awesome library you have made. I have integrated it in my code. Working fine. But just one feature I want, that is to remove mention in just one stroke while backspacing. I just tried the following code,

    if let mention = mentions |> mentionBeingEdited(at: range) { mention |> clearMention() /* let str = mentionsTextView.attributedText.string let replaceStr = NSAttributedString(string:str.replacingOccurrences(of: mention.object.display, with: "")) print("NAME ",mention.object.display) print("RANGE ",range) let str = mentionsTextView.attributedText.string let replacedNameString = str.replacingOccurrences(of: mention.object.display, with: "")O print("NAME AFTER REPLACE ",replacedNameString) let (text, selectedRange) = mentionsTextView.attributedText |> replace(charactersIn: NSRange(str.startIndex..., in: str), with: replacedNameString) print("TEXT ",text.string) print("selectedRange ",selectedRange)*/ // mentionsTextView.selectedRange = NSRange(mention.object.display.startIndex..., in: mention.object.display) self.mentionsTextView.text = self.mentionsTextView.text.replacingOccurrences(of: mention.object.display, with: "") print("self.mentionsTextView.text ",self.mentionsTextView.text) print("mentionsTextView.attributedText ",mentionsTextView.attributedText) print("RANGE ",NSRange(self.mentionsTextView.text.startIndex..., in: self.mentionsTextView.text)) print(mentions.count) let (text, selectedRange) = mentionsTextView.attributedText |> replace(charactersIn: NSRange(self.mentionsTextView.text.startIndex..., in: self.mentionsTextView.text), with: self.mentionsTextView.text) /let (text, selectedRange) = mentionsTextView.attributedText |> replace(charactersIn: range, with: text)/ mentionsTextView.attributedText = text mentionsTextView.selectedRange = selectedRange shouldChangeText = false

    above code is working fine, when we tried to remove mention from last. But if we tried to remove it from the middle then app crashed.

    Example. Suppose I have a note like this, test @abc and @pqr 1] Now if I start to remove mention @pqr first, then it will remove in one stroke 2] But when I start to remove mention @abc first, then app crashes. Please help if anyone is having the solution for this

    opened by kiran4991 0
  • not calling delegate method with new line

    not calling delegate method with new line

    when trying @text with new line in textview delegate method "showMentionsListWithString" not being called. can you please help for the same?

    opened by DhavalBhimani 0
Owner
Steven Zweier
Swift
Steven Zweier
Framework to help you better manage UITableViews

UITableView made simple ?? Main Features ?? Skip the UITableViewDataSource & UITableViewDelegate boilerplate and get right to building your UITableVie

null 84 Feb 4, 2022
SwiftUI-Text-Animation-Library - Text animation library for SwiftUI

āš ļø This repository is under construction. SwiftUI Text Animation Library Make yo

null 28 Jan 8, 2023
This library for animating text. Developed with SwiftUI. This library supports iOS/macOS.

AnimateText This library for animating text. Developed with SwiftUI. This library supports iOS/macOS. Screenshot AnimateText.mp4 Example https://fabul

jasu 123 Jan 2, 2023
A Swift library to take the power of UIView.animateWithDuration(_:, animations:...) to a whole new level - layers, springs, chain-able animations and mixing view and layer animations together!

ver 2.0 NB! Breaking changes in 2.0 - due to a lot of requests EasyAnimation does NOT automatically install itself when imported. You need to enable i

Marin Todorov 3k Dec 27, 2022
An iOS library to natively render After Effects vector animations

Lottie for iOS, macOS (and Android and React Native) View documentation, FAQ, help, examples, and more at airbnb.io/lottie Lottie is a mobile library

Airbnb 23.6k Dec 31, 2022
A library to simplify iOS animations in Swift.

Updated for Swift 4.2 Requires Xcode 10 and Swift 4.2. Installation Drop in the Spring folder to your Xcode project (make sure to enable "Copy items i

Meng To 14k Jan 3, 2023
Swift library for choreographing animations on the screen.

Spruce iOS Animation Library (and Android) What is it? Spruce is a lightweight animation library that helps choreograph the animations on the screen.

WillowTree, LLC 3.4k Jan 3, 2023
A fantastic Physical animation library for swift

A fantastic Physical animation library for swift(Not Just Spring !!!), it is base on UIDynamic and extension to it, friendly APIs make you use it or c

August 2.9k Jan 4, 2023
Easy animation library on iOS with Swift2

Cheetah Cheetah is an animation utility on iOS with Swift. Cheetah can animate any properties since Cheetah uses simple CADisplayLink run loop to chan

Suguru Namura 592 Dec 6, 2022
A radical & elegant animation library for iOS.

Installation ā€¢ Usage ā€¢ Debugging ā€¢ Animatable Properties ā€¢ License Dance is a powerful and straightforward animation framework built upon the new UIVi

Saoud Rizwan 648 Dec 14, 2022
Fortune spinning wheel library built using SwiftUI, supports dynamic content.

Fortune Wheel Fortune spinning wheel ?? library built using SwiftUI, supports dynamic content. Preview - Spin Wheel āš™ļø CocoaPods Installation FortuneW

Sameer Nawaz 51 Dec 23, 2022
An extensible iOS and OS X animation library, useful for physics-based interactions.

Pop is an extensible animation engine for iOS, tvOS, and OS X. In addition to basic static animations, it supports spring and decay dynamic animations

Meta Archive 19.8k Dec 28, 2022
A library of custom iOS View Controller Animations and Interactions.

RZTransitions is a library to help make iOS7 custom View Controller transitions slick and simple. Installation CocoaPods (Recommended) Add the followi

Rightpoint 1.9k Nov 20, 2022
A powerful, elegant, and modular animation library for Swift.

MotionMachine provides a modular, powerful, and generic platform for manipulating values, whether that be animating UI elements or interpolating prope

Brett Walker 387 Dec 9, 2022
An Objective-C animation library used to create floating image views.

JRMFloatingAnimation [![CI Status](http://img.shields.io/travis/Caroline Harrison/JRMFloatingAnimation.svg?style=flat)](https://travis-ci.org/Caroline

Caroline Harrison 233 Dec 28, 2022
SamuraiTransition is an open source Swift based library providing a collection of ViewController transitions featuring a number of neat ā€œcuttingā€ animations.

SamuraiTransiton is a ViewController transition framework in Swift. It is an animation as if Samurai cut out the screen with a sword. transition types

hachinobu 273 Dec 29, 2022
Swift animation library for iOS, tvOS and macOS.

anim is an animation library written in Swift with a simple, declarative API in mind. // moves box to 100,100 with default settings anim { self.bo

Onur Ersel 555 Dec 12, 2022
Animation library for iOS in Swift

TweenKit TweenKit is a powerful animation library that allows you to animate (or 'tween') anything. TweenKit's animations are also scrubbable, perfect

Steve Barnegren 1.3k Dec 18, 2022