diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d3bc74..e02ac78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# V1.7.5 +**2020-09-02** + +adds TypeScript definitions, see [detail](https://github.com/c19354837/react-native-system-setting/pull/116) + # V1.7.4 **2020-01-30** diff --git a/SystemSetting.d.ts b/SystemSetting.d.ts new file mode 100644 index 0000000..363aa00 --- /dev/null +++ b/SystemSetting.d.ts @@ -0,0 +1,79 @@ +export {}; + +interface EmitterSubscription { + remove: () => void; +} + +type VolumeType = + | "call" + | "system" + | "ring" + | "music" + | "alarm" + | "notification"; + +interface VolumeConfig { + type?: VolumeType; + playSound?: boolean; + showUI?: boolean; +} + +interface VolumeData { + value: number; + call?: number; + system?: number; + ring?: number; + music?: number; + alarm?: number; + notification?: number; +} + +interface SystemSetting { + getBrightness: () => Promise; + setBrightness: (val: number) => Promise; + setBrightnessForce: (val: number) => Promise; + getAppBrightness: () => Promise; + setAppBrightness: (val: number) => Promise; + grantWriteSettingPremission: () => void; + getScreenMode: () => Promise; + setScreenMode: (val: number) => Promise; + saveBrightness: () => Promise; + restoreBrightness: () => number; + getVolume: (type?: VolumeType) => Promise; + setVolume: (value: number, config?: VolumeConfig | VolumeType) => void; + addVolumeListener: ( + callback: (volumeData: VolumeData) => void + ) => EmitterSubscription; + removeVolumeListener: (listener?: EmitterSubscription) => void; + isWifiEnabled: () => Promise; + switchWifiSilence: () => void; + switchWifi: () => void; + isLocationEnabled: () => Promise; + getLocationMode: () => Promise; + switchLocation: () => void; + isBluetoothEnabled: () => Promise; + switchBluetooth: () => void; + switchBluetoothSilence: () => void; + isAirplaneEnabled: () => Promise; + switchAirplane: () => void; + openAppSystemSettings: () => Promise; + addBluetoothListener: ( + callback: (bluetoothEnabled: boolean) => void + ) => Promise; + addWifiListener: ( + callback: (wifiEnabled: boolean) => void + ) => Promise; + addLocationListener: ( + callback: (locationEnabled: boolean) => void + ) => Promise; + addLocationModeListener: ( + callback: (locationMode: number) => void + ) => Promise; + addAirplaneListener: ( + callback: (airplaneModeEnabled: boolean) => void + ) => Promise; + removeListener: (listener?: EmitterSubscription) => void; +} + +declare const systemSetting: SystemSetting; +export default systemSetting; diff --git a/package.json b/package.json index 69534ed..ddfc86f 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,9 @@ { "name": "react-native-system-setting", - "version": "1.7.4", + "version": "1.7.5", "description": "provide some system setting APIs. Volume, brightness, wifi, location, bluetooth, airplane...", "main": "SystemSetting.js", + "types": "SystemSetting.d.ts", "homepage": "https://github.com/c19354837/react-native-system-setting", "bugs": { "url": "https://github.com/c19354837/react-native-system-setting/issues"