Skip to content

Sample App

Austin Zheng edited this page Feb 18, 2015 · 1 revision

Hakawai ships with a sample app that demonstrates some of its capabilities, including the Mentions plug-in. You can try it by running the CocoaPod command pod try Hakawai, or by cloning the project repository. Change the scheme to HakawaiDemo and build and run the app.

First Tab

The first tab demonstrates the basic features of the text view. Type some text into the text view, then select some or all of the text. Tap the Palindrome button to reverse the text, or the ROT13 button to apply a ROT13 transformation. Tap the Done Editing button to dismiss the keyboard.

Code for the first tab can be found in the BasicDemoViewController.m file. Both transformation buttons use the text view's block-based transformer API to define a transformation on the selected text that should be applied.

Second Tab

The second tab demonstrates the abstraction layer. Type text into the upper text field and watch the abstraction layer report higher-level text change events in the smaller scroll view.

Code for the second tab can be found in AbstractionLayerDemoViewController.m. A very simple control flow plug-in is implemented in SampleAbstractionLayerPLugin.m; this plug-in sits atop the abstraction layer, receiving events, and updates the scroll view accordingly.

Third Tab

The third tab demonstrates the mentions plug-in. Type text into the text field. The mentions plug-in will suggest entities (for demonstration's sake, the first 25 Turing Award winners) if you type in the control characters @ or +, or the first three characters of an entity's first name.

Code for the third tab can be found in the Mentions group. There are a number of changes you can make to try out different features.

  • If you want to see an example of a completely custom chooser, go to viewDidLoad: in MentionsDemoViewController.m and uncomment the line mentionsPlugin.chooserViewClass = [SimpleChooserView class];. The alternate chooser is defined in SimpleChooserView.swift and relies upon a picker view rather than the default chooser's table view.

  • If you want to see an example of custom mentions trimming behavior (in this case, trimming the entity name to the first 8 characters if it's longer than 8 characters), uncomment the line #define USE_CUSTOM_TRIMMING_BEHAVIOR in MentionsManager.m.

  • If you want to see an example of asynchronous loading, multiple responses, and a loading cell, comment out the line #define SHOULD_BE_SYNCHRONOUS in MentionsManager.m.

You are of course free to change the sample app code in any way you want. Experiment and try different things!

Default chooser Alternate chooser

Clone this wiki locally