Skip to content

Commit ca64e19

Browse files
authored
Merge pull request #79 from zoyi-jin/0.7.1
0.7.1
2 parents 9c532fb + 43afb01 commit ca64e19

File tree

6 files changed

+76
-2
lines changed

6 files changed

+76
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.7.1
2+
## Update
3+
* support bootConfig - bubbleOption
4+
15
# 0.7.0
26
## Update
37
* Updated channeltalk plugin v10

android/src/main/java/com/zoyi/channel/rn/Const.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class Const {
1818
public static final String KEY_TRACK_DEFAULT_EVENT = "trackDefaultEvent";
1919
public static final String KEY_HIDE_POPUP = "hidePopup";
2020
public static final String KEY_CHANNEL_BUTTON_OPTION = "channelButtonOption";
21+
public static final String KEY_BUBBLE_OPTION = "bubbleOption";
2122
public static final String KEY_TAGS = "tags";
2223
public static final String KEY_PROFILE_ONCE = "profileOnce";
2324
public static final String KEY_ID = "id";
@@ -43,6 +44,10 @@ public class Const {
4344
public static final String KEY_X_MARGIN = "xMargin";
4445
public static final String KEY_Y_MARGIN = "yMargin";
4546

47+
// BubbleOption
48+
public static final String KEY_BUBBLE_POSITION_TOP = "top";
49+
public static final String KEY_BUBBLE_POSITION_BOTTOM = "bottom";
50+
4651
// Result
4752
public static final String RESULT_KEY_STATUS = "status";
4853
public static final String RESULT_KEY_ERROR = "error";

android/src/main/java/com/zoyi/channel/rn/ParseUtils.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
import java.util.*;
1313

14+
import io.channel.plugin.android.enumerate.BubblePosition;
15+
import io.channel.plugin.android.open.option.BubbleOption;
16+
1417
/**
1518
* Created by jerry on 2018. 10. 11..
1619
*/
@@ -200,6 +203,25 @@ public static ChannelButtonOption toChannelButtonOption(ReadableMap channelButto
200203
return null;
201204
}
202205

206+
public static BubbleOption toBubbleOption(ReadableMap bubbleOptionMap) {
207+
if (bubbleOptionMap != null) {
208+
String positionString = Utils.getString(bubbleOptionMap, Const.KEY_POSITION).getValue();
209+
Double yPosition = Utils.getDouble(bubbleOptionMap, Const.KEY_Y_MARGIN).getValue();
210+
211+
if (positionString != null && yPosition != null) {
212+
switch (positionString) {
213+
case Const.KEY_BUBBLE_POSITION_TOP:
214+
return new BubbleOption(BubblePosition.TOP, yPosition.floatValue());
215+
216+
case Const.KEY_BUBBLE_POSITION_BOTTOM:
217+
return new BubbleOption(BubblePosition.BOTTOM, yPosition.floatValue());
218+
}
219+
}
220+
}
221+
222+
return null;
223+
}
224+
203225
private static Profile toProfile(ReadableMap profileMap) {
204226
if (profileMap != null) {
205227
Profile profile = Profile.create();
@@ -290,6 +312,11 @@ public static BootConfig toBootConfig(ReadableMap configMap) {
290312
bootConfig.setChannelButtonOption(toChannelButtonOption(channelButtonOption.getValue()));
291313
}
292314

315+
MapEntry<ReadableMap> bubbleOption = Utils.getReadableMap(configMap, Const.KEY_BUBBLE_OPTION);
316+
if (bubbleOption.hasValue()) {
317+
bootConfig.setBubbleOption(toBubbleOption(bubbleOption.getValue()));
318+
}
319+
293320
MapEntry<ReadableMap> profile = Utils.getReadableMap(configMap, Const.KEY_PROFILE);
294321
if (profile.hasValue()) {
295322
bootConfig.setProfile(toProfile(profile.getValue()));

ios/RCTConvert+ChannelIO.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static NSString * const BOOT_STATUS_REQUIRE_PAYMENT = @"REQUIRE_PAYMENT";
3434
static NSString * const BOOT_STATUS_ACCESS_DENIED = @"ACCESS_DENIED";
3535
static NSString * const BOOT_STATUS_UNKNOWN_ERROR = @"UNKNOWN_ERROR";
3636

37-
// ChannelBUttonOption
37+
// ChannelButtonOptionPosition
3838
static NSString * const KEY_CHANNEL_BUTTON_OPTION_POSITION_RIGHT = @"right";
3939
static NSString * const KEY_CHANNEL_BUTTON_OPTION_POSITION_LEFT = @"left";
4040

@@ -45,11 +45,22 @@ static NSString * const CHANNEL_BUTTON_OPTION_POSITION_LEFT = @"left";
4545
static NSString * const CHANNEL_BUTTON_OPTION_X_MARGIN = @"xMargin";
4646
static NSString * const CHANNEL_BUTTON_OPTION_Y_MARGIN = @"yMargin";
4747

48+
// BubblePostition
49+
static NSString * const KEY_BUBBLE_POSITION_TOP = @"top";
50+
static NSString * const KEY_BUBBLE_POSITION_BOTTOM = @"bottom";
51+
52+
// BubbleOption
53+
static NSString * const BUBBLE_OPTION_POSITION = @"position";
54+
static NSString * const BUBBLE_OPTION_POSITION_TOP = @"top";
55+
static NSString * const BUBBLE_OPTION_POSITION_BOTTOM = @"bottom";
56+
static NSString * const BUBBLE_OPTION_Y_MARGIN = @"yMargin";
57+
4858
static NSString * const KEY_PLUGIN_KEY = @"pluginKey";
4959
static NSString * const KEY_MEMBER_HASH = @"memberHash";
5060
static NSString * const KEY_HIDE_POPUP = @"hidePopup";
5161
static NSString * const KEY_TRACK_DEFAULT_EVENT = @"trackDefaultEvent";
5262
static NSString * const KEY_CHANNEL_BUTTON_OPTION = @"channelButtonOption";
63+
static NSString * const KEY_BUBBLE_OPTION = @"bubbleOption";
5364
static NSString * const KEY_UNSUBSCRIBE_EMAIL = @"unsubscribeEmail";
5465
static NSString * const KEY_UNSUBSCRIBE_TEXTING = @"unsubscribeTexting";
5566

ios/RCTConvert+ChannelIO.m

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ @implementation RCTConvert (ChannelIOEnums)
4545
integerValue
4646
)
4747

48+
RCT_ENUM_CONVERTER(
49+
BubblePosition,
50+
(@{BUBBLE_OPTION_POSITION_TOP: @(BubblePositionTop),
51+
BUBBLE_OPTION_POSITION_BOTTOM: @(BubblePositionBottom)
52+
}),
53+
BubblePositionTop,
54+
integerValue
55+
)
56+
4857
@end
4958

5059
@implementation RCTConvert (ChannelIO)
@@ -59,6 +68,7 @@ + (BootConfig *)bootConfig:(id)json {
5968
? [RCTConvert BOOL:json[KEY_TRACK_DEFAULT_EVENT]] : [RCTConvert BOOL:json[KEY_ENABLED_TRACK_DEFAULT_EVENT]];
6069
config.unsubscribeEmail = [RCTConvert BOOL:json[KEY_UNSUBSCRIBE_EMAIL]];
6170
config.unsubscribeTexting = [RCTConvert BOOL:json[KEY_UNSUBSCRIBE_TEXTING]];
71+
config.bubbleOption = [RCTConvert bubbleOption:json[KEY_BUBBLE_OPTION]];
6272

6373
if (json[KEY_LAUNCHER_CONFIG] == nil && json[KEY_CHANNEL_BUTTON_OPTION] != nil) {
6474
config.channelButtonOption = [RCTConvert channelButtonOption:json[KEY_CHANNEL_BUTTON_OPTION]];
@@ -134,4 +144,21 @@ + (ChannelButtonOption *)channelButtonOption:(id)json {
134144
return option;
135145
}
136146

147+
+ (BubbleOption *)bubbleOption:(id)json {
148+
if (json == nil) {
149+
return nil;
150+
}
151+
152+
BubbleOption *option = [[BubbleOption alloc] init];
153+
154+
option.yMargin = [RCTConvert NSNumber:json[BUBBLE_OPTION_Y_MARGIN]];
155+
NSString *position = [RCTConvert NSString:json[BUBBLE_OPTION_POSITION]];
156+
if ([position isEqualToString:BUBBLE_OPTION_POSITION_TOP]) {
157+
option.position = BubblePositionTop;
158+
} else {
159+
option.position = BubblePositionBottom;
160+
}
161+
return option;
162+
}
163+
137164
@end

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-channel-plugin",
3-
"version": "0.7.0",
3+
"version": "0.7.1",
44
"description": "react native module for channel io",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)