Massive/use-settings.ts

31 lines
552 B
TypeScript
Raw Normal View History

2022-10-31 04:22:08 +00:00
import React, {useContext} from 'react'
import Settings from './settings'
2022-10-29 23:56:58 +00:00
export const defaultSettings: Settings = {
alarm: 0,
color: '',
date: '',
images: 1,
notify: 0,
showDate: 0,
showSets: 1,
showUnit: 1,
sound: '',
steps: 0,
theme: 'system',
vibrate: 1,
noSound: 0,
2022-10-31 04:22:08 +00:00
}
2022-10-29 23:56:58 +00:00
export const SettingsContext = React.createContext<{
2022-10-31 04:22:08 +00:00
settings: Settings
setSettings: (value: Settings) => void
}>({
2022-10-29 23:56:58 +00:00
settings: defaultSettings,
setSettings: () => null,
2022-10-31 04:22:08 +00:00
})
export function useSettings() {
2022-10-31 04:22:08 +00:00
return useContext(SettingsContext)
}