Skip to content

Commit

Permalink
Add customLayoutItems for android
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshLipan committed Sep 11, 2018
1 parent d408210 commit aeb0e2a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
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

0 comments on commit aeb0e2a

Please sign in to comment.