-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a16cd4
commit 7335ad5
Showing
6 changed files
with
144 additions
and
19 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import AsyncStorage from '@react-native-async-storage/async-storage'; | ||
import { ModeSettings } from '@jikan0/ui'; | ||
import * as S from "@effect/schema/Schema"; | ||
import { Effect, Option, pipe, flow } from "effect" | ||
|
||
const KEY = 'modeSettings' as const; | ||
|
||
export const save = (settings: ModeSettings) => | ||
Effect.promise((_signal/*not supported by AsyncStorage*/) => AsyncStorage.setItem(KEY, JSON.stringify(settings))); | ||
|
||
export const load = () => | ||
Effect.promise(async (_signal/*not supported by AsyncStorage*/) => AsyncStorage.getItem(KEY)) | ||
.pipe( | ||
Effect.flatMap(Effect.fromNullable), | ||
Effect.flatMap(flow(S.decode(S.parseJson()), S.decodeUnknown(ModeSettings))), | ||
Effect.optionFromOptional, | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { ModeSettings } from '@jikan0/ui'; | ||
import React from 'react'; | ||
import { Text, View } from 'react-native'; | ||
import { useForm } from 'react-hook-form'; | ||
|
||
|
||
export type Props = { | ||
settings: ModeSettings | ||
} | ||
|
||
const simpleSettings: React.FC<{settings: ModeSettings['settings']['simple']}> = ({settings}) => | ||
{ | ||
const {register, handleSubmit} = useForm({ | ||
defaultValues: settings | ||
}); | ||
return ( | ||
<View> | ||
|
||
</View> | ||
) | ||
} | ||
|
||
export const view: React.FC<Props> = ({settings: {selected, settings}}) => | ||
<View> | ||
<View>Settings</View> | ||
<View><Text>Mode: {selected}</Text></View> | ||
</View> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters