add keepAwake prop
This commit is contained in:
parent
1feb274458
commit
61b950403d
|
@ -67,6 +67,7 @@ export default class Camera extends Component {
|
|||
PropTypes.string,
|
||||
PropTypes.number
|
||||
]),
|
||||
keepAwake: PropTypes.bool,
|
||||
onBarCodeRead: PropTypes.func,
|
||||
onFocusChanged: PropTypes.func,
|
||||
onZoomChanged: PropTypes.func,
|
||||
|
|
|
@ -211,6 +211,10 @@ If `defaultOnFocusComponent` set to false, default internal implementation of vi
|
|||
Called when focus has changed.
|
||||
By default, `onZoomChanged` is not defined and pinch-to-zoom is disabled.
|
||||
|
||||
#### `iOS` `keepAwake`
|
||||
|
||||
If set to `true`, the device will not sleep while the camera preview is visible. This mimics the behavior of the default camera app, which keeps the device awake while open.
|
||||
|
||||
## Component instance methods
|
||||
|
||||
You can access component methods by adding a `ref` (ie. `ref="camera"`) prop to your `<Camera>` element, then you can use `this.refs.camera.capture(cb)`, etc. inside your component.
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
BOOL _onFocusChanged;
|
||||
BOOL _defaultOnFocusComponent;
|
||||
BOOL _onZoomChanged;
|
||||
BOOL _previousIdleTimerDisabled;
|
||||
}
|
||||
|
||||
- (void)setAspect:(NSInteger)aspect
|
||||
|
@ -90,6 +91,13 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void)setKeepAwake:(BOOL)enabled
|
||||
{
|
||||
if (enabled) {
|
||||
[UIApplication sharedApplication].idleTimerDisabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
- (id)initWithManager:(RCTCameraManager*)manager bridge:(RCTBridge *)bridge
|
||||
{
|
||||
|
||||
|
@ -104,6 +112,7 @@
|
|||
_onFocusChanged = NO;
|
||||
_defaultOnFocusComponent = YES;
|
||||
_onZoomChanged = NO;
|
||||
_previousIdleTimerDisabled = [UIApplication sharedApplication].idleTimerDisabled;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -133,6 +142,7 @@
|
|||
[self.manager stopSession];
|
||||
[super removeFromSuperview];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
|
||||
[UIApplication sharedApplication].idleTimerDisabled = _previousIdleTimerDisabled;
|
||||
}
|
||||
|
||||
- (void)orientationChanged:(NSNotification *)notification{
|
||||
|
|
|
@ -30,6 +30,7 @@ RCT_EXPORT_VIEW_PROPERTY(type, NSInteger);
|
|||
RCT_EXPORT_VIEW_PROPERTY(orientation, NSInteger);
|
||||
RCT_EXPORT_VIEW_PROPERTY(flashMode, NSInteger);
|
||||
RCT_EXPORT_VIEW_PROPERTY(torchMode, NSInteger);
|
||||
RCT_EXPORT_VIEW_PROPERTY(keepAwake, BOOL);
|
||||
|
||||
- (NSDictionary *)constantsToExport
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue