badoo / badoo/Chatto

Enable send Button in custom ChatInputItem

Open
#38 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
4.6k
Forks
588
PR merge metrics
No merged PRs in 30d

Description

I have created my own ChatInputItem where the user can specify a date and a location. After the data has been entered the send button should get active so that I can call my REST-service to create an appointment request.

To achive this I think I need two modifications from you:
1. A way to enable the send button
2. Some kind of hook to inform me that the send button was pressed. Then I send the create appointent request to my backend that creates a message for me and the receiver that should be displayed in the chat module (For the receiver the message contains buttons to reply - but this problem is already solved).

Here my AppointmentInputItem:

```
extension AppointmentInputItem : ChatInputItemProtocol {

public var presentationMode: ChatInputItemPresentationMode {
return .CustomView
}

public var showsSendButton: Bool {

return true
}

public var inputView: UIView? {

if let view = self.appointmentInputView{
return view
}
if let customView = NSBundle.mainBundle().loadNibNamed("AppointmentInput", owner: self, options: nil).first as? AppointmentInputView {

customView.frame = CGRectMake(0, 0, 300, 250)

return customView
}
return nil

}

public var tabView: UIView {
return self.internalTabView
}

public func handleInput(input: AnyObject) {}
```

Another problem that I discovered is that the AppointmentInputItem loses its focus if I launch an UIAlertController to ask for another location. It would be great if this could be prevented too.

Contributor guide

Open the contributing guide

Research direction

Start from ChatInputItemProtocol and the AppointmentInputItem example in the issue, then trace how the chat module handles showsSendButton, input events, and focus changes. Done should provide a way for a custom item to enable the send button, receive a send callback, and retain focus when an UIAlertController is presented.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
mobile-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.