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

Add custom menu API #453

Merged
merged 16 commits into from
Sep 11, 2018
Prev Previous commit
Next Next commit
Add customLayoutItems for android
  • Loading branch information
JoshLipan committed Sep 11, 2018
commit aeb0e2a55dca8ef8b5e622ffee4b51784f6fce6e
2 changes: 1 addition & 1 deletion ReactNative/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'cn.jiguang.imui:messagelist:0.7.4'
compile 'cn.jiguang.imui:chatinput:0.8.3'
compile 'cn.jiguang.imui:chatinput:0.9.0'
compile 'pub.devrel:easypermissions:1.0.1'
compile 'org.greenrobot:eventbus:3.0.0'
implementation 'com.android.support:appcompat-v7:27.1.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import cn.jiguang.imui.chatinput.listener.OnCameraCallbackListener;
import cn.jiguang.imui.chatinput.listener.OnMenuClickListener;
import cn.jiguang.imui.chatinput.listener.RecordVoiceListener;
import cn.jiguang.imui.chatinput.menu.Menu;
import cn.jiguang.imui.chatinput.model.FileItem;
import cn.jiguang.imui.chatinput.model.VideoItem;
import cn.jiguang.imui.messagelist.AuroraIMUIModule;
Expand Down Expand Up @@ -554,6 +555,7 @@ public void onPageScrollStateChanged(int state) {

}
});

return mChatInput;
}

Expand Down Expand Up @@ -742,6 +744,44 @@ public void hidePhotoButton(ChatInputView chatInputView, boolean hide) {
chatInputView.getPhotoBtnContainer().setVisibility(hide ? View.GONE : View.VISIBLE);
}

@ReactProp(name = "customLayoutItems")
public void setCustomItems(ChatInputView chatInputView, ReadableMap map) {
ReadableArray left = map.hasKey("left")?map.getArray("left"):null;
ReadableArray right = map.hasKey("right")?map.getArray("right"):null;
ReadableArray bottom = map.hasKey("bottom")?map.getArray("bottom"):null;
String[] bottomTags = new String[0];
if(bottom!=null){
bottomTags = new String[bottom.size()];
for(int i =0;i<bottom.size();i++){
bottomTags[i] = bottom.getString(i);
}
}

String[] leftTags = new String[0];
if(left!=null){
leftTags = new String[left.size()];
for(int i =0;i<left.size();i++){
leftTags[i] = left.getString(i);
}
}

String[] rightTags = new String[0];
if(right!=null){
rightTags = new String[right.size()];
for(int i =0;i<right.size();i++){
rightTags[i] = right.getString(i);
}
}
mChatInput.getMenuManager()
.setMenu(Menu.newBuilder()
.customize(true)
.setLeft(leftTags)
.setRight(rightTags)
.setBottom(bottomTags)
.build());

}

@Override
public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
return MapBuilder.<String, Object>builder()
Expand Down
1 change: 1 addition & 0 deletions ReactNative/chatinput.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ ChatInput.propTypes = {
hideVoiceButton: PropTypes.bool,
hideEmojiButton: PropTypes.bool,
hidePhotoButton: PropTypes.bool,
customLayoutItems: PropTypes.object,
...ViewPropTypes
};

Expand Down