From 7995e0c1c8955cedf4092561dea8a57375e9adb2 Mon Sep 17 00:00:00 2001 From: Mark Miyashita Date: Thu, 23 Jul 2015 16:19:27 -0700 Subject: [PATCH] [StatusBar] Add ability to toggle the network activity indicator in the status bar + example in UIExplorer Summary: Added the ability to turn on and off the network activity indicator using: ``` StatusBarIOS.setNetworkActivityIndicatorVisible(true) ``` and ``` StatusBarIOS.setNetworkActivityIndicatorVisible(false) ``` Also added an example to the UIExplorer example app. Fix #986 Closes https://github.com/facebook/react-native/pull/2079 Github Author: Mark Miyashita --- Examples/UIExplorer/StatusBarIOSExample.js | 20 +++++++++++++++++++ .../Components/StatusBar/StatusBarIOS.ios.js | 4 ++++ React/Modules/RCTStatusBarManager.m | 5 +++++ 3 files changed, 29 insertions(+) diff --git a/Examples/UIExplorer/StatusBarIOSExample.js b/Examples/UIExplorer/StatusBarIOSExample.js index ab649197eed994..28d5e2a7c07692 100644 --- a/Examples/UIExplorer/StatusBarIOSExample.js +++ b/Examples/UIExplorer/StatusBarIOSExample.js @@ -83,6 +83,26 @@ exports.examples = [{ ); }, +}, { + title: 'Status Bar Network Activity Indicator', + render() { + return ( + + StatusBarIOS.setNetworkActivityIndicatorVisible(true)}> + + setNetworkActivityIndicatorVisible(true) + + + StatusBarIOS.setNetworkActivityIndicatorVisible(false)}> + + setNetworkActivityIndicatorVisible(false) + + + + ); + }, }]; var styles = StyleSheet.create({ diff --git a/Libraries/Components/StatusBar/StatusBarIOS.ios.js b/Libraries/Components/StatusBar/StatusBarIOS.ios.js index adfed78b7b23a5..59369ef143dd37 100644 --- a/Libraries/Components/StatusBar/StatusBarIOS.ios.js +++ b/Libraries/Components/StatusBar/StatusBarIOS.ios.js @@ -35,6 +35,10 @@ var StatusBarIOS = { animation = animation || 'none'; RCTStatusBarManager.setHidden(hidden, animation); }, + + setNetworkActivityIndicatorVisible(visible: boolean) { + RCTStatusBarManager.setNetworkActivityIndicatorVisible(visible); + }, }; module.exports = StatusBarIOS; diff --git a/React/Modules/RCTStatusBarManager.m b/React/Modules/RCTStatusBarManager.m index cb9ddfe690a088..bf32f835cf5d77 100644 --- a/React/Modules/RCTStatusBarManager.m +++ b/React/Modules/RCTStatusBarManager.m @@ -71,4 +71,9 @@ - (dispatch_queue_t)methodQueue } } +RCT_EXPORT_METHOD(setNetworkActivityIndicatorVisible:(BOOL)visible) +{ + [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:visible]; +} + @end