Skip to content

Commit

Permalink
Merge pull request #667 from SUI-Components/feat/add-network-plugin
Browse files Browse the repository at this point in the history
feat(components/tool/app): Add network plugin
  • Loading branch information
oegea authored Jun 12, 2024
2 parents 999564a + be4ab59 commit 51a0edf
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions components/tool/app/bin/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ module.exports = async () => {

if (!hasDependency('@capacitor/browser')) installDependency('@capacitor/browser@6')

if (!hasDependency('@capacitor/network')) installDependency('@capacitor/network@6')

// If app has already been initialized
if (hasCapacitorConfig()) {
reportError(`\nThis project has already-been initialized. Please run sui-app remove before initializing again.\n`)
Expand Down
1 change: 1 addition & 0 deletions components/tool/app/bin/commands/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const uninstallPlugins = () => {
uninstallPackage('@capgo/capacitor-updater')
uninstallPackage('@capacitor/app')
uninstallPackage('@capacitor/browser')
uninstallPackage('@capacitor/network')
}

// Business logic
Expand Down
3 changes: 2 additions & 1 deletion components/tool/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
"dependencies": {
"@capacitor/android": "^6",
"@capacitor/app": "^6",
"@capacitor/browser": "^6",
"@capacitor/cli": "^6",
"@capacitor/core": "^6",
"@capacitor/ios": "^6",
"@capacitor/browser": "^6",
"@capacitor/network": "^6",
"@capgo/capacitor-native-biometric": "^5.1.0",
"@capgo/capacitor-updater": "^5.9.4",
"readline": "^1.3.0",
Expand Down
3 changes: 2 additions & 1 deletion components/tool/app/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import * as browser from './browser.js'
import * as core from './core.js'
import * as liveUpdates from './liveUpdates.js'
import * as localNotifications from './localNotifications.js'
import * as network from './network.js'

export default function SuiApp() {
throw new Error('sui-app is a set of tools and is not intended to be renderized as a React component')
}

export {biometric, browser, core, liveUpdates, localNotifications}
export {biometric, browser, core, liveUpdates, localNotifications, network}
5 changes: 5 additions & 0 deletions components/tool/app/src/network.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {Network} from '@capacitor/network'

export const onNetworkChange = callback => Network.addListener('networkStatusChange', callback)
export const removeOnNetworkChange = () => Network.removeAllListeners()
export const getStatus = () => Network.getStatus()

0 comments on commit 51a0edf

Please sign in to comment.