From d21b7b001cd9bad4cc6e27305b05cc46c35eaa12 Mon Sep 17 00:00:00 2001 From: Andreas Linde Date: Tue, 4 Jun 2013 14:54:04 +0200 Subject: [PATCH] More changes to the behavior of first forced user data and compose UI presentation This is a change to previous behavior! Now the SDK by default shows the user data UI and subsequent compose UI always modally to ensure proper functionality on all scenarios the feedback viewer can be presented. The new property `showFirstRequiredPresentationModal` in `BITFeedbackManager` can be set to `NO` if the previous behavior of pushing the UI and Compose view onto the stack, when those are being forced to be shown on the first presentation of the feedback UI. Especially if you present the UI in a popover, you should NOT change this property! --- Classes/BITFeedbackListViewController.m | 52 +++++++++++++++++++------ Classes/BITFeedbackManager.h | 23 +++++++++++ Classes/BITFeedbackManager.m | 1 + 3 files changed, 64 insertions(+), 12 deletions(-) diff --git a/Classes/BITFeedbackListViewController.m b/Classes/BITFeedbackListViewController.m index 817a2647b1..bcda008e63 100644 --- a/Classes/BITFeedbackListViewController.m +++ b/Classes/BITFeedbackListViewController.m @@ -197,12 +197,16 @@ ) { self.userDataComposeFlow = YES; - // In case of presenting the feedback in a UIPopoverController it appears - // that the animation is not yet finished (though it should) and pushing - // the user data view on top of the navigation stack right away will - // cause the following warning to appear in the console: - // "nested push animation can result in corrupted navigation bar" - [self performSelector:@selector(showDelayedUserDataViewController) withObject:nil afterDelay:0.0]; + if ([self.manager showFirstRequiredPresentationModal]) { + [self setUserDataAction:nil]; + } else { + // In case of presenting the feedback in a UIPopoverController it appears + // that the animation is not yet finished (though it should) and pushing + // the user data view on top of the navigation stack right away will + // cause the following warning to appear in the console: + // "nested push animation can result in corrupted navigation bar" + [self performSelector:@selector(showDelayedUserDataViewController) withObject:nil afterDelay:0.0]; + } } else { [self.tableView reloadData]; } @@ -299,7 +303,15 @@ -(void)userDataUpdateCancelled { if (self.userDataComposeFlow) { - [self.navigationController popToViewController:self animated:YES]; + if ([self.manager showFirstRequiredPresentationModal]) { + __weak typeof(self) weakSelf = self; + [self dismissViewControllerAnimated:YES completion:^(void){ + typeof(self) strongSelf = weakSelf; + [strongSelf.tableView reloadData]; + }]; + } else { + [self.navigationController popToViewController:self animated:YES]; + } } else { [self dismissViewControllerAnimated:YES completion:^(void){}]; } @@ -309,10 +321,18 @@ [self.manager saveMessages]; if (self.userDataComposeFlow) { - BITFeedbackComposeViewController *composeController = [[BITFeedbackComposeViewController alloc] init]; - composeController.delegate = self; - - [self.navigationController pushViewController:composeController animated:YES]; + if ([self.manager showFirstRequiredPresentationModal]) { + __weak typeof(self) weakSelf = self; + [self dismissViewControllerAnimated:YES completion:^(void){ + typeof(self) strongSelf = weakSelf; + [strongSelf newFeedbackAction:nil]; + }]; + } else { + BITFeedbackComposeViewController *composeController = [[BITFeedbackComposeViewController alloc] init]; + composeController.delegate = self; + + [self.navigationController pushViewController:composeController animated:YES]; + } } else { [self dismissViewControllerAnimated:YES completion:^(void){}]; } @@ -323,7 +343,15 @@ - (void)feedbackComposeViewControllerDidFinish:(BITFeedbackComposeViewController *)composeViewController { if (self.userDataComposeFlow) { - [self.navigationController popToViewController:self animated:YES]; + if ([self.manager showFirstRequiredPresentationModal]) { + __weak typeof(self) weakSelf = self; + [self dismissViewControllerAnimated:YES completion:^(void){ + typeof(self) strongSelf = weakSelf; + [strongSelf.tableView reloadData]; + }]; + } else { + [self.navigationController popToViewController:self animated:YES]; + } } else { [self dismissViewControllerAnimated:YES completion:^(void){}]; } diff --git a/Classes/BITFeedbackManager.h b/Classes/BITFeedbackManager.h index 1bda3dfc71..e84996e40b 100644 --- a/Classes/BITFeedbackManager.h +++ b/Classes/BITFeedbackManager.h @@ -166,6 +166,29 @@ typedef enum { ///----------------------------------------------------------------------------- +/** + Indicates if an forced user data UI presentation is shown modal + + If `requireUserName` and/or `requireUserEmail` are enabled, the first presentation + of `feedbackListViewController:` and subsequent `feedbackComposeViewController:` + will automatically present a UI that lets the user provide this data and compose + a message. By default this is shown (since SDK 3.1) as a modal sheet. + + If you want the SDK to push this UI onto the navigation stack in this specific scenario, + then change the property to `NO`. + + @warning If you presenting the `BITFeedbackListViewController` in a popover, this property should not be changed! + + Default is `YES` + @see requireUserName + @see requireUserEmail + @see showFeedbackComposeView + @see feedbackComposeViewController: + @see showFeedbackListView + @see feedbackListViewController: + */ +@property (nonatomic, readwrite) BOOL showFirstRequiredPresentationModal; + /** Present the modal feedback list user interface. */ diff --git a/Classes/BITFeedbackManager.m b/Classes/BITFeedbackManager.m index eec35575e2..c54e76da40 100644 --- a/Classes/BITFeedbackManager.m +++ b/Classes/BITFeedbackManager.m @@ -71,6 +71,7 @@ _requireUserName = BITFeedbackUserDataElementOptional; _requireUserEmail = BITFeedbackUserDataElementOptional; _showAlertOnIncomingMessages = YES; + _showFirstRequiredPresentationModal = YES; _disableFeedbackManager = NO; _didSetupDidBecomeActiveNotifications = NO;