Coder Social home page Coder Social logo

nathantannar4 / inputbaraccessoryview Goto Github PK

View Code? Open in Web Editor NEW
1.1K 21.0 227.0 6.15 MB

A simple and easily customizable InputAccessoryView for making powerful input bars with autocomplete and attachments

License: MIT License

Swift 99.47% Objective-C 0.21% Shell 0.32%
swift input uikit uicomponent

inputbaraccessoryview's People

Contributors

aldrincb avatar andrewsb avatar austinwright avatar barakgong avatar carlsondev avatar cwalo avatar danqing avatar frizlab avatar geraldvoit avatar hemangshah avatar jameshays avatar kaspik avatar landonr avatar lordcodes avatar martinpucik avatar muhtasimtanmoy avatar nathantannar4 avatar nixon506e avatar rivera-ernesto avatar sebastienkb avatar sgraesser avatar thomassnielsen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

inputbaraccessoryview's Issues

How to add a custom separator at top?

Hi @nathantannar4 , thanks for this project!
So, i need to customize the top separator ( i can hide the default ). But how to add an UIView at top ( UIStack top ). There is a way ? Reeded all README file and GET START too.
Thanks!

Pod install issue

Hello,

[!] Unable to find a specification for InputBarAccessoryView

Text input maximum number of lines

How do you set the text input to only grow to a maximum number of lines before it becomes scrollable instead.

I have seen the ability to set the maximum height of the view, however, this value is automatically set at certain places in the code.

To set the max height height to 3 lines, I currently have the following.

        inputBar.shouldAutoUpdateMaxTextViewHeight = false
        inputBar.maxTextViewHeight = 70

However, the maxTextViewHeight can be set back to default by a method for if the view moves to a new window. Not sure when this might happen though.

Do you know if the above is the best way of achieving this? Or if there is a nicer way?

Cannot Run example project

getting this error No such module 'InputBarAccessoryView'

there is no pod file in root of example folder

Also, this error occur

directory not found for option '-F/Users//Library/Developer/Xcode/DerivedData//Build/Products/Debug-iphonesimulator/InputBarAccessoryView'

Pasting multiple lines causes whitespace at the bottom of the view

Hi, it seems that pasting text consisting of multiple lines causes a lot of whitespace to appear at the bottom.
Steps to repro:

  1. Start the example app
  2. Select any of the styles
  3. Paste some multiline text
    Expected result: Last line of text is at the bottom of the control
    Actual result: Last line of text is almost at the top.

Here's some text that shows the issue:

A beluga whale seen in the Thames for a second day is "swimming strongly and feeding normally", the RSPCA has said. The animal welfare charity said the whale, nicknamed Benny, had moved towards the estuary, and there were no major concerns for its welfare. It was first spotted around barges in the Thames on Tuesday near Gravesend.

Thanks!

Focussing input text view before view appeared

We've found self.bar.inputTextView.becomeFirstResponder() has to be called in or after viewDidAppear. Placing this call earlier in the view's lifecycle has no effect. We've also tried calling becomeFirstResponder() then this call to no avail.

We'd like the input text view to be focussed without animation immediately (akin to Messenger). How can we go about this?

Input bar disappear when have another textfield

Hi, i have a bug little complicate to explain

I have a textfield in the view where I use the InputBarAccessoryView

When I select this textfield, InputBarAccessoryView disappear as I expect, but when I resignFirstResponder my texfield and keyboard disappear InputBarAccessoryView is gone and never come back again... Any suggestion?

Adding Video as an Attachment - Thumbnail not showing

Hi, I am trying to add a video as an attachment to the input bar. I have tried both ways by adding as Data and by adding as URL. It doesn't show up the thumbnail of the video in the attachment.

Do you have any idea how to show the thumbnail if Video is attached from UIImagePickerController?

Content offset problem

Hi @nathantannar4

The content offset is wrong when user enter the scrollable view, the bottom item is unreadable though user scroll to the bottom. But when user tap the input text field, keyboard show, the bottom item can be seen again

image

image

InputBar stack over keyboard

I download example project and run it.
but when I switch app to Facebook message rand in Facebook messager app is active keyboard and I switch return to example app it happen

Device

  • iPhone XS

** example subview style
IMG_7345

** and InputAccessView happen same subview but I animation down to correct positions like pull down to hide

thank you

Any way to add extra panel to the bottomStackView?

I try it this way:

messageInputBar.bottomStackView.axis = .vertical
messageInputBar.bottomStackView.distribution = .fillProportionally

Then I add two stackViews to the bottomStackView

messageInputBar.bottomStackView.addArrangedSubview(toolBarStackView)
messageInputBar.bottomStackView.addArrangedSubview(functionPanelStackView)

It only shows the first stackView which is toolBarStackView

What I want is to add a functionPanel below it so I can add extra content in it.

Swift 4.2 Issue

Not all warnings and renames was changed in last update.
For example
2018-09-21 15 41 22

Another text field with an input accessory view possible?

This may be an interesting question.

I have a scenario in my app where I need a view controller to have a text view in an inputAccessoryView and a text field at the top. This works great, when both become first responder the bottom input bar is always above the keyboard as desired. But it gets interesting when I assign an inputAccessoryView to the top text field. This causes the input bar to drop down to the bottom underneath the keyboard and only that text field's input accessory view is visible. I actually need both to be visible. It sounds strange, but the top text field's input accessory view blends right into the keyboard, so it would appear as part of the keyboard with a single input accessory view even though it's actually two stacked views. Do you see any way to do that?

Looks like it might work with the subview approach instead but this isn't really acceptable because when you drag down on the keyboard the input bar sluggishly responds.

RTL support

I've reversed the stack views to provide a RTL layout with the send button on the left and input on the right. Unfortunately the placeholder's constraints means it stays on the left of this input bar regardless of the underlying text views alignment:
simulator screen shot - iphone x - 2018-07-10 at 09 05 14
These are the programmatic constraints related to the UILabel acting as the placeholder, from what I can gather this is referencing the left and right anchors of the parent, aka UITextView. For this reason I'm confused to why the UILabel isn't the full width of the UITextView?

If this were the case I could easily set the text alignment property on the placeholder to achieve the RTL effect.

Send button text too long when internationalized

I'm trying to internationalize the text of the send button in InputBarAccessoryView in MessageKit. The text in French is a little longer than the text in English ("Envoyer" vs "Send") and the size of the button seems to be fixed. I tried the following code but it doesn't seem to work:

    messageInputBar.sendButton.configure {
        let font = UIFont.systemFont(ofSize: 15, weight: .bold)
        
        let fontAttributes = [NSAttributedString.Key.font: font]
        let title = NSLocalizedString("Send", comment: "")
        let size = (title as NSString).size(withAttributes: fontAttributes)
        
        $0.setSize(CGSize(width: size.width + 10, height: 36), animated: false)
        $0.title = title
        $0.titleLabel?.font = font
    }

How can I change the title of the button and adapt its width automatically?

KeyboardManager doesn't seem to handle bottom UITabBar

My app has a bottom UITabBarController.tabBar and I believe that the KeyboardManager doesn't handle it out of the box.

The InputBar has a red background color.

I'm using the code from the "Example" folder.

Initial state:

image

When opening the keyboard state, there is a white padding that I suspect coming from the UITabBar:

image

