Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency on Different Devices #1547

Closed
aswinputra opened this issue Feb 26, 2021 · 2 comments
Closed

Inconsistency on Different Devices #1547

aswinputra opened this issue Feb 26, 2021 · 2 comments

Comments

@aswinputra
Copy link

aswinputra commented Feb 26, 2021

Hi,

I am in need of help from fellow developers

I have created a component called Curve Header that pretty much creates a header in a shape of a svg. I successfully created one for Pixel 4 phone, however, When I tried to open the component in a Pixel 2 Screen it is out of scale and I couldn't figure out what is wrong with it.

Picture below is what the header component should look like:

Screenshot 2021-02-26 111233

However, I received this result on a Pixel 2 phone

image

import Svg, {Path, Text, } from 'react-native-svg';
import colors from "../config/colors";
import {
    StyleSheet,
    View,
    StatusBar, 
    TouchableOpacity
} from "react-native";
import { Icon } from "react-native-elements";
const SAFE_STATUS_BAR = Platform.select({
    ios: 44,
    android: StatusBar.currentHeight,
  });

function CurveHeader(props){
    return(
        <View style={styles.container}>
            <Svg viewBox="0 0 100 44">
                <Path stroke={colors.primary} d="M0 0 h100 v40 q-50 -20, -100 0 Z" fill={colors.primary}></Path>
                <Text x="50%" y="45%" textAnchor="middle" alignmentBaseline="middle" fontSize="7" fill="white" fontWeight="bold" letterSpacing="0.1">{props.title.toUpperCase()}</Text>
            </Svg>
            {
                props.showBackButton ? 
                <View style={styles.backButton}>
                    <TouchableOpacity onPress={() => props.returnFunction()}>
                        <Icon
                        name="arrow-left"
                        type="font-awesome-5"
                        size={30}
                        iconStyle={{ color: "#fff" }}
                        />
                    </TouchableOpacity>
                </View>
                : <View style={styles.backButton}></View>
            }
        </View>
    );
};

const styles = StyleSheet.create({
    container: {
        // paddingTop: SAFE_STATUS_BAR,
        // flex: 1,
        height: '22%'
    },
    backButton: { 
        flex: 1,
        alignItems:"flex-start",
        marginHorizontal:20,
        marginVertical:55,
        elevation:3, 
        position: 'absolute' 
    }
})

export default CurveHeader;

Can someone please help me figure out what is wrong?
Thanks

@jupdike
Copy link

jupdike commented Apr 4, 2021

You probably need to change the view box with the width of the device, or scale the entire SVG up. This does not seem like a bug with the React Native SVG library.

@bohdanprog
Copy link
Member

Hello @aswinputra,
As @jupdike mentioned, this problem is not related to react-native-svg.
However, if you continue to experience any issues, please feel free to open a new one.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants