question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CheckBox Icon misaligned

See original GitHub issue

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® Core™ 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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:15
  • Comments:17

github_iconTop GitHub Comments

7reactions
shivrajkumarcommented, Jan 11, 2021

This issue is fixed in the latest version. If you have ejected the theme and using it, please make changes as per these values https://github.com/GeekyAnts/NativeBase/blob/master/src/theme/variables/platform.js#L127 https://github.com/GeekyAnts/NativeBase/blob/master/src/theme/variables/platform.js#L129

4reactions
orungraucommented, Dec 24, 2020

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

  1. Run “npm i -g patch-package”
  2. Make a new folder called patches
  3. Make a new file called native-base+2.13.15.patch inside that folder
  4. Add the source code above.
  5. Run “patch-package” on the root of the project
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to align checkboxes and their labels consistently cross ...
Put each checkbox and label within an <li> element. Add overflow:hidden to the <li> and float the label and checkbox left. Then they...
Read more >
How to Align a Checkbox and Its Label Consistently Cross ...
Checkbox is one of HTML forms that is used on every website. This tutorial will show how to align checkboxes and their labels...
Read more >
How to align checkboxes and their labels on cross-browsers ...
Method 1: By making the position of checkbox relative, set the vertical-align to the middle can align the checkboxes and their labels. Here,...
Read more >
Checkboxes don't vertically align with text : r/elementor - Reddit
I have a contact form where the checkboxes don't vertically align with ... This is via the form widget within Elementor, not the...
Read more >
check box not aligned - WordPress.org
I've added a checkbox to my form. It has one checkbox with a single line of text. The checkbox itself is not aligned...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found