Skip to content

pmattos/ExpandableTextView

Repository files navigation

ExpandableTextView

This project provides a sample SwiftUI based integration for the TextExpander SDK.

The SDK integration is provided by the custom ExpandableTextView SwiftUI view. This provides a simple, reusable, (almost) self-contained component to quickly support the TextExpander SDK in any SwiftUI based app. This includes supports for the following TextExpander features:

  • inline snippets expansion
  • fill-in support for complex snippets (done externally by the TextExpander app)
  • simple snippets library management (e.g., synchronization, clearing, etc)

The ExpandableTextView works just like any other SwiftUI view that binds to a String value (e.g., TextField, TextEditor, etc), for instance:

struct TextEditingView: View {
    @State private var text: String = "Hello World"

    var body: some View {
        ExpandableTextView(text: $text)
    }
}

The ExpandableTextView view wraps a UITextView, providing all expected multi-line text editing capabilities. The UITextView delegate is implemented by an internal, per view SMTEDelegateController instance. The global TextExpander settings are controlled by the TextExpanderStatus singleton.

Finally, the sample app shows two ExpandableTextView working side by side plus some global settings, as demonstrated by the video below:

Demo.mp4

Future Ideas

In the future, we could extend this in the following ways:

  • Support for rich text editing (i.e., attributed strings, etc).
  • Expose this as a proper Swift Package framework around the aforementioned reusable ExpandableTextView.
  • Improve the ExpandableTextView API, providing per view settings such as: turning off snippets expansion; turning off fill-in support; etc.
  • Provide more information about the number of available snippets, last synchronization date, etc.

About

Sample TextExpander SDK integration using SwiftUI.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors