-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAccountSelector.js
43 lines (35 loc) · 1.17 KB
/
AccountSelector.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import ModalSelector from 'react-native-modal-selector'
import React, { useState, useEffect } from "react";
const { setActiveAccountIndexToStorage } = require('./AccountHelper');
export default function AccountSelector({ activeAccountIndex, setActiveAccountIndex, accountIndexesArray }) {
const [data, setData] = useState(null);
useEffect(() => {
let accountIndexesData = [];
accountIndexesData.push({ key: -1, section: true, label: 'Accounts' })
accountIndexesArray.forEach(
(accountIndex) => {
accountIndexesData.push({ key:accountIndex, label: accountIndex });
});
setData(accountIndexesData);
}, [accountIndexesArray]);
if (!data) {
return (<></>);
}
return (
<ModalSelector
data={data}
initValue={activeAccountIndex.toString()}
initValueTextStyle={{fontWeight: "bold", color:"black"}}
sectionTextStyle={{fontWeight: "bold", color:"black"}}
onModalClose={(option)=> {
if (option && option.key) {
setActiveAccountIndexToStorage(option.key);
setActiveAccountIndex(option.key);
}
}
}
backdropPressToClose={true}
cancelText={"Cancel"}
/>
);
}