Nativebase: CheckBox Icon misaligned

Created on 22 Jul 2020  路  8Comments  路  Source: GeekyAnts/NativeBase

I have gone through these following points

Issue Description


Versions used:
native-base: 2.13.13
react-native-vector-icons: 7.0.0

npx react-native info

System:
OS: macOS 10.15.5
CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Memory: 398.30 MB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 13.7.0 - /usr/local/bin/node
npm: 6.14.5 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.5, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK:
API Levels: 29
Build Tools: 29.0.3, 30.0.1
System Images: android-29 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.6 AI-192.7142.36.36.6392135
Xcode: 11.5/11E608c - /usr/bin/xcodebuild
npmPackages:
@react-native-community/cli: ^4.0.1 => 4.10.1
react: 16.9.0 => 16.9.0
react-native: ~0.61.5 => 0.61.5
npmGlobalPackages:
react-native-ble-plx: 1.0.3
react-native-create-library: 3.1.2
react-native-git-upgrade: 0.2.7
react-native-permissions: 1.1.1

Expected behaviour

Checkmarks being aligned properly inside CheckBox

Actual behaviour

checkmark_alignment_issue_nativebase

Steps to reproduce

return issues.map((obj: NazzaApi.FeedbackContentRequest) =>  (
          <ListItem
            key={obj.id}
            onPress={() => obj.id != null && this.toggleCheckbox(obj.id)}
          >
            <CheckBox
              color={this.colorAccent}
              checked={
                this.state.selectedIssues &&
                this.state.selectedIssues.includes(obj.id)
              }
            />
            <Body>
              <Text>{obj.description}</Text>
            </Body>
          </ListItem>
        )
);

Is the bug present in both iOS and Android or in any one of them?

Present in both, but more obvious on iOS (see pictures)

Any other additional info which would help us debug the issue quicker.

x

PR Added

Most helpful comment

Could it be merged and fixed please?
For me this is a blocker, I can't go in production with these checkboxes.

All 8 comments

On IOS
I have the same issue native-base after link react-native-vector-icon. with vector icons
Simulator Screen Shot - iPhone 11 - 2020-08-08 at 16 47 23

I like to use native-base icons but their icon mapping not correct, on my side Check box show like this, hyphen icon instead of a check
Simulator Screen Shot - iPhone 11 - 2020-08-08 at 16 42 06
i resolved in my sample project by removing all Build Settings -> Search Paths -> Header Search Path
but this is not a genuine way to resolve this, because Header Search Paths may needed in another project

"native-base": "^2.13.13",
"react": "16.11.0",
"react-native": "0.62.2"

Same here!

I'm also having this issue. Any answers?

I am also having same issue with android its been 28 days, when we will get this fixed? Whole app is broken!

"native-base": "^2.13.13",
"react": "16.13.1",
"react-native": "0.63.2"

Same issue here. Any updates?

Could it be merged and fixed please?
For me this is a blocker, I can't go in production with these checkboxes.

Any updates with this issue?

Use native-base+2.13.15.patch

