diff --git a/README.md b/README.md
index 3d01072..69951d0 100644
--- a/README.md
+++ b/README.md
@@ -10,8 +10,10 @@ This app can be compiled and uploaded to Filecoin via [web3.storage](https://web
- [react-bootstrap](https://react-bootstrap.github.io/) is used for general style and layout control.
- An easily customized *waiting modal* component can be invoked while waiting for network calls to complete.
- [minimal-slp-wallet](https://www.npmjs.com/package/minimal-slp-wallet) is used to access tokens and BCH on the Bitcoin Cash blockchain.
-- A 'server selection' dropdown allows the user to select from an array of redundant back end servers.
+- A 'server selection' dropdown allows the user to select from an array of redundant [web3 back end servers](https://cashstack.info).
- This site is statically compiled, uploaded to Filecoin, and served over IPFS for censorship resistance and version control.
+- A collapsible navigation menu is used to load different views.
+- This app can be compiled into an native Android app using [react-bootstrap-web3-android](https://github.com/Permissionless-Software-Foundation/react-bootstrap-web3-android).
## Installation
```bash
diff --git a/package-lock.json b/package-lock.json
index d270678..4e88ee6 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,11 +1,11 @@
{
- "name": "nft-browser-v2",
+ "name": "react-bootstrap-web3-spa",
"version": "1.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
- "name": "nft-browser-v2",
+ "name": "react-bootstrap-web3-spa",
"version": "1.0.0",
"dependencies": {
"axios": "0.27.2",
diff --git a/src/App.js b/src/App.js
index 56d4753..3ae60b7 100644
--- a/src/App.js
+++ b/src/App.js
@@ -10,13 +10,12 @@ import { useQueryParam, StringParam } from 'use-query-params'
// Local libraries
import './App.css'
import LoadScripts from './components/load-scripts'
-// import NFTs from './components/nfts'
import WaitingModal from './components/waiting-modal'
import AsyncLoad from './services/async-load'
import ServerSelect from './components/servers'
import Footer from './components/footer'
-import GetBalance from './components/balance'
import NavMenu from './components/nav-menu'
+import AppBody from './components/app-body'
// Default restURL for a back-end server.
let serverURL = 'https://free-bch.fullstack.cash'
@@ -32,13 +31,13 @@ class App extends React.Component {
// Working array for storing modal output.
this.modalBody = []
- this.tokenData = {}
this.state = {
walletInitialized: false,
wallet: false,
modalBody: this.modalBody,
- hideSpinner: false
+ hideSpinner: false,
+ menuState: 0
}
this.cnt = 0
@@ -56,27 +55,6 @@ class App extends React.Component {
const wallet = await this.asyncLoad.initWallet(serverURL)
- // this.addToModal('Getting Group Token Information')
-
- // Get Group Token info
- // const groupData = await this.asyncLoad.getGroupData(groupTokenId)
- // console.log(`groupData: ${JSON.stringify(groupData, null, 2)}`)
-
- // this.addToModal('Getting NFT Information')
-
- /// Get NFT child info
- // const nftData = []
- // for (let i = 0; i < groupData.nfts.length; i++) {
- // const tokenData = await this.asyncLoad.getTokenData(groupData.nfts[i])
- // nftData.push(tokenData)
- // }
- // console.log(`nft data: ${JSON.stringify(nftData, null, 2)}`)
-
- // this.tokenData = {
- // groupData,
- // nftData
- // }
-
this.setState({
wallet,
walletInitialized: true
@@ -96,13 +74,14 @@ class App extends React.Component {
render () {
// console.log('App component rendered. this.state.wallet: ', this.state.wallet)
+ // console.log(`App component menuState: ${this.state.menuState}`)
return (
<>
-
- {this.state.walletInitialized ? : }
+
+ {this.state.walletInitialized ? : }
>
@@ -117,6 +96,17 @@ class App extends React.Component {
modalBody: this.modalBody
})
}
+
+ // This handler is passed into the child menu component. When an item in the
+ // nav menu is clicked, this handler will update the state. The state is
+ // used by the AppBody component to determine which View component to display.
+ onMenuClick (menuState) {
+ // console.log('menuState: ', menuState)
+
+ _this.setState({
+ menuState
+ })
+ }
}
// This is rendered *before* the BCH wallet is initialized.
@@ -132,14 +122,18 @@ function UninitializedView (props) {
// This is rendered *after* the BCH wallet is initialized.
function InitializedView (props) {
+ // console.log(`InitializedView props.menuState: ${props.menuState}`)
+ // console.log(`InitializedView _this.state.menuState: ${_this.state.menuState}`)
+
return (
<>
-
+
>
)
}
+// Get the restURL query parameter.
function GetRestUrl (props) {
const [restURL] = useQueryParam('restURL', StringParam)
// console.log('restURL: ', restURL)
@@ -149,8 +143,4 @@ function GetRestUrl (props) {
return (<>>)
}
-// function sleep (ms) {
-// return new Promise(resolve => setTimeout(resolve, ms))
-// }
-
export default App
diff --git a/src/components/app-body/index.js b/src/components/app-body/index.js
new file mode 100644
index 0000000..84b299f
--- /dev/null
+++ b/src/components/app-body/index.js
@@ -0,0 +1,55 @@
+/*
+ This Body component is a container for all the different Views of the app.
+ Views are equivalent to 'pages' in a multi-page app. Views are hidden or
+ displayed to simulate the use of pages in an SPA.
+ The Body app contains all the Views and chooses which to show, based on
+ the state of the Menu component.
+*/
+
+// Global npm libraries
+import React from 'react'
+
+// Local libraries
+import GetBalance from '../balance'
+import TakePicture from '../take-picture'
+
+let _this
+
+class AppBody extends React.Component {
+ constructor (props) {
+ super(props)
+
+ this.state = {
+ activeView: 0,
+ menuState: props.menuState,
+ wallet: props.wallet
+ }
+
+ _this = this
+ }
+
+ render () {
+ // console.log(`AppBody menu state: ${this.props.menuState}`)
+
+ return (
+ <>
+ {this.chooseView(this.props.menuState)}
+ >
+ )
+ }
+
+ chooseView (menuState) {
+ // console.log(`chooseView() menuState: ${menuState}`)
+
+ switch (menuState) {
+ case 0:
+ return ()
+ case 1:
+ return ()
+ default:
+ return ()
+ }
+ }
+}
+
+export default AppBody
diff --git a/src/components/balance.js b/src/components/balance.js
index bab20a0..6a04be5 100644
--- a/src/components/balance.js
+++ b/src/components/balance.js
@@ -9,7 +9,7 @@ import { Container, Row, Col, Form, Button, Spinner } from 'react-bootstrap'
let _this
class GetBalance extends React.Component {
- constructor(props) {
+ constructor (props) {
super(props)
this.state = {
@@ -31,10 +31,10 @@ class GetBalance extends React.Component {
Enter a BCH address to check the balance.
- this.setState({textInput: e.target.value})} />
+ this.setState({ textInput: e.target.value })} />
-