Skip to content

Splash04/TagTextView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TagTextView

This is a continuation of the project DPTagTextView created by Datt1994 (Datt Patel) · GitHub . SwiftUI wrapper was taken from GitHub - SwiftUI-Plus/TextView: Provides a SwiftUI multi-line TextView implementation including support for auto-sizing. (iOS) repository created by shaps80 (Shaps) · GitHub. TagTextView Demo

Example

To run the example project, clone the repo, and run pod install from the TagTextViewExample directory first.

Story

I was not able to find Tag TextView with need for my project functionality and SwiftUI support. So to speed up the development process, I had taken DPTagTextView and update it. Please feel free to report any issue you will face with.

Installation

pod 'TagTextView', '~> 1.0.2'
https://github.com/Splash04/TagTextView.git

Usage

You have to add logs component first if you want your logs to be separated by components:

TagTextView(
    $viewModel.inputText,
    tags: $viewModel.selectedTagsList,
    onDidBeginEditing: {
        viewModel.inputState = .selected
    },
    onDidEndEditing: {
        viewModel.inputState = .base
    },
    didChangedTagSearchString: { searchString, isHashTag in
        if !isHashTag {
            viewModel.searchTags(by: searchString)
        } else {
            viewModel.searchTags(by: nil)
        }
    }
)
.placeholder(viewModel.placeholder ?? .empty) {
    $0.foregroundColor(Color(viewModel.inputState.textFieldStyle.placeholder.textColor))
}
.foregroundColor(viewModel.inputState.textFieldStyle.text.textColor)
.font(Constants.inputTextFont)
.textLengthLimit(1000)
.mentionColor(Constants.mentionColor)
.mentionFont(Constants.inputTextFont)
.mentionMinLength(3)
.hashTagColor(Constants.hashTagColor)
.hashTagFont(Constants.inputTextFont)
.scrollingBehavior(.maxHeight(100))
.padding(.vertical, 4)
.padding(.horizontal, 12)
.background {
    RoundedRectangle(cornerRadius: viewModel.inputState.cornerRadius)
        .stroke(Color(viewModel.inputState.borderColor), lineWidth: viewModel.inputState.borderWidth)
}
.padding(.vertical, 0)

See example and test projects for more details.

Still not ready

  • UIKit Example

Contributions

Any contribution is more than welcome! You can contribute through pull requests and issues on GitHub.

Author

Igor Kharytaniuk, kharytaniuk@gmail.com

License

TagTextView is available under the MIT license. See the LICENSE file for more info.

About

TagTextView for SwiftUI and UIKit

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors