Commit 9f935f00 authored by Mattia541993's avatar Mattia541993

implement view accessible wrapper

parent 7ba1aa98
/* This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License. */
import React from 'react';
import PropTypes from 'prop-types';
import {
requireNativeComponent,
ViewPropTypes,
} from 'react-native';
const iface = {
name: 'AccessibilityFocus',
propTypes: {
...ViewPropTypes, // include the default view properties
},
};
const RNAccessibilityFocus = requireNativeComponent('RNAccessibilityFocus', iface);
const emptyFn = _ => _;
export default class IosAccessibleWrapper extends React.Component {
render() {
return (<RNAccessibilityFocus
style={{...this.props.style}}
onFocusStart={(this.props.onFocusStart) ? this.props.onFocusStart : emptyFn}
onFocusEnd={(this.props.onFocusEnd) ? this.props.onFocusEnd : emptyFn}>
{this.props.children}
</RNAccessibilityFocus>);
}
}
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:RNAccessibileView.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
/* This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License. */
#import <React/RCTViewManager.h>
@interface RNAccessibilityFocus:RCTViewManager
@end
/* This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License. */
#import "RNAccessibilityFocus.h"
#import "RNTAccessibleWrapper.h"
@implementation RNAccessibilityFocus
RCT_EXPORT_MODULE()
RCT_EXPORT_VIEW_PROPERTY(onFocusStart, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onFocusEnd, RCTDirectEventBlock)
-(UIView*) view{
RNTAccessibleWrapper* wrapper=[[RNTAccessibleWrapper alloc]init];
return wrapper;
}
@end
/* This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License. */
//
// RNTAccessibleImage.h
// RNAccessibilityFocus
//
#import <UIKit/UIKit.h>
#import <React/RCTComponent.h>
#import <React/RCTView.h>
NS_ASSUME_NONNULL_BEGIN
@interface RNTAccessibleWrapper : RCTView
@property (nonatomic, copy) RCTDirectEventBlock onFocusStart;
@property (nonatomic, copy) RCTDirectEventBlock onFocusEnd;
@end
NS_ASSUME_NONNULL_END
/* This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License. */
//
// RNTAccessibleWrapper.m
// RNAccessibilityFocus
//
#import "RNTAccessibleWrapper.h"
@implementation RNTAccessibleWrapper
//From React parameters methods
#pragma mark - Accessibility
- (void)accessibilityElementDidBecomeFocused{
_onFocusStart(@{});
}
- (BOOL)isAccessibilityElement{
return YES;
}
- (void)accessibilityElementDidLoseFocus{
_onFocusEnd(@{});
}
@end
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment