This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| setOperand(op: Operation): ?Operation { | |
| let newNumber: ?string; | |
| if (!Validator.validDigit(op.stringVal, this.queue)) { | |
| return null; | |
| } | |
| let lastOp: ?Operation = lastOrNull(this.queue); | |
| if (lastOp && ( | |
| this.cleared || |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| setOperand(op: Operation): ?Operation { | |
| let newNumber: ?string; | |
| if (!Validator.validDigit(op.stringVal, this.queue)) { | |
| return null; | |
| } | |
| let lastOp: ?Operation = lastOrNull(this.queue); | |
| if (lastOp && ( | |
| this.cleared || |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //@flow | |
| export const OperationType = Object.freeze({ | |
| 'Constant': 1, // a constant value (e.g. 2, 5, pi) | |
| 'Operation': 2, // can be calculated based on inputs (e.g. cos, +, !) | |
| 'Equals': 3, // clears and evaluates the queue | |
| 'Clear': 4, // clears the queue | |
| 'Parenthesis': 5, // parenthesis | |
| }); | |
| export const OperationSubType = Object.freeze({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //@flow | |
| import {Operation, newOperation} from './Operations'; | |
| import {OperationType, OperationSubType, OperationArgs} from './OperationTypes'; | |
| import {zipWithIndexTwice, lastOrNull, isInArray, numberWithCommas, isNumeric} from '../utils/Utils'; | |
| import CalcUtils from '../utils/CalculatorUtils'; | |
| import Validator from '../utils/Validator'; | |
| export default class CalculatorBrain { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //@flow | |
| import {isInArray, multiply} from '../utils/Utils'; | |
| import {OperationType, OperationSubType, OperationArgs} from './OperationTypes'; | |
| const OperationsOverloaded = Object.freeze({ | |
| '−': Object.freeze({ | |
| UnaryOp: 'neg', | |
| BinaryOp: '−' | |
| }) | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //@flow | |
| import React, {Component} from 'react'; | |
| import {SafeAreaView, Text, ScrollView, StyleSheet, TouchableHighlight, Alert, Clipboard, Dimensions} from 'react-native'; | |
| import Colors from '../constants/Colors'; | |
| import Constants from '../constants/Constants' | |
| import { isNumeric } from '../utils/Utils'; | |
| type Props = { | |
| topDisplay: string, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { AppRegistry } from 'react-native'; | |
| import App from './app/App'; | |
| import { YellowBox } from 'react-native'; | |
| AppRegistry.registerComponent('OpenCalc', () => App); | |
| YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated', 'Module RCTImageLoader','Class RCTCxxModule']); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //@flow | |
| import React, {Component} from 'react'; | |
| import {StyleSheet, View, Clipboard} from 'react-native'; | |
| import CalculatorResponse from './components/CalculatorResponse'; | |
| import CalculatorBrain from './core/CalculatorBrain'; | |
| import Colors from './constants/Colors'; | |
| import Constants from './constants/Constants' |