From 3de8a0a99f74cef8032d718e4b51d5c9c364db56 Mon Sep 17 00:00:00 2001 From: "Thomas F. K. Jorna" Date: Thu, 15 Jul 2021 13:54:55 +0200 Subject: made graph interactively tweakable --- app/components/tweaks/tweaks.tsx | 62 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 app/components/tweaks/tweaks.tsx (limited to 'app/components/tweaks/tweaks.tsx') diff --git a/app/components/tweaks/tweaks.tsx b/app/components/tweaks/tweaks.tsx new file mode 100644 index 0000000..d1c8c2a --- /dev/null +++ b/app/components/tweaks/tweaks.tsx @@ -0,0 +1,62 @@ +import * as React from "react" +import { StyleProp, Switch, TextStyle, View, ViewStyle } from "react-native" +import { observer } from "mobx-react-lite" +import { color, typography } from "../../theme" +import { Text } from "../" +import { flatten } from "ramda" +import Slider from "@react-native-community/slider" +import { useState } from "react" + +const CONTAINER: ViewStyle = { + justifyContent: "center", +} + +const TEXT: TextStyle = { + fontFamily: typography.primary, + fontSize: 14, + color: color.primary, +} + +export interface TweaksProps { + /** + * An optional style override useful for padding & margin. + */ + style?: StyleProp + physics + setPhysics +} + +/** + * Describe your component here + */ +export const Tweaks = observer(function Tweaks(props: TweaksProps) { + const { style, physics, setPhysics } = props + const styles = flatten([CONTAINER, style]) + + return ( + <> + { setPhysics({...physics, charge: value}) }} + value={physics.charge} + step={1}/> + { setPhysics({...physics, linkStrength: value}) }} + value={physics.linkStrength} + step={1}/> + { setPhysics({...physics, linkIts: value}) }} + value={physics.linkIts} + step={1}/> + {setPhysics({...physics, collision: !physics.collision})}} + /> + + ) +}) -- cgit v1.2.3