Skip to content

Commit

Permalink
Merge pull request #362 from TimOliver/fix-cancel-crash
Browse files Browse the repository at this point in the history
Fixed crash when trying to confirm cancel action on iPad
  • Loading branch information
TimOliver authored Jul 7, 2019
2 parents 6672f22 + 7de4a54 commit 3870234
Show file tree
Hide file tree
Showing 29 changed files with 64 additions and 41 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
x.y.z Release Notes (yyyy-MM-dd)
=============================================================

2.5.1 Release Notes (2019-07-08)
=============================================================

## Added

* Finnish Language Support ([#360](https://github.com/TimOliver/TOCropViewController/pull/360))

## Enhancements

* Improved the UX of the cancellation dialog by changing the buttons from affirmative actions to explicit actions. ([#362](https://github.com/TimOliver/TOCropViewController/pull/362))

## Fixed
* A crash that would occur if the cancellation confirmation dialog was attempted to be displayed on iPad. ([#362](https://github.com/TimOliver/TOCropViewController/pull/362))

2.5.0 Release Notes (2019-04-21)
=============================================================

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"Reset" = "Reset";
"Original" = "Original";
"Square" = "Square";
"Delete Changes?" = "Delete Changes?";
"Delete Changes" = "Delete Changes";
"Yes" = "Yes";
"No" = "No";
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Reset" = "إعادة تعيين";
"Original" = "أصلي";
"Square" = "مربع";
"Delete Changes?" = "حذف التغييرات؟";
"Delete Changes" = "حذف التغييرات";
"Yes" = "نعم";
"No" = "لا";

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"Reset" = "Nulstil";
"Original" = "Original";
"Square" = "Firkantet";
"Delete Changes?" = "Slet ændringer?";
"Delete Changes" = "Slet ændringer";
"Yes" = "Ja";
"No" = "Nej";
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"Reset" = "Zurücksetzen";
"Original" = "Original";
"Square" = "Quadrat";
"Delete Changes?" = "Änderungen löschen?";
"Delete Changes" = "Änderungen löschen";
"Yes" = "Ja";
"No" = "Nein";
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"Reset" = "Reset";
"Original" = "Original";
"Square" = "Square";
"Delete Changes?" = "Delete Changes?";
"Delete Changes" = "Delete Changes";
"Yes" = "Yes";
"No" = "No";
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"Reset" = "Cambiar";
"Original" = "Original";
"Square" = "Cuadrada";
"Delete Changes?" = "Eliminar cambios?";
"Delete Changes" = "Eliminar cambios";
"Yes" = "Sí";
"No" = "No";
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"Reset" = "بازنشانی";
"Original" = "اصلی";
"Square" = "مربع";
"Delete Changes?" = "حذف تغییرات؟";
"Delete Changes" = "حذف تغییرات";
"Yes" = "آری";
"No" = "نه";
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"Reset" = "بازنشانی";
"Original" = "اصلی";
"Square" = "مربع";
"Delete Changes?" = "حذف تغییرات؟";
"Delete Changes" = "حذف تغییرات";
"Yes" = "آری";
"No" = "نه";
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"Reset" = "Palauta";
"Original" = "Alkuperäinen";
"Square" = "Neliö";
"Delete Changes?" = "Peru muutokset?";
"Delete Changes" = "Peru muutokset";
"Yes" = "Kyllä";
"No" = "Ei";
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"Reset" = "Réinitialiser";
"Original" = "D’origine";
"Square" = "Carré";
"Delete Changes?" = "Supprimer les modifications?";
"Delete Changes" = "Supprimer les modifications";
"Yes" = "Oui";
"No" = "Non";
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Reset" = "Visszaállítás";
"Original" = "Eredeti";
"Square" = "Négyzet";
"Delete Changes?" = "Módosítások törlése?";
"Delete Changes" = "Módosítások törlése";
"Yes" = "Igen";
"No" = "Nem";

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"Reset" = "Atur Ulang";
"Original" = "Asli";
"Square" = "Persegi";
"Delete Changes?" = "Hapus Perubahan?";
"Delete Changes" = "Hapus Perubahan";
"Yes" = "Ya";
"No" = "Tidak";
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"Reset" = "Ripristina";
"Original" = "Originale";
"Square" = "Quadrato";
"Delete Changes?" = "Elimina modifiche?";
"Delete Changes" = "Elimina modifiche";
"Yes" = "Sì";
"No" = "No";
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"Reset" = "リセット";
"Original" = "オリジナル";
"Square" = "スクエア";
"Delete Changes?" = "変更を削除?";
"Delete Changes" = "変更を削除";
"Yes" = "はい";
"No" = "いいえ";
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"Reset" = "재설정";
"Original" = "원본";
"Square" = "정방형";
"Delete Changes?" = "변경사항 삭제";
"Delete Changes" = "변경사항 삭제";
"Yes" = "예";
"No" = "아니요";
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"Reset" = "Reset";
"Original" = "Asal";
"Square" = "Segi empat";
"Delete Changes?" = "Padam Perubahan?";
"Delete Changes" = "Padam Perubahan";
"Yes" = "Ya";
"No" = "Tidak";
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"Reset" = "Herstel";
"Original" = "Origineel";
"Square" = "Vierkant";
"Delete Changes?" = "Wis wijzigingen?";
"Delete Changes" = "Wis wijzigingen";
"Yes" = "Ja";
"No" = "Nee";
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"Reset" = "Wyzeruj";
"Original" = "Orygin.";
"Square" = "Kwadrat";
"Delete Changes?" = "Usuń zmiany";
"Delete Changes" = "Usuń zmiany";
"Yes" = "Tak";
"No" = "Nie";
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"Reset" = "Redefinir";
"Original" = "Original";
"Square" = "Quadrada";
"Delete Changes?" = "Apagar Alterações?";
"Delete Changes" = "Apagar Alterações";
"Yes" = "Sim";
"No" = "Não";
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"Reset" = "Resetare";
"Original" = "Original";
"Square" = "Patrat";
"Delete Changes?" = "Ștergeți modificările";
"Delete Changes" = "Ștergeți modificările";
"Yes" = "Da";
"No" = "Nu";
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"Reset" = "Сбросить";
"Original" = "Оригинал";
"Square" = "Квадрат";
"Delete Changes?" = "Удалить изменения?";
"Delete Changes" = "Удалить изменения";
"Yes" = "Да";
"No" = "Нет";
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Reset" = "Sıfırla";
"Original" = "Orjinal";
"Square" = "Kare";
"Delete Changes?" = "Değişiklikleri Sil";
"Delete Changes" = "Değişiklikleri Sil";
"Yes" = "Evet";
"No" = "Hayır";

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Reset" = "Đặt lại";
"Original" = "Gốc";
"Square" = "Vuông";
"Delete Changes?" = "Xóa Thay đổi?";
"Delete Changes" = "Xóa Thay đổi";
"Yes" = "Có";
"No" = "Không";

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Reset" = "重设";
"Original" = "原有";
"Square" = "正方形";
"Delete Changes?" = "删除更改?";
"Delete Changes" = "删除更改";
"Yes" = "是";
"No" = "否";

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Reset" = "重置";
"Original" = "原始檔";
"Square" = "正方形";
"Delete Changes?" = "刪除更動?";
"Delete Changes" = "刪除更動";

"Yes" = "是";
"No" = "否";
11 changes: 5 additions & 6 deletions Objective-C/TOCropViewController/TOCropViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -841,22 +841,21 @@ - (void)dismissAnimatedFromParentViewController:(UIViewController *)viewControll
#pragma mark - Button Feedback -
- (void)cancelButtonTapped
{
if (!self.cropView.canBeReset || !self.showCancelConfirmationDialog) {
if (!self.showCancelConfirmationDialog) {
[self dismissCropViewController];
return;
}

// Get the resource bundle depending on the framework/dependency manager we're using
NSBundle *resourceBundle = TO_CROP_VIEW_RESOURCE_BUNDLE_FOR_OBJECT(self);

NSString *title = NSLocalizedStringFromTableInBundle(@"Delete Changes?", @"TOCropViewControllerLocalizable", resourceBundle, nil);
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
alertController.popoverPresentationController.sourceView = self.toolbar.visibleCancelButton;


NSString *yesButtonTitle = NSLocalizedStringFromTableInBundle(@"Yes", @"TOCropViewControllerLocalizable", resourceBundle, nil);
NSString *noButtonTitle = NSLocalizedStringFromTableInBundle(@"No", @"TOCropViewControllerLocalizable", resourceBundle, nil);
NSString *yesButtonTitle = NSLocalizedStringFromTableInBundle(@"Delete Changes", @"TOCropViewControllerLocalizable", resourceBundle, nil);
NSString *noButtonTitle = NSLocalizedStringFromTableInBundle(@"Cancel", @"TOCropViewControllerLocalizable", resourceBundle, nil);

__weak typeof (self) weakSelf = self;
UIAlertAction *yesAction = [UIAlertAction actionWithTitle:yesButtonTitle style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
Expand Down
21 changes: 11 additions & 10 deletions Objective-C/TOCropViewController/Views/TOCropToolbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,25 @@ NS_ASSUME_NONNULL_BEGIN

/* The 'Done' buttons to commit the crop. The text button is displayed
in portrait mode and the icon one, in landscape. */
@property (nonnull, nonatomic, strong, readonly) UIButton *doneTextButton;
@property (nonnull, nonatomic, strong, readonly) UIButton *doneIconButton;
@property (nonnull, nonatomic, copy) NSString *doneTextButtonTitle;
@property (nonatomic, strong, readonly) UIButton *doneTextButton;
@property (nonatomic, strong, readonly) UIButton *doneIconButton;
@property (nonatomic, copy) NSString *doneTextButtonTitle;


/* The 'Cancel' buttons to cancel the crop. The text button is displayed
in portrait mode and the icon one, in landscape. */
@property (nonnull, nonatomic, strong, readonly) UIButton *cancelTextButton;
@property (nonnull, nonatomic, strong, readonly) UIButton *cancelIconButton;
@property (nonnull, nonatomic, copy) NSString *cancelTextButtonTitle;
@property (nonatomic, strong, readonly) UIButton *cancelTextButton;
@property (nonatomic, strong, readonly) UIButton *cancelIconButton;
@property (nonatomic, readonly) UIView *visibleCancelButton;
@property (nonatomic, copy) NSString *cancelTextButtonTitle;

/* The cropper control buttons */
@property (nonnull, nonatomic, strong, readonly) UIButton *rotateCounterclockwiseButton;
@property (nonnull, nonatomic, strong, readonly) UIButton *resetButton;
@property (nonnull, nonatomic, strong, readonly) UIButton *clampButton;
@property (nonatomic, strong, readonly) UIButton *rotateCounterclockwiseButton;
@property (nonatomic, strong, readonly) UIButton *resetButton;
@property (nonatomic, strong, readonly) UIButton *clampButton;
@property (nullable, nonatomic, strong, readonly) UIButton *rotateClockwiseButton;

@property (nonnull, nonatomic, readonly) UIButton *rotateButton; // Points to `rotateCounterClockwiseButton`
@property (nonatomic, readonly) UIButton *rotateButton; // Points to `rotateCounterClockwiseButton`

/* Button feedback handler blocks */
@property (nullable, nonatomic, copy) void (^cancelButtonTapped)(void);
Expand Down
9 changes: 9 additions & 0 deletions Objective-C/TOCropViewController/Views/TOCropToolbar.m
Original file line number Diff line number Diff line change
Expand Up @@ -613,4 +613,13 @@ - (void)setStatusBarHeightInset:(CGFloat)statusBarHeightInset
[self setNeedsLayout];
}

- (UIView *)visibleCancelButton
{
if (self.cancelIconButton.hidden == NO) {
return self.cancelIconButton;
}

return self.cancelTextButton;
}

@end

0 comments on commit 3870234

Please sign in to comment.