Skip to content

Commit 35df5ed

Browse files
committed
clean up and remove katex
1 parent 41e3b64 commit 35df5ed

24 files changed

+110
-169
lines changed

Diff for: package.json

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"react-mathjax2": "^0.0.1",
3434
"react-native": "0.55.4",
3535
"react-native-i18n": "2.0.12",
36-
"react-native-katex": "^0.3.0",
3736
"react-native-keyboard-aware-scroll-view": "^0.6.0",
3837
"react-native-keyboard-aware-view": "^0.0.14",
3938
"react-native-keychain": "3.0.0-rc.3",

Diff for: src/images/cubic.png

11.1 KB
Loading

Diff for: src/images/[email protected]

29.7 KB
Loading

Diff for: src/images/[email protected]

56.4 KB
Loading

Diff for: src/images/linear.png

7.12 KB
Loading

Diff for: src/images/[email protected]

20 KB
Loading

Diff for: src/images/[email protected]

37.4 KB
Loading

Diff for: src/images/quadratic.png

8.15 KB
Loading

Diff for: src/images/[email protected]

21.7 KB
Loading

Diff for: src/images/[email protected]

40.5 KB
Loading

Diff for: src/navigation/root-navigator.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { createStackNavigator } from "react-navigation"
2-
import { Home } from "../views/example/home/home-screen"
3-
import { ThreeLinearEquation } from "../views/example/three-linear-equation/three-linear-equation-screen"
4-
import { TwoLinearEquation } from "../views/example/two-linear-equation/two-linear-equation-screen"
5-
import { CubicEquation } from "../views/example/cubic-equation/cubic-equation-screen"
6-
import { QuadraticEquation } from "../views/example/quadratic-equation/quadratic-equation-screen"
7-
import { LinearEquation } from "../views/example/linear-equation/linear-equation-screen"
2+
import { Home } from "../views/screens/home/home-screen"
3+
import { ThreeLinearEquation } from "../views/screens/three-linear-equation/three-linear-equation-screen"
4+
import { TwoLinearEquation } from "../views/screens/two-linear-equation/two-linear-equation-screen"
5+
import { CubicEquation } from "../views/screens/cubic-equation/cubic-equation-screen"
6+
import { QuadraticEquation } from "../views/screens/quadratic-equation/quadratic-equation-screen"
7+
import { LinearEquation } from "../views/screens/linear-equation/linear-equation-screen"
88

