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.

Unnecessary marginTop

See original GitHub issue

Hello,

Thank you for this project which is working perfectly.

I want to discuss about the hardcoded top margin line 138 in index.js:

  ...
  render() {
    return (
      <View style={{
          flex: 1,
          marginTop: 64, //               <-- this line
        }}>
        <View style={[styles.infoView, this.props.topViewStyle]}>
          {this._renderTopContent()}
        </View>
        {this._renderCamera()}
        <View style={[styles.infoView, this.props.bottomViewStyle]}>
          {this._renderBottomContent()}
        </View>
      </View>
    )
  }
  ...

This prevents me from making the camera fill the screen vertically, see this Android screenshot:

  <QRCodeScanner onRead={this.handleRead} />

image

I believe this property was added to compensate for the navigation bar. Since a navigation bar doesn’t always have a height of 64, I would suggest removing this line and allow the parent component to manage the margin himself. This way, we could adapt the necessary margin depending on how we manage the navigation bar.

If that makes sense, I would be happy to make a PR for this.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
metinozkancommented, Jun 13, 2020

const screenHeight = Math.round(Dimensions.get('window').height); <QRCodeScanner topViewStyle={{height: 0, flex: 0}} cameraStyle={{ height: screenHeight, }}

0reactions
verybluebotcommented, Jun 8, 2020

still having the same in v1.41 hardcoding cameraStyle={{marginTop: -190 }} is a pretty ugly walk around… but working…

NOTE: I started getting this issue only after updating from v1.1.2 to v1.4.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

I'm using next.js and getting unnecessary top margin in index.js
h1, h2, h3, h4, h5, h6, p all tags are having default margin top in next.js. index.js import React, { Component } from...
Read more >
margin-top - CSS: Cascading Style Sheets - MDN Web Docs
The margin-top CSS property sets the margin area on the top of an element. A positive value places it farther from its neighbors, ......
Read more >
The Rules of Margin Collapse - Josh W Comeau
Siblings can combine adjacent margins (if the first element has margin-bottom, and the second one has margin-top). A parent and child can ...
Read more >
[modern][styles] Remove unnecessary `margin-top` · b0e54eec45 ...
[modern][styles] Remove unnecessary `margin-top`. Following-up Iecb0d6c4c80cee1d1684597a6dedf7323e2ec54d. It isn't set anywhere inherited, hence we don't ...
Read more >
Everything You Need To Know About CSS Margins
The margin-top , margin-right , margin-bottom and margin-left ... If your CMS was adding redundant paragraph elements, you probably wouldn't ...
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