EDIT: I found out that trying to pass a potentiel uitabbar in @discardableResult open func bind(inputAccessoryView: UIView, usingTabBar tabBar: UITabBar? = nil) -> Self does fix the problem as so:

    let tabBarHeight = tabBar?.bounds.size.height ?? 0
    callbacks[.willShow] = { [weak self] (notification) in
        let keyboardHeight = notification.endFrame.height
        guard
            self?.isKeyboardHidden == false,
            self?.constraints?.bottom?.constant == 0,
            notification.isForCurrentApp else { return }
        self?.animateAlongside(notification) {
            self?.constraints?.bottom?.constant = -keyboardHeight + tabBarHeight
            self?.inputAccessoryView?.superview?.layoutIfNeeded()
        }
    }
    callbacks[.willChangeFrame] = { [weak self] (notification) in
        let keyboardHeight = notification.endFrame.height
        guard
            self?.isKeyboardHidden == false,
            notification.isForCurrentApp else { return }
        self?.animateAlongside(notification) {
            self?.constraints?.bottom?.constant = -keyboardHeight + tabBarHeight
            self?.inputAccessoryView?.superview?.layoutIfNeeded()
        }
    }

Framework error

I have downloaded the code and trying to run the example but getting error for missing framework

also getting this error No such module 'InputBarAccessoryView'

Jumpy `inputAccessoryView ` when used in a UIViewController but not when in UITableViewController

The inputAccessoryView jumps up and down when used in a UIViewController but not when in UITableViewController/UICollectionViewController

You can recreate this by simply changing the Example to a UIViewController.

I'm using ASyncDisplayKit's ASCollectionNode instead of UIKit's collection view for performance, therefore I'm using a UIViewController. Have I missed something or are there any known solutions for this?

jumpy

Offset Position for TabBarController

InputBarAccessoryView covers tabBarController. I didn't see a setting to offset the backgroundView. Is this possible? Much of the methods or properties like backgroundViewBottomAnchor are private.

I tried resetting some anchors but didn't take effect.

Thanks!

Replace hardcoded screen height check for iPhone X

In InputBarAccessoryViewController, the function setupConstraints(to window: UIWindow?) is modifying a constraint if UIScreen.main.nativeBounds.height == 2436. This will not work for iPhone XS Max, iPhone XR, and iPads should they gain a home indicator in place of a home button. Can this be updated to go off something other than the screen height?

Aysnc Autocomplete Results

I need to develop a better way to return async results. I welcome any input.

Currently, the method of doing this is to fetch your async results, cache them in an array, and then call reloadData() on AutocompleteManager (assuming you are also using the AutocompleteManagerDataSource

Async autocomplete

Hey, great job on the library!

Is it possible to have async autocomplete results ?

Constraint bug when setting inputTextView text directly to long string

I am having an issue with the inputBarAccessoryView within an app.

We need to set a draft message that was previously stored. This is done using:

inputBar.inputTextView.text = draftMessage

In our app this causes the inputBarTextView to grow past the top of the screen (going underneath status bar) and the inputBarTextView is left unscrollable so you cannot scroll within it. However, when I reproduced this in the example app, the box doesn't go beyond the maximum height, however, it is still not scrollable, so the same issue has been encountered.

If you look in the console when this happens, it is due to some conflicting constraints and so the end result in UI depends on which constraints the system decides to break.

2018-10-22 14:01:14.392632+0100 Example[63316:4832764] [LayoutConstraints] Unable to simultaneously satisfy constraints.
	Probably at least one of the constraints in the following list is one you don't want. 
	Try this: 
		(1) look at each constraint and try to figure out which you don't expect; 
		(2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x600003df63f0 UIView:0x7fb4e6e4a740.bottom == UILayoutGuide:0x6000027c55e0'UIViewSafeAreaLayoutGuide'.bottom - 6   (active)>",
    "<NSLayoutConstraint:0x600003df63a0 V:|-(0)-[InputBarAccessoryView.InputStackView:0x7fb4e6e55c40]   (active, names: '|':Example.iMessageInputBar:0x7fb4e6e47a40 )>",
    "<NSLayoutConstraint:0x600003df6350 InputBarAccessoryView.InputStackView:0x7fb4e6e55c40.bottom == UIView:0x7fb4e6e4a740.top - 6   (active)>",
    "<NSLayoutConstraint:0x600003dda300 '_UITemporaryLayoutHeight' Example.iMessageInputBar:0x7fb4e6e47a40.height == 0   (active)>",
    "<NSLayoutConstraint:0x600003df5e00 'UIViewSafeAreaLayoutGuide-bottom' V:[UILayoutGuide:0x6000027c55e0'UIViewSafeAreaLayoutGuide']-(0)-|   (active, names: '|':Example.iMessageInputBar:0x7fb4e6e47a40 )>"
)

To reproduce in example app, I set long text at the end of viewDidLoad within CommonTableViewController.

inputBar.inputTextView.text = """
"""

I pasted about 10 paragraphs of lorum ipsum within the string.

Selecting text in the input view causes hang and ever-growing memory footprint

Multiple users have reported that long pressing to select text (paste works fine) causes the application to freeze. I am able to replicate fairly reliably with the Example project and in the context of MessageKit on devices running iOS 10.3.1 and 11.0.3. I've attached the potentially relevant bit from the Instruments trace, but ping me in slack for the full trace file. Possibly related to the getter for intrinsicContentSize? @nathantannar4

screen shot 2017-11-01 at 12 24 12 pm

screen shot 2017-11-01 at 12 25 40 pm

screen shot 2017-11-01 at 12 23 16 pm

Mention Spaces when not start of text not working

I've spent the day in the code trying to figure out a solution for this and haven't, so I'll throw it back to the author for guidance and hopefully a solution.

In my app and the Example app:
When I type @Rick S I get autocompletion results as expected.

When I type Hey @Rick I get autocompletion results as expected

When I add a space and type Hey @Rick or Hey @Rick S, I don't get results.

A couple of things I'm seeing.

  1. I think this code session.spaceCounter += spaceCountDiff on lie 410 of AutocompleteManager should read session.spaceCounter = spaceCountDiff. Otherwise, I don't see where session.spaceCounter ever decreases or resets to 0. It always grows. If it always grows, this line if let session = currentSession, session.spaceCounter <= maxSpaceCountDuringCompletion on 164 in AutocompleteManager always fails and the session is unregistered

  2. If I set session.spaceCount = spaceCountDiff, the code is then allowed to pass that mentioned if statement and the .whitespaces character set is removed from the copy of delimiters. This then calls textField.find with the set of prefixes and the reduced delimiter set. Since it no longer breaks on white spaces, the wordAtCarat function returns the entire string, causing result.word.hasPrefix(prefix) on line 20 of UITextView+Extensions to fail.

Any thoughts on how to resolve this?

Incorrect Behavior of Library?

I might be wrong, and don't want to sham on all the hard work of the library creator and contributors, but it seems that this project is missing some key functionality of the interactive keyboard + custom inputAccessoryView:

I ran the example and I noticed:

  • The content inset / visible cells aren't adjusted when the keyboard is shown/hidden as in Facebook/WhatsApp
  • The input accessory view's animation lags when dragging the keyboard up and down

Am I missing something here?

Thanks

Hiding the input text view

In some scenarios, we'd like the input bar to contain buttons only. Is there a way to collapse/hide the middle stack view?

InputBarAccessoryView overlaps navigationbar in landscape orientation

The InputBarAccessoryView overlaps navigationbar in landscape orientation.

I was testing MessageKit on my iPhone 7 and noticed a problem with the MessageInputBar overlapping the navigationbar so that lead me to testing the InputBarAccessoryView example on my iPhone 7 as well and they both have the same problems.

Steps to reproduce the issue:

  1. Launch Example project in portrait
  2. Start typing and press return on the keyboard to create multiple lines
  3. Rotate to landscape

The InputBarAccessorryView is now overlapping the navigationbar:
b98cd441-3990-4efa-92c6-84fab15446ee

I was also able to reproduce this issue in the iOS Simulator with the following steps:

  1. Launch Example project in portrait
  2. Press return multiple times to create multiple lines
  3. Rotate to landscape
  4. Make the keyboard visible if it isnt showing

The InputBarAccessorryView is now overlapping the navigationbar

endEditing not working

For usablity puposes I want the keyboard to disappear before the message is acutally send on pressing a button.

So I tried to use

  • inputBar.endEditing(true)
  • inputBar.inputTextView.endEditing(true)
  • self.view.endEditing(true)

But they are all not working. The inputBar stays active and the keyboard doesn't hide.
Any idea?

Input Bar appear automatic when dismissal image

Sorry I not good at English
In Chat view controller, I present a ImageView that has dismissal.
When i just try dismiss and release, not dismiss completion. inputbar automatic appear.
Please help me to prevent inputbar appear
ezgif com-optimize

Just one attachment

if you set

showAddAttachmentCell = false

because you want just 1 attachment

and press again the StackViewItems second attachment is added.

How can i set a maximum of 1 attachment or disable the StackViewItems wen one attachment is added?

CocoaPod could not find version 4.2.2

Hello, Thanks for your Awesome library :)
I tried to install InputBarAccessoryView with pod, but some error I found

CocoaPods could not find compatible versions for pod "InputBarAccessoryView":
  In Podfile:
    InputBarAccessoryView (= 4.2.2)

so I do it with 4.2.1 and It works well.

RxInputBarAccessoryViewDelegate

Hi !

Thank you for this awesome library.
I'd like to use the Rx proxy, but it seems that this extension is not accessible (not public) so I cannot use it. I tried using inputBar.rx_delegate but this is not recognized.

Maybe this extension could also be used like other rx libraries, so renaming rx_delegate to rx only ?

Thank you :)

Protocols shouldComplete & shouldUnregister

@nathantannar4 Using your example project... this is the output I get for shouldComplete and shouldUnregister

image

Tried to access manager.currentSession as the optional in image above. The text parameter is empty in shouldComplete

Shouldn't text be the autocomplete I selected?

Thanks!

Set long text to inputTextView height constraint bug

I am having an issue with the inputBarAccessoryView within an app.

We need to set a draft message that was previously stored. This is done using:

inputBar.inputTextView.text = draftMessage

In our app this causes the inputBarTextView to grow past the top of the screen (going underneath status bar) and the inputBarTextView is left unscrollable so you cannot scroll within it. However, when I reproduced this in the example app, the box doesn't go beyond the maximum height, however, it is still not scrollable, so the same issue has been encountered.

If you look in the console when this happens, it is due to some conflicting constraints and so the end result in UI depends on which constraints the system decides to break.

2018-10-22 14:01:14.392632+0100 Example[63316:4832764] [LayoutConstraints] Unable to simultaneously satisfy constraints.
	Probably at least one of the constraints in the following list is one you don't want. 
	Try this: 
		(1) look at each constraint and try to figure out which you don't expect; 
		(2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x600003df63f0 UIView:0x7fb4e6e4a740.bottom == UILayoutGuide:0x6000027c55e0'UIViewSafeAreaLayoutGuide'.bottom - 6   (active)>",
    "<NSLayoutConstraint:0x600003df63a0 V:|-(0)-[InputBarAccessoryView.InputStackView:0x7fb4e6e55c40]   (active, names: '|':Example.iMessageInputBar:0x7fb4e6e47a40 )>",
    "<NSLayoutConstraint:0x600003df6350 InputBarAccessoryView.InputStackView:0x7fb4e6e55c40.bottom == UIView:0x7fb4e6e4a740.top - 6   (active)>",
    "<NSLayoutConstraint:0x600003dda300 '_UITemporaryLayoutHeight' Example.iMessageInputBar:0x7fb4e6e47a40.height == 0   (active)>",
    "<NSLayoutConstraint:0x600003df5e00 'UIViewSafeAreaLayoutGuide-bottom' V:[UILayoutGuide:0x6000027c55e0'UIViewSafeAreaLayoutGuide']-(0)-|   (active, names: '|':Example.iMessageInputBar:0x7fb4e6e47a40 )>"
)

To reproduce in example app, I set long text at the end of viewDidLoad within CommonTableViewController.

inputBar.inputTextView.text = """
"""

I pasted about 10 paragraphs of lorum ipsum within the string.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.