99
export const RootNavigator = createStackNavigator(
1010
{

Diff for: src/views/example/cubic-equation/cubic-equation-screen.tsx renamed to src/views/screens/cubic-equation/cubic-equation-screen.tsx

+34-36
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
import * as React from "react"
2-
import { ViewStyle, TextStyle, View, Dimensions, ScrollView } from "react-native"
2+
import {
3+
ViewStyle,
4+
TextStyle,
5+
View,
6+
Dimensions,
7+
Keyboard,
8+
ImageStyle,
9+
Image } from "react-native"
10+
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'
11+
import { NavigationScreenProps } from "react-navigation"
12+
import Toast from 'react-native-simple-toast'
13+
314
import { Text } from "../../shared/text"
4-
import Katex from 'react-native-katex';
515
import { color } from "../../../theme"
616
import { Header } from '../../shared/header'
717
import { TextField } from '../../shared/text-field'
818
import { Button } from '../../shared/button'
919
import isNotValid from '../../../lib/isValid'
10-
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'
11-
import { NavigationScreenProps } from "react-navigation"
1220
import SolveCubic from '../../../lib/cubic'
1321

1422
export interface CubicEquationScreenProps extends NavigationScreenProps<{}> {
@@ -25,7 +33,8 @@ const TextStyle: TextStyle = {
2533
}
2634
const InputView: ViewStyle = {
2735
flexDirection: 'row',
28-
margin: 20
36+
margin: 20,
37+
width: width / 2
2938
}
3039

3140
const inputStyle: TextStyle = {
@@ -58,22 +67,15 @@ const ButtonView: ViewStyle = {
5867
justifyContent: 'space-between'
5968
}
6069

61-
const inlineStyle =`
62-
html, body {
63-
display: flex;
64-
background-color: #1d1d1d;
65-
justify-content: center;
66-
align-items: center;
67-
padding: 0;
68-
margin-top: 9px;
70+
const ImageStyle: ImageStyle = {
71+
width: width - 20
6972
}
70-
.katex {
71-
font-size: 5em;
72-
margin: 0;
73-
display: flex;
74-
color: white;
73+
74+
const InputStyle: ViewStyle = {
75+
flex: 0.6,
76+
justifyContent: 'space-around'
7577
}
76-
`;
78+
7779

7880
interface State {
7981
a: string,
@@ -95,9 +97,10 @@ export class CubicEquation extends React.Component<CubicEquationScreenProps, Sta
9597
state = initialState
9698

9799
solve = async () => {
100+
Keyboard.dismiss
98101
const { a, b , c , d } = this.state
99102
if(isNotValid(a) || isNotValid(b) || isNotValid(c) || isNotValid(d)){
100-
return;
103+
return Toast.showWithGravity('The input should be a number.', Toast.SHORT, Toast.CENTER)
101104
}
102105

103106

@@ -113,6 +116,7 @@ export class CubicEquation extends React.Component<CubicEquationScreenProps, Sta
113116
const { goBack } = this.props.navigation
114117
const { roots, a, b , c , d } = this.state
115118
return (
119+
<KeyboardAwareScrollView contentContainerStyle={{ flex: 1}}>
116120
<View style={ROOT} >
117121
<Header
118122
headerTx="cubic.header"
@@ -122,29 +126,21 @@ export class CubicEquation extends React.Component<CubicEquationScreenProps, Sta
122126
onLeftPress={() => goBack()}
123127
/>
124128
<View style={EquationView}>
125-
<Katex
126-
expression="ax^3 + bx^2 + cx + d = 0"
127-
style={{flex: 1}}
128-
inlineStyle={inlineStyle}
129-
displayMode={false}
130-
colorIsTextColor={false}
131-
onError={() => console.error('Error')}
132-
/>
129+
<Image source={require('../../../images/cubic.png')} resizeMode="contain" style={ImageStyle} />
133130
</View>
134-
<KeyboardAwareScrollView contentContainerStyle={{ flex: 1}}>
135-
<View style={{ flex: 0.6,justifyContent: 'space-around',}}>
131+
<View style={InputStyle}>
136132
<View style={InputView}>
137-
<Text style={textStyle}>a =</Text>
133+
<Text style={textStyle}>a =</Text>
138134
<TextField
139135
style={Input}
140136
value={a}
141137
inputStyle={inputStyle}
142138
keyboardType={'numeric'}
143139
onChangeText={(a) => this.setState({ a })}
144-
/>
140+
/>
145141
</View>
146142
<View style={InputView}>
147-
<Text style={textStyle}>b =</Text>
143+
<Text style={textStyle}>b =</Text>
148144
<TextField
149145
style={Input}
150146
value={b}
@@ -154,7 +150,7 @@ export class CubicEquation extends React.Component<CubicEquationScreenProps, Sta
154150
/>
155151
</View>
156152
<View style={InputView}>
157-
<Text style={textStyle}> c =</Text>
153+
<Text style={textStyle}>c =</Text>
158154
<TextField
159155
style={Input}
160156
value={c}
@@ -164,7 +160,7 @@ export class CubicEquation extends React.Component<CubicEquationScreenProps, Sta
164160
/>
165161
</View>
166162
<View style={InputView}>
167-
<Text style={textStyle}>d =</Text>
163+
<Text style={textStyle}>d =</Text>
168164
<TextField
169165
style={Input}
170166
value={d}
@@ -178,7 +174,7 @@ export class CubicEquation extends React.Component<CubicEquationScreenProps, Sta
178174
<Button preset="solve" text="Clear" onPress={this.clear} />
179175
</View>
180176
</View>
181-
</KeyboardAwareScrollView>
177+
182178
<View style={{ justifyContent: 'space-around', alignItems: 'center', flex: 0.2}}>
183179
{
184180
roots && roots.map((item, index) => {
@@ -187,7 +183,9 @@ export class CubicEquation extends React.Component<CubicEquationScreenProps, Sta
187183
})
188184
}
189185
</View>
186+
190187
</View>
188+
</KeyboardAwareScrollView>
191189
)
192190
}
193191
}
File renamed without changes.
File renamed without changes.

Diff for: src/views/example/linear-equation/linear-equation-screen.tsx renamed to src/views/screens/linear-equation/linear-equation-screen.tsx

+24-30
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
import * as React from "react"
2-
import { ViewStyle, View, TextStyle, Dimensions } from "react-native"
2+
import {
3+
ViewStyle,
4+
View,
5+
TextStyle,
6+
Dimensions,
7+
ScrollView,
8+
ImageStyle,
9+
Image } from "react-native"
10+
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'
11+
import { NavigationScreenProps } from "react-navigation"
12+
import Toast from 'react-native-simple-toast'
13+
314
import { Text } from "../../shared/text"
4-
import Katex from 'react-native-katex';
515
import { color } from "../../../theme"
6-
import Toast from 'react-native-simple-toast'
716
import { Header } from '../../shared/header'
817
import { Button } from '../../shared/button'
918
import isNotValid from '../../../lib/isValid'
1019
import { TextField } from '../../shared/text-field'
11-
import { NavigationScreenProps } from "react-navigation"
20+
1221

1322
export interface LinearEquationScreenProps extends NavigationScreenProps<{}> {
1423
}
@@ -58,22 +67,9 @@ const ButtonView: ViewStyle = {
5867
justifyContent: 'space-between'
5968
}
6069

61-
const inlineStyle =`
62-
html, body {
63-
display: flex;
64-
background-color: #1d1d1d;
65-
justify-content: center;
66-
align-items: center;
67-
padding: 0;
68-
margin-top: 9px;
69-
}
70-
.katex {
71-
font-size: 5em;
72-
margin: 0;
73-
display: flex;
74-
color: white;
70+
const ImageStyle: ImageStyle = {
71+
width: width - 20
7572
}
76-
`;
7773

7874
interface State {
7975
a: string,
@@ -96,7 +92,7 @@ export class LinearEquation extends React.Component<LinearEquationScreenProps, S
9692
solve = async () => {
9793
const { a, b, c } = this.state
9894
if(isNotValid(a) || isNotValid(b) || isNotValid(c) ){
99-
Toast.showWithGravity('The input should be a number.', Toast.SHORT, Toast.CENTER)
95+
10096
return;
10197
}
10298

@@ -116,24 +112,20 @@ export class LinearEquation extends React.Component<LinearEquationScreenProps, S
116112
const { goBack } = this.props.navigation
117113
const { roots, a, b, c} = this.state
118114
return (
119-
<View style={ROOT} >
115+
116+
<ScrollView style={ROOT} scrollEnabled={false} >
120117
<Header
121118
headerTx="linear.header"
122119
style={HeaderStyle}
123120
titleStyle={TextStyle}
124121
leftIcon="chevron-left"
125122
onLeftPress={() => goBack()}
126123
/>
124+
<KeyboardAwareScrollView contentContainerStyle={{ flex: 1}}>
127125
<View style={EquationView}>
128-
<Katex
129-
expression="ax + b = c"
130-
style={{flex: 1}}
131-
inlineStyle={inlineStyle}
132-
displayMode={false}
133-
colorIsTextColor={false}
134-
onError={() => console.error('Error')}
135-
/>
126+
<Image source={require('../../../images/linear.png')} resizeMode="contain" style={ImageStyle} />
136127
</View>
128+
137129
<View style={InputView}>
138130
<Text style={textStyle}> a = </Text>
139131
<TextField
@@ -176,7 +168,9 @@ export class LinearEquation extends React.Component<LinearEquationScreenProps, S
176168
})
177169
}
178170
</View>
179-
</View>
171+
172+
</KeyboardAwareScrollView>
173+
</ScrollView>
180174
)
181175
}
182176
}

0 commit comments

Comments
 (0)