mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-16 19:57:52 +01:00
37 lines
1.0 KiB
JavaScript
37 lines
1.0 KiB
JavaScript
import { Appearance } from 'react-native';
|
|
import create from 'zustand';
|
|
import { ACCENT, COLOR_SCHEME_DARK, COLOR_SCHEME_LIGHT } from '../src/utils/color-scheme';
|
|
import { MMKV } from '../src/utils/database/mmkv';
|
|
|
|
export const useShareStore = create((set, get) => ({
|
|
colors: Appearance.getColorScheme() === 'dark' ? COLOR_SCHEME_DARK : COLOR_SCHEME_LIGHT,
|
|
accent: ACCENT,
|
|
setAccent: async () => {
|
|
let accent = await MMKV.getItem('accentColor');
|
|
if (accent) {
|
|
accent = {
|
|
color: accent,
|
|
shade: accent + '12'
|
|
};
|
|
set({ accent: accent });
|
|
}
|
|
},
|
|
setColors: () => {
|
|
set({
|
|
colors: Appearance.getColorScheme() === 'dark' ? COLOR_SCHEME_DARK : COLOR_SCHEME_LIGHT
|
|
});
|
|
},
|
|
appendNote: null,
|
|
setAppendNote: note => {
|
|
MMKV.setItem('shareMenuAppendNote', JSON.stringify(note));
|
|
set({ appendNote: note });
|
|
},
|
|
restoreAppendNote: async () => {
|
|
let note = await MMKV.getItem('shareMenuAppendNote');
|
|
if (note) {
|
|
note = JSON.parse(note);
|
|
set({ appendNote: note });
|
|
}
|
|
}
|
|
}));
|