From 7989c20c1a396e4577399865be2f50219a416ffa Mon Sep 17 00:00:00 2001 From: smolgrrr Date: Fri, 15 Sep 2023 01:03:19 +1000 Subject: [PATCH] add swipes --- client/package.json | 2 ++ client/src/App.tsx | 31 +++++++++------- client/src/components/Settings.tsx | 57 ++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 13 deletions(-) create mode 100644 client/src/components/Settings.tsx diff --git a/client/package.json b/client/package.json index 0080ac7..2e01785 100644 --- a/client/package.json +++ b/client/package.json @@ -11,11 +11,13 @@ "@types/node": "^17.0.45", "@types/react": "^18.2.21", "@types/react-dom": "^18.2.7", + "@types/react-swipeable-views": "^0.13.2", "nostr-tools": "latest", "react": "^18.2.0", "react-dom": "^18.2.0", "react-router-dom": "^6.15.0", "react-scripts": "5.0.1", + "react-swipeable-views": "^0.14.0", "web-vitals": "^2.1.4", "workbox-background-sync": "^6.6.0", "workbox-broadcast-update": "^6.6.0", diff --git a/client/src/App.tsx b/client/src/App.tsx index f90f0e2..2ac97ca 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -1,25 +1,30 @@ import React from 'react'; -import logo from './logo.svg'; import './App.css'; -import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'; import Home from './components/Home'; - -declare global { - interface Window { - nostr?: any; - } -} +import Settings from './components/Settings'; +import SwipeableViews from 'react-swipeable-views'; function App() { + const [index, setIndex] = React.useState(1); + + const handleChangeIndex = (index: number) => { + console.log("Changed index to:", index); // Add a log to see if this function is called + setIndex(index); + }; + return ( -
- - } /> - + +
+ +
+
+ +
+
-
); } export default App; + diff --git a/client/src/components/Settings.tsx b/client/src/components/Settings.tsx new file mode 100644 index 0000000..99c9aab --- /dev/null +++ b/client/src/components/Settings.tsx @@ -0,0 +1,57 @@ +import React, { useEffect, useState } from 'react'; + +const Settings = () => { + // State variables to hold the settings + const [isDarkMode, setIsDarkMode] = useState(false); + const [username, setUsername] = useState(''); + + // Mimic fetching existing settings from an API or local storage + useEffect(() => { + // Simulate fetching existing settings + const existingSettings = { + isDarkMode: false, // replace with actual value + username: '' // replace with actual value + }; + setIsDarkMode(existingSettings.isDarkMode); + setUsername(existingSettings.username); + }, []); + + // Function to save changes (simulate API call or local storage update) + const saveChanges = () => { + // Replace this with an actual API call or local storage update + console.log('Dark Mode:', isDarkMode); + console.log('Username:', username); + }; + + return ( +
+

Settings

+ +
+ +
+ +
+ +
+ + +
+ ); +}; + +export default Settings;