diff --git a/node_modules/native-base/dist/src/basic/Checkbox.js b/node_modules/native-base/dist/src/basic/Checkbox.js
index 428a148..96d6161 100644
--- a/node_modules/native-base/dist/src/basic/Checkbox.js
+++ b/node_modules/native-base/dist/src/basic/Checkbox.js
@@ -1,2 +1,2 @@
-Object.defineProperty(exports,"__esModule",{value:true});exports.CheckBox=undefined;var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};var _jsxFileName='src/basic/Checkbox.js';var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};}();var _react=require('react');var _react2=_interopRequireDefault(_react);var _propTypes=require('prop-types');var _propTypes2=_interopRequireDefault(_propTypes);var _reactNative=require('react-native');var _Ionicons=require('react-native-vector-icons/Ionicons');var _Ionicons2=_interopRequireDefault(_Ionicons);var _nativeBaseShoutemTheme=require('native-base-shoutem-theme');var _mapPropsToStyleNames=require('../utils/mapPropsToStyleNames');var _mapPropsToStyleNames2=_interopRequireDefault(_mapPropsToStyleNames);var _platform=require('../theme/variables/platform');var _platform2=_interopRequireDefault(_platform);var _commonColor=require('../theme/variables/commonColor');var _computeProps=require('../utils/computeProps');var _computeProps2=_interopRequireDefault(_computeProps);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call&&(typeof call==="object"||typeof call==="function")?call:self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass;}var CheckBox=function(_Component){_inherits(CheckBox,_Component);function CheckBox(){_classCallCheck(this,CheckBox);return _possibleConstructorReturn(this,(CheckBox.__proto__||Object.getPrototypeOf(CheckBox)).apply(this,arguments));}_createClass(CheckBox,[{key:'getInitialStyle',value:function getInitialStyle(variables){var _props=this.props,color=_props.color,checked=_props.checked;return{checkStyle:{borderColor:color||variables.checkboxBgColor,backgroundColor:checked===true?color||variables.checkboxBgColor:variables.checkboxDefaultColor}};}},{key:'prepareRootProps',value:function prepareRootProps(variables){var defaultProps={style:this.getInitialStyle(variables).checkStyle};return(0,_computeProps2.default)(this.props,defaultProps);}},{key:'render',value:function render(){var _this2=this;var checked=this.props.checked;var variables=this.context.theme?this.context.theme['@@shoutem.theme/themeStyle'].variables:_platform2.default;var platformStyle=variables.platformStyle;var platform=variables.platform;return _react2.default.createElement(_reactNative.TouchableOpacity,_extends({ref:function ref(c){return _this2._root=c;}},this.prepareRootProps(variables),{__source:{fileName:_jsxFileName,lineNumber:45}}),_react2.default.createElement(_Ionicons2.default,{style:{color:checked===true?variables.checkboxTickColor:variables.checkboxDefaultColor,fontSize:variables.CheckboxFontSize,lineHeight:variables.CheckboxIconSize,marginTop:variables.CheckboxIconMarginTop,textShadowRadius:variables.checkboxTextShadowRadius},name:platform===_commonColor.PLATFORM.IOS&&platformStyle!==_commonColor.PLATFORM.MATERIAL?'ios-checkmark':'md-checkmark',__source:{fileName:_jsxFileName,lineNumber:49}}));}}]);return CheckBox;}(_react.Component);CheckBox.contextTypes={theme:_propTypes2.default.object};CheckBox.propTypes=_extends({},_reactNative.TouchableOpacity.propTypes,{style:_propTypes2.default.oneOfType([_propTypes2.default.object,_propTypes2.default.number,_propTypes2.default.array]),checked:_propTypes2.default.bool,onPress:_propTypes2.default.func});var StyledCheckBox=(0,_nativeBaseShoutemTheme.connectStyle)('NativeBase.CheckBox',{},_mapPropsToStyleNames2.default)(CheckBox);exports.CheckBox=StyledCheckBox;
+Object.defineProperty(exports,"__esModule",{value:true});exports.CheckBox=undefined;var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};var _jsxFileName='src/basic/Checkbox.js';var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};}();var _react=require('react');var _react2=_interopRequireDefault(_react);var _propTypes=require('prop-types');var _propTypes2=_interopRequireDefault(_propTypes);var _reactNative=require('react-native');var _Ionicons=require('react-native-vector-icons/Ionicons');var _Ionicons2=_interopRequireDefault(_Ionicons);var _nativeBaseShoutemTheme=require('native-base-shoutem-theme');var _mapPropsToStyleNames=require('../utils/mapPropsToStyleNames');var _mapPropsToStyleNames2=_interopRequireDefault(_mapPropsToStyleNames);var _platform=require('../theme/variables/platform');var _platform2=_interopRequireDefault(_platform);var _commonColor=require('../theme/variables/commonColor');var _computeProps=require('../utils/computeProps');var _computeProps2=_interopRequireDefault(_computeProps);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call&&(typeof call==="object"||typeof call==="function")?call:self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass;}var CheckBox=function(_Component){_inherits(CheckBox,_Component);function CheckBox(){_classCallCheck(this,CheckBox);return _possibleConstructorReturn(this,(CheckBox.__proto__||Object.getPrototypeOf(CheckBox)).apply(this,arguments));}_createClass(CheckBox,[{key:'getInitialStyle',value:function getInitialStyle(variables){var _props=this.props,color=_props.color,checked=_props.checked;return{checkStyle:{borderColor:color||variables.checkboxBgColor,backgroundColor:checked===true?color||variables.checkboxBgColor:variables.checkboxDefaultColor}};}},{key:'prepareRootProps',value:function prepareRootProps(variables){var defaultProps={style:this.getInitialStyle(variables).checkStyle};return(0,_computeProps2.default)(this.props,defaultProps);}},{key:'render',value:function render(){var _this2=this;var checked=this.props.checked;var variables=this.context.theme?this.context.theme['@@shoutem.theme/themeStyle'].variables:_platform2.default;var platformStyle=variables.platformStyle;var platform=variables.platform;return _react2.default.createElement(_reactNative.TouchableOpacity,_extends({ref:function ref(c){return _this2._root=c;}},this.prepareRootProps(variables),{__source:{fileName:_jsxFileName,lineNumber:45}}),_react2.default.createElement(_Ionicons2.default,{style:{color: checked === true ? variables.checkboxTickColor : variables.checkboxDefaultColor, fontSize: 16, lineHeight: 16, textAlign: 'center', textAlignVertical: 'center', marginLeft: platform === _commonColor.PLATFORM.IOS && platformStyle !== _commonColor.PLATFORM.MATERIAL ? -2: 0, marginTop: platform === _commonColor.PLATFORM.IOS && platformStyle !== _commonColor.PLATFORM.MATERIAL ? 2 : 0,textShadowRadius:variables.checkboxTextShadowRadius},name:platform===_commonColor.PLATFORM.IOS&&platformStyle!==_commonColor.PLATFORM.MATERIAL?'ios-checkmark':'md-checkmark',__source:{fileName:_jsxFileName,lineNumber:49}}));}}]);return CheckBox;}(_react.Component);CheckBox.contextTypes={theme:_propTypes2.default.object};CheckBox.propTypes=_extends({},_reactNative.TouchableOpacity.propTypes,{style:_propTypes2.default.oneOfType([_propTypes2.default.object,_propTypes2.default.number,_propTypes2.default.array]),checked:_propTypes2.default.bool,onPress:_propTypes2.default.func});var StyledCheckBox=(0,_nativeBaseShoutemTheme.connectStyle)('NativeBase.CheckBox',{},_mapPropsToStyleNames2.default)(CheckBox);exports.CheckBox=StyledCheckBox;
 //# sourceMappingURL=Checkbox.js.map
\ No newline at end of file

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mcpracht picture mcpracht  路  3Comments

elnygren picture elnygren  路  3Comments

Cotel picture Cotel  路  3Comments

nschurmann picture nschurmann  路  3Comments

aloifolia picture aloifolia  路  3Comments