Swiftpack.co -  krzyzanowskim/SwiftUI.TextEdit as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
krzyzanowskim/SwiftUI.TextEdit
SwiftUI proof-of-concept text edit component
.package(url: "https://github.com/krzyzanowskim/SwiftUI.TextEdit.git", from: "0.0.1")

SwiftUI TextEdit View

A proof-of-concept text edit component in SwiftUI & CoreText. No UIKit, No AppKit, no UITextView/NSTextView/UITextField involved.

Note Due to SwiftUI limitations (as of May 2021) it's not possible to handle keystrokes just with SwiftUI. To overcome this limitation, the UIKeyboardViewController is responsible for handling keys and forward to SwiftUI codebase.

If you have questions or want to reach to me, use this thread: https://twitter.com/krzyzanowskim/status/1269402396217745410

Authors

Marcin Krzyzanowski @krzyzanowskim

Screenshots

TextEdit 2021-05-03 19_00_33

Usage/Examples

struct TextEditingView: View {
    @State private var text = "type here...\n"
    @State private var font = UIFont.preferredFont(forTextStyle: .body) as CTFont
    @State private var carretWidth = 2.0 as CGFloat

    var body: some View {
        TextEdit(
            text: $text,
            font: $font,
            carretWidth: $carretWidth
        )
    }
}

FAQ

How?

CoreText + SwiftUI.

Why?

For fun and profit.

Related

Here are some related projects

CoreTextSwift

GitHub

link
Stars: 66
Last commit: Yesterday

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

20 weeks ago
  • Initial release

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics