react-native-navigation的迁移库

TransitionOptions.m 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #import "TransitionOptions.h"
  2. @implementation TransitionOptions
  3. - (instancetype)initWithDict:(NSDictionary *)dict {
  4. self = [super init];
  5. self.alpha = [[TransitionDetailsOptions alloc] initWithDict:dict[@"alpha"]];
  6. self.x = [[TransitionDetailsOptions alloc] initWithDict:dict[@"x"]];
  7. self.y = [[TransitionDetailsOptions alloc] initWithDict:dict[@"y"]];
  8. self.translationX = [[TransitionDetailsOptions alloc] initWithDict:dict[@"translationX"]];
  9. self.translationY = [[TransitionDetailsOptions alloc] initWithDict:dict[@"translationY"]];
  10. self.rotationX = [[TransitionDetailsOptions alloc] initWithDict:dict[@"rotationX"]];
  11. self.rotationY = [[TransitionDetailsOptions alloc] initWithDict:dict[@"rotationY"]];
  12. self.waitForRender = [BoolParser parse:dict key:@"waitForRender"];
  13. self.enable = [BoolParser parse:dict key:@"enabled"];
  14. return self;
  15. }
  16. - (BOOL)hasAnimation {
  17. return self.x.hasAnimation || self.y.hasAnimation || self.alpha.hasAnimation || self.translationX.hasAnimation || self.translationY.hasAnimation || self.rotationX.hasAnimation || self.rotationY.hasAnimation;
  18. }
  19. - (NSTimeInterval)maxDuration {
  20. double maxDuration = 0;
  21. if ([_x.duration getWithDefaultValue:0] > maxDuration) {
  22. maxDuration = [_x.duration getWithDefaultValue:0];
  23. }
  24. if ([_y.duration getWithDefaultValue:0] > maxDuration) {
  25. maxDuration = [_y.duration getWithDefaultValue:0];
  26. }
  27. if ([_translationX.duration getWithDefaultValue:0] > maxDuration) {
  28. maxDuration = [_translationX.duration getWithDefaultValue:0];
  29. }
  30. if ([_translationY.duration getWithDefaultValue:0] > maxDuration) {
  31. maxDuration = [_translationY.duration getWithDefaultValue:0];
  32. }
  33. if ([_rotationX.duration getWithDefaultValue:0] > maxDuration) {
  34. maxDuration = [_rotationX.duration getWithDefaultValue:0];
  35. }
  36. if ([_rotationY.duration getWithDefaultValue:0] > maxDuration) {
  37. maxDuration = [_rotationY.duration getWithDefaultValue:0];
  38. }
  39. if ([_alpha.duration getWithDefaultValue:0] > maxDuration) {
  40. maxDuration = [_alpha.duration getWithDefaultValue:0];
  41. }
  42. return maxDuration;
  43. }
  44. @end