possibly fix loading indicator on ios

This commit is contained in:
ammarahm-ed
2020-04-26 16:08:50 +05:00
parent 72575692cb
commit 1c0e3714af
3 changed files with 66 additions and 55 deletions

View File

@@ -34,7 +34,7 @@ const SimpleList = ({
isHome = false,
}) => {
const [state, dispatch] = useTracked();
const {colors, selectionMode} = state;
const {colors, selectionMode, syncing} = state;
const searchResults = {...state.searchResults};
const insets = useSafeArea();
const _onScroll = event => {
@@ -84,8 +84,8 @@ const SimpleList = ({
marginTop:
Platform.OS == 'ios'
? data[0] && !selectionMode
? 135
: 135 - 60
? 115
: 115 - 60
: data[0] && !selectionMode
? 155 - insets.top
: 155 - insets.top - 60,
@@ -120,8 +120,8 @@ const SimpleList = ({
marginTop:
Platform.OS == 'ios'
? data[0] && !selectionMode
? 135
: 135 - 60
? 115
: 115 - 60
: data[0] && !selectionMode
? 155 - insets.top
: 155 - 60 - insets.top,
@@ -257,14 +257,15 @@ const SimpleList = ({
<RefreshControl
tintColor={colors.accent}
colors={[colors.accent]}
progressViewOffset={165}
progressViewOffset={150}
onRefresh={onRefresh}
refreshing={refreshing}
refreshing={syncing}
/>
}
keyExtractor={_listKeyExtractor}
renderSectionHeader={_renderSectionHeader}
onScroll={_onScroll}
stickySectionHeadersEnabled={false}
ListEmptyComponent={_ListEmptyComponent}
ListHeaderComponent={_ListHeaderComponent_S}
contentContainerStyle={{
@@ -292,7 +293,7 @@ const SimpleList = ({
<RefreshControl
tintColor={colors.accent}
colors={[colors.accent]}
progressViewOffset={165}
progressViewOffset={-200}
onRefresh={onRefresh}
refreshing={refreshing}
/>

View File

@@ -44,7 +44,7 @@ const InfoBarRef = createRef();
const EditorWebView = createRef();
let note = {};
let id = null;
var content = null;
var content = {};
var title = null;
let timer = null;
let saveCounter = 0;
@@ -386,50 +386,50 @@ const Editor = ({noMenu}) => {
};
const updateEditor = async () => {
title = note.title;
id = note.id;
saveCounter = 0;
InfoBarRef.current?.setDateCreated(note.dateCreated);
content.text = await db.notes.note(id).text();
InfoBarRef.current?.setDateEdited(
note.dateEdited,
content.text.split(' ').length,
);
if (title !== null || title === '') {
post({
type: 'title',
value: note.title,
});
} else {
post({
type: 'clearTitle',
});
post({
type: 'clearEditor',
});
post({
type: 'focusTitle',
});
}
if (content.text === '' && note.content.delta === null) {
post({
type: 'clearEditor',
});
} else if (note.content.delta) {
if (typeof note.content.delta !== 'string') {
content.delta = note.content.delta;
try {
title = note.title;
id = note.id;
saveCounter = 0;
InfoBarRef.current?.setDateCreated(note.dateCreated);
content.text = await db.notes.note(id).text();
InfoBarRef.current?.setDateEdited(
note.dateEdited,
content.text.split(' ').length,
);
if (title !== null || title === '') {
post({
type: 'title',
value: note.title,
});
} else {
content.delta = await db.notes.note(id).delta();
post({
type: 'clearTitle',
});
post({
type: 'clearEditor',
});
post({
type: 'focusTitle',
});
}
post({
type: 'delta',
value: content.delta,
});
} else {
post({type: 'text', value: content.text});
}
if (content.text === '' && note.content.delta === null) {
post({
type: 'clearEditor',
});
} else if (note.content.delta) {
if (typeof note.content.delta !== 'string') {
content.delta = note.content.delta;
} else {
content.delta = await db.notes.note(id).delta();
}
post({
type: 'delta',
value: content.delta,
});
} else {
post({type: 'text', value: content.text});
}
} catch (e) {}
};
const params = 'platform=' + Platform.OS;

View File

@@ -41,14 +41,24 @@ export const Home = ({navigation}) => {
}, [isFocused]);
const _onRefresh = async () => {
setRefreshing(true);
dispatch({
type: ACTIONS.SYNCING,
syncing: true,
});
try {
await db.sync();
setRefreshing(false);
dispatch({
type: ACTIONS.SYNCING,
syncing: false,
});
ToastEvent.show('Sync Complete', 'success');
} catch (e) {
setRefreshing(false);
console.log(e);
dispatch({
type: ACTIONS.SYNCING,
syncing: false,
});
ToastEvent.show(e.message, 'error');
}
dispatch({type: ACTIONS.NOTES});