Skip to content

support setting default message #2

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 29 additions & 14 deletions ios/Classes/ZendeskPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
} else if ([@"startChat" isEqualToString:call.method]) {
NSNumber *navigationBarColor = call.arguments[@"iosNavigationBarColor"];
NSNumber *navigationTitleColor = call.arguments[@"iosNavigationTitleColor"];


NSString *defaultInputFieldValue = call.arguments[@"defaultInputFieldValue"];

UINavigationController *navVc = [[UINavigationController alloc] init];
navVc.navigationBar.translucent = NO;
navVc.navigationBar.barTintColor = ARGB_COLOR([navigationBarColor integerValue]);//
navVc.navigationBar.barTintColor = ARGB_COLOR([navigationBarColor integerValue]);
navVc.navigationBar.titleTextAttributes = @{
NSForegroundColorAttributeName: ARGB_COLOR([navigationTitleColor integerValue])
};
Expand All @@ -68,7 +67,6 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
messagingConfiguration.name = @"";
NSError *error = nil;


ZDKChatConfiguration *chatConfiguration = [[ZDKChatConfiguration alloc] init];
chatConfiguration.isPreChatFormEnabled = NO;
chatConfiguration.isAgentAvailabilityEnabled = YES;
Expand All @@ -85,20 +83,37 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
error:&error];
// Present view controller
[navVc pushViewController:viewController animated:YES];



if (defaultInputFieldValue != nil && ![defaultInputFieldValue isKindOfClass:[NSNull class]] && defaultInputFieldValue.length > 0) {
for (UIView *item in viewController.view.subviews) {
if([NSStringFromClass([item class]) isEqualToString:@"CommonUISDK.InputField"]) {
for (UIView* subItem in item.subviews) {
if ([subItem isKindOfClass:[UIView class]]) {
for (UIView* view in subItem.subviews) {
if ([view isKindOfClass:[UITextView class]]) {
((UITextView*)view).text = defaultInputFieldValue;
for (UIView* subview in view.subviews) {
if ([subview isKindOfClass:[UILabel class]]) {
subview.hidden = true;
}
}
}
}
}
}
}
}
}

UIBarButtonItem *back = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Back", comment: @"")
style:UIBarButtonItemStylePlain target:self action:@selector(close:)];
[back setTitleTextAttributes:@{ NSForegroundColorAttributeName: ARGB_COLOR([navigationTitleColor integerValue])} forState:UIControlStateNormal];
navVc.topViewController.navigationItem.leftBarButtonItem = back;

UIViewController *rootVc = [UIApplication sharedApplication].keyWindow.rootViewController ;
[rootVc presentViewController:navVc
animated:true
completion:^{
UIBarButtonItem *back = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Back", comment: @"")
style:UIBarButtonItemStylePlain
target:self
action:@selector(close:)];
[back setTitleTextAttributes:@{ NSForegroundColorAttributeName: ARGB_COLOR([navigationTitleColor integerValue])} forState:UIControlStateNormal];

navVc.topViewController.navigationItem.leftBarButtonItem = back;

}];
[ZDKCoreLogger setEnabled:YES];
[ZDKCoreLogger setLogLevel:ZDKLogLevelDebug];
Expand Down
2 changes: 2 additions & 0 deletions lib/zendesk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ class Zendesk {
Future<void> startChat({
Color iosNavigationBarColor,
Color iosNavigationTitleColor,
String defaultInputFieldValue = "",
}) async {
await _channel.invokeMethod('startChat', {
'iosNavigationBarColor': iosNavigationBarColor?.value,
'iosNavigationTitleColor': iosNavigationTitleColor?.value,
'defaultInputFieldValue': defaultInputFieldValue,
});
}

Expand Down