ShaMan123 / react-native-math-view

Math view for react native! No WebView!
https://github.com/ShaMan123/react-native-math-view
MIT License
78 stars 24 forks source link

Is it possible to set dimension? #25

Closed ggunti closed 4 years ago

ggunti commented 4 years ago

Platform: iOS

I just rendered the example from readme:

import React from 'react';
import { SafeAreaView, StyleSheet } from 'react-native';
import MathView from 'react-native-math-view';

const App: React.FC<{}> = () => {
  return (
    <SafeAreaView style={styles.container}>
      <MathView math={'x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}'} />
    </SafeAreaView>
  );
};

export default App;

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
});

But the problem is that the resulted math expression is too small. Is it possible to somehow make it bigger?:

Captură de ecran din 2020-04-03 la 00 32 55
ShaMan123 commented 4 years ago

You can try styling the MathView with flex: 1 or with width and see how that goes.

const App: React.FC<{}> = () => {
  return (
    <SafeAreaView style={styles.container}>
      <MathView math={'x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}'} 
+          style={styles.container}
        />
    </SafeAreaView>
  );
};

There's an option to control the font size, see example

ShaMan123 commented 4 years ago

Try changing style as well

const styles = StyleSheet.create({
  container: {
    flex: 1,
-    alignItems: 'center',
-    justifyContent: 'center',
  },
});
ggunti commented 4 years ago

style for MathView does not have effect, but config={{ ex: 50 }} works well, I think it should be included in the readme. Thank you for your help!

ShaMan123 commented 4 years ago

I want to expose a prop for font size. Styling should work though. Did you try changing styles.container? Centering might be interfering. This could be solved by wrapping MathView with another view. Look at the example.

ggunti commented 4 years ago

I removed centering from SafeAreaView, but the actual size of math expression did not changed by styling the MathView.

ggunti commented 4 years ago

Also, I like this library so much. I did not saw another library for react native which is capable to render math without using a webview. If I can help you making this library better, please let me know, I am not a pro in how native math rendering actually works, but I'm really enthusiastic and love math, of course.

ShaMan123 commented 4 years ago

Happy to hear. I created this library exactly because what you said. And now I know why resizing on iOS doesn't work. That is the behavior I implemented in native, so android resizes to fit the parent when resizeMode is cover. iOS is implemented with react-native-svg because I didn't finish the standalone implementation yet.

If you want to contribute there's work to do on iOS. I want to move to the standalone implementation. The first thing to do is to handle the measuring of the view in native. react-native uses it's own layout flow and at the time I didn't figure it out. After that it's all about exposing props.

If you're not an iOS dev you can try to fix this issue for the current implementation. This would require looking into react-native-svg.

For android I have in mind for the next major version moving to this implementation if it's stable and good, retex, so you can look it to it as well.

Barklegne commented 3 years ago

style for MathView does not have effect, but config={{ ex: 50 }} works well, I think it should be included in the readme. Thank you for your help!

This is amazing. works like a charm Bro thank you!

bharathy-kannan commented 1 week ago

I am in "react-native-math-view": "^3.9.5", "react-native": "0.74.5", Android platform.

The config property does not work for me at all with MathView. I created a simple page with just the MathView but the fonts are too tiny. <MathView math={'\triangle x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}'} config={{ ex: 50}} /> Please help. Am I missing anything?