Skip to content

Commit

Permalink
Merge branch 'main' into migrate-6
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Mar 4, 2024
2 parents 3b95b48 + 2fc1f22 commit cba52d7
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 25 deletions.
7 changes: 6 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import React, { useEffect } from 'react';
import { Redirect, Route } from 'react-router-dom';
import { IonApp, IonRouterOutlet, IonSplitPane, setupIonicReact } from '@ionic/react';
import {
IonApp,
IonRouterOutlet,
IonSplitPane,
setupIonicReact,
} from '@ionic/react';
import { IonReactRouter } from '@ionic/react-router';
import { SplashScreen } from '@capacitor/splash-screen';

Expand Down
20 changes: 12 additions & 8 deletions src/pages/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,39 @@ const AppPage: React.FC = () => {
let restoredResultHandler: PluginListenerHandle;

useIonViewDidEnter(() => {
stateChangeHandler = App.addListener(
setListeners();

getLaunchUrl();
});

const setListeners = async () => {
stateChangeHandler = await App.addListener(
'appStateChange',
(state: AppState) => {
console.log('App state changed', state);
},
);

pauseHandler = App.addListener('pause', async () => {
pauseHandler = await App.addListener('pause', async () => {
console.log('App paused');
});

resumeHandler = App.addListener('resume', () => {
resumeHandler = await App.addListener('resume', () => {
console.log('App resumed');
});

urlOpenHandler = App.addListener('appUrlOpen', (data: any) => {
urlOpenHandler = await App.addListener('appUrlOpen', (data: any) => {
alert('APP URL OPEN: ' + data.url);
});

restoredResultHandler = App.addListener(
restoredResultHandler = await App.addListener(
'appRestoredResult',
(data: any) => {
alert('Got restored result');
console.log('Restored result:', data);
},
);

getLaunchUrl();
});
};

const getLaunchUrl = async () => {
const ret = await App.getLaunchUrl();
Expand Down
10 changes: 6 additions & 4 deletions src/pages/Browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const BrowserPage: React.FC = () => {

const autoCloseAfterDelay = async () => {
loadedHandler?.remove();
loadedHandler = Browser.addListener('browserPageLoaded', async () => {
loadedHandler = await Browser.addListener('browserPageLoaded', async () => {
await timeout(1000);
await Browser.close();
await timeout(200);
Expand All @@ -37,12 +37,14 @@ const BrowserPage: React.FC = () => {
};

useIonViewDidEnter(() => {
finishedHandler = Browser.addListener('browserFinished', async () => {
setListeners();
});
const setListeners = async () => {
finishedHandler = await Browser.addListener('browserFinished', async () => {
await timeout(200);
alert(`You closed the window`);
});
});

};
useIonViewDidLeave(() => {
finishedHandler?.remove();
loadedHandler?.remove();
Expand Down
7 changes: 6 additions & 1 deletion src/pages/Filesystem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ import {
IonProgressBar,
} from '@ionic/react';
import React, { useState } from 'react';
import { Filesystem, Directory, Encoding, ProgressStatus } from '@capacitor/filesystem';
import {
Filesystem,
Directory,
Encoding,
ProgressStatus,
} from '@capacitor/filesystem';

interface myCallback {
(path: string): void;
Expand Down
10 changes: 7 additions & 3 deletions src/pages/Keyboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ const KeyboardPage: React.FC = () => {
let scrollEnabled = true;

useIonViewDidEnter(() => {
showHandler = Keyboard.addListener('keyboardWillShow', info => {
setListeners();
});

const setListeners = async () => {
showHandler = await Keyboard.addListener('keyboardWillShow', info => {
console.log('keyboard show', info);
});
hideHandler = Keyboard.addListener('keyboardWillHide', () => {
hideHandler = await Keyboard.addListener('keyboardWillHide', () => {
console.log('keyboard hide');
});
});
};

useIonViewDidLeave(() => {
hideHandler.remove();
Expand Down
2 changes: 1 addition & 1 deletion src/pages/LocalNotifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const LocalNotificationsPage: React.FC = () => {
const checkPermissions = async () => {
const permissions = await ensurePermissions();
setHasPermission(permissions);
}
};

return (
<IonPage>
Expand Down
8 changes: 6 additions & 2 deletions src/pages/Network.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ class NetworkPage extends React.Component<{}, NetworkPageState> {

ionViewDidEnter() {
this.updateNetworkStatus();
const handler = Network?.addListener(
this.setListeners();
}

setListeners = async () => {
const handler = await Network?.addListener(
'networkStatusChange',
(status: ConnectionStatus) => {
this.setState({
Expand All @@ -42,7 +46,7 @@ class NetworkPage extends React.Component<{}, NetworkPageState> {
},
);
this.setState({ handler: handler });
}
};

ionViewDidLeave() {
this.state.handler?.remove();
Expand Down
2 changes: 1 addition & 1 deletion src/pages/PushNotifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const PushNotificationsPage: React.FC = () => {
const hasPermission = await ensurePermissions();
setHasPermission(hasPermission);
await register();
}
};

return (
<IonPage>
Expand Down
8 changes: 6 additions & 2 deletions src/pages/ScreenReader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ const ScreenReaderPage: React.FC = () => {
const [sentence, setSentence] = useState('Hello World?');

useIonViewDidEnter(() => {
handler = ScreenReader.addListener('stateChange', ({ value }: any) =>
setListeners();
});

const setListeners = async () => {
handler = await ScreenReader.addListener('stateChange', ({ value }: any) =>
alert(`State Change! Screen Reader on? ${value}`),
);
});
};

useIonViewDidLeave(() => {
handler.remove();
Expand Down
4 changes: 2 additions & 2 deletions src/pages/TextZoom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const TextZoomPage: React.FC = () => {

const getInitialZoom = async () => {
const { value: level } = await TextZoom.get();
setLevel(level.toString());
}
setLevel(level.toString());
};

const handleLevelInputChange = createEventTargetValueExtractor(setLevel);

Expand Down

0 comments on commit cba52d7

Please sign in to comment.