Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with TextView ( add placeholder to TextView in Editor component ). #598

Closed
theolof opened this issue Nov 16, 2016 · 8 comments
Closed

Comments

@theolof
Copy link

theolof commented Nov 16, 2016

I used this code before:
var textView: TextView! /// A Text storage object that monitors the changes within the textView. lazy var text: Text = Text()
I did a pod update and now I cannot compile. "Use of undeclared type 'Text'".
Need help :-)

@daniel-jonathan
Copy link
Member

daniel-jonathan commented Nov 16, 2016

Hey,

So in Material 2, I silently launched a new component that is officially launched at the end of the month. It is called Editor. It now encapsulates all the work needed to setup a dynamic textView. Later today I will post an example for you, and for now if you can take a look at the Editor and EditorController API, that will get you started. For example:

let editor = Editor()
editor.textViewEdgeInsetsPreset = .square4
editor.textView.font = RobotoFont.regular

view.layout(editor).edges()

Place that code in a UIViewController and see what happens. You could also hook delegation methods and a new enum for tapping into character attributes. For example:

extension ViewController: EditorDelegate {
    @objc
    fileprivate func editor(editor: Editor, willProcessEditing textStorage: TextStorage, text: String, range: NSRange) {
        textStorage.updateAttributes(characterAttributes: [.font: RobotoFont.regular, .forgroundColor: Color.black], range: range)
    }

    @objc
    fileprivate func editor(editor: Editor, didProcessEditing textStorage: TextStorage, text: String, range: NSRange) {
        textStorage.updateAttributes(characterAttributes: [.font: RobotoFont.bold, .forgroundColor: Color.blue.base], range: range)
        print(editor.uniqueMatches)
    }
}

Let me know how it goes. Also, I made an issue Samples Editor Issue that we can use to get you up to speed with a sample project :)

@theolof
Copy link
Author

theolof commented Nov 17, 2016

Thanks, I'm trying to implement Editor now. I'll let you know how it goes.

@theolof
Copy link
Author

theolof commented Dec 13, 2016

I have Editor working now, but I still need the placeholder text. Can I do a workaround until you release the full version? Or is the full version coming really soon?

@daniel-jonathan
Copy link
Member

@theolof Its coming really soon :) When is the latest you need it by?

@theolof
Copy link
Author

theolof commented Dec 15, 2016

Well, we are ready to release the next version except for some color changes and this. Thinking of changing to TextField in the meantime.

@daniel-jonathan
Copy link
Member

Okay, I will do my best to have it done really soon. It is one of the final parts to releasing the Editor component. So I need it and want it done as well. Thanks for your patience.

@daniel-jonathan daniel-jonathan changed the title Problem with TextView Problem with TextView ( add placeholder to TextView in Editor component ). Dec 15, 2016
@daniel-jonathan
Copy link
Member

I am a few hours from being done the TextView will placeholder and simplified interface. I will push a release by tomorrow. Thank you!

@daniel-jonathan
Copy link
Member

Hey, please find your feature request in Material 2.6.0 and a sample TextView project. Thank you and all the best!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants