提交
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// TUICustomerServicePluginPrivateConfig.h
|
||||
// TUICustomerServicePlugin
|
||||
//
|
||||
// Created by xia on 2023/7/5.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TUICustomerServicePluginPrivateConfig : NSObject
|
||||
|
||||
+ (TUICustomerServicePluginPrivateConfig *)sharedInstance;
|
||||
|
||||
@property (nonatomic, assign) BOOL canEvaluate;
|
||||
@property (nonatomic, copy) NSArray *customerServiceAccounts;
|
||||
|
||||
- (BOOL)isCustomerServiceAccount:(NSString *)userID;
|
||||
- (BOOL)isOnlineShopping:(NSString *)userID;
|
||||
|
||||
+ (BOOL)isCustomerServiceSupported;
|
||||
+ (void)checkCommercialAbility;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// TUICustomerServicePluginPrivateConfig.m
|
||||
// TUICustomerServicePlugin
|
||||
//
|
||||
// Created by xia on 2023/7/5.
|
||||
//
|
||||
|
||||
#import "TUICustomerServicePluginPrivateConfig.h"
|
||||
#import <TUIChat/TUIChatConfig.h>
|
||||
|
||||
static const long long kTUICustomerServiceCommercialAbility = 1LL << 40;
|
||||
static BOOL gEnableCustomerService = NO;
|
||||
static NSString *gDefaultCustomerServiceAccount = @"@customer_service_account";
|
||||
|
||||
@implementation TUICustomerServicePluginPrivateConfig
|
||||
|
||||
+ (TUICustomerServicePluginPrivateConfig *)sharedInstance {
|
||||
static dispatch_once_t onceToken;
|
||||
static TUICustomerServicePluginPrivateConfig * g_sharedInstance = nil;
|
||||
dispatch_once(&onceToken, ^{
|
||||
g_sharedInstance = [[TUICustomerServicePluginPrivateConfig alloc] init];
|
||||
g_sharedInstance.customerServiceAccounts = @[gDefaultCustomerServiceAccount];
|
||||
[self checkCommercialAbility];
|
||||
});
|
||||
return g_sharedInstance;
|
||||
}
|
||||
|
||||
#pragma mark - Public
|
||||
- (BOOL)isCustomerServiceAccount:(NSString *)userID {
|
||||
if (userID.length == 0) {
|
||||
return NO;
|
||||
}
|
||||
return [self.customerServiceAccounts containsObject:userID];
|
||||
}
|
||||
|
||||
- (BOOL)isOnlineShopping:(NSString *)userID {
|
||||
return [userID tui_containsString:@"#online_shopping_mall"];
|
||||
}
|
||||
|
||||
+ (BOOL)isCustomerServiceSupported {
|
||||
return gEnableCustomerService;
|
||||
}
|
||||
|
||||
#pragma mark - Private
|
||||
+ (void)checkCommercialAbility {
|
||||
[TUITool checkCommercialAbility:kTUICustomerServiceCommercialAbility
|
||||
succ:^(BOOL enabled) {
|
||||
gEnableCustomerService = enabled;
|
||||
}
|
||||
fail:^(int code, NSString *desc) {
|
||||
gEnableCustomerService = NO;
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// TUICustomerServicePluginProductInfo.h
|
||||
// TUICustomerServicePlugin
|
||||
//
|
||||
// Created by xia on 2023/7/5.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TUICustomerServicePluginProductInfo : NSObject
|
||||
|
||||
@property (nonatomic, copy) NSString *title;
|
||||
@property (nonatomic, copy) NSString *desc;
|
||||
@property (nonatomic, copy) NSString *picURL;
|
||||
@property (nonatomic, copy) NSString *linkURL;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// TUICustomerServicePluginProductInfo.m
|
||||
// TUICustomerServicePlugin
|
||||
//
|
||||
// Created by xia on 2023/7/5.
|
||||
//
|
||||
|
||||
#import "TUICustomerServicePluginProductInfo.h"
|
||||
|
||||
@implementation TUICustomerServicePluginProductInfo
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSPrivacyTracking</key>
|
||||
<false/>
|
||||
<key>NSPrivacyTrackingDomains</key>
|
||||
<array/>
|
||||
<key>NSPrivacyCollectedDataTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>NSPrivacyCollectedDataType</key>
|
||||
<string>NSPrivacyCollectedDataTypeUserID</string>
|
||||
<key>NSPrivacyCollectedDataTypeLinked</key>
|
||||
<false/>
|
||||
<key>NSPrivacyCollectedDataTypeTracking</key>
|
||||
<false/>
|
||||
<key>NSPrivacyCollectedDataTypePurposes</key>
|
||||
<array>
|
||||
<string>NSPrivacyCollectedDataTypePurposeProductPersonalization</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>NSPrivacyAccessedAPITypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>NSPrivacyAccessedAPIType</key>
|
||||
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
|
||||
<key>NSPrivacyAccessedAPITypeReasons</key>
|
||||
<array>
|
||||
<string>CA92.1</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
|
After Width: | Height: | Size: 375 B |
|
After Width: | Height: | Size: 517 B |
|
After Width: | Height: | Size: 815 B |
|
After Width: | Height: | Size: 469 B |
|
After Width: | Height: | Size: 91 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 388 B |
|
After Width: | Height: | Size: 469 B |
1
TUIKit/TUICustomerServicePlugin/Resources/TUICustomerServicePlugin.bundle/marked.min.js
vendored
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 475 B |
|
After Width: | Height: | Size: 650 B |
|
After Width: | Height: | Size: 5.7 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 662 B |
|
After Width: | Height: | Size: 885 B |
@@ -0,0 +1,112 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>id</key>
|
||||
<string>dark</string>
|
||||
<key>name</key>
|
||||
<string>黑夜</string>
|
||||
<key>name_en</key>
|
||||
<string>Dark</string>
|
||||
<key>customer_service_evaluation_star_selected_img</key>
|
||||
<string>star_selected.png</string>
|
||||
<key>customer_service_evaluation_star_unselected_img</key>
|
||||
<string>star_unselected.png</string>
|
||||
<key>customer_service_evaluation_number_selected_img</key>
|
||||
<string>number_selected.png</string>
|
||||
<key>customer_service_evaluation_number_unselected_img</key>
|
||||
<string>number_unselected.png</string>
|
||||
<key>customer_service_branch_dotted_line_img</key>
|
||||
<string>dotted_line.png</string>
|
||||
<key>customer_service_branch_arrow_img</key>
|
||||
<string>arrow.png</string>
|
||||
<key>customer_service_collection_submit_img</key>
|
||||
<string>submit.png</string>
|
||||
<key>customer_service_contact_menu_icon_img</key>
|
||||
<string>contact_customer_service.png</string>
|
||||
<key>customer_service_card_pic_placeholder_img</key>
|
||||
<string>card_pic_placeholder.png</string>
|
||||
<key>bot_branch_cell_arrow_img</key>
|
||||
<string>branch_cell_arrow.png</string>
|
||||
<key>bot_branch_cell_dotted_line_img</key>
|
||||
<string>branch_cell_dotted_line.png</string>
|
||||
<key>bot_branch_cell_head_bk_img</key>
|
||||
<string>branch_cell_head_bk.png</string>
|
||||
<key>bot_branch_cell_refresh_img</key>
|
||||
<string>branch_cell_refresh.png</string>
|
||||
<key>customer_service_card_item_desc_text_color</key>
|
||||
<string>#D9D9D9</string>
|
||||
<key>customer_service_card_input_bg_color</key>
|
||||
<string>#3A3A3A</string>
|
||||
<key>customer_service_card_input_text_color</key>
|
||||
<string>#999999</string>
|
||||
<key>customer_service_card_bg_color</key>
|
||||
<string>#000000</string>
|
||||
<key>customer_service_card_backview_bg_color</key>
|
||||
<string>#2D2D2D</string>
|
||||
<key>customer_service_card_header_text_color</key>
|
||||
<string>#CECECE</string>
|
||||
<key>customer_service_card_desc_text_color</key>
|
||||
<string>#FF6C2E</string>
|
||||
<key>customer_service_card_submit_text_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>customer_service_card_submit_bg_color</key>
|
||||
<string>#2E8BD8</string>
|
||||
<key>customer_service_card_close_text_color</key>
|
||||
<string>#2170B1</string>
|
||||
<key>customer_service_branch_content_text_color</key>
|
||||
<string>#368DFF</string>
|
||||
<key>customer_service_branch_header_text_color</key>
|
||||
<string>#D9D9D9</string>
|
||||
<key>customer_service_collection_content_text_color</key>
|
||||
<string>#368DFF</string>
|
||||
<key>customer_service_collection_header_text_color</key>
|
||||
<string>#D9D9D9</string>
|
||||
<key>customer_service_collection_border_bg_color</key>
|
||||
<string>#464646</string>
|
||||
<key>customer_service_collection_textfield_bg_color</key>
|
||||
<string>#464646</string>
|
||||
<key>customer_service_collection_textfield_text_color</key>
|
||||
<string>#D9D9D9</string>
|
||||
<key>customer_service_evaluation_bg_color</key>
|
||||
<string>#2D2D2D</string>
|
||||
<key>customer_service_evaluation_top_text_color</key>
|
||||
<string>#585858</string>
|
||||
<key>customer_service_evaluation_header_text_color</key>
|
||||
<string>#D9D9D9</string>
|
||||
<key>customer_service_evaluation_button_text_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>customer_service_evaluation_button_bg_color</key>
|
||||
<string>#2E8BD8</string>
|
||||
<key>customer_service_evaluation_bottom_text_color</key>
|
||||
<string>#585858</string>
|
||||
<key>customer_service_evaluation_button_selected_bg_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>customer_service_evaluation_button_unselected_bg_color</key>
|
||||
<string>#2170B1</string>
|
||||
<key>customer_service_menu_button_border_color</key>
|
||||
<string>#2D2D2D</string>
|
||||
<key>customer_service_menu_button_text_color</key>
|
||||
<string>#999999</string>
|
||||
<key>customer_service_menu_button_bg_color</key>
|
||||
<string>#2D2D2D</string>
|
||||
<key>customer_service_phrase_bg_color</key>
|
||||
<string>#000000</string>
|
||||
<key>customer_service_phrase_text_color</key>
|
||||
<string>#CCCCCC</string>
|
||||
<key>customer_service_phrase_backview_bg_color</key>
|
||||
<string>#2D2D2D</string>
|
||||
<key>bot_branch_cell_header_dot_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>bot_branch_cell_header_text_color_1</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>bot_branch_cell_header_text_color_2</key>
|
||||
<string>#000000</string>
|
||||
<key>bot_branch_cell_refresh_btn_color</key>
|
||||
<string>#147AFF</string>
|
||||
<key>bot_branch_cell_number_text_color</key>
|
||||
<string>#147AFF</string>
|
||||
<key>bot_branch_cell_content_text_color</key>
|
||||
<string>#D9D9D9</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
After Width: | Height: | Size: 483 B |
|
After Width: | Height: | Size: 815 B |
|
After Width: | Height: | Size: 469 B |
|
After Width: | Height: | Size: 91 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 282 B |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 800 B |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 925 B |
@@ -0,0 +1,112 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>id</key>
|
||||
<string>light</string>
|
||||
<key>name</key>
|
||||
<string>轻量</string>
|
||||
<key>name_en</key>
|
||||
<string>Light</string>
|
||||
<key>customer_service_evaluation_star_selected_img</key>
|
||||
<string>star_selected.png</string>
|
||||
<key>customer_service_evaluation_star_unselected_img</key>
|
||||
<string>star_unselected.png</string>
|
||||
<key>customer_service_evaluation_number_selected_img</key>
|
||||
<string>number_selected.png</string>
|
||||
<key>customer_service_evaluation_number_unselected_img</key>
|
||||
<string>number_unselected.png</string>
|
||||
<key>customer_service_branch_dotted_line_img</key>
|
||||
<string>dotted_line.png</string>
|
||||
<key>customer_service_branch_arrow_img</key>
|
||||
<string>arrow.png</string>
|
||||
<key>customer_service_collection_submit_img</key>
|
||||
<string>submit.png</string>
|
||||
<key>customer_service_contact_menu_icon_img</key>
|
||||
<string>contact_customer_service.png</string>
|
||||
<key>customer_service_card_pic_placeholder_img</key>
|
||||
<string>card_pic_placeholder.png</string>
|
||||
<key>bot_branch_cell_arrow_img</key>
|
||||
<string>branch_cell_arrow.png</string>
|
||||
<key>bot_branch_cell_dotted_line_img</key>
|
||||
<string>branch_cell_dotted_line.png</string>
|
||||
<key>bot_branch_cell_head_bk_img</key>
|
||||
<string>branch_cell_head_bk.png</string>
|
||||
<key>bot_branch_cell_refresh_img</key>
|
||||
<string>branch_cell_refresh.png</string>
|
||||
<key>customer_service_card_item_desc_text_color</key>
|
||||
<string>#999999</string>
|
||||
<key>customer_service_card_input_bg_color</key>
|
||||
<string>#F9F9F9</string>
|
||||
<key>customer_service_card_input_text_color</key>
|
||||
<string>#000000</string>
|
||||
<key>customer_service_card_bg_color</key>
|
||||
<string>#000000</string>
|
||||
<key>customer_service_card_backview_bg_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>customer_service_card_header_text_color</key>
|
||||
<string>#000000</string>
|
||||
<key>customer_service_card_desc_text_color</key>
|
||||
<string>#FF6C2E</string>
|
||||
<key>customer_service_card_submit_text_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>customer_service_card_submit_bg_color</key>
|
||||
<string>#006EFF</string>
|
||||
<key>customer_service_card_close_text_color</key>
|
||||
<string>#3370FF</string>
|
||||
<key>customer_service_branch_content_text_color</key>
|
||||
<string>#368DFF</string>
|
||||
<key>customer_service_branch_header_text_color</key>
|
||||
<string>#000000</string>
|
||||
<key>customer_service_collection_content_text_color</key>
|
||||
<string>#368DFF</string>
|
||||
<key>customer_service_collection_header_text_color</key>
|
||||
<string>#000000</string>
|
||||
<key>customer_service_collection_border_bg_color</key>
|
||||
<string>#DDDDDD</string>
|
||||
<key>customer_service_collection_textfield_bg_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>customer_service_collection_textfield_text_color</key>
|
||||
<string>#000000</string>
|
||||
<key>customer_service_evaluation_bg_color</key>
|
||||
<string>#FBFBFB</string>
|
||||
<key>customer_service_evaluation_top_text_color</key>
|
||||
<string>#9A9A9A</string>
|
||||
<key>customer_service_evaluation_header_text_color</key>
|
||||
<string>#1C1C1C</string>
|
||||
<key>customer_service_evaluation_button_text_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>customer_service_evaluation_button_bg_color</key>
|
||||
<string>#2F80ED</string>
|
||||
<key>customer_service_evaluation_bottom_text_color</key>
|
||||
<string>#9A9A9A</string>
|
||||
<key>customer_service_evaluation_button_selected_bg_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>customer_service_evaluation_button_unselected_bg_color</key>
|
||||
<string>#006EFF</string>
|
||||
<key>customer_service_menu_button_border_color</key>
|
||||
<string>#DDDDDD</string>
|
||||
<key>customer_service_menu_button_text_color</key>
|
||||
<string>#999999</string>
|
||||
<key>customer_service_menu_button_bg_color</key>
|
||||
<string>#F6F6F6</string>
|
||||
<key>customer_service_phrase_bg_color</key>
|
||||
<string>#000000</string>
|
||||
<key>customer_service_phrase_text_color</key>
|
||||
<string>#000000</string>
|
||||
<key>customer_service_phrase_backview_bg_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>bot_branch_cell_header_dot_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>bot_branch_cell_header_text_color_1</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>bot_branch_cell_header_text_color_2</key>
|
||||
<string>#000000</string>
|
||||
<key>bot_branch_cell_refresh_btn_color</key>
|
||||
<string>#006EFF</string>
|
||||
<key>bot_branch_cell_number_text_color</key>
|
||||
<string>#006EFF</string>
|
||||
<key>bot_branch_cell_content_text_color</key>
|
||||
<string>#333333</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
After Width: | Height: | Size: 517 B |
|
After Width: | Height: | Size: 815 B |
|
After Width: | Height: | Size: 469 B |
|
After Width: | Height: | Size: 91 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 469 B |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 650 B |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 885 B |
@@ -0,0 +1,112 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>id</key>
|
||||
<string>lively</string>
|
||||
<key>name</key>
|
||||
<string>活泼</string>
|
||||
<key>name_en</key>
|
||||
<string>Lively</string>
|
||||
<key>customer_service_evaluation_star_selected_img</key>
|
||||
<string>star_selected.png</string>
|
||||
<key>customer_service_evaluation_star_unselected_img</key>
|
||||
<string>star_unselected.png</string>
|
||||
<key>customer_service_evaluation_number_selected_img</key>
|
||||
<string>number_selected.png</string>
|
||||
<key>customer_service_evaluation_number_unselected_img</key>
|
||||
<string>number_unselected.png</string>
|
||||
<key>customer_service_branch_dotted_line_img</key>
|
||||
<string>dotted_line.png</string>
|
||||
<key>customer_service_branch_arrow_img</key>
|
||||
<string>arrow.png</string>
|
||||
<key>customer_service_collection_submit_img</key>
|
||||
<string>submit.png</string>
|
||||
<key>customer_service_contact_menu_icon_img</key>
|
||||
<string>contact_customer_service.png</string>
|
||||
<key>customer_service_card_pic_placeholder_img</key>
|
||||
<string>card_pic_placeholder.png</string>
|
||||
<key>bot_branch_cell_arrow_img</key>
|
||||
<string>branch_cell_arrow.png</string>
|
||||
<key>bot_branch_cell_dotted_line_img</key>
|
||||
<string>branch_cell_dotted_line.png</string>
|
||||
<key>bot_branch_cell_head_bk_img</key>
|
||||
<string>branch_cell_head_bk.png</string>
|
||||
<key>bot_branch_cell_refresh_img</key>
|
||||
<string>branch_cell_refresh.png</string>
|
||||
<key>customer_service_card_item_desc_text_color</key>
|
||||
<string>#999999</string>
|
||||
<key>customer_service_card_input_bg_color</key>
|
||||
<string>#F9F9F9</string>
|
||||
<key>customer_service_card_input_text_color</key>
|
||||
<string>#000000</string>
|
||||
<key>customer_service_card_bg_color</key>
|
||||
<string>#000000</string>
|
||||
<key>customer_service_card_backview_bg_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>customer_service_card_header_text_color</key>
|
||||
<string>#333333</string>
|
||||
<key>customer_service_card_desc_text_color</key>
|
||||
<string>#FF6C2E</string>
|
||||
<key>customer_service_card_submit_text_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>customer_service_card_submit_bg_color</key>
|
||||
<string>#FF9D85</string>
|
||||
<key>customer_service_card_close_text_color</key>
|
||||
<string>#FF5739</string>
|
||||
<key>customer_service_branch_content_text_color</key>
|
||||
<string>#FF7756</string>
|
||||
<key>customer_service_branch_header_text_color</key>
|
||||
<string>#171538</string>
|
||||
<key>customer_service_collection_content_text_color</key>
|
||||
<string>#FF7756</string>
|
||||
<key>customer_service_collection_header_text_color</key>
|
||||
<string>#171538</string>
|
||||
<key>customer_service_collection_border_bg_color</key>
|
||||
<string>#DDDDDD</string>
|
||||
<key>customer_service_collection_textfield_bg_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>customer_service_collection_textfield_text_color</key>
|
||||
<string>#000000</string>
|
||||
<key>customer_service_evaluation_bg_color</key>
|
||||
<string>#FBFBFB</string>
|
||||
<key>customer_service_evaluation_top_text_color</key>
|
||||
<string>#8F959E</string>
|
||||
<key>customer_service_evaluation_header_text_color</key>
|
||||
<string>#1C1C1C</string>
|
||||
<key>customer_service_evaluation_button_text_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>customer_service_evaluation_button_bg_color</key>
|
||||
<string>#FF9D85</string>
|
||||
<key>customer_service_evaluation_bottom_text_color</key>
|
||||
<string>#9A9A9A</string>
|
||||
<key>customer_service_evaluation_button_selected_bg_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>customer_service_evaluation_button_unselected_bg_color</key>
|
||||
<string>#FF7756</string>
|
||||
<key>customer_service_menu_button_border_color</key>
|
||||
<string>#C5CBD4</string>
|
||||
<key>customer_service_menu_button_text_color</key>
|
||||
<string>#8F959E</string>
|
||||
<key>customer_service_menu_button_bg_color</key>
|
||||
<string>#F6F7F9</string>
|
||||
<key>customer_service_phrase_bg_color</key>
|
||||
<string>#000000</string>
|
||||
<key>customer_service_phrase_text_color</key>
|
||||
<string>#000000</string>
|
||||
<key>customer_service_phrase_backview_bg_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>bot_branch_cell_header_dot_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>bot_branch_cell_header_text_color_1</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>bot_branch_cell_header_text_color_2</key>
|
||||
<string>#000000</string>
|
||||
<key>bot_branch_cell_refresh_btn_color</key>
|
||||
<string>#FF7756</string>
|
||||
<key>bot_branch_cell_number_text_color</key>
|
||||
<string>#FF7756</string>
|
||||
<key>bot_branch_cell_content_text_color</key>
|
||||
<string>#333333</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
After Width: | Height: | Size: 484 B |
|
After Width: | Height: | Size: 815 B |
|
After Width: | Height: | Size: 469 B |
|
After Width: | Height: | Size: 91 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 469 B |
|
After Width: | Height: | Size: 8.9 KiB |
|
After Width: | Height: | Size: 683 B |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 963 B |
@@ -0,0 +1,112 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>id</key>
|
||||
<string>serious</string>
|
||||
<key>name</key>
|
||||
<string>严肃</string>
|
||||
<key>name_en</key>
|
||||
<string>Business</string>
|
||||
<key>customer_service_evaluation_star_selected_img</key>
|
||||
<string>star_selected.png</string>
|
||||
<key>customer_service_evaluation_star_unselected_img</key>
|
||||
<string>star_unselected.png</string>
|
||||
<key>customer_service_evaluation_number_selected_img</key>
|
||||
<string>number_selected.png</string>
|
||||
<key>customer_service_evaluation_number_unselected_img</key>
|
||||
<string>number_unselected.png</string>
|
||||
<key>customer_service_branch_dotted_line_img</key>
|
||||
<string>dotted_line.png</string>
|
||||
<key>customer_service_branch_arrow_img</key>
|
||||
<string>arrow.png</string>
|
||||
<key>customer_service_collection_submit_img</key>
|
||||
<string>submit.png</string>
|
||||
<key>customer_service_contact_menu_icon_img</key>
|
||||
<string>contact_customer_service.png</string>
|
||||
<key>customer_service_card_pic_placeholder_img</key>
|
||||
<string>card_pic_placeholder.png</string>
|
||||
<key>bot_branch_cell_arrow_img</key>
|
||||
<string>branch_cell_arrow.png</string>
|
||||
<key>bot_branch_cell_dotted_line_img</key>
|
||||
<string>branch_cell_dotted_line.png</string>
|
||||
<key>bot_branch_cell_head_bk_img</key>
|
||||
<string>branch_cell_head_bk.png</string>
|
||||
<key>bot_branch_cell_refresh_img</key>
|
||||
<string>branch_cell_refresh.png</string>
|
||||
<key>customer_service_card_item_desc_text_color</key>
|
||||
<string>#999999</string>
|
||||
<key>customer_service_card_input_bg_color</key>
|
||||
<string>#F9F9F9</string>
|
||||
<key>customer_service_card_input_text_color</key>
|
||||
<string>#000000</string>
|
||||
<key>customer_service_card_bg_color</key>
|
||||
<string>#000000</string>
|
||||
<key>customer_service_card_backview_bg_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>customer_service_card_header_text_color</key>
|
||||
<string>#000000</string>
|
||||
<key>customer_service_card_desc_text_color</key>
|
||||
<string>#FF6C2E</string>
|
||||
<key>customer_service_card_submit_text_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>customer_service_card_submit_bg_color</key>
|
||||
<string>#006EFF</string>
|
||||
<key>customer_service_card_close_text_color</key>
|
||||
<string>#3370FF</string>
|
||||
<key>customer_service_branch_content_text_color</key>
|
||||
<string>#368DFF</string>
|
||||
<key>customer_service_branch_header_text_color</key>
|
||||
<string>#000000</string>
|
||||
<key>customer_service_collection_content_text_color</key>
|
||||
<string>#368DFF</string>
|
||||
<key>customer_service_collection_header_text_color</key>
|
||||
<string>#000000</string>
|
||||
<key>customer_service_collection_border_bg_color</key>
|
||||
<string>#DDDDDD</string>
|
||||
<key>customer_service_collection_textfield_bg_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>customer_service_collection_textfield_text_color</key>
|
||||
<string>#000000</string>
|
||||
<key>customer_service_evaluation_bg_color</key>
|
||||
<string>#FBFBFB</string>
|
||||
<key>customer_service_evaluation_top_text_color</key>
|
||||
<string>#9A9A9A</string>
|
||||
<key>customer_service_evaluation_header_text_color</key>
|
||||
<string>#1C1C1C</string>
|
||||
<key>customer_service_evaluation_button_text_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>customer_service_evaluation_button_bg_color</key>
|
||||
<string>#2F80ED</string>
|
||||
<key>customer_service_evaluation_bottom_text_color</key>
|
||||
<string>#9A9A9A</string>
|
||||
<key>customer_service_evaluation_button_selected_bg_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>customer_service_evaluation_button_unselected_bg_color</key>
|
||||
<string>#006EFF</string>
|
||||
<key>customer_service_menu_button_border_color</key>
|
||||
<string>#C5CBD4</string>
|
||||
<key>customer_service_menu_button_text_color</key>
|
||||
<string>#8F959E</string>
|
||||
<key>customer_service_menu_button_bg_color</key>
|
||||
<string>#F6F7F9</string>
|
||||
<key>customer_service_phrase_bg_color</key>
|
||||
<string>#000000</string>
|
||||
<key>customer_service_phrase_text_color</key>
|
||||
<string>#000000</string>
|
||||
<key>customer_service_phrase_backview_bg_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>bot_branch_cell_header_dot_color</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>bot_branch_cell_header_text_color_1</key>
|
||||
<string>#FFFFFF</string>
|
||||
<key>bot_branch_cell_header_text_color_2</key>
|
||||
<string>#000000</string>
|
||||
<key>bot_branch_cell_refresh_btn_color</key>
|
||||
<string>#147AFF</string>
|
||||
<key>bot_branch_cell_number_text_color</key>
|
||||
<string>#147AFF</string>
|
||||
<key>bot_branch_cell_content_text_color</key>
|
||||
<string>#333333</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
After Width: | Height: | Size: 517 B |
|
After Width: | Height: | Size: 815 B |
|
After Width: | Height: | Size: 469 B |
|
After Width: | Height: | Size: 91 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 469 B |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 650 B |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 885 B |
@@ -0,0 +1,29 @@
|
||||
Pod::Spec.new do |spec|
|
||||
spec.name = 'TUICustomerServicePlugin'
|
||||
spec.version = '8.4.6667'
|
||||
spec.platform = :ios
|
||||
spec.ios.deployment_target = '9.0'
|
||||
spec.license = { :type => 'Proprietary',
|
||||
:text => <<-LICENSE
|
||||
copyright 2017 tencent Ltd. All rights reserved.
|
||||
LICENSE
|
||||
}
|
||||
spec.homepage = 'https://cloud.tencent.com/document/product/269/3794'
|
||||
spec.documentation_url = 'https://cloud.tencent.com/document/product/269/9147'
|
||||
spec.authors = 'tencent video cloud'
|
||||
spec.summary = 'TUICustomerServicePlugin'
|
||||
spec.dependency 'TUICore'
|
||||
spec.dependency 'TIMCommon'
|
||||
spec.dependency 'TUIChat'
|
||||
spec.dependency 'TUIContact'
|
||||
spec.dependency 'SDWebImage'
|
||||
|
||||
spec.requires_arc = true
|
||||
|
||||
spec.source = { :git => 'https://git.woa.com/lynxzhang/tui-components.git', :tag => spec.version}
|
||||
spec.source_files = '**/*.{h,m,mm,c}'
|
||||
spec.resource = ['Resources/*.bundle']
|
||||
spec.resource_bundle = {
|
||||
"#{spec.module_name}_Privacy" => '**/TUICustomerServicePlugin/Resources/PrivacyInfo.xcprivacy'
|
||||
}
|
||||
end
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// TUIBotBranchCell.h
|
||||
// TUICustomerServicePlugin
|
||||
//
|
||||
// Created by lynx on 2023/10/30.
|
||||
//
|
||||
|
||||
#import <TIMCommon/TUIBubbleMessageCell.h>
|
||||
#import "TUIBotBranchCellData.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TUIBotBranchItemCell : UITableViewCell
|
||||
@property (nonatomic, assign) BranchMsgSubType subType;
|
||||
@property (nonatomic, strong) UIImageView *topLine;
|
||||
@property (nonatomic, strong) UILabel *numberLabel;
|
||||
@property (nonatomic, strong) UILabel *contentLabel;
|
||||
@property (nonatomic, strong) UIImageView *arrowView;
|
||||
@end
|
||||
|
||||
@interface TUIBotBranchCell : TUIBubbleMessageCell
|
||||
@property (nonatomic, strong) UIImageView *headerBkView;
|
||||
@property (nonatomic, strong) UIImageView *headerDotView;
|
||||
@property (nonatomic, strong) UILabel *headerLabel;
|
||||
@property (nonatomic, strong) UIButton *headerRefreshBtn;
|
||||
@property (nonatomic, strong) UIImageView *headerRefreshView;
|
||||
@property (nonatomic, strong) UITableView *itemsTableView;
|
||||
|
||||
- (void)fillWithData:(TUIBotBranchCellData *)data;
|
||||
|
||||
@property (nonatomic, strong) TUIBotBranchCellData *customData;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,339 @@
|
||||
//
|
||||
// TUIBotBranchCell.m
|
||||
// TUICustomerServicePlugin
|
||||
//
|
||||
// Created by lynx on 2023/10/30.
|
||||
//
|
||||
|
||||
#import "TUIBotBranchCell.h"
|
||||
#import "TUICustomerServicePluginDataProvider.h"
|
||||
#import "TUICustomerServicePluginDataProvider+CalculateSize.h"
|
||||
#import <TIMCommon/TIMDefine.h>
|
||||
#import <TIMCommon/TIMRTLUtil.h>
|
||||
#import <TUICore/TUICore.h>
|
||||
|
||||
@implementation TUIBotBranchItemCell
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
if (self) {
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
self.contentView.backgroundColor = [UIColor clearColor];
|
||||
|
||||
_topLine = [[UIImageView alloc] init];
|
||||
[_topLine setImage:TUICustomerServicePluginBundleThemeImage(@"bot_branch_cell_dotted_line_img", @"branch_cell_dotted_line")];
|
||||
[self.contentView addSubview:_topLine];
|
||||
|
||||
_numberLabel = [[UILabel alloc] init];
|
||||
_numberLabel.font = [UIFont systemFontOfSize:17];
|
||||
_numberLabel.numberOfLines = 0;
|
||||
_numberLabel.lineBreakMode = NSLineBreakByTruncatingTail;
|
||||
_numberLabel.textColor = TUICustomerServicePluginDynamicColor(@"bot_branch_cell_number_text_color", @"#006EFF");
|
||||
[self.contentView addSubview:_numberLabel];
|
||||
|
||||
_contentLabel = [[UILabel alloc] init];
|
||||
_contentLabel.font = [UIFont systemFontOfSize:14];
|
||||
_contentLabel.numberOfLines = 0;
|
||||
_contentLabel.lineBreakMode = NSLineBreakByTruncatingTail;
|
||||
_contentLabel.textColor = TUICustomerServicePluginDynamicColor(@"bot_branch_cell_content_text_color", @"#333333");
|
||||
[self.contentView addSubview:_contentLabel];
|
||||
|
||||
_arrowView = [[UIImageView alloc] init];
|
||||
UIImage *arrowImage = TUICustomerServicePluginBundleThemeImage(@"bot_branch_cell_arrow_img", @"branch_cell_arrow");
|
||||
[_arrowView setImage:[arrowImage rtl_imageFlippedForRightToLeftLayoutDirection]];
|
||||
[self.contentView addSubview:_arrowView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
// this is Apple's recommended place for adding/updating constraints
|
||||
- (void)updateConstraints {
|
||||
[super updateConstraints];
|
||||
|
||||
[self.topLine mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(TUIBotBranchCellMargin);
|
||||
make.top.mas_equalTo(0);
|
||||
make.width.mas_equalTo(self.mm_w - TUIBotBranchCellMargin * 2);
|
||||
make.height.mas_equalTo(0.5);
|
||||
}];
|
||||
|
||||
if (BranchMsgSubType_Welcome == self.subType) {
|
||||
CGFloat height = [TUICustomerServicePluginDataProvider calcBranchCellHeightOfContent:self.contentLabel.text];
|
||||
[self.numberLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(TUIBotBranchCellMargin);
|
||||
make.centerY.mas_equalTo(self.contentView.mas_centerY);
|
||||
make.width.mas_equalTo(20);
|
||||
make.height.mas_equalTo(20);
|
||||
}];
|
||||
[self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.numberLabel.mas_trailing).offset(TUIBotBranchCellMargin);
|
||||
make.centerY.mas_equalTo(self.contentView.mas_centerY);
|
||||
make.width.mas_equalTo(self.mm_w - TUIBotBranchCellMargin * 4 - kScale375(16) - 6);
|
||||
make.height.mas_equalTo(height);
|
||||
}];
|
||||
} else {
|
||||
[self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(TUIBotBranchCellMargin);
|
||||
make.top.mas_equalTo(0);
|
||||
make.width.mas_equalTo(self.mm_w - TUIBotBranchCellMargin * 2 - kScale375(16) - 6);
|
||||
make.height.mas_equalTo([TUICustomerServicePluginDataProvider calcBranchCellHeightOfContent:self.contentLabel.text]);
|
||||
}];
|
||||
}
|
||||
|
||||
[self.arrowView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.contentLabel.mas_trailing).offset(6);
|
||||
make.centerY.mas_equalTo(self.contentView);
|
||||
make.width.mas_equalTo(kScale375(16));
|
||||
make.height.mas_equalTo(kScale375(16));
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#define BranchItemCellMaxCountPerPage 4
|
||||
@interface TUIBotBranchCell() <UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@end
|
||||
|
||||
@implementation TUIBotBranchCell
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
if (self) {
|
||||
_headerBkView = [[UIImageView alloc] init];
|
||||
UIImage *headerBkImage = TUICustomerServicePluginBundleThemeImage(@"bot_branch_cell_head_bk_img", @"branch_cell_head_bk");
|
||||
[_headerBkView setImage:[headerBkImage rtl_imageFlippedForRightToLeftLayoutDirection]];
|
||||
[self.container addSubview:_headerBkView];
|
||||
|
||||
_headerDotView = [[UIImageView alloc] init];
|
||||
[_headerDotView setBackgroundColor:TUICustomerServicePluginDynamicColor(@"bot_branch_cell_header_dot_color", @"#FFFFFF")];
|
||||
_headerDotView.layer.cornerRadius = kScale375(8) / 2;
|
||||
_headerDotView.layer.masksToBounds = YES;
|
||||
[self.container addSubview:_headerDotView];
|
||||
|
||||
_headerLabel = [[UILabel alloc] init];
|
||||
_headerLabel.font = [UIFont systemFontOfSize:14];
|
||||
_headerLabel.numberOfLines = 0;
|
||||
_headerLabel.lineBreakMode = NSLineBreakByTruncatingTail;
|
||||
_headerLabel.textColor = TUICustomerServicePluginDynamicColor(@"bot_branch_cell_header_text_color_1", @"#FFFFFF");
|
||||
[self.container addSubview:_headerLabel];
|
||||
|
||||
_headerRefreshBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
_headerRefreshBtn.backgroundColor = [UIColor clearColor];
|
||||
[_headerRefreshBtn setTitle:TIMCommonLocalizableString(TUIChatBotChangeQuestion) forState:UIControlStateNormal];
|
||||
[_headerRefreshBtn.titleLabel setFont:[UIFont systemFontOfSize:14]];
|
||||
[_headerRefreshBtn setTitleColor:TUICustomerServicePluginDynamicColor(@"bot_branch_cell_refresh_btn_color", @"#006EFF") forState:UIControlStateNormal];
|
||||
[_headerRefreshBtn addTarget:self action:@selector(onRefresh) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.container addSubview:_headerRefreshBtn];
|
||||
|
||||
_headerRefreshView = [[UIImageView alloc] init];
|
||||
[_headerRefreshView setImage:TUICustomerServicePluginBundleThemeImage(@"bot_branch_cell_refresh_img", @"branch_cell_refresh")];
|
||||
UITapGestureRecognizer *tag = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onRefresh)];
|
||||
[_headerRefreshView addGestureRecognizer:tag];
|
||||
_headerRefreshView.userInteractionEnabled = YES;
|
||||
[self.container addSubview:_headerRefreshView];
|
||||
|
||||
_itemsTableView = [[UITableView alloc] init];
|
||||
_itemsTableView.tableFooterView = [[UIView alloc] init];
|
||||
// _itemsTableView.backgroundColor = TUICoreDynamicColor(@"customer_service_brance_bg_color", @"#FFFFFF");
|
||||
_itemsTableView.backgroundColor = [UIColor clearColor];
|
||||
_itemsTableView.delegate = self;
|
||||
_itemsTableView.dataSource = self;
|
||||
_itemsTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
[_itemsTableView registerClass:[TUIBotBranchItemCell class] forCellReuseIdentifier:@"item_cell"];
|
||||
[self.container addSubview:_itemsTableView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)onRefresh {
|
||||
if (!self.customData || 0 == self.customData.items.count) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSUInteger pageCount = self.customData.items.count / BranchItemCellMaxCountPerPage;
|
||||
if (self.customData.items.count % BranchItemCellMaxCountPerPage > 0) {
|
||||
pageCount++;
|
||||
}
|
||||
|
||||
NSUInteger oldPageIndex = self.customData.pageIndex;
|
||||
if (self.customData.pageIndex < pageCount - 1) {
|
||||
self.customData.pageIndex++;
|
||||
} else {
|
||||
self.customData.pageIndex = 0;
|
||||
}
|
||||
|
||||
if (self.customData.pageIndex != oldPageIndex) {
|
||||
NSUInteger location = self.customData.pageIndex * BranchItemCellMaxCountPerPage;
|
||||
NSUInteger length = MIN(self.customData.items.count - location, BranchItemCellMaxCountPerPage);
|
||||
self.customData.pageItems = [self.customData.items subarrayWithRange:NSMakeRange(location, length)];
|
||||
|
||||
[self notifyCellSizeChanged];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)notifyCellSizeChanged {
|
||||
NSDictionary *param = @{TUICore_TUIPluginNotify_PluginViewSizeChangedSubKey_Message : self.customData.innerMessage};
|
||||
[TUICore notifyEvent:TUICore_TUIPluginNotify
|
||||
subKey:TUICore_TUIPluginNotify_PluginViewSizeChangedSubKey
|
||||
object:nil
|
||||
param:param];
|
||||
}
|
||||
|
||||
- (void)fillWithData:(TUIBotBranchCellData *)data {
|
||||
[super fillWithData:data];
|
||||
|
||||
self.customData = data;
|
||||
self.headerLabel.text = data.header;
|
||||
if (BranchMsgSubType_Welcome == data.subType) {
|
||||
self.headerDotView.hidden = NO;
|
||||
self.headerRefreshBtn.hidden = NO;
|
||||
self.headerRefreshView.hidden = NO;
|
||||
self.headerBkView.hidden = NO;
|
||||
self.headerLabel.font = [UIFont systemFontOfSize:14];
|
||||
self.headerLabel.textColor = TUICustomerServicePluginDynamicColor(@"bot_branch_cell_header_text_color_1", @"#FFFFFF");
|
||||
} else {
|
||||
self.headerDotView.hidden = YES;
|
||||
self.headerRefreshBtn.hidden = YES;
|
||||
self.headerRefreshView.hidden = YES;
|
||||
self.headerBkView.hidden = YES;
|
||||
self.headerLabel.font = [UIFont boldSystemFontOfSize:14];
|
||||
self.headerLabel.textColor = TUICustomerServicePluginDynamicColor(@"bot_branch_cell_header_text_color_2", @"#000000");
|
||||
}
|
||||
[self.itemsTableView reloadData];
|
||||
|
||||
// tell constraints they need updating
|
||||
[self setNeedsUpdateConstraints];
|
||||
|
||||
// update constraints now so we can animate the change
|
||||
[self updateConstraintsIfNeeded];
|
||||
|
||||
[self layoutIfNeeded];
|
||||
}
|
||||
|
||||
// Override, the size of bubble content.
|
||||
+ (CGSize)getContentSize:(TUIMessageCellData *)data {
|
||||
NSAssert([data isKindOfClass:TUIBotBranchCellData.class],
|
||||
@"data must be a kind of TUIBotBranchCellData");
|
||||
TUIBotBranchCellData *branchCellData = (TUIBotBranchCellData *)data;
|
||||
if (!branchCellData.pageItems) {
|
||||
if (BranchMsgSubType_Welcome == branchCellData.subType) {
|
||||
branchCellData.pageItems = [branchCellData.items subarrayWithRange:
|
||||
NSMakeRange(0, MIN(branchCellData.items.count, BranchItemCellMaxCountPerPage))];
|
||||
} else {
|
||||
branchCellData.pageItems = branchCellData.items;
|
||||
}
|
||||
}
|
||||
return [TUICustomerServicePluginDataProvider calcBranchCellSize:branchCellData.header items:branchCellData.pageItems];
|
||||
}
|
||||
|
||||
- (void)updateConstraints {
|
||||
[super updateConstraints];
|
||||
|
||||
CGFloat cellHeight = [TUICustomerServicePluginDataProvider calcBranchCellSize:self.customData.header
|
||||
items:self.customData.pageItems].height;
|
||||
CGSize tableViewSize = [TUICustomerServicePluginDataProvider calcBranchCellSizeOfTableView:self.customData.pageItems];
|
||||
CGSize headerLabelSize = [TUICustomerServicePluginDataProvider calcBranchCellSizeOfHeader:self.customData.header];
|
||||
CGSize headerSize = CGSizeMake(self.container.mm_w, headerLabelSize.height + TUIBotBranchCellMargin + TUIBotBranchCellInnerMargin);
|
||||
|
||||
self.container
|
||||
.mm_width(TUIBotBranchCellWidth)
|
||||
.mm_height(cellHeight);
|
||||
|
||||
if (BranchMsgSubType_Welcome == self.customData.subType) {
|
||||
[self.headerBkView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(0);
|
||||
make.top.mas_equalTo(0);
|
||||
make.width.mas_equalTo(headerSize.width);
|
||||
make.height.mas_equalTo(headerSize.height);
|
||||
}];
|
||||
|
||||
[self.headerDotView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(TUIBotBranchCellMargin);
|
||||
make.centerY.mas_equalTo(self.headerBkView);
|
||||
make.width.mas_equalTo(TUIBotBranchCellInnerMargin);
|
||||
make.height.mas_equalTo(TUIBotBranchCellInnerMargin);
|
||||
}];
|
||||
|
||||
[self.headerRefreshView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.trailing.mas_equalTo(self.container.mas_trailing).offset(-TUIBotBranchCellMargin);
|
||||
make.centerY.mas_equalTo(self.headerBkView);
|
||||
make.width.mas_equalTo(12);
|
||||
make.height.mas_equalTo(16);
|
||||
}];
|
||||
|
||||
[self.headerRefreshBtn sizeToFit];
|
||||
[self.headerRefreshBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.trailing.mas_equalTo(self.headerRefreshView.mas_leading).offset(-TUIBotBranchCellMargin);
|
||||
make.centerY.mas_equalTo(self.headerBkView);
|
||||
make.size.mas_equalTo(self.headerRefreshBtn.frame.size);
|
||||
}];
|
||||
|
||||
[self.headerLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.headerDotView.mas_trailing).offset(TUIBotBranchCellMargin);
|
||||
make.trailing.mas_equalTo(self.headerRefreshBtn.mas_leading).offset(-TUIBotBranchCellMargin);
|
||||
make.centerY.mas_equalTo(self.headerBkView);
|
||||
make.height.mas_equalTo(headerLabelSize.height);
|
||||
}];
|
||||
} else {
|
||||
[self.headerLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(TUIBotBranchCellMargin);
|
||||
make.top.mas_equalTo(TUIBotBranchCellMargin);
|
||||
make.width.mas_equalTo(headerLabelSize.width);
|
||||
make.height.mas_equalTo(headerLabelSize.height);
|
||||
}];
|
||||
}
|
||||
|
||||
[self.itemsTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(0);
|
||||
make.top.mas_equalTo(headerSize.height);
|
||||
make.width.mas_equalTo(tableViewSize.width);
|
||||
make.height.mas_equalTo(tableViewSize.height);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - UITableViewDelegate & UITableViewDataSource
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
return [TUICustomerServicePluginDataProvider calcBranchCellHeightOfTableView:self.customData.pageItems row:indexPath.row];
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if (self.customData.pageItems.count <= indexPath.row) {
|
||||
return;
|
||||
}
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:NO];
|
||||
|
||||
NSString *content = self.customData.pageItems[indexPath.row];
|
||||
[TUICustomerServicePluginDataProvider sendTextMessage:content];
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
return self.customData.pageItems.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if (self.customData.pageItems.count <= indexPath.row) {
|
||||
return nil;
|
||||
}
|
||||
TUIBotBranchItemCell *cell = [tableView dequeueReusableCellWithIdentifier:@"item_cell" forIndexPath:indexPath];
|
||||
cell.subType = self.customData.subType;
|
||||
if (BranchMsgSubType_Welcome == self.customData.subType) {
|
||||
cell.numberLabel.hidden = NO;
|
||||
cell.numberLabel.text = @(indexPath.row + 1).stringValue;
|
||||
} else {
|
||||
cell.numberLabel.hidden = YES;
|
||||
}
|
||||
cell.contentLabel.text = self.customData.pageItems[indexPath.row];
|
||||
|
||||
// tell constraints they need updating
|
||||
[cell setNeedsUpdateConstraints];
|
||||
|
||||
// update constraints now so we can animate the change
|
||||
[cell updateConstraintsIfNeeded];
|
||||
|
||||
[cell layoutIfNeeded];
|
||||
return cell;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// TUIBotBranchCellData.h
|
||||
// TUICustomerServicePlugin
|
||||
//
|
||||
// Created by lynx on 2023/10/30.
|
||||
//
|
||||
|
||||
#import <TIMCommon/TUIMessageCell.h>
|
||||
#import <TIMCommon/TUIBubbleMessageCellData.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NS_ENUM(NSInteger, BranchMsgSubType) {
|
||||
BranchMsgSubType_Welcome = 0,
|
||||
BranchMsgSubType_Clarify = 1,
|
||||
};
|
||||
|
||||
@interface TUIBotBranchCellData : TUIBubbleMessageCellData
|
||||
|
||||
@property (nonatomic, assign) BranchMsgSubType subType;
|
||||
@property (nonatomic, copy) NSString *header;
|
||||
@property (nonatomic, strong) NSMutableArray *items;
|
||||
@property (nonatomic, assign) NSUInteger pageIndex;
|
||||
@property (nonatomic, strong) NSArray *pageItems;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,63 @@
|
||||
//
|
||||
// TUIBotBranchCellData.m
|
||||
// TUICustomerServicePlugin
|
||||
//
|
||||
// Created by lynx on 2023/10/30.
|
||||
//
|
||||
|
||||
#import "TUIBotBranchCellData.h"
|
||||
#import "TUICustomerServicePluginDataProvider+CalculateSize.h"
|
||||
|
||||
@implementation TUIBotBranchCellData
|
||||
|
||||
+ (TUIMessageCellData *)getCellData:(V2TIMMessage *)message {
|
||||
NSDictionary *param = [NSJSONSerialization JSONObjectWithData:message.customElem.data
|
||||
options:NSJSONReadingAllowFragments error:nil];
|
||||
if (param == nil) {
|
||||
return nil;
|
||||
}
|
||||
TUIBotBranchCellData *cellData = [[TUIBotBranchCellData alloc] initWithDirection:message.isSelf ? MsgDirectionOutgoing : MsgDirectionIncoming];
|
||||
cellData.innerMessage = message;
|
||||
|
||||
NSString *subType = param[@"subtype"];
|
||||
if ([subType isEqualToString:@"welcome_msg"]) {
|
||||
cellData.subType = BranchMsgSubType_Welcome;
|
||||
} else if ([subType isEqualToString:@"clarify_msg"]) {
|
||||
cellData.subType = BranchMsgSubType_Clarify;
|
||||
}
|
||||
|
||||
NSDictionary *content = param[@"content"];
|
||||
cellData.header = content[@"title"];
|
||||
NSArray *items = content[@"items"];
|
||||
for (NSDictionary *item in items) {
|
||||
[cellData.items addObject:item[@"content"]];
|
||||
}
|
||||
|
||||
return cellData;
|
||||
}
|
||||
|
||||
+ (NSString *)getDisplayString:(V2TIMMessage *)message {
|
||||
NSDictionary *param = [NSJSONSerialization JSONObjectWithData:message.customElem.data
|
||||
options:NSJSONReadingAllowFragments error:nil];
|
||||
if (param == nil) {
|
||||
return nil;
|
||||
}
|
||||
TUIBotBranchCellData *cellData = [[TUIBotBranchCellData alloc] initWithDirection:message.isSelf ? MsgDirectionOutgoing : MsgDirectionIncoming];
|
||||
cellData.innerMessage = message;
|
||||
NSDictionary *content = param[@"content"];
|
||||
return content[@"title"];
|
||||
}
|
||||
|
||||
// Override
|
||||
- (BOOL)canForward {
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSMutableArray *)items {
|
||||
if (!_items) {
|
||||
_items = [[NSMutableArray alloc] init];
|
||||
}
|
||||
return _items;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
// Created by lynx on 2024/3/1.
|
||||
// Copyright © 2024 Tencent. All rights reserved.
|
||||
|
||||
#import <TIMCommon/TUIBubbleMessageCell.h>
|
||||
#import "TUIBotRichTextCellData.h"
|
||||
|
||||
@interface TUIBotRichTextCell : TUIBubbleMessageCell
|
||||
@property TUIBotRichTextCellData *webViewData;
|
||||
|
||||
- (void)fillWithData:(TUIBotRichTextCellData *)data;
|
||||
@end
|
||||
@@ -0,0 +1,254 @@
|
||||
//
|
||||
// TUIBotRichTextCell.m
|
||||
// TUICustomerServicePlugin
|
||||
//
|
||||
// Created by lynx on 2024/3/1.
|
||||
// Copyright © 2024 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIBotRichTextCell.h"
|
||||
#import <TUIChat/TUITextMessageCell.h>
|
||||
#import <TIMCommon/TIMDefine.h>
|
||||
#import <TUICore/TUICore.h>
|
||||
#import <WebKit/WebKit.h>
|
||||
|
||||
@interface TUIBotRichTextCell ()<WKNavigationDelegate>
|
||||
@property(nonatomic, strong) WKWebView *webView;
|
||||
@property(nonatomic, strong) UIColor *webViewBkColor;
|
||||
@property(nonatomic, strong) UIColor *webViewTextColor;
|
||||
@end
|
||||
|
||||
@implementation TUIBotRichTextCell
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
if (self) {
|
||||
[self.container addSubview:self.webView];
|
||||
self.webViewTextColor = [TUITextMessageCell incommingTextColor];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
|
||||
self.webViewBkColor = nil;
|
||||
[self.webView evaluateJavaScript:[NSString stringWithFormat:@"document.body.style.backgroundColor=\"%@\"",
|
||||
[self hexStringFromColor:self.webViewBkColor]] completionHandler:nil];
|
||||
[self.webView evaluateJavaScript:[NSString stringWithFormat:@"document.getElementById('content').style.color=\"%@\"",
|
||||
[self hexStringFromColor:self.webViewTextColor]] completionHandler:nil];
|
||||
}
|
||||
|
||||
- (WKWebView *)webView {
|
||||
if (!_webView) {
|
||||
WKWebViewConfiguration *config = [WKWebViewConfiguration new];
|
||||
NSString *script = @"var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appendChild(meta);";
|
||||
WKUserScript *wkUserScript = [[WKUserScript alloc] initWithSource:script injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES];
|
||||
WKUserContentController *wkUserController = [[WKUserContentController alloc] init];
|
||||
[wkUserController addUserScript: wkUserScript];
|
||||
config.userContentController = wkUserController;
|
||||
_webView = [[WKWebView alloc]initWithFrame:self.bounds configuration:config];
|
||||
_webView.navigationDelegate = self;
|
||||
_webView.backgroundColor = [UIColor clearColor];
|
||||
[_webView.scrollView addObserver:self forKeyPath:@"contentSize" options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew context:nil];
|
||||
_webView.scrollView.scrollEnabled = NO;
|
||||
|
||||
NSString *bundlePath = TUIBundlePath(TUICustomerServicePluginBundle,TUICustomerServicePluginBundle_Key_Class);
|
||||
NSString *path = [bundlePath stringByAppendingPathComponent:@"markdown.html"];
|
||||
if (path) {
|
||||
NSURL *url = [NSURL fileURLWithPath:path];
|
||||
NSURLRequest *requset = [NSURLRequest requestWithURL:url];
|
||||
[_webView loadRequest:requset];
|
||||
}
|
||||
}
|
||||
return _webView;
|
||||
}
|
||||
|
||||
- (UIColor *)webViewBkColor {
|
||||
if (!_webViewBkColor && self.bubbleView.image) {
|
||||
UIImage *image = [self.bubbleView.image.imageAsset imageWithTraitCollection:[UITraitCollection currentTraitCollection]];
|
||||
_webViewBkColor = [self colorFromImage:image point:CGPointMake(trunc(10), trunc(10))];
|
||||
}
|
||||
return _webViewBkColor;
|
||||
}
|
||||
|
||||
- (void)layoutSubviews {
|
||||
[super layoutSubviews];
|
||||
}
|
||||
|
||||
// this is Apple's recommended place for adding/updating constraints
|
||||
- (void)updateConstraints {
|
||||
[super updateConstraints];
|
||||
[self.webView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(10);
|
||||
make.top.mas_equalTo(2);
|
||||
make.width.mas_equalTo(self.container.mm_w - 10 * 2);
|
||||
make.height.mas_equalTo(self.container.mm_h - 2 * 2);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)fillWithData:(TUIBotRichTextCellData *)data {
|
||||
// set data
|
||||
[super fillWithData:data];
|
||||
self.webViewData = data;
|
||||
[self loadMarkdownContent];
|
||||
|
||||
// tell constraints they need updating
|
||||
[self setNeedsUpdateConstraints];
|
||||
|
||||
// update constraints now so we can animate the change
|
||||
[self updateConstraintsIfNeeded];
|
||||
|
||||
[self layoutIfNeeded];
|
||||
}
|
||||
|
||||
- (void)loadMarkdownContent {
|
||||
NSString *content = [self getMarkdownContentWithMarkdowString:self.webViewData.content];
|
||||
NSString *js = [NSString stringWithFormat:@"javascript:parseMarkdown(\"%@\",true)", content];
|
||||
[self.webView evaluateJavaScript:js completionHandler:nil];
|
||||
// Set webview background color
|
||||
[self.webView evaluateJavaScript:[NSString stringWithFormat:@"document.body.style.backgroundColor=\"%@\"",
|
||||
[self hexStringFromColor:self.webViewBkColor]] completionHandler:nil];
|
||||
// Set webview text color
|
||||
[self.webView evaluateJavaScript:[NSString stringWithFormat:@"document.getElementById('content').style.color=\"%@\"",
|
||||
[self hexStringFromColor:self.webViewTextColor]] completionHandler:nil];
|
||||
// Webview disables sliding and zooming
|
||||
NSString *injectionJSString = @"var script = document.createElement('meta');script.name = 'viewport';"
|
||||
"script.content=\"width=device-width, user-scalable=no\";"
|
||||
"document.getElementsByTagName('head')[0].appendChild(script);";
|
||||
[self.webView evaluateJavaScript:injectionJSString completionHandler:nil];
|
||||
}
|
||||
|
||||
- (NSString *)getMarkdownContentWithMarkdowString:(NSString *)markdown {
|
||||
markdown = [markdown stringByReplacingOccurrencesOfString:@"\r"withString:@""];
|
||||
markdown = [markdown stringByReplacingOccurrencesOfString:@"\n"withString:@"\\n"];
|
||||
markdown = [markdown stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""];
|
||||
markdown = [markdown stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"];
|
||||
markdown = [markdown stringByReplacingOccurrencesOfString:@"<br>" withString:@"\\n"];
|
||||
return markdown;
|
||||
}
|
||||
|
||||
#pragma mark - TUIMessageCellProtocol
|
||||
+ (CGSize)getContentSize:(TUIMessageCellData *)data {
|
||||
if ([data isKindOfClass:[TUIBotRichTextCellData class]]) {
|
||||
return CGSizeMake(TRichTextMessageCell_Width_Max, [(TUIBotRichTextCellData *)data cellHeight]);
|
||||
}
|
||||
return CGSizeZero;
|
||||
}
|
||||
|
||||
#pragma mark - WKNavigationDelegate
|
||||
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
|
||||
[self loadMarkdownContent];
|
||||
[self updateCellSize];
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
|
||||
if ([keyPath isEqualToString:@"contentSize"]) {
|
||||
[self limitUpdateCellSize];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
|
||||
if (navigationAction.navigationType == WKNavigationTypeLinkActivated) {
|
||||
if ([[UIApplication sharedApplication] canOpenURL:navigationAction.request.URL]) {
|
||||
[[UIApplication sharedApplication] openURL:navigationAction.request.URL options:@{} completionHandler:nil];
|
||||
}
|
||||
decisionHandler(WKNavigationActionPolicyCancel);
|
||||
} else {
|
||||
decisionHandler (WKNavigationActionPolicyAllow);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)limitUpdateCellSize {
|
||||
uint64_t curTs = [[NSDate date] timeIntervalSince1970];
|
||||
uint64_t interval = 1; // s
|
||||
if (curTs - self.webViewData.lastUpdateTs >= interval && self.webViewData.lastUpdateTs) {
|
||||
self.webViewData.lastUpdateTs = curTs;
|
||||
[self updateCellSize];
|
||||
} else {
|
||||
if (self.webViewData.delayUpdate) {
|
||||
return;
|
||||
}
|
||||
self.webViewData.delayUpdate = YES;
|
||||
@weakify(self)
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(interval * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
@strongify(self)
|
||||
[self updateCellSize];
|
||||
self.webViewData.delayUpdate = NO;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateCellSize {
|
||||
@weakify(self);
|
||||
[self.webView evaluateJavaScript:@"document.body.scrollWidth" completionHandler:^(id _Nullable result,NSError *_Nullable error) {
|
||||
CGFloat scrollWidth= [result doubleValue];
|
||||
[self.webView evaluateJavaScript:@"document.body.scrollHeight"completionHandler:^(id _Nullable result,NSError*_Nullable error) {
|
||||
@strongify(self)
|
||||
CGFloat scrollHeight = [result doubleValue];
|
||||
CGFloat ratio = CGRectGetWidth(self.webView.frame) /scrollWidth;
|
||||
CGFloat webHeight = scrollHeight * ratio;
|
||||
if (self.webViewData.cellHeight != webHeight) {
|
||||
self.webViewData.cellHeight = webHeight;
|
||||
[self notifyCellSizeChanged];
|
||||
}
|
||||
}];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)notifyCellSizeChanged {
|
||||
NSDictionary *param = @{TUICore_TUIPluginNotify_PluginViewSizeChangedSubKey_Message : self.webViewData.innerMessage};
|
||||
[TUICore notifyEvent:TUICore_TUIPluginNotify
|
||||
subKey:TUICore_TUIPluginNotify_PluginViewSizeChangedSubKey
|
||||
object:nil
|
||||
param:param];
|
||||
}
|
||||
|
||||
#pragma mark Util
|
||||
- (UIColor *)colorFromImage:(UIImage *)image point:(CGPoint)point {
|
||||
CGImageRef cgImage = image.CGImage;
|
||||
NSUInteger width = image.size.width;
|
||||
NSUInteger height = image.size.height;
|
||||
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
|
||||
int bytesPerPixel = 4;
|
||||
int bytesPerRow = bytesPerPixel * 1;
|
||||
NSUInteger bitsPerComponent = 8;
|
||||
unsigned char pixelData[4] = { 0, 0, 0, 0 };
|
||||
CGContextRef context = CGBitmapContextCreate(pixelData,
|
||||
1,
|
||||
1,
|
||||
bitsPerComponent,
|
||||
bytesPerRow,
|
||||
colorSpace,
|
||||
kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
|
||||
CGColorSpaceRelease(colorSpace);
|
||||
CGContextSetBlendMode(context, kCGBlendModeCopy);
|
||||
|
||||
// Draw the pixel we are interested in onto the bitmap context
|
||||
CGContextTranslateCTM(context, -point.x, point.y-(CGFloat)height);
|
||||
CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, (CGFloat)width, (CGFloat)height), cgImage);
|
||||
CGContextRelease(context);
|
||||
|
||||
// Convert color values [0..255] to floats [0.0..1.0]
|
||||
CGFloat red = (CGFloat)pixelData[0] / 255.0f;
|
||||
CGFloat green = (CGFloat)pixelData[1] / 255.0f;
|
||||
CGFloat blue = (CGFloat)pixelData[2] / 255.0f;
|
||||
CGFloat alpha = (CGFloat)pixelData[3] / 255.0f;
|
||||
return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
|
||||
}
|
||||
|
||||
- (NSString *)hexStringFromColor:(UIColor *)color {
|
||||
if (!color) {
|
||||
return @"";
|
||||
}
|
||||
const CGFloat *components = CGColorGetComponents(color.CGColor);
|
||||
|
||||
CGFloat r = components[0];
|
||||
CGFloat g = components[1];
|
||||
CGFloat b = components[2];
|
||||
|
||||
return [NSString stringWithFormat:@"#%02lX%02lX%02lX",
|
||||
lroundf(r * 255),
|
||||
lroundf(g * 255),
|
||||
lroundf(b * 255)];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
// Created by lynx on 2024/3/1.
|
||||
// Copyright © 2024 Tencent. All rights reserved.
|
||||
|
||||
#import <TIMCommon/TUIBubbleMessageCellData.h>
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TUIBotRichTextCellData : TUIBubbleMessageCellData
|
||||
@property(nonatomic, strong) NSString *content;
|
||||
@property(nonatomic, assign) CGFloat cellHeight;
|
||||
@property(nonatomic, assign) CGFloat lastUpdateTs;
|
||||
@property(nonatomic, assign) BOOL delayUpdate;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// TUIBotRichTextCellData.m
|
||||
// TUICustomerServicePlugin
|
||||
//
|
||||
// Created by lynx on 2024/3/1.
|
||||
// Copyright © 2024 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIBotRichTextCellData.h"
|
||||
#import <TIMCommon/TIMDefine.h>
|
||||
|
||||
@implementation TUIBotRichTextCellData
|
||||
|
||||
+ (TUIMessageCellData *)getCellData:(V2TIMMessage *)message {
|
||||
NSDictionary *param = [NSJSONSerialization JSONObjectWithData:message.customElem.data
|
||||
options:NSJSONReadingAllowFragments error:nil];
|
||||
if (param == nil) {
|
||||
return nil;
|
||||
}
|
||||
TUIBotRichTextCellData *cellData = [[TUIBotRichTextCellData alloc] initWithDirection:message.isSelf ? MsgDirectionOutgoing : MsgDirectionIncoming];
|
||||
cellData.innerMessage = message;
|
||||
cellData.content = param[@"content"];
|
||||
cellData.reuseId = TRichTextMessageCell_ReuserId;
|
||||
cellData.status = Msg_Status_Init;
|
||||
cellData.cellHeight = TRichTextMessageCell_Height_Default;
|
||||
return cellData;
|
||||
}
|
||||
|
||||
+ (NSString *)getDisplayString:(V2TIMMessage *)message {
|
||||
return @"Rich Text";
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// TUIChatBotStreamTextCell.h
|
||||
// TUICustomerServicePlugin
|
||||
//
|
||||
// Created by lynx on 2023/10/30.
|
||||
//
|
||||
|
||||
#import <TUIChat/TUITextMessageCell.h>
|
||||
#import "TUIBotStreamTextCellData.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TUIBotStreamTextCell : TUITextMessageCell
|
||||
- (void)fillWithData:(TUIBotStreamTextCellData *)data;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// TUIChatBotStreamTextCell.m
|
||||
// TUICustomerServicePlugin
|
||||
//
|
||||
// Created by lynx on 2023/10/30.
|
||||
//
|
||||
|
||||
#import "TUIBotStreamTextCell.h"
|
||||
#import <TIMCommon/TIMDefine.h>
|
||||
#import <TUICore/TUICore.h>
|
||||
|
||||
@implementation TUIBotStreamTextCell
|
||||
- (void)fillWithData:(TUIBotStreamTextCellData *)data {
|
||||
[super fillWithData:data];
|
||||
// 在线 Push 的文本需要流式展示
|
||||
if (Msg_Source_OnlinePush == data.source) {
|
||||
data.timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_main_queue());
|
||||
NSTimeInterval period = 0.05;
|
||||
dispatch_time_t start = dispatch_time(DISPATCH_TIME_NOW, period * NSEC_PER_SEC);
|
||||
dispatch_source_set_timer(data.timer, start, period * NSEC_PER_SEC, 0 * NSEC_PER_SEC);
|
||||
dispatch_source_set_event_handler(data.timer, ^{
|
||||
if (data.displayedContentLength == data.contentString.length) {
|
||||
[self stopTimer:data.timer];
|
||||
return;
|
||||
}
|
||||
data.displayedContentLength++;
|
||||
|
||||
if (self.textView.attributedText.length > 1 &&
|
||||
[self getAttributeStringRect:self.textView.attributedText].size.height >
|
||||
[self getAttributeStringRect:[self.textView.attributedText attributedSubstringFromRange:
|
||||
NSMakeRange(0, self.textView.attributedText.length - 1)]].size.height) {
|
||||
[self stopTimer:data.timer];
|
||||
[self notifyCellSizeChanged];
|
||||
} else {
|
||||
UIColor *textColor = self.class.incommingTextColor;
|
||||
UIFont *textFont = self.class.incommingTextFont;
|
||||
if (data.direction == MsgDirectionIncoming) {
|
||||
textColor = self.class.incommingTextColor;
|
||||
textFont = self.class.incommingTextFont;
|
||||
} else {
|
||||
textColor = self.class.outgoingTextColor;
|
||||
textFont = self.class.outgoingTextFont;
|
||||
}
|
||||
self.textView.attributedText = [data getContentAttributedString:textFont];
|
||||
self.textView.textColor = textColor;
|
||||
[self updateCellConstraints];
|
||||
}
|
||||
});
|
||||
dispatch_resume(data.timer);
|
||||
}
|
||||
}
|
||||
|
||||
- (CGRect)getAttributeStringRect:(NSAttributedString *)attributeString {
|
||||
return [attributeString boundingRectWithSize:CGSizeMake(TTextMessageCell_Text_Width_Max, MAXFLOAT)
|
||||
options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil];
|
||||
}
|
||||
|
||||
- (void)stopTimer:(dispatch_source_t)timer {
|
||||
if (timer) {
|
||||
dispatch_source_cancel(timer);
|
||||
timer = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)notifyCellSizeChanged {
|
||||
NSDictionary *param = @{TUICore_TUIPluginNotify_PluginViewSizeChangedSubKey_Message : self.textData.innerMessage};
|
||||
[TUICore notifyEvent:TUICore_TUIPluginNotify
|
||||
subKey:TUICore_TUIPluginNotify_PluginViewSizeChangedSubKey
|
||||
object:nil
|
||||
param:param];
|
||||
}
|
||||
|
||||
- (void)updateCellConstraints {
|
||||
// tell constraints they need updating
|
||||
[self setNeedsUpdateConstraints];
|
||||
// update constraints now so we can animate the change
|
||||
[self updateConstraintsIfNeeded];
|
||||
[self layoutIfNeeded];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// TUIBotStreamTextCellData.h
|
||||
// TUICustomerServicePlugin
|
||||
//
|
||||
// Created by lynx on 2023/10/30.
|
||||
//
|
||||
|
||||
#import <TUIChat/TUITextMessageCellData.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TUIBotStreamTextCellData : TUITextMessageCellData
|
||||
@property(nonatomic, strong) dispatch_source_t timer;
|
||||
@property(nonatomic, strong) UIFont *contentFont;
|
||||
@property(nonatomic, strong) NSAttributedString *contentString;
|
||||
@property(nonatomic, assign) NSInteger displayedContentLength;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,87 @@
|
||||
//
|
||||
// TUIBotStreamTextCellData.m
|
||||
// TUICustomerServicePlugin
|
||||
//
|
||||
// Created by lynx on 2023/10/30.
|
||||
//
|
||||
|
||||
#import "TUIBotStreamTextCellData.h"
|
||||
#import <TUICore/TUICore.h>
|
||||
|
||||
#ifndef CGFLOAT_CEIL
|
||||
#ifdef CGFLOAT_IS_DOUBLE
|
||||
#define CGFLOAT_CEIL(value) ceil(value)
|
||||
#else
|
||||
#define CGFLOAT_CEIL(value) ceilf(value)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@implementation TUIBotStreamTextCellData
|
||||
+ (TUIMessageCellData *)getCellData:(V2TIMMessage *)message {
|
||||
NSDictionary *param = [NSJSONSerialization JSONObjectWithData:message.customElem.data
|
||||
options:NSJSONReadingAllowFragments error:nil];
|
||||
if (param == nil) {
|
||||
return nil;
|
||||
}
|
||||
TUIBotStreamTextCellData *cellData = [[TUIBotStreamTextCellData alloc] initWithDirection:message.isSelf ? MsgDirectionOutgoing : MsgDirectionIncoming];
|
||||
cellData.innerMessage = message;
|
||||
cellData.content = [self getDisplayString:message];
|
||||
cellData.displayedContentLength = 0;
|
||||
cellData.reuseId = TTextMessageCell_ReuseId;
|
||||
cellData.status = Msg_Status_Init;
|
||||
return cellData;
|
||||
}
|
||||
|
||||
+ (NSString *)getDisplayString:(V2TIMMessage *)message {
|
||||
NSDictionary *param = [NSJSONSerialization JSONObjectWithData:message.customElem.data
|
||||
options:NSJSONReadingAllowFragments error:nil];
|
||||
if (param == nil) {
|
||||
return @"";
|
||||
}
|
||||
NSMutableString *displyString = [NSMutableString string];
|
||||
NSArray *chunks = param[@"chunks"];
|
||||
for (NSString *chunk in chunks) {
|
||||
[displyString appendString:chunk];
|
||||
}
|
||||
return [displyString copy];
|
||||
}
|
||||
|
||||
- (BOOL)customReloadCellWithNewMsg:(V2TIMMessage *)newMessage {
|
||||
NSDictionary *param = [NSJSONSerialization JSONObjectWithData:newMessage.customElem.data
|
||||
options:NSJSONReadingAllowFragments error:nil];
|
||||
if (param == nil) {
|
||||
return YES;
|
||||
}
|
||||
NSString *newContent = [self.class getDisplayString:newMessage];
|
||||
if (newContent.length <= self.content.length) {
|
||||
return YES;
|
||||
}
|
||||
self.innerMessage = newMessage;
|
||||
self.content = [self.class getDisplayString:newMessage];
|
||||
[TUICore notifyEvent:TUICore_TUIPluginNotify
|
||||
subKey:TUICore_TUIPluginNotify_DidChangePluginViewSubKey
|
||||
object:nil
|
||||
param:@{TUICore_TUIPluginNotify_DidChangePluginViewSubKey_Data : self}];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSAttributedString *)getContentAttributedString:(UIFont *)textFont {
|
||||
self.contentFont = textFont;
|
||||
self.contentString = [super getContentAttributedString:textFont];
|
||||
if (Msg_Source_OnlinePush == self.source) {
|
||||
if (self.displayedContentLength < self.contentString.length) {
|
||||
return [self.contentString attributedSubstringFromRange:NSMakeRange(0, self.displayedContentLength + 1)];
|
||||
}
|
||||
}
|
||||
return self.contentString;
|
||||
}
|
||||
|
||||
- (CGSize)getContentAttributedStringSize:(NSAttributedString *)attributeString maxTextSize:(CGSize)maxTextSize {
|
||||
CGSize size = [super getContentAttributedStringSize:attributeString maxTextSize:maxTextSize];
|
||||
if (size.height > CGFLOAT_CEIL(self.contentFont.lineHeight)) {
|
||||
return CGSizeMake(TTextMessageCell_Text_Width_Max, size.height);
|
||||
} else {
|
||||
return size;
|
||||
}
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// TUICustomerServicePluginBranchCell.h
|
||||
// TUICustomerServicePlugin
|
||||
//
|
||||
// Created by xia on 2023/5/30.
|
||||
//
|
||||
|
||||
#import <TIMCommon/TUIBubbleMessageCell.h>
|
||||
#import "TUICustomerServicePluginBranchCellData.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TUICustomerServicePluginBranchItemCell : UITableViewCell
|
||||
|
||||
@property (nonatomic, strong) UIImageView *topLine;
|
||||
@property (nonatomic, strong) UILabel *contentLabel;
|
||||
@property (nonatomic, strong) UIImageView *arrowView;
|
||||
|
||||
@end
|
||||
|
||||
@interface TUICustomerServicePluginBranchCell : TUIBubbleMessageCell
|
||||
|
||||
@property (nonatomic, strong) UILabel *headerLabel;
|
||||
//@property (nonatomic, strong) NSMutableArray *itemButtons;
|
||||
@property (nonatomic, strong) UITableView *itemsTableView;
|
||||
|
||||
- (void)fillWithData:(TUICustomerServicePluginBranchCellData *)data;
|
||||
|
||||
@property (nonatomic, strong) TUICustomerServicePluginBranchCellData *customData;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,188 @@
|
||||
//
|
||||
// TUICustomerServicePluginBranchCell.m
|
||||
// TUICustomerServicePlugin
|
||||
//
|
||||
// Created by xia on 2023/5/30.
|
||||
//
|
||||
|
||||
#import "TUICustomerServicePluginBranchCell.h"
|
||||
#import "TUICustomerServicePluginDataProvider.h"
|
||||
#import "TUICustomerServicePluginDataProvider+CalculateSize.h"
|
||||
#import <TIMCommon/TIMDefine.h>
|
||||
|
||||
@implementation TUICustomerServicePluginBranchItemCell
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
if (self) {
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
self.contentView.backgroundColor = [UIColor clearColor];
|
||||
|
||||
_topLine = [[UIImageView alloc] init];
|
||||
[_topLine setImage:TUICustomerServicePluginBundleThemeImage(@"customer_service_branch_dotted_line_img", @"dotted_line")];
|
||||
[self.contentView addSubview:_topLine];
|
||||
|
||||
_contentLabel = [[UILabel alloc] init];
|
||||
_contentLabel.font = [UIFont systemFontOfSize:16];
|
||||
_contentLabel.numberOfLines = 0;
|
||||
_contentLabel.lineBreakMode = NSLineBreakByTruncatingTail;
|
||||
_contentLabel.textColor = TUICustomerServicePluginDynamicColor(@"customer_service_branch_content_text_color", @"#368DFF");
|
||||
[self.contentView addSubview:_contentLabel];
|
||||
|
||||
_arrowView = [[UIImageView alloc] init];
|
||||
[_arrowView setImage:TUICustomerServicePluginBundleThemeImage(@"customer_service_branch_arrow_img", @"arrow")];
|
||||
[self.contentView addSubview:_arrowView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
// this is Apple's recommended place for adding/updating constraints
|
||||
- (void)updateConstraints {
|
||||
[super updateConstraints];
|
||||
|
||||
[self.topLine mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(TUICustomerServicePluginBranchCellMargin);
|
||||
make.top.mas_equalTo(0);
|
||||
make.width.mas_equalTo(self.mm_w - TUICustomerServicePluginBranchCellMargin * 2);
|
||||
make.height.mas_equalTo(0.5);
|
||||
}];
|
||||
|
||||
[self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(TUICustomerServicePluginBranchCellMargin);
|
||||
make.top.mas_equalTo(0);
|
||||
make.width.mas_equalTo(self.mm_w - TUICustomerServicePluginBranchCellMargin * 2 - 5 - 6);
|
||||
make.height.mas_equalTo([TUICustomerServicePluginDataProvider calcBranchCellHeightOfContent:self.contentLabel.text]);
|
||||
}];
|
||||
|
||||
[self.arrowView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.contentLabel.mas_trailing).offset(6);
|
||||
make.top.mas_equalTo((self.mm_h - self.arrowView.mm_h) / 2.0);
|
||||
make.width.mas_equalTo(5);
|
||||
make.height.mas_equalTo(9);
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface TUICustomerServicePluginBranchCell() <UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@end
|
||||
|
||||
@implementation TUICustomerServicePluginBranchCell
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
if (self) {
|
||||
_headerLabel = [[UILabel alloc] init];
|
||||
_headerLabel.font = [UIFont systemFontOfSize:16];
|
||||
_headerLabel.numberOfLines = 0;
|
||||
_headerLabel.lineBreakMode = NSLineBreakByTruncatingTail;
|
||||
_headerLabel.textColor = TUICustomerServicePluginDynamicColor(@"customer_service_branch_header_text_color", @"#000000");
|
||||
[self.container addSubview:_headerLabel];
|
||||
|
||||
_itemsTableView = [[UITableView alloc] init];
|
||||
_itemsTableView.tableFooterView = [[UIView alloc] init];
|
||||
// _itemsTableView.backgroundColor = TUICoreDynamicColor(@"customer_service_brance_bg_color", @"#FFFFFF");
|
||||
_itemsTableView.backgroundColor = [UIColor clearColor];
|
||||
_itemsTableView.delegate = self;
|
||||
_itemsTableView.dataSource = self;
|
||||
_itemsTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
[_itemsTableView registerClass:[TUICustomerServicePluginBranchItemCell class] forCellReuseIdentifier:@"item_cell"];
|
||||
[self.container addSubview:_itemsTableView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)fillWithData:(TUICustomerServicePluginBranchCellData *)data {
|
||||
[super fillWithData:data];
|
||||
|
||||
self.customData = data;
|
||||
self.headerLabel.text = data.header;
|
||||
[self.itemsTableView reloadData];
|
||||
|
||||
// tell constraints they need updating
|
||||
[self setNeedsUpdateConstraints];
|
||||
|
||||
// update constraints now so we can animate the change
|
||||
[self updateConstraintsIfNeeded];
|
||||
|
||||
[self layoutIfNeeded];
|
||||
}
|
||||
|
||||
// Override, the size of bubble content.
|
||||
+ (CGSize)getContentSize:(TUIMessageCellData *)data {
|
||||
NSAssert([data isKindOfClass:TUICustomerServicePluginBranchCellData.class],
|
||||
@"data must be a kind of TUICustomerServicePluginBranchCellData");
|
||||
TUICustomerServicePluginBranchCellData *branchCellData = (TUICustomerServicePluginBranchCellData *)data;
|
||||
return [TUICustomerServicePluginDataProvider calcBranchCellSize:branchCellData.header
|
||||
items:branchCellData.items];
|
||||
}
|
||||
|
||||
- (void)updateConstraints {
|
||||
[super updateConstraints];
|
||||
|
||||
CGFloat cellHeight = [TUICustomerServicePluginDataProvider calcBranchCellSize:self.customData.header
|
||||
items:self.customData.items].height;
|
||||
CGSize tableViewSize = [TUICustomerServicePluginDataProvider calcBranchCellSizeOfTableView:self.customData.items];
|
||||
CGSize headerSize= [TUICustomerServicePluginDataProvider calcBranchCellSizeOfHeader:self.customData.header];
|
||||
|
||||
self.container
|
||||
.mm_width(TUICustomerServicePluginBranchCellWidth)
|
||||
.mm_height(cellHeight);
|
||||
|
||||
[self.headerLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(TUICustomerServicePluginBranchCellMargin);
|
||||
make.top.mas_equalTo(TUICustomerServicePluginBranchCellMargin);
|
||||
make.width.mas_equalTo(headerSize.width);
|
||||
make.height.mas_equalTo(headerSize.height);
|
||||
}];
|
||||
|
||||
[self.itemsTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(0);
|
||||
make.top.mas_equalTo(self.headerLabel.mas_bottom).offset(TUICustomerServicePluginBranchCellInnerMargin);
|
||||
make.width.mas_equalTo(tableViewSize.width);
|
||||
make.height.mas_equalTo(tableViewSize.height);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - UITableViewDelegate & UITableViewDataSource
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
return [TUICustomerServicePluginDataProvider calcBranchCellHeightOfTableView:self.customData.items row:indexPath.row];
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if (self.customData.items.count <= indexPath.row) {
|
||||
return;
|
||||
}
|
||||
if (self.customData.selected) {
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:NO];
|
||||
return;
|
||||
}
|
||||
NSString *content = self.customData.items[indexPath.row];
|
||||
[TUICustomerServicePluginDataProvider sendTextMessage:content];
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
return self.customData.items.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if (self.customData.items.count <= indexPath.row) {
|
||||
return nil;
|
||||
}
|
||||
NSString *content = self.customData.items[indexPath.row];
|
||||
TUICustomerServicePluginBranchItemCell *cell = [tableView dequeueReusableCellWithIdentifier:@"item_cell" forIndexPath:indexPath];
|
||||
cell.contentLabel.text = content;
|
||||
|
||||
// tell constraints they need updating
|
||||
[cell setNeedsUpdateConstraints];
|
||||
|
||||
// update constraints now so we can animate the change
|
||||
[cell updateConstraintsIfNeeded];
|
||||
|
||||
[cell layoutIfNeeded];
|
||||
return cell;
|
||||
}
|
||||
|
||||
@end
|
||||