add src
This commit is contained in:
parent
6113911f41
commit
e3b736a60d
0
src/actions/anki-edit-actions.js
Normal file
0
src/actions/anki-edit-actions.js
Normal file
46
src/actions/anki-get-actions.js
Normal file
46
src/actions/anki-get-actions.js
Normal file
|
@ -0,0 +1,46 @@
|
|||
import {AnkiDroid} from 'react-native-ankidroid/dist/ankidroid';
|
||||
import {
|
||||
CHECK_ANKI_ACCESS,
|
||||
ERROR,
|
||||
GET_DECK_LIST,
|
||||
GET_FIELD_LIST,
|
||||
GET_MODEL_LIST,
|
||||
REQUEST_PERMISSIONS,
|
||||
} from '../constants/anki-constants';
|
||||
|
||||
export const requestAnkiPermissions = async (
|
||||
ankiProvider = AnkiDroid.requestPermission,
|
||||
) => {
|
||||
const [err, res] = await ankiProvider();
|
||||
const permission = res === 'granted';
|
||||
return err ? {type: ERROR, err} : {type: REQUEST_PERMISSIONS, permission};
|
||||
};
|
||||
|
||||
export const checkAnkiAccess = async (
|
||||
ankiApiProvider = AnkiDroid.isApiAvailable,
|
||||
) => {
|
||||
const [err, res] = await ankiApiProvider();
|
||||
return err ? {type: ERROR, err} : {type: CHECK_ANKI_ACCESS, payload: res};
|
||||
};
|
||||
|
||||
export const getDeckList = async (
|
||||
getDeckListFunction = AnkiDroid.getDeckList,
|
||||
) => {
|
||||
const [err, res] = await getDeckListFunction();
|
||||
return err ? {type: ERROR, err} : {type: GET_DECK_LIST, payload: res};
|
||||
};
|
||||
|
||||
export const getModelList = async (
|
||||
getModelListFunction = AnkiDroid.getModelList,
|
||||
) => {
|
||||
const [err, res] = await getModelListFunction();
|
||||
return err ? {type: ERROR, err} : {type: GET_MODEL_LIST, payload: res};
|
||||
};
|
||||
|
||||
export const getFieldList = async (
|
||||
id,
|
||||
getFieldListFunction = AnkiDroid.getFieldList,
|
||||
) => {
|
||||
const [err, res] = await getFieldListFunction(id);
|
||||
return err ? {type: ERROR, err} : {type: GET_FIELD_LIST, payload: res};
|
||||
};
|
7
src/actions/anki-set-actions.js
Normal file
7
src/actions/anki-set-actions.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
import {AnkiDroid} from 'react-native-ankidroid/dist/ankidroid';
|
||||
import {SET_DECK} from '../constants/anki-constants';
|
||||
|
||||
export const selectDeck = id => ({
|
||||
type: SET_DECK,
|
||||
payload: id,
|
||||
});
|
0
src/actions/anki-ui-actions.js
Normal file
0
src/actions/anki-ui-actions.js
Normal file
8
src/components/start-screen.jsx
Normal file
8
src/components/start-screen.jsx
Normal file
|
@ -0,0 +1,8 @@
|
|||
import React from 'react';
|
||||
import {Container, Text} from 'native-base';
|
||||
|
||||
const StartScreen = props => {
|
||||
return <Text>world , УХТЫ БЛЯ</Text>;
|
||||
};
|
||||
|
||||
export default StartScreen;
|
18
src/constants/anki-constants.js
Normal file
18
src/constants/anki-constants.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
//export const ct = 'ct';
|
||||
//Anki edit actions
|
||||
export const ERROR = 'ERROR';
|
||||
export const CREATE_MODEL = 'CREATE_MODEL';
|
||||
export const EDIT_INPUT_WORD = 'EDIT_INPUT_WORD';
|
||||
//Anki get actions
|
||||
export const REQUEST_PERMISSIONS = 'REQUEST_PERMISSIONS';
|
||||
export const CHECK_ANKI_ACCESS = 'CHECK_ANKI_ACCESS';
|
||||
export const GET_DECK_LIST = 'GET_DECK_LIST';
|
||||
export const GET_MODEL_LIST = 'GET_MODEL_LIST';
|
||||
export const GET_FIELD_LIST = 'GET_FIELD_LIST';
|
||||
//Anki set actions
|
||||
export const SET_DECK = 'SET_DECK';
|
||||
export const SET_WORD_DEFINITION = 'SET_DEFINITION';
|
||||
export const SET_WORD_SOUND = 'SET_WORD_SOUND';
|
||||
export const SET_WORD_TRANSLATE = 'SET_WORD_TRANSLATE';
|
||||
//Anki ui actions
|
||||
export const SHOW_FIELDS = 'SHOW_FIELDS';
|
15
src/reducers/anki-reducer.js
Normal file
15
src/reducers/anki-reducer.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
const initialState = {
|
||||
isApiAvailable: false,
|
||||
isAnkiConnected: false,
|
||||
deckList: [],
|
||||
mainFieldIsAvailable: false,
|
||||
fieldList: [],
|
||||
};
|
||||
|
||||
const ankiReducer = (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
export default ankiReducer;
|
9
src/reducers/api-reducer.js
Normal file
9
src/reducers/api-reducer.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
const initialState = {};
|
||||
|
||||
const apiReducer = (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
export default apiReducer;
|
10
src/reducers/main-reducer.js
Normal file
10
src/reducers/main-reducer.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
import {combineReducers} from 'redux';
|
||||
import ankiReducer from './anki-reducer';
|
||||
import apiReducer from './api-reducer';
|
||||
|
||||
const mainReducer = combineReducers({
|
||||
ankiReducer,
|
||||
apiReducer,
|
||||
});
|
||||
|
||||
export default mainReducer;
|
10
src/store.js
Normal file
10
src/store.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
import {createStore, applyMiddleware} from 'redux';
|
||||
import {composeWithDevTools} from 'redux-devtools-extension';
|
||||
import mainReducer from './reducers/main-reducer'; //your reducer
|
||||
|
||||
const composeEnhancers = composeWithDevTools({realtime: true, port: 8081}); //possible to run without arguments
|
||||
const store = createStore(
|
||||
mainReducer,
|
||||
/* preloadedState, */ composeEnhancers(/*connect of middelwares*/),
|
||||
);
|
||||
export default store;
|
Loading…
Reference in a new issue