Skip to content

Commit

Permalink
Merge pull request #116 from runtrizapps/feature/typescript
Browse files Browse the repository at this point in the history
Add TypeScript definitions
  • Loading branch information
c19354837 authored Sep 4, 2020
2 parents f6f29f9 + ae492ae commit 06fdac1
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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**

Expand Down
79 changes: 79 additions & 0 deletions SystemSetting.d.ts
Original file line number Diff line number Diff line change
@@ -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<number>;
setBrightness: (val: number) => Promise<boolean>;
setBrightnessForce: (val: number) => Promise<boolean>;
getAppBrightness: () => Promise<number>;
setAppBrightness: (val: number) => Promise<true>;
grantWriteSettingPremission: () => void;
getScreenMode: () => Promise<number>;
setScreenMode: (val: number) => Promise<boolean>;
saveBrightness: () => Promise<void>;
restoreBrightness: () => number;
getVolume: (type?: VolumeType) => Promise<number>;
setVolume: (value: number, config?: VolumeConfig | VolumeType) => void;
addVolumeListener: (
callback: (volumeData: VolumeData) => void
) => EmitterSubscription;
removeVolumeListener: (listener?: EmitterSubscription) => void;
isWifiEnabled: () => Promise<boolean>;
switchWifiSilence: () => void;
switchWifi: () => void;
isLocationEnabled: () => Promise<boolean>;
getLocationMode: () => Promise<number>;
switchLocation: () => void;
isBluetoothEnabled: () => Promise<boolean>;
switchBluetooth: () => void;
switchBluetoothSilence: () => void;
isAirplaneEnabled: () => Promise<boolean>;
switchAirplane: () => void;
openAppSystemSettings: () => Promise<void>;
addBluetoothListener: (
callback: (bluetoothEnabled: boolean) => void
) => Promise<EmitterSubscription>;
addWifiListener: (
callback: (wifiEnabled: boolean) => void
) => Promise<EmitterSubscription | null>;
addLocationListener: (
callback: (locationEnabled: boolean) => void
) => Promise<EmitterSubscription | null>;
addLocationModeListener: (
callback: (locationMode: number) => void
) => Promise<EmitterSubscription | null>;
addAirplaneListener: (
callback: (airplaneModeEnabled: boolean) => void
) => Promise<EmitterSubscription | null>;
removeListener: (listener?: EmitterSubscription) => void;
}

declare const systemSetting: SystemSetting;
export default systemSetting;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 06fdac1

Please sign in to comment.