fix eslint warnings

This commit is contained in:
ammarahm-ed
2022-01-25 11:10:22 +05:00
parent 4a4830d21b
commit 073cea789b
3 changed files with 65 additions and 74 deletions

View File

@@ -1,6 +1,6 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Appearance, SafeAreaView } from 'react-native'; import { Appearance, SafeAreaView } from 'react-native';
import RNBootSplash from "react-native-bootsplash"; import RNBootSplash from 'react-native-bootsplash';
import { COLOR_SCHEME_DARK, COLOR_SCHEME_LIGHT } from '../src/utils/Colors'; import { COLOR_SCHEME_DARK, COLOR_SCHEME_LIGHT } from '../src/utils/Colors';
import NotesnookShare from './index'; import NotesnookShare from './index';
@@ -8,16 +8,13 @@ export default class QuickNoteIOS extends Component {
constructor(props, context) { constructor(props, context) {
super(props, context); super(props, context);
this.state = { this.state = {
colors: colors: Appearance.getColorScheme() === 'dark' ? COLOR_SCHEME_DARK : COLOR_SCHEME_LIGHT,
Appearance.getColorScheme() === 'dark'
? COLOR_SCHEME_DARK
: COLOR_SCHEME_LIGHT,
height: 0 height: 0
}; };
} }
componentDidMount() { componentDidMount() {
RNBootSplash.hide({fade:true}) RNBootSplash.hide({ fade: true });
} }
render() { render() {
@@ -28,7 +25,8 @@ export default class QuickNoteIOS extends Component {
height: '100%', height: '100%',
justifyContent: 'flex-start', justifyContent: 'flex-start',
backgroundColor: this.state.colors.nav backgroundColor: this.state.colors.nav
}}> }}
>
<NotesnookShare quicknote={true} /> <NotesnookShare quicknote={true} />
</SafeAreaView> </SafeAreaView>
); );

View File

@@ -1,5 +1,5 @@
import React, {useEffect, useRef, useState} from 'react'; import React, { useEffect, useRef, useState } from 'react';
import {StatusBar} from 'react-native'; import { StatusBar } from 'react-native';
import { import {
ActivityIndicator, ActivityIndicator,
FlatList, FlatList,
@@ -10,26 +10,23 @@ import {
useWindowDimensions, useWindowDimensions,
View View
} from 'react-native'; } from 'react-native';
import {useSafeAreaInsets} from 'react-native-safe-area-context'; import { useSafeAreaInsets } from 'react-native-safe-area-context';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import {getElevation} from '../src/utils'; import { getElevation } from '../src/utils';
import {db} from '../src/utils/database'; import { db } from '../src/utils/database';
import {useShareStore} from './store'; import { useShareStore } from './store';
export const Search = ({close, getKeyboardHeight, quicknote}) => { export const Search = ({ close, getKeyboardHeight, quicknote }) => {
const colors = useShareStore(state => state.colors); const colors = useShareStore(state => state.colors);
const setAppendNote = useShareStore(state => state.setAppendNote); const setAppendNote = useShareStore(state => state.setAppendNote);
const [results, setResults] = useState([]); const [results, setResults] = useState([]);
const [searching, setSearching] = useState(false); const [searching, setSearching] = useState(false);
const searchKeyword = useRef(null); const searchKeyword = useRef(null);
const {width, height} = useWindowDimensions(); const { width, height } = useWindowDimensions();
const notes = useRef(null); const notes = useRef(null);
const timer = useRef(null); const timer = useRef(null);
const inputRef = useRef(); const inputRef = useRef();
const insets = const insets = Platform.OS === 'android' ? { top: StatusBar.currentHeight } : useSafeAreaInsets();
Platform.OS === 'android'
? {top: StatusBar.currentHeight}
: useSafeAreaInsets();
const onSelectItem = async item => { const onSelectItem = async item => {
if (item.locked) { if (item.locked) {
@@ -65,7 +62,7 @@ export const Search = ({close, getKeyboardHeight, quicknote}) => {
(async () => { (async () => {
await db.init(); await db.init();
await db.notes.init(); await db.notes.init();
notes.current = db.notes.all notes.current = db.notes.all;
setResults(notes.current); setResults(notes.current);
})(); })();
setTimeout(() => { setTimeout(() => {
@@ -73,21 +70,24 @@ export const Search = ({close, getKeyboardHeight, quicknote}) => {
}, 300); }, 300);
}, []); }, []);
const renderItem = ({item, index}) => !item.locked ? ( const renderItem = ({ item, index }) =>
!item.locked ? (
<TouchableOpacity <TouchableOpacity
activeOpacity={0.7} activeOpacity={0.7}
onPress={() => onSelectItem(item)} onPress={() => onSelectItem(item)}
style={{ style={{
height: 50, height: 50,
paddingHorizontal: 12 paddingHorizontal: 12
}}> }}
>
<Text <Text
numberOfLines={1} numberOfLines={1}
style={{ style={{
color: colors.pri, color: colors.pri,
fontFamily: 'OpenSans-SemiBold', fontFamily: 'OpenSans-SemiBold',
fontSize: 15 fontSize: 15
}}> }}
>
{item.title} {item.title}
</Text> </Text>
@@ -97,11 +97,12 @@ export const Search = ({close, getKeyboardHeight, quicknote}) => {
color: colors.icon, color: colors.icon,
fontSize: 12, fontSize: 12,
fontFamily: 'OpenSans-Regular' fontFamily: 'OpenSans-Regular'
}}> }}
>
{item.headline} {item.headline}
</Text> </Text>
</TouchableOpacity> </TouchableOpacity>
) : null ) : null;
let extra = quicknote let extra = quicknote
? { ? {
@@ -123,7 +124,8 @@ export const Search = ({close, getKeyboardHeight, quicknote}) => {
zIndex: 999, zIndex: 999,
...getElevation(quicknote ? 1 : 5), ...getElevation(quicknote ? 1 : 5),
...extra ...extra
}}> }}
>
<View <View
style={{ style={{
flexShrink: 1, flexShrink: 1,
@@ -133,7 +135,8 @@ export const Search = ({close, getKeyboardHeight, quicknote}) => {
paddingHorizontal: 12, paddingHorizontal: 12,
marginBottom: 10, marginBottom: 10,
height: 50 height: 50
}}> }}
>
<TextInput <TextInput
ref={inputRef} ref={inputRef}
placeholder="Search for a note" placeholder="Search for a note"
@@ -152,12 +155,7 @@ export const Search = ({close, getKeyboardHeight, quicknote}) => {
{searching ? ( {searching ? (
<ActivityIndicator size={25} color={colors.icon} /> <ActivityIndicator size={25} color={colors.icon} />
) : ( ) : (
<Icon <Icon name="magnify" color={colors.pri} size={25} onPress={onSearch} />
name="magnify"
color={colors.pri}
size={25}
onPress={onSearch}
/>
)} )}
</View> </View>
@@ -177,12 +175,14 @@ export const Search = ({close, getKeyboardHeight, quicknote}) => {
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',
height: 200 height: 200
}}> }}
>
<Text <Text
style={{ style={{
fontFamily: 'OpenSans-Regular', fontFamily: 'OpenSans-Regular',
color: colors.icon color: colors.icon
}}> }}
>
Search for a note to append to it. Search for a note to append to it.
</Text> </Text>
</View> </View>

