PreviewImageViewController.m 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // _____ _
  2. // |_ _| |_ _ _ ___ ___ _ __ __ _
  3. // | | | ' \| '_/ -_) -_) ' \/ _` |_
  4. // |_| |_||_|_| \___\___|_|_|_\__,_(_)
  5. //
  6. // Threema iOS Client
  7. // Copyright (c) 2012-2020 Threema GmbH
  8. //
  9. // This program is free software: you can redistribute it and/or modify
  10. // it under the terms of the GNU Affero General Public License, version 3,
  11. // as published by the Free Software Foundation.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU Affero General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Affero General Public License
  19. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. #import "PreviewImageViewController.h"
  21. #import "FLAnimatedImage.h"
  22. @interface PreviewImageViewController ()
  23. @end
  24. @implementation PreviewImageViewController
  25. - (void)viewWillAppear:(BOOL)animated {
  26. [super viewWillAppear:animated];
  27. if (self.gifData != nil) {
  28. FLAnimatedImageView *animatedImageView;
  29. animatedImageView = [[FLAnimatedImageView alloc] init];
  30. animatedImageView.animatedImage = [FLAnimatedImage animatedImageWithGIFData:self.gifData];
  31. animatedImageView.frame = self.imageView.frame;
  32. animatedImageView.contentMode = self.imageView.contentMode;
  33. animatedImageView.autoresizingMask = self.imageView.autoresizingMask;
  34. [self.imageView removeFromSuperview];
  35. [self.view addSubview:animatedImageView];
  36. self.imageView = animatedImageView;
  37. } else {
  38. self.imageView.image = [UIImage imageWithData:self.image];
  39. }
  40. if (!self.hasCancelButton)
  41. self.navigationItem.leftBarButtonItem = nil;
  42. }
  43. - (BOOL)shouldAutorotate {
  44. return YES;
  45. }
  46. -(UIInterfaceOrientationMask)supportedInterfaceOrientations {
  47. if (SYSTEM_IS_IPAD) {
  48. return UIInterfaceOrientationMaskAll;
  49. }
  50. return UIInterfaceOrientationMaskAllButUpsideDown;
  51. }
  52. - (IBAction)sendAction:(id)sender {
  53. if (self.gifData != nil)
  54. [self.delegate previewImageControllerDidChooseToSend:self gif:self.gifData];
  55. else
  56. [self.delegate previewImageControllerDidChooseToSend:self imageData:self.image];
  57. }
  58. - (IBAction)cancelAction:(id)sender {
  59. [self.delegate previewImageControllerDidChooseToCancel:self];
  60. }
  61. @end