Procházet zdrojové kódy

Add confirmation action sheet when clearing requests.

Makes it more clear that the delete has occurred.
Ryan Olson před 11 roky
rodič
revize
3eae2ce457

+ 12 - 2
Classes/Network/FLEXNetworkSettingsTableViewController.m

@@ -11,7 +11,7 @@
 #import "FLEXNetworkRecorder.h"
 #import "FLEXNetworkRecorder.h"
 #import "FLEXUtility.h"
 #import "FLEXUtility.h"
 
 
-@interface FLEXNetworkSettingsTableViewController ()
+@interface FLEXNetworkSettingsTableViewController () <UIActionSheetDelegate>
 
 
 @property (nonatomic, copy) NSArray *cells;
 @property (nonatomic, copy) NSArray *cells;
 
 
@@ -82,7 +82,8 @@
 
 
 - (void)clearRequestsTapped:(UIButton *)sender
 - (void)clearRequestsTapped:(UIButton *)sender
 {
 {
-    [[FLEXNetworkRecorder defaultRecorder] clearRecordedActivity];
+    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Clear Recorded Requests" otherButtonTitles:nil];
+    [actionSheet showInView:self.view];
 }
 }
 
 
 #pragma mark - Table view data source
 #pragma mark - Table view data source
@@ -102,6 +103,15 @@
     return [self.cells objectAtIndex:indexPath.row];
     return [self.cells objectAtIndex:indexPath.row];
 }
 }
 
 
+#pragma mark - UIActionSheetDelegate
+
+- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
+{
+    if (buttonIndex != actionSheet.cancelButtonIndex) {
+        [[FLEXNetworkRecorder defaultRecorder] clearRecordedActivity];
+    }
+}
+
 #pragma mark - Helpers
 #pragma mark - Helpers
 
 
 - (UITableViewCell *)switchCellWithTitle:(NSString *)title toggleAction:(SEL)toggleAction isOn:(BOOL)isOn
 - (UITableViewCell *)switchCellWithTitle:(NSString *)title toggleAction:(SEL)toggleAction isOn:(BOOL)isOn