react-native-navigation的迁移库

RNNScreenTransition.m 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #import "RNNScreenTransition.h"
  2. #import "OptionsArrayParser.h"
  3. @implementation RNNScreenTransition
  4. - (instancetype)initWithDict:(NSDictionary *)dict {
  5. self = [super init];
  6. self.topBar = [[ElementTransitionOptions alloc] initWithDict:dict[@"topBar"]];
  7. self.content = [[ElementTransitionOptions alloc] initWithDict:dict[@"content"]];
  8. self.bottomTabs = [[ElementTransitionOptions alloc] initWithDict:dict[@"bottomTabs"]];
  9. self.enable = [BoolParser parse:dict key:@"enabled"];
  10. self.waitForRender = [BoolParser parse:dict key:@"waitForRender"];
  11. self.duration = [TimeIntervalParser parse:dict key:@"duration"];
  12. self.sharedElementTransitions = [OptionsArrayParser parse:dict key:@"sharedElementTransitions" ofClass:SharedElementTransitionOptions.class];
  13. self.elementTransitions = [OptionsArrayParser parse:dict key:@"elementTransitions" ofClass:ElementTransitionOptions.class];
  14. return self;
  15. }
  16. - (BOOL)hasCustomAnimation {
  17. return (self.topBar.hasAnimation || self.content.hasAnimation || self.bottomTabs.hasAnimation || self.sharedElementTransitions || self.elementTransitions);
  18. }
  19. - (BOOL)shouldWaitForRender {
  20. return [self.waitForRender getWithDefaultValue:NO] || self.hasCustomAnimation;
  21. }
  22. - (NSTimeInterval)maxDuration {
  23. NSTimeInterval maxDuration = 0;
  24. if ([self.topBar maxDuration] > maxDuration) {
  25. maxDuration = [self.topBar maxDuration];
  26. }
  27. if ([self.content maxDuration] > maxDuration) {
  28. maxDuration = [self.content maxDuration];
  29. }
  30. if ([self.bottomTabs maxDuration] > maxDuration) {
  31. maxDuration = [self.bottomTabs maxDuration];
  32. }
  33. for (ElementTransitionOptions* elementTransition in self.elementTransitions) {
  34. if (elementTransition.maxDuration > maxDuration) {
  35. maxDuration = elementTransition.maxDuration;
  36. }
  37. }
  38. for (SharedElementTransitionOptions* sharedElementTransition in self.sharedElementTransitions) {
  39. if (sharedElementTransition.maxDuration > maxDuration) {
  40. maxDuration = sharedElementTransition.maxDuration;
  41. }
  42. }
  43. return maxDuration;
  44. }
  45. @end