Skip to content

Commit

Permalink
TS lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cakesoft-shashank committed Nov 30, 2023
1 parent 3f16beb commit 0901962
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
37 changes: 25 additions & 12 deletions src/BorderWalletGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,21 @@ const styles = StyleSheet.create({

const rows = Array.from(Array(128).keys());

export const Cell = ({ onPress, text, index, selected, accentColor }) => {
interface CellProps {
text: string;
index: number;
selected: number[];
accentColor: string;
onPress: (index: number) => {};
}

export const Cell = ({
onPress,
text,
index,
selected,
accentColor,
}: CellProps) => {
const isSelected = selected.includes(index);
const sequence = isSelected ? selected.findIndex((i) => i === index) + 1 : -1;
return (
Expand Down Expand Up @@ -147,10 +161,10 @@ const defaultProps: Props = {

const BorderWalletGrid = (props: Props) => {
const gridType = props.gridType || GridType.WORDS;
const [grid, setGrid] = useState([]);
const [selected, setSelected] = useState([]);
const columnHeaderRef = useRef();
const rowHeaderRef = useRef();
const [grid, setGrid] = useState<string[][]>([]);
const [selected, setSelected] = useState<number[]>([]);
const columnHeaderRef = useRef<FlatList>(null);
const rowHeaderRef = useRef<FlatList>(null);
const [loading, setLoading] = useState(true);

useEffect(() => {
Expand Down Expand Up @@ -181,21 +195,20 @@ const BorderWalletGrid = (props: Props) => {
return ' ';
}
});
const _grid = [];
const _grid: string[][] = [];
Array.from(
{
length: 128,
},
(_, rowIndex) => {
_grid.push(cells.slice(rowIndex * 16, (rowIndex + 1) * 16));
}
(_, rowIndex) =>
_grid.push(cells.slice(rowIndex * 16, (rowIndex + 1) * 16))
);
setGrid(_grid);
props.onGridLoaded(_grid);
props.onGridLoaded(words);
setLoading(false);
};

const onCellPress = (index) => {
const onCellPress = (index: number) => {
const isSelected = selected.includes(index);
if (isSelected) {
const i = selected.findIndex((i) => i === index);
Expand Down Expand Up @@ -319,7 +332,7 @@ const BorderWalletGrid = (props: Props) => {
showsHorizontalScrollIndicator={false}
renderItem={({ item, index: i }) => (
<Cell
onPress={(i) => onCellPress(i)}
onPress={async (i) => onCellPress(i)}
text={item}
index={index * 16 + i}
selected={selected}
Expand Down
4 changes: 3 additions & 1 deletion src/generateBorderWalletGrid.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { GridType } from './Interface';
// @ts-ignore
import uheprng from './uheprng';
import { wordList } from './wordlist';

import crypto from 'crypto';
const wordlists = wordList;

const rnd11Bit = (limit = 2048) => {
let small = limit;
while (small >= limit) {
const big = crypto.getRandomValues(new Uint16Array(1))[0];
// @ts-ignore
const bigString = big.toString(2).padStart(16, '0');
const smallString = bigString.slice(5);
small = parseInt(smallString, 2);
Expand Down

0 comments on commit 0901962

Please sign in to comment.