Skip to content

Commit

Permalink
v1.0.1 & clean code & refine icon
Browse files Browse the repository at this point in the history
  • Loading branch information
k3-cat committed Apr 7, 2021
1 parent 06306a4 commit 662c723
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 48 deletions.
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "TransBox",
"slug": "TransBox",
"privacy": "public",
"version": "1.0.0",
"version": "1.1.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
Expand All @@ -12,7 +12,7 @@
"backgroundColor": "#fcfcfc"
},
"updates": {
"fallbackToCacheTimeout": 7000
"fallbackToCacheTimeout": 5000
},
"assetBundlePatterns": [
"assets/*"
Expand Down
4 changes: 2 additions & 2 deletions app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { enableScreens } from 'react-native-screens';

import Navigator from './screens/Navigator';
import Screens from './screens/Index';
import { rootStore, StoreProvider } from './stores/rootStore';
import { initTheme } from './themes/themeManager';

Expand All @@ -24,7 +24,7 @@ export default function Main() {
return (
<StoreProvider value={rootStore}>
<SafeAreaProvider>
<Navigator />
<Screens />
</SafeAreaProvider>
</StoreProvider>
);
Expand Down
6 changes: 3 additions & 3 deletions app/screens/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import React, { useRef } from 'react';
import { createDrawerNavigator } from '@react-navigation/drawer';
import { NavigationContainer, NavigationContainerRef } from '@react-navigation/native';

import Header from '../components/Header';
import { pages } from '../components/pages';
import SideDrawer from '../components/SideDrawer';
import Header from './navigator/Header';
import { pages } from './navigator/pages';
import SideDrawer from './navigator/SideDrawer';

const Drawer = createDrawerNavigator();

Expand Down
2 changes: 1 addition & 1 deletion app/screens/ho_units/MolInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function MolInput() {
</TouchableOpacity>}
/>
</Dialog>
</Fragment >
</Fragment>
);
}

Expand Down
42 changes: 18 additions & 24 deletions app/screens/ho_units/Output.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { TouchableWithoutFeedback } from 'react-native-gesture-handler';
import { RadioButton } from 'react-native-ui-lib';
import { Text, View } from 'react-native-ui-lib/core';

import { Ionicons } from '@expo/vector-icons';

import { useStore } from '../../stores/rootStore';

const com = ['pg/mL', 'ng/dL', 'ng/mL'];
Expand Down Expand Up @@ -48,8 +50,10 @@ function Output() {
bottom: 10
}}
>
<View row>
<Text text50M>{'=> '}</Text>
<View row centerV>
<Text style={{ fontSize: 27, color: '#808080', marginRight: -7, marginTop: -3 }}>=</Text>
<Ionicons size={27} color='#808080' name='chevron-forward-outline' />
<View paddingR-12 />
<Text text50M style={{ color: !strResult.endsWith(' ') ? '#64b5f6' : '#ef5350' }}>
{strResult}
</Text>
Expand All @@ -58,27 +62,17 @@ function Output() {
}
</View>
<View row paddingH-10 style={{ alignContent: 'space-between' }}>
<View flexG>
<RadioButton
label={com[0]}
selected={R.unit.tUnit === com[0]}
onPress={() => R.unit.setT(com[0])}
/>
</View>
<View flexG>
<RadioButton
label={com[1]}
selected={R.unit.tUnit === com[1]}
onPress={() => R.unit.setT(com[1])}
/>
</View>
<View flexG>
<RadioButton
label={com[2]}
selected={R.unit.tUnit === com[2]}
onPress={() => R.unit.setT(com[2])}
/>
</View>
{
com.map((u, i) =>
<View key={i} flexG>
<RadioButton
label={u}
selected={R.unit.tUnit === u}
onPress={() => R.unit.setT(u)}
/>
</View>
)
}
<View>
<RadioButton
label={com.includes(R.unit.tUnit) ? '自定义' : R.unit.tUnit}
Expand All @@ -88,7 +82,7 @@ function Output() {
/>
</View>
</View>
</Fragment >
</Fragment>
);
}

Expand Down
7 changes: 3 additions & 4 deletions app/screens/ho_units/QuickAccess.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ function QuickAccess() {
R.unit.qa.presets.length === 0 ?
<View centerV flexG>
<View style={{ top: '-7%' }}>
<Text center text60M grey30 >点击按钮保存预设</Text>
<Text center text60M grey30>点击按钮保存预设</Text>
<View paddingV-3 />
<Text center text60M grey30 >长按加载&emsp;左滑移除</Text>
<Text center text60M grey30>长按加载&emsp;左滑移除</Text>
</View>
</View>
:
Expand All @@ -51,8 +51,7 @@ function QuickAccess() {
</Text>
</ListItem.Part>
</ListItem>
</Drawer>
}
</Drawer>}
/>
}
</View>
Expand Down
5 changes: 2 additions & 3 deletions app/screens/ho_units/UnitDiag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,11 @@ function UnitDiag() {
<View paddingL-20 paddingR-30 paddingV-10>
<Text center text70M style={{ color: o === ob.vv ? '#ff5722' : '#2196f3' }}>{o}</Text>
</View>
</TouchableOpacity>}
</Observer>}
</TouchableOpacity>}</Observer>}
/>
</View>
</View>
</Dialog >
</Dialog>
);
}

Expand Down
10 changes: 5 additions & 5 deletions app/screens/navigator/pages.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import About from '../screens/About';
import HoUnits from '../screens/ho_units/Index';
import Lollipop from '../screens/Lollipop';
import Memorial from '../screens/memorial/Index';
import Reminder from '../screens/reminder/Index';
import About from '../About';
import HoUnits from '../ho_units/Index';
import Lollipop from '../Lollipop';
import Memorial from '../memorial/Index';
import Reminder from '../reminder/Index';

interface page {
name: string;
Expand Down
2 changes: 1 addition & 1 deletion app/stores/rootStore.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { types } from 'mobx-state-tree';
import React, { useContext } from 'react';

import { UnitStore, unitStore } from './unit/unit';
import { UnitStore, unitStore } from './unit/store';
import { UpdaterStore, updaterStore } from './updater/store';
import { triggerUpdateAction } from './updater/trigger';

Expand Down
7 changes: 4 additions & 3 deletions app/stores/unit/convertor.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { comMolIndex, vUnitIndex, wUnitIndex } from '../../screens/ho_units/utils';

function getMol(mol: string) {
function getMol(mol?: string) {
if (!mol) { return NaN; }
if (comMolIndex.has(mol)) {
return comMolIndex.get(mol)!;
}
const n = parseFloat(mol);
return n > 100 ? n : NaN;
}

export function convert(value: string, sUnit: string, tUnit: string, mol: string = '') {
export function convert(source: string, sUnit: string, tUnit: string, mol?: string) {
const s = sUnit.split('/');
const t = tUnit.split('/');

let result = parseFloat(value) * wUnitIndex.get(s[0])! / wUnitIndex.get(t[0])! / vUnitIndex.get(s[1])! * vUnitIndex.get(t[1])!;
let result = parseFloat(source) * wUnitIndex.get(s[0])! / wUnitIndex.get(t[0])! / vUnitIndex.get(s[1])! * vUnitIndex.get(t[1])!;

if (s[0].endsWith('mol')) { result *= getMol(mol); }
else if (s[0].endsWith('IU')) { result /= getMol(mol); }
Expand Down
File renamed without changes.
Binary file modified assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 662c723

Please sign in to comment.