View File

@@ -1,38 +1,31 @@
import { Appearance } from 'react-native'; import { Appearance } from 'react-native';
import create from 'zustand'; import create from 'zustand';
import { import { ACCENT, COLOR_SCHEME_DARK, COLOR_SCHEME_LIGHT, setAccentColor } from '../src/utils/Colors';
ACCENT, COLOR_SCHEME_DARK,
COLOR_SCHEME_LIGHT,
setAccentColor
} from '../src/utils/Colors';
import { MMKV } from '../src/utils/mmkv'; import { MMKV } from '../src/utils/mmkv';
export const useShareStore = create((set, get) => ({ export const useShareStore = create((set, get) => ({
colors: colors: Appearance.getColorScheme() === 'dark' ? COLOR_SCHEME_DARK : COLOR_SCHEME_LIGHT,
Appearance.getColorScheme() === 'dark' accent: ACCENT,
? COLOR_SCHEME_DARK
: COLOR_SCHEME_LIGHT,
accent:ACCENT,
setAccent: async () => { setAccent: async () => {
let accent = await MMKV.getItem('accentColor'); let accent = await MMKV.getItem('accentColor');
if (accent) { if (accent) {
accent = { accent = {
color:accent, color: accent,
shade:accent + "12" shade: accent + '12'
}
set({accent:accent});
}; };
set({ accent: accent });
}
}, },
appendNote: null, appendNote: null,
setAppendNote: note => { setAppendNote: note => {
MMKV.setItem('shareMenuAppendNote', JSON.stringify(note)); MMKV.setItem('shareMenuAppendNote', JSON.stringify(note));
set({appendNote: note}); set({ appendNote: note });
}, },
restoreAppendNote: async () => { restoreAppendNote: async () => {
let note = await MMKV.getItem('shareMenuAppendNote'); let note = await MMKV.getItem('shareMenuAppendNote');
if (note) { if (note) {
note = JSON.parse(note); note = JSON.parse(note);
set({appendNote: note}); set({ appendNote: note });
} }
} }
})); }));