commit
f3d6389951
Binary file not shown.
|
@ -1,5 +1,7 @@
|
||||||
# AnkiLan
|
# AnkiLan
|
||||||
App which provide translating and adding words to anki
|
App provide creating automatically fill fields with English words and their definitions, examples, translates and add it to Anki.
|
||||||
|
|
||||||
|
App required already installed [Anki](https://apps.ankiweb.net/) on your phone.
|
||||||
|
|
||||||
- - -
|
- - -
|
||||||
![screenshot](./readme-files/screenshot1.png)
|
![screenshot](./readme-files/screenshot1.png)
|
||||||
|
|
|
@ -68,12 +68,10 @@ const setModelList = res => {
|
||||||
export const getModelList = () => async dispatch => {
|
export const getModelList = () => async dispatch => {
|
||||||
try {
|
try {
|
||||||
const [err, res] = await AnkiDroid.getModelList();
|
const [err, res] = await AnkiDroid.getModelList();
|
||||||
console.log('RESRES', res);
|
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
await dispatch(setModelList(res));
|
await dispatch(setModelList(res));
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
|
@ -105,10 +103,9 @@ const setExistingOfAnkiLanModel = existing => {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
export const checkAnkiLanModelForExisting = name => async dispatch => {
|
export const checkAnkiLanModelForExisting = name => async dispatch => {
|
||||||
setTimeout( async () => {
|
setTimeout(async () => {
|
||||||
try {
|
try {
|
||||||
const [error, modelList] = await AnkiDroid.getModelList()
|
const [error, modelList] = await AnkiDroid.getModelList();
|
||||||
console.log('CECKCKC', name, modelList);
|
|
||||||
for (let model of modelList) {
|
for (let model of modelList) {
|
||||||
if (model.name === name) {
|
if (model.name === name) {
|
||||||
await dispatch(setExistingOfAnkiLanModel(true));
|
await dispatch(setExistingOfAnkiLanModel(true));
|
||||||
|
@ -121,7 +118,7 @@ export const checkAnkiLanModelForExisting = name => async dispatch => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
await dispatch(setExistingOfAnkiLanModel(false));
|
await dispatch(setExistingOfAnkiLanModel(false));
|
||||||
}
|
}
|
||||||
}, 2000)
|
}, 2000);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getModelId = (models, name) => {
|
export const getModelId = (models, name) => {
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
import {SELECT_POS_ID} from '../constants/anki-constants';
|
||||||
|
|
||||||
|
export const setPosId = (id, value) => {
|
||||||
|
console.log('setPosId');
|
||||||
|
console.log(id);
|
||||||
|
console.log(value);
|
||||||
|
return {
|
||||||
|
type: SELECT_POS_ID,
|
||||||
|
payload: value,
|
||||||
|
id,
|
||||||
|
};
|
||||||
|
};
|
|
@ -58,7 +58,7 @@ export const addNote = async words => {
|
||||||
const ankiData = await getAnkiData();
|
const ankiData = await getAnkiData();
|
||||||
await console.log(ankiData);
|
await console.log(ankiData);
|
||||||
const template = await ankiData.fieldList;
|
const template = await ankiData.fieldList;
|
||||||
const deckId = store.getState().anki.selectedDeck.id;
|
const deckId = store.getState().anki.selectedDeck.deck.id;
|
||||||
const modelId = await ankiData.modelId;
|
const modelId = await ankiData.modelId;
|
||||||
console.log(template, deckId, modelId);
|
console.log(template, deckId, modelId);
|
||||||
const settings = {
|
const settings = {
|
||||||
|
|
|
@ -12,3 +12,8 @@ export const sendField = field => ({
|
||||||
payload: field.text,
|
payload: field.text,
|
||||||
role: field.role,
|
role: field.role,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const selectCertainFormValue = (
|
||||||
|
unicName = String,
|
||||||
|
value = String,
|
||||||
|
) => ({});
|
||||||
|
|
|
@ -1,163 +0,0 @@
|
||||||
import React, {useEffect, useRef, useState} from 'react';
|
|
||||||
import TextField from 'react-native-material-textfield/src/components/field';
|
|
||||||
import {StyleSheet} from 'react-native';
|
|
||||||
import {Picker, Text, View} from 'native-base';
|
|
||||||
import IconedButton from '../view/iconed-button.jsx';
|
|
||||||
import {POS_PICKER} from '../../constants/component-types';
|
|
||||||
|
|
||||||
const FieldEditor = props => {
|
|
||||||
const [data, setData] = useState(props.data);
|
|
||||||
const [values, setValues] = useState(props.data.values);
|
|
||||||
const [editing, setEditing] = useState(false);
|
|
||||||
const [selectedValue, setSelectedValue] = useState(
|
|
||||||
props.data.values[props.id] || props.data.values[0],
|
|
||||||
);
|
|
||||||
const [userText, setUserText] = useState(
|
|
||||||
props.data.values[props.id] || props.data.values[0],
|
|
||||||
);
|
|
||||||
const [valuesUpdated, setValuesUpdated] = useState(false);
|
|
||||||
const input = useRef();
|
|
||||||
useEffect(() => {
|
|
||||||
// console.log(userText)
|
|
||||||
// console.log("SELECTED", selectedValue)
|
|
||||||
if (props.hasChanged) {
|
|
||||||
// console.log("HAS CHANGED")
|
|
||||||
props.hasChanged(selectedValue);
|
|
||||||
}
|
|
||||||
if (props.type === POS_PICKER) {
|
|
||||||
console.log(userText);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
useEffect(() => {
|
|
||||||
if (props.data.values.length === values.length) {
|
|
||||||
setData(props.data);
|
|
||||||
setValues(props.data.values);
|
|
||||||
}
|
|
||||||
}, [props.data.values]);
|
|
||||||
|
|
||||||
const selectValue = selected => {
|
|
||||||
setSelectedValue(selected);
|
|
||||||
if (props.type === POS_PICKER) {
|
|
||||||
values.forEach((value, id) => {
|
|
||||||
if (value === selected) {
|
|
||||||
console.warn(id);
|
|
||||||
props.onSelect(id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const typing = text => {
|
|
||||||
setUserText(text);
|
|
||||||
};
|
|
||||||
const select = value => {
|
|
||||||
setUserText(value);
|
|
||||||
selectValue(value);
|
|
||||||
};
|
|
||||||
const confirmTyped = () => {
|
|
||||||
let newValues = new Set(values);
|
|
||||||
const valuesArray = Array.from(newValues.add(userText));
|
|
||||||
setValues(valuesArray);
|
|
||||||
setData({...data, values: valuesArray});
|
|
||||||
setEditing(!editing);
|
|
||||||
if (valuesArray.length !== values.length) {
|
|
||||||
setValuesUpdated(true);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (valuesUpdated) {
|
|
||||||
setSelectedValue(values[values.length - 1]);
|
|
||||||
setUserText(values[values.length - 1]);
|
|
||||||
setValuesUpdated(false);
|
|
||||||
}
|
|
||||||
setValuesUpdated(false);
|
|
||||||
}, [valuesUpdated]);
|
|
||||||
const styles = StyleSheet.create({
|
|
||||||
wrapper: {},
|
|
||||||
inner: {
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
flexDirection: 'row',
|
|
||||||
alignItems: 'center',
|
|
||||||
alignContent: 'center',
|
|
||||||
},
|
|
||||||
row: {
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'row',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
width: 90,
|
|
||||||
},
|
|
||||||
button: {
|
|
||||||
width: 40,
|
|
||||||
height: 40,
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'center',
|
|
||||||
alignItems: 'center',
|
|
||||||
},
|
|
||||||
tfWrapper: {
|
|
||||||
width: editing ? '75%' : '84%',
|
|
||||||
},
|
|
||||||
pickerLabel: {
|
|
||||||
color: '#00000050',
|
|
||||||
fontSize: 12,
|
|
||||||
marginLeft: 2,
|
|
||||||
},
|
|
||||||
hr: {
|
|
||||||
height: 1,
|
|
||||||
width: '100%',
|
|
||||||
backgroundColor: '#00000070',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<View style={styles.wrapper}>
|
|
||||||
<View style={styles.inner}>
|
|
||||||
<View style={styles.tfWrapper}>
|
|
||||||
{editing ? (
|
|
||||||
<TextField
|
|
||||||
lineType={'none'}
|
|
||||||
multiline={true}
|
|
||||||
label={props.data.label}
|
|
||||||
value={userText}
|
|
||||||
editable={true}
|
|
||||||
ref={input}
|
|
||||||
onChangeText={text => typing(text)}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<View>
|
|
||||||
<Text style={styles.pickerLabel}>{props.data.label}</Text>
|
|
||||||
<Picker
|
|
||||||
selectedValue={selectedValue}
|
|
||||||
onValueChange={value => select(value)}>
|
|
||||||
{values.map((value, id) => {
|
|
||||||
return <Picker.Item value={value} label={value} key={id} />;
|
|
||||||
})}
|
|
||||||
</Picker>
|
|
||||||
</View>
|
|
||||||
)}
|
|
||||||
</View>
|
|
||||||
{editing ? (
|
|
||||||
<View style={styles.row}>
|
|
||||||
<IconedButton
|
|
||||||
icon="caret-down"
|
|
||||||
onPress={() => {
|
|
||||||
setEditing(!editing);
|
|
||||||
setUserText(selectedValue);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<IconedButton icon="check" onPress={confirmTyped} />
|
|
||||||
</View>
|
|
||||||
) : (
|
|
||||||
<IconedButton
|
|
||||||
icon="pen"
|
|
||||||
onPress={() => {
|
|
||||||
setEditing(!editing);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</View>
|
|
||||||
<View style={styles.hr} />
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
export default FieldEditor;
|
|
|
@ -6,7 +6,7 @@ import IconedButton from '../view/iconed-button.jsx';
|
||||||
import {POS_PICKER} from '../../constants/component-types';
|
import {POS_PICKER} from '../../constants/component-types';
|
||||||
import set from '@babel/runtime/helpers/esm/set';
|
import set from '@babel/runtime/helpers/esm/set';
|
||||||
|
|
||||||
const FieldEditor = props => {
|
const FieldEditor = (props) => {
|
||||||
const label = props.data.label;
|
const label = props.data.label;
|
||||||
const constantValues = props.pos | '';
|
const constantValues = props.pos | '';
|
||||||
const [values, setValues] = useState(props.data.values);
|
const [values, setValues] = useState(props.data.values);
|
||||||
|
@ -24,19 +24,19 @@ const FieldEditor = props => {
|
||||||
const [] = useState();
|
const [] = useState();
|
||||||
const [] = useState();
|
const [] = useState();
|
||||||
|
|
||||||
const select = value => {
|
const select = (value) => {
|
||||||
setSelectedValue(value);
|
setSelectedValue(value);
|
||||||
setFiniteValue(value);
|
setFiniteValue(value);
|
||||||
setEditingValue(value);
|
setEditingValue(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const typing = text => {
|
const typing = (text) => {
|
||||||
setEditingValue(text);
|
setEditingValue(text);
|
||||||
};
|
};
|
||||||
|
|
||||||
const setTyped = () => {
|
const setTyped = () => {
|
||||||
try {
|
try {
|
||||||
let valuesSet = new Set(values);
|
let valuesSet = new Set(props.data.values);
|
||||||
valuesSet.add(editingValue);
|
valuesSet.add(editingValue);
|
||||||
const valuesArray = Array.from(valuesSet).slice();
|
const valuesArray = Array.from(valuesSet).slice();
|
||||||
setValues(valuesArray);
|
setValues(valuesArray);
|
||||||
|
@ -51,7 +51,7 @@ const FieldEditor = props => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.type === POS_PICKER) {
|
if (props.type === POS_PICKER) {
|
||||||
values.forEach((value, id) => {
|
props.data.values.forEach((value, id) => {
|
||||||
if (value === finiteValue) {
|
if (value === finiteValue) {
|
||||||
props.hasChanged(id);
|
props.hasChanged(id);
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,6 @@ const FieldEditor = props => {
|
||||||
}, [finiteValue]);
|
}, [finiteValue]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setValues(props.data.values);
|
setValues(props.data.values);
|
||||||
setSelectedValue(props.data.values[0]);
|
|
||||||
console.log('EXECUTIN');
|
console.log('EXECUTIN');
|
||||||
}, [constantValues]);
|
}, [constantValues]);
|
||||||
|
|
||||||
|
@ -119,8 +118,8 @@ const FieldEditor = props => {
|
||||||
<Text style={styles.pickerLabel}>{props.data.label}</Text>
|
<Text style={styles.pickerLabel}>{props.data.label}</Text>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={selectedValue}
|
selectedValue={selectedValue}
|
||||||
onValueChange={value => select(value)}>
|
onValueChange={(value) => select(value)}>
|
||||||
{values.map((value, id) => {
|
{props.data.values.map((value, id) => {
|
||||||
return <Picker.Item value={value} label={value} key={id} />;
|
return <Picker.Item value={value} label={value} key={id} />;
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
|
@ -137,7 +136,7 @@ const FieldEditor = props => {
|
||||||
label={label}
|
label={label}
|
||||||
value={editingValue}
|
value={editingValue}
|
||||||
editable={true}
|
editable={true}
|
||||||
onChangeText={text => typing(text)}
|
onChangeText={(text) => typing(text)}
|
||||||
autoFocus={true}
|
autoFocus={true}
|
||||||
/>
|
/>
|
||||||
<View style={styles.hr} />
|
<View style={styles.hr} />
|
||||||
|
@ -147,8 +146,8 @@ const FieldEditor = props => {
|
||||||
<Text style={styles.pickerLabel}>{props.data.label}</Text>
|
<Text style={styles.pickerLabel}>{props.data.label}</Text>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={selectedValue}
|
selectedValue={selectedValue}
|
||||||
onValueChange={value => select(value)}>
|
onValueChange={(value) => select(value)}>
|
||||||
{values.map((value, id) => {
|
{props.data.values.map((value, id) => {
|
||||||
return (
|
return (
|
||||||
<Picker.Item value={value} label={value} key={id} />
|
<Picker.Item value={value} label={value} key={id} />
|
||||||
);
|
);
|
||||||
|
|
|
@ -18,7 +18,7 @@ import {
|
||||||
import {sendField} from '../../actions/form-actions';
|
import {sendField} from '../../actions/form-actions';
|
||||||
import {addNote} from '../../actions/createAnkiLanModel';
|
import {addNote} from '../../actions/createAnkiLanModel';
|
||||||
|
|
||||||
const FieldList = props => {
|
const FieldList = (props) => {
|
||||||
const [pronunciation, setPronunciation] = useState(
|
const [pronunciation, setPronunciation] = useState(
|
||||||
props.response.pronunciation,
|
props.response.pronunciation,
|
||||||
);
|
);
|
||||||
|
@ -46,10 +46,11 @@ const FieldList = props => {
|
||||||
setSound(props.response.sound);
|
setSound(props.response.sound);
|
||||||
setPronunciation(props.response.pronunciation);
|
setPronunciation(props.response.pronunciation);
|
||||||
setExamples(props.response.examples);
|
setExamples(props.response.examples);
|
||||||
|
console.log('DPEDDDDD', props.response.compounded);
|
||||||
}, [props]);
|
}, [props]);
|
||||||
const [loadingState, setLoadingState] = useState(false);
|
const [loadingState, setLoadingState] = useState(false);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('STATE', examples, pronunciation, sound);
|
// console.log('STATE', examples, pronunciation, sound);
|
||||||
if (examples && pronunciation && sound) {
|
if (examples && pronunciation && sound) {
|
||||||
setLoadingState(true);
|
setLoadingState(true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -64,15 +65,11 @@ const FieldList = props => {
|
||||||
<ScrollView keyboardShouldPersistTaps={'handled'} style={{height: '100%'}}>
|
<ScrollView keyboardShouldPersistTaps={'handled'} style={{height: '100%'}}>
|
||||||
{loadingState && props.loadingState ? (
|
{loadingState && props.loadingState ? (
|
||||||
<View>
|
<View>
|
||||||
<PickerList labelNum={1} id={0} role={DEF_LIST1} />
|
<PickerList labelNum={1} id={props.pos1id} role={DEF_LIST1} />
|
||||||
{/*<PickerList labelNum={2} id={1} role={DEF_LIST2} />*/}
|
{/*<PickerList labelNum={2} id={1} role={DEF_LIST2} />*/}
|
||||||
<PickerList
|
<PickerList labelNum={2} id={props.pos2id} role={DEF_LIST2} />
|
||||||
labelNum={2}
|
|
||||||
id={props.response.compounded.length >= 2 ? 1 : 0}
|
|
||||||
role={DEF_LIST2}
|
|
||||||
/>
|
|
||||||
<FieldEditor
|
<FieldEditor
|
||||||
hasChanged={c =>
|
hasChanged={(c) =>
|
||||||
props.sendField({
|
props.sendField({
|
||||||
text: c,
|
text: c,
|
||||||
role: EXAMPLES,
|
role: EXAMPLES,
|
||||||
|
@ -85,7 +82,7 @@ const FieldList = props => {
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<FieldEditor
|
<FieldEditor
|
||||||
hasChanged={c =>
|
hasChanged={(c) =>
|
||||||
props.sendField({
|
props.sendField({
|
||||||
text: c,
|
text: c,
|
||||||
role: SOUND,
|
role: SOUND,
|
||||||
|
@ -95,7 +92,7 @@ const FieldList = props => {
|
||||||
role={SOUND}
|
role={SOUND}
|
||||||
/>
|
/>
|
||||||
<FieldEditor
|
<FieldEditor
|
||||||
hasChanged={c =>
|
hasChanged={(c) =>
|
||||||
props.sendField({
|
props.sendField({
|
||||||
text: c,
|
text: c,
|
||||||
role: PRONUNCIATION,
|
role: PRONUNCIATION,
|
||||||
|
@ -119,11 +116,13 @@ const FieldList = props => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
export default connect(
|
export default connect(
|
||||||
state => ({
|
(state) => ({
|
||||||
response: state.api.parsedDictionary,
|
response: state.api.parsedDictionary,
|
||||||
word: state.api.availableApi.word,
|
word: state.api.availableApi.word,
|
||||||
loadingState: state.api.apiIsLoaded,
|
loadingState: state.api.apiIsLoaded,
|
||||||
fields: state.anki.currentFields,
|
fields: state.anki.currentFields,
|
||||||
|
pos1id: state.anki.pos1id,
|
||||||
|
pos2id: state.anki.pos2id,
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
sendField,
|
sendField,
|
||||||
|
|
|
@ -5,30 +5,23 @@ import PosPicker from './pos-picker';
|
||||||
import FieldEditor from './field-editor';
|
import FieldEditor from './field-editor';
|
||||||
import {setDef} from '../../actions/anki-set-actions';
|
import {setDef} from '../../actions/anki-set-actions';
|
||||||
import {sendField} from '../../actions/form-actions';
|
import {sendField} from '../../actions/form-actions';
|
||||||
|
import {setPosId} from '../../actions/anki-ui-actions';
|
||||||
/*
|
/*
|
||||||
****************** props:*****************
|
****************** props:*****************
|
||||||
* startId props.data[0] / [1] /[8] ...
|
* startId props.data[0] / [1] /[8] ...
|
||||||
* labelNum // Translate 1 / Translate 2 ...
|
* labelNum // Translate 1 / Translate 2 ...
|
||||||
* */
|
* */
|
||||||
const PickerList = props => {
|
const PickerList = (props) => {
|
||||||
const [data, setData] = useState(props.data[props.id]);
|
|
||||||
const [tr, setTr] = useState(props.data[props.id].definitions[0]);
|
const [tr, setTr] = useState(props.data[props.id].definitions[0]);
|
||||||
const [def, setDef] = useState(props.data[props.id].definitions[0]);
|
const [def, setDef] = useState(props.data[props.id].definitions[0]);
|
||||||
const [pos, setPos] = useState(props.data[props.id].pos);
|
const [pos, setPos] = useState(props.data[props.id].pos);
|
||||||
const [globID, setId] = useState(props.id);
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setData(props.data[props.id]);
|
// props.setPosId(props.id, props.id);
|
||||||
setTimeout(() => {
|
setPos(props.data[props.id].pos);
|
||||||
selectDef(0);
|
setDef(props.data[props.id].definitions[0]);
|
||||||
}, 0);
|
setTr(props.data[props.id].translates[0]);
|
||||||
|
console.log('emmit', props.id);
|
||||||
}, [props]);
|
}, [props]);
|
||||||
const selectDef = id => {
|
|
||||||
setId(id);
|
|
||||||
setPos(props.data[id].pos);
|
|
||||||
setDef(props.data[id].definitions[0]);
|
|
||||||
setTr(props.data[id].translates[0]);
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
props.sendField({
|
props.sendField({
|
||||||
|
@ -39,17 +32,9 @@ const PickerList = props => {
|
||||||
},
|
},
|
||||||
role: props.role,
|
role: props.role,
|
||||||
});
|
});
|
||||||
props.sendField('HDFSL:FJL:SKDJF: SLDKJF:LSDJF:LSDKFJ SDF', {
|
|
||||||
text: {
|
|
||||||
pos: pos,
|
|
||||||
tr: tr,
|
|
||||||
definition: def,
|
|
||||||
},
|
|
||||||
role: props.role,
|
|
||||||
});
|
|
||||||
}, [tr, def, pos]);
|
}, [tr, def, pos]);
|
||||||
|
|
||||||
const updateData = c => {
|
const updateData = (c) => {
|
||||||
console.log('HDFLSDKFJ SDF', {
|
console.log('HDFLSDKFJ SDF', {
|
||||||
text: {
|
text: {
|
||||||
pos: pos,
|
pos: pos,
|
||||||
|
@ -65,40 +50,43 @@ const PickerList = props => {
|
||||||
<PosPicker
|
<PosPicker
|
||||||
labelNum={props.labelNum}
|
labelNum={props.labelNum}
|
||||||
defaultId={props.id}
|
defaultId={props.id}
|
||||||
onSelect={id => selectDef(id | props.id)}
|
onSelect={(id) => {
|
||||||
|
props.setPosId(props.labelNum - 1, id);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<FieldEditor
|
<FieldEditor
|
||||||
hasChanged={c => {
|
hasChanged={(c) => {
|
||||||
setTr(c);
|
setTr(c);
|
||||||
updateData(c);
|
updateData(c);
|
||||||
}}
|
}}
|
||||||
pos={pos}
|
pos={pos}
|
||||||
data={{
|
data={{
|
||||||
label: `Translate ${props.labelNum}`,
|
label: `Translate ${props.labelNum}`,
|
||||||
values: props.data[globID].translates,
|
values: props.data[props.id].translates,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<FieldEditor
|
<FieldEditor
|
||||||
hasChanged={c => {
|
hasChanged={(c) => {
|
||||||
setDef(c);
|
setDef(c);
|
||||||
updateData(c);
|
updateData(c);
|
||||||
}}
|
}}
|
||||||
pos={pos}
|
pos={pos}
|
||||||
data={{
|
data={{
|
||||||
label: `Definition ${props.labelNum}`,
|
label: `Definition ${props.labelNum}`,
|
||||||
values: props.data[globID].definitions,
|
values: props.data[props.id].definitions,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
export default connect(
|
export default connect(
|
||||||
state => ({
|
(state) => ({
|
||||||
data: state.api.parsedDictionary.compounded,
|
data: state.api.parsedDictionary.compounded,
|
||||||
word: state.api.availableApi.word,
|
word: state.api.availableApi.word,
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
setDef,
|
setDef,
|
||||||
sendField,
|
sendField,
|
||||||
|
setPosId,
|
||||||
},
|
},
|
||||||
)(PickerList);
|
)(PickerList);
|
||||||
|
|
|
@ -9,6 +9,7 @@ const PosPicker = props => {
|
||||||
const [poses, setPoses] = useState([]);
|
const [poses, setPoses] = useState([]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.parts) {
|
if (props.parts) {
|
||||||
|
console.log('PARTASSDFSD', props.defaultId)
|
||||||
let posArray = props.parts.map((part, id) => part.pos);
|
let posArray = props.parts.map((part, id) => part.pos);
|
||||||
setPoses(posArray);
|
setPoses(posArray);
|
||||||
setReady(true);
|
setReady(true);
|
||||||
|
|
|
@ -23,7 +23,7 @@ const StartScreen = props => {
|
||||||
props.getSavedData();
|
props.getSavedData();
|
||||||
props.checkAnkiLanModelForExisting(props.modelName, props.modelList);
|
props.checkAnkiLanModelForExisting(props.modelName, props.modelList);
|
||||||
} else {
|
} else {
|
||||||
alert('Troubles');
|
console.log('Troubles with permissions');
|
||||||
props.requestAnkiPermission();
|
props.requestAnkiPermission();
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
|
@ -32,6 +32,7 @@ export const ANKILAN_DATA = 'ANKILAN_DATA';
|
||||||
|
|
||||||
//form actions
|
//form actions
|
||||||
export const SEND_FIELD = 'SEND_FIELD';
|
export const SEND_FIELD = 'SEND_FIELD';
|
||||||
|
export const SELECT_POS_ID = 'SELECT_POS_ID';
|
||||||
//field names
|
//field names
|
||||||
|
|
||||||
export const SOUND = 'SOUND';
|
export const SOUND = 'SOUND';
|
||||||
|
|
|
@ -6,6 +6,7 @@ import {
|
||||||
GET_MODEL_LIST,
|
GET_MODEL_LIST,
|
||||||
PRONUNCIATION,
|
PRONUNCIATION,
|
||||||
REQUEST_PERMISSIONS,
|
REQUEST_PERMISSIONS,
|
||||||
|
SELECT_POS_ID,
|
||||||
SEND_FIELD,
|
SEND_FIELD,
|
||||||
SET_ANKI_DATA,
|
SET_ANKI_DATA,
|
||||||
SET_ANKI_NOTE_CREATOR,
|
SET_ANKI_NOTE_CREATOR,
|
||||||
|
@ -31,6 +32,8 @@ const initialState = {
|
||||||
ankiLanModelName: 'develop_final_maybe_maybe_maybe',
|
ankiLanModelName: 'develop_final_maybe_maybe_maybe',
|
||||||
noteCreator: {},
|
noteCreator: {},
|
||||||
noteTemplate: [],
|
noteTemplate: [],
|
||||||
|
pos1id: 0,
|
||||||
|
pos2id: 0,
|
||||||
currentFields: {
|
currentFields: {
|
||||||
word: '',
|
word: '',
|
||||||
compounded: [
|
compounded: [
|
||||||
|
@ -68,6 +71,12 @@ const ankiReducer = (state = initialState, action) => {
|
||||||
...state,
|
...state,
|
||||||
savedData: action.payload,
|
savedData: action.payload,
|
||||||
};
|
};
|
||||||
|
case SELECT_POS_ID: {
|
||||||
|
console.log('click', action.id);
|
||||||
|
return action.id == 1
|
||||||
|
? {...state, pos2id: action.payload}
|
||||||
|
: {...state, pos1id: action.payload};
|
||||||
|
}
|
||||||
case SEND_FIELD: {
|
case SEND_FIELD: {
|
||||||
const fields = state.currentFields;
|
const fields = state.currentFields;
|
||||||
switch (action.role) {
|
switch (action.role) {
|
||||||
|
@ -120,6 +129,7 @@ const ankiReducer = (state = initialState, action) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue