WXNavigationProtocol.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. #import "WXModuleProtocol.h"
  20. /**
  21. * This enum is used to define the position of navbar item.
  22. */
  23. typedef NS_ENUM(NSInteger, WXNavigationItemPosition) {
  24. WXNavigationItemPositionCenter = 0x00,
  25. WXNavigationItemPositionRight,
  26. WXNavigationItemPositionLeft,
  27. WXNavigationItemPositionMore
  28. };
  29. /**
  30. * @abstract The callback after executing navigator operations. The code has some status such as 'WX_SUCCESS'、'WX_FAILED' etc. The responseData
  31. * contains some useful info you can handle.
  32. */
  33. typedef void (^WXNavigationResultBlock)(NSString *code, NSDictionary * responseData);
  34. @protocol WXNavigationProtocol <WXModuleProtocol>
  35. /**
  36. * @abstract Returns the navigation controller.
  37. *
  38. * @param container The target controller.
  39. */
  40. - (id)navigationControllerOfContainer:(UIViewController *)container;
  41. /**
  42. * @abstract Sets the navigation bar hidden.
  43. *
  44. * @param hidden If YES, the navigation bar is hidden.
  45. *
  46. * @param animated Specify YES to animate the transition or NO if you do not want the transition to be animated.
  47. *
  48. * @param container The navigation controller.
  49. *
  50. */
  51. - (void)setNavigationBarHidden:(BOOL)hidden animated:(BOOL)animated
  52. withContainer:(UIViewController *)container;
  53. /**
  54. * @abstract Sets the background color of navigation bar.
  55. *
  56. * @param backgroundColor The background color of navigation bar.
  57. *
  58. * @param container The target controller.
  59. *
  60. */
  61. - (void)setNavigationBackgroundColor:(UIColor *)backgroundColor
  62. withContainer:(UIViewController *)container;
  63. /**
  64. * @abstract Sets the item in navigation bar.
  65. *
  66. * @param param The data which is passed to the implementation of the protocol.
  67. *
  68. * @param position The value indicates the position of item.
  69. *
  70. * @param block A block called once the action is completed.
  71. *
  72. * @param container The target controller.
  73. *
  74. */
  75. - (void)setNavigationItemWithParam:(NSDictionary *)param
  76. position:(WXNavigationItemPosition)position
  77. completion:(WXNavigationResultBlock)block
  78. withContainer:(UIViewController *)container;
  79. /**
  80. * @abstract Clears the item in navigation bar.
  81. *
  82. * @param param The data which is passed to the implementation of the protocol.
  83. *
  84. * @param position The value indicates the position of item.
  85. *
  86. * @param block A block called once the action is completed.
  87. *
  88. * @param container The target controller.
  89. *
  90. */
  91. - (void)clearNavigationItemWithParam:(NSDictionary *)param
  92. position:(WXNavigationItemPosition)position
  93. completion:(WXNavigationResultBlock)block
  94. withContainer:(UIViewController *)container;
  95. /**
  96. * @abstract Pushes a view controller onto the receiver’s stack.
  97. *
  98. * @param param The data which is passed to the implementation of the protocol.
  99. *
  100. * @param block A block called once the action is completed.
  101. *
  102. * @param container The target controller.
  103. *
  104. */
  105. - (void)pushViewControllerWithParam:(NSDictionary *)param
  106. completion:(WXNavigationResultBlock)block
  107. withContainer:(UIViewController *)container;
  108. /**
  109. * @abstract Pops the top view controller from the navigation stack.
  110. *
  111. * @param param The data which is passed to the implementation of the protocol.
  112. *
  113. * @param block A block called once the action is completed.
  114. *
  115. * @param container The target controller.
  116. *
  117. */
  118. - (void)popViewControllerWithParam:(NSDictionary *)param
  119. completion:(WXNavigationResultBlock)block
  120. withContainer:(UIViewController *)container;
  121. @optional
  122. /**
  123. * @abstract open the resource at the specified URL which supports many common schemes, including the http, https, tel and mailto schemes.
  124. *
  125. * @param param The data which is passed to the implementation of the protocol.
  126. *
  127. * @param success A block called once the action is completed successfully.
  128. *
  129. * @param failure A block called once the action failed to be completed.
  130. *
  131. * @param container The target controller.
  132. *
  133. */
  134. - (void)open:(NSDictionary *)param success:(WXModuleCallback)success
  135. failure:(WXModuleCallback)failure
  136. withContainer:(UIViewController *)container;
  137. /**
  138. * @abstract close the current weex page
  139. *
  140. * @param param The data which is passed to the implementation of the protocol.
  141. *
  142. * @param success A block called once the action is completed successfully.
  143. *
  144. * @param failure A block called once the action failed to be completed.
  145. *
  146. * @param container The target controller.
  147. *
  148. */
  149. - (void)close:(NSDictionary *)param success:(WXModuleCallback)success
  150. failure:(WXModuleCallback)failure
  151. withContainer:(UIViewController *)container;
  152. @end