Fix issues in feedback compose UI

- "Add image" button not reappearing when deleting the 3rd attachment
- Attachment scrollview not being always scrollable when it should be
- Support for rotating and correctly adjusting the attachment scrollview
This commit is contained in:
Andreas Linde 2015-02-12 21:13:57 +01:00
parent 62482b1721
commit bc475061f2

View File

@ -56,6 +56,8 @@
@property (nonatomic, strong) UIScrollView *attachmentScrollView; @property (nonatomic, strong) UIScrollView *attachmentScrollView;
@property (nonatomic, strong) NSMutableArray *attachmentScrollViewImageViews; @property (nonatomic, strong) NSMutableArray *attachmentScrollViewImageViews;
@property (nonatomic, strong) UIButton *addPhotoButton;
@property (nonatomic, strong) NSString *text; @property (nonatomic, strong) NSString *text;
@property (nonatomic, strong) NSMutableArray *attachments; @property (nonatomic, strong) NSMutableArray *attachments;
@ -229,13 +231,14 @@
// Add Photo Button + Container that's displayed above the keyboard. // Add Photo Button + Container that's displayed above the keyboard.
self.textAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 44)]; self.textAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 44)];
self.textAccessoryView.backgroundColor = [UIColor colorWithRed:0.9f green:0.9f blue:0.9f alpha:1.0f]; self.textAccessoryView.backgroundColor = [UIColor colorWithRed:0.9f green:0.9f blue:0.9f alpha:1.0f];
UIButton *addPhotoButton = [UIButton buttonWithType:UIButtonTypeCustom]; self.addPhotoButton = [UIButton buttonWithType:UIButtonTypeCustom];
[addPhotoButton setTitle:BITHockeyLocalizedString(@"HockeyFeedbackComposeAttachmentAddImage") forState:UIControlStateNormal]; [self.addPhotoButton setTitle:BITHockeyLocalizedString(@"HockeyFeedbackComposeAttachmentAddImage") forState:UIControlStateNormal];
[addPhotoButton setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal]; [self.addPhotoButton setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
addPhotoButton.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 44); [self.addPhotoButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateDisabled];
[addPhotoButton addTarget:self action:@selector(addPhotoAction:) forControlEvents:UIControlEventTouchUpInside]; self.addPhotoButton.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 44);
[self.addPhotoButton addTarget:self action:@selector(addPhotoAction:) forControlEvents:UIControlEventTouchUpInside];
[self.textAccessoryView addSubview:addPhotoButton]; [self.textAccessoryView addSubview:self.addPhotoButton];
self.textView.inputAccessoryView = self.textAccessoryView; self.textView.inputAccessoryView = self.textAccessoryView;
@ -329,7 +332,8 @@
if (!alreadySetup) { if (!alreadySetup) {
textViewFrame.size.width -= scrollViewWidth; textViewFrame.size.width -= scrollViewWidth;
scrollViewFrame = CGRectMake(CGRectGetMaxX(textViewFrame), self.view.frame.origin.y, scrollViewWidth, CGRectGetHeight(self.view.bounds)); // height has to be identical to the textview!
scrollViewFrame = CGRectMake(CGRectGetMaxX(textViewFrame), self.view.frame.origin.y, scrollViewWidth, CGRectGetHeight(self.textView.bounds));
self.textView.frame = textViewFrame; self.textView.frame = textViewFrame;
self.attachmentScrollView.frame = scrollViewFrame; self.attachmentScrollView.frame = scrollViewFrame;
self.attachmentScrollView.contentInset = self.textView.contentInset; self.attachmentScrollView.contentInset = self.textView.contentInset;
@ -382,13 +386,22 @@
} }
if (self.imageAttachments.count > 2){ if (self.imageAttachments.count > 2){
self.textView.inputAccessoryView = nil; [self.addPhotoButton setEnabled:NO];
} else { } else {
self.textView.inputAccessoryView = self.textAccessoryView; [self.addPhotoButton setEnabled:YES];
} }
} }
- (void)removeAttachmentScrollView {
CGRect frame = self.attachmentScrollView.frame;
frame.size.width = 0;
self.attachmentScrollView.frame = frame;
frame = self.textView.frame;
frame.size.width += 100;
self.textView.frame = frame;
}
#pragma mark - UIViewController Rotation #pragma mark - UIViewController Rotation
@ -396,6 +409,12 @@
return YES; return YES;
} }
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[self removeAttachmentScrollView];
[self refreshAttachmentScrollview];
}
#pragma mark - Private methods #pragma mark - Private methods