react-native-navigation的迁移库

RNNSplitViewOptions.m 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #import "RNNSplitViewOptions.h"
  2. #import "RNNParentProtocol.h"
  3. @implementation RNNSplitViewOptions
  4. - (instancetype)initWithDict:(NSDictionary *)dict {
  5. self = [super init];
  6. self.displayMode = dict[@"displayMode"];
  7. self.primaryEdge = dict[@"primaryEdge"];
  8. NSNumberFormatter *f = [[NSNumberFormatter alloc] init];
  9. f.numberStyle = NSNumberFormatterDecimalStyle;
  10. self.minWidth = [f numberFromString:dict[@"minWidth"]];
  11. self.maxWidth = [f numberFromString:dict[@"maxWidth"]];
  12. return self;
  13. }
  14. -(void)applyOn:(UIViewController<RNNParentProtocol> *)viewController {
  15. UISplitViewController *svc = (UISplitViewController*) viewController;
  16. if (@available(iOS 11.0, *)) {
  17. if ([self.primaryEdge isEqualToString:@"trailing"]) {
  18. [svc setPrimaryEdge:UISplitViewControllerPrimaryEdgeTrailing];
  19. } else {
  20. [svc setPrimaryEdge:UISplitViewControllerPrimaryEdgeLeading];
  21. }
  22. }
  23. if ([self.displayMode isEqualToString:@"visible"]) {
  24. [svc setPreferredDisplayMode:UISplitViewControllerDisplayModeAllVisible];
  25. } else if ([self.displayMode isEqualToString:@"hidden"]) {
  26. [svc setPreferredDisplayMode:UISplitViewControllerDisplayModePrimaryHidden];
  27. } else if ([self.displayMode isEqualToString:@"overlay"]) {
  28. [svc setPreferredDisplayMode:UISplitViewControllerDisplayModePrimaryOverlay];
  29. } else {
  30. [svc setPreferredDisplayMode:UISplitViewControllerDisplayModeAutomatic];
  31. }
  32. if (self.minWidth) {
  33. [svc setMinimumPrimaryColumnWidth:[self.minWidth doubleValue]];
  34. }
  35. if (self.maxWidth) {
  36. [svc setMaximumPrimaryColumnWidth:[self.maxWidth doubleValue]];
  37. }
  38. }
  39. @end