diff --git a/components/Home.js b/components/Home.js
index 97ea60b..9857954 100644
--- a/components/Home.js
+++ b/components/Home.js
@@ -3,9 +3,6 @@ import { ScrollView, StyleSheet, View } from 'react-native'
import PropTypes from 'prop-types'
import moment from 'moment'
-import { connect } from 'react-redux'
-import { navigate } from '../slices/navigation'
-
import AppText from './common/app-text'
import Button from './common/button'
@@ -136,15 +133,9 @@ const styles = StyleSheet.create({
},
})
-const mapDispatchToProps = (dispatch) => {
- return {
- navigate: (page) => dispatch(navigate(page)),
- }
-}
-
Home.propTypes = {
navigate: PropTypes.func,
setDate: PropTypes.func,
}
-export default connect(null, mapDispatchToProps)(Home)
+export default Home
diff --git a/components/app-wrapper.js b/components/app-wrapper.js
index 47cbd2b..3afcca3 100644
--- a/components/app-wrapper.js
+++ b/components/app-wrapper.js
@@ -1,5 +1,4 @@
import React, { useState, useEffect } from 'react'
-import { Provider } from 'react-redux'
import nodejs from 'nodejs-mobile-react-native'
import { getLicenseFlag, saveEncryptionFlag } from '../local-storage'
@@ -11,8 +10,6 @@ import AppStatusBar from './common/app-status-bar'
import License from './License'
import PasswordPrompt from './password-prompt'
-import store from '../store'
-
export default function AppWrapper() {
const [isLoading, setIsLoading] = useState(true)
const [isLicenseAccepted, setIsLicenseAccepted] = useState(false)
@@ -45,13 +42,13 @@ export default function AppWrapper() {
}
return (
-
+ <>
{isDbEncrypted ? (
setIsDbEncrypted(false)} />
) : (
checkIsDbEncrypted()} />
)}
-
+ >
)
}
diff --git a/components/app.js b/components/app.js
index 9613f19..98484ab 100644
--- a/components/app.js
+++ b/components/app.js
@@ -2,15 +2,12 @@ import React, { Component } from 'react'
import { BackHandler, StyleSheet, View } from 'react-native'
import PropTypes from 'prop-types'
-import { connect } from 'react-redux'
import { LocalDate } from '@js-joda/core'
-import { getNavigation, navigate, goBack } from '../slices/navigation'
-
import Header from './header'
import Menu from './menu'
import { viewsList } from './views'
-import { isSettingsView } from './pages'
+import { isSettingsView, pages } from './pages'
import { headerTitles } from '../i18n/en/labels'
import setupNotifications from '../lib/notifications'
@@ -36,9 +33,14 @@ class App extends Component {
this.state = {
date: LocalDate.now().toString(),
+ currentPage: 'Home',
}
- setupNotifications(this.props.navigate, this.props.setDate)
+ setupNotifications(this.navigate, this.setDate)
+ }
+
+ navigate = (page) => {
+ this.setState({ currentPage: page })
}
setDate = (date) => {
@@ -46,13 +48,14 @@ class App extends Component {
}
goBack = () => {
- const { currentPage } = this.props.navigation
+ const { currentPage } = this.state
if (currentPage === 'Home') {
closeDb()
BackHandler.exitApp()
} else {
- this.props.goBack()
+ const { parent } = pages.find((p) => p.component === currentPage)
+ this.navigate(parent)
}
return true
@@ -63,9 +66,9 @@ class App extends Component {
}
render() {
- const { navigation, goBack, restartApp } = this.props
- const { date } = this.state
- const { currentPage } = navigation
+ const { goBack, restartApp } = this.props
+ const { date, currentPage } = this.state
+ const { navigate } = this
if (!currentPage) {
return false
@@ -80,19 +83,21 @@ class App extends Component {
const headerProps = {
title,
handleBack: isSettingsSubView ? goBack : null,
+ navigate,
}
const pageProps = {
date,
setDate: this.setDate,
isTemperatureEditView,
+ navigate,
}
return (
-
+
)
}
@@ -104,17 +109,4 @@ const styles = StyleSheet.create({
},
})
-const mapStateToProps = (state) => {
- return {
- navigation: getNavigation(state),
- }
-}
-
-const mapDispatchToProps = (dispatch) => {
- return {
- navigate: (page) => dispatch(navigate(page)),
- goBack: () => dispatch(goBack()),
- }
-}
-
-export default connect(mapStateToProps, mapDispatchToProps)(App)
+export default App
diff --git a/components/calendar.js b/components/calendar.js
index 9cebb66..cb01791 100644
--- a/components/calendar.js
+++ b/components/calendar.js
@@ -3,9 +3,6 @@ import PropTypes from 'prop-types'
import { StyleSheet, View } from 'react-native'
import { CalendarList } from 'react-native-calendars'
-import { connect } from 'react-redux'
-import { navigate } from '../slices/navigation'
-
import { getBleedingDaysSortedByDate } from '../db'
import cycleModule from '../lib/cycle'
import nothingChanged from '../db/db-unchanged'
@@ -88,10 +85,4 @@ const styles = StyleSheet.create({
container: { flex: 1 },
})
-const mapDispatchToProps = (dispatch) => {
- return {
- navigate: (page) => dispatch(navigate(page)),
- }
-}
-
-export default connect(null, mapDispatchToProps)(CalendarView)
+export default CalendarView
diff --git a/components/chart/chart.js b/components/chart/chart.js
index 3155d08..9d16920 100644
--- a/components/chart/chart.js
+++ b/components/chart/chart.js
@@ -19,9 +19,6 @@ import NoData from './no-data'
import Tutorial from './tutorial'
import YAxis from './y-axis'
-import { connect } from 'react-redux'
-import { navigate } from '../../slices/navigation'
-
import { getCycleDaysSortedByDate } from '../../db'
import nothingChanged from '../../db/db-unchanged'
import {
@@ -167,7 +164,7 @@ class CycleChart extends Component {
onLayout={this.onLayout}
scrollViewStyle={styles.page}
>
- {!hasDataToDisplay && }
+ {!hasDataToDisplay && }
{hasDataToDisplay && !chartHeight && !chartLoaded && }
{shouldShowHint && chartLoaded && (
@@ -261,10 +258,4 @@ const styles = StyleSheet.create({
},
})
-const mapDispatchToProps = (dispatch) => {
- return {
- navigate: (page) => dispatch(navigate(page)),
- }
-}
-
-export default connect(null, mapDispatchToProps)(CycleChart)
+export default CycleChart
diff --git a/components/chart/day-column.js b/components/chart/day-column.js
index f260e27..942fe31 100644
--- a/components/chart/day-column.js
+++ b/components/chart/day-column.js
@@ -1,9 +1,6 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { TouchableOpacity } from 'react-native'
-import { connect } from 'react-redux'
-
-import { navigate } from '../../slices/navigation'
import { getCycleDay } from '../../db'
@@ -128,10 +125,4 @@ class DayColumn extends Component {
}
}
-const mapDispatchToProps = (dispatch) => {
- return {
- navigate: (page) => dispatch(navigate(page)),
- }
-}
-
-export default connect(null, mapDispatchToProps)(DayColumn)
+export default DayColumn
diff --git a/components/chart/no-data.js b/components/chart/no-data.js
index 79abed5..0bca637 100644
--- a/components/chart/no-data.js
+++ b/components/chart/no-data.js
@@ -5,9 +5,6 @@ import PropTypes from 'prop-types'
import AppText from '../common/app-text'
import Button from '../common/button'
-import { connect } from 'react-redux'
-import { navigate } from '../../slices/navigation'
-
import { Containers } from '../../styles'
import { shared } from '../../i18n/en/labels'
@@ -37,10 +34,4 @@ const styles = StyleSheet.create({
},
})
-const mapDispatchToProps = (dispatch) => {
- return {
- navigate: (page) => dispatch(navigate(page)),
- }
-}
-
-export default connect(null, mapDispatchToProps)(NoData)
+export default NoData
diff --git a/components/header/hamburger-menu.js b/components/header/hamburger-menu.js
index d3a92f2..4e9705b 100644
--- a/components/header/hamburger-menu.js
+++ b/components/header/hamburger-menu.js
@@ -6,6 +6,7 @@ import {
TouchableOpacity,
View,
} from 'react-native'
+import PropTypes from 'prop-types'
import AppIcon from '../common/app-icon'
import CloseIcon from '../common/close-icon'
@@ -39,7 +40,7 @@ export default class HamburgerMenu extends Component {
const { shouldShowMenu } = this.state
return (
-
+ <>
{!shouldShowMenu && (
@@ -65,16 +66,21 @@ export default class HamburgerMenu extends Component {
item={item}
key={item.name}
closeMenu={this.toggleMenu}
+ navigate={this.props.navigate}
/>
))}
)}
-
+ >
)
}
}
+HamburgerMenu.propTypes = {
+ navigate: PropTypes.func,
+}
+
const styles = StyleSheet.create({
blackBackground: {
backgroundColor: 'black',
diff --git a/components/header/index.js b/components/header/index.js
index a19f9cc..14f7beb 100644
--- a/components/header/index.js
+++ b/components/header/index.js
@@ -1,5 +1,5 @@
import React from 'react'
-import { StyleSheet, View } from 'react-native'
+import { StyleSheet, TouchableOpacity, View } from 'react-native'
import PropTypes from 'prop-types'
import Logo from './logo'
@@ -7,21 +7,30 @@ import HamburgerMenu from './hamburger-menu'
import { Colors, Containers, Sizes } from '../../styles'
-const Header = ({ isSideMenuEnabled }) => {
+const Header = ({ isStatic, navigate }) => {
return (
-
- {isSideMenuEnabled && }
+ {isStatic ? (
+
+ ) : (
+ <>
+ navigate('Home')}>
+
+
+
+ >
+ )}
)
}
Header.propTypes = {
- isSideMenuEnabled: PropTypes.bool,
+ isStatic: PropTypes.bool,
+ navigate: PropTypes.func,
}
Header.defaultProps = {
- isSideMenuEnabled: true,
+ isStatic: false,
}
const styles = StyleSheet.create({
diff --git a/components/header/logo.js b/components/header/logo.js
index 9748b68..3c113c7 100644
--- a/components/header/logo.js
+++ b/components/header/logo.js
@@ -1,24 +1,12 @@
import React from 'react'
-import { StyleSheet, TouchableOpacity } from 'react-native'
-import PropTypes from 'prop-types'
+import { StyleSheet } from 'react-native'
import AppText from '../common/app-text'
-import { connect } from 'react-redux'
-import { navigate } from '../../slices/navigation'
-
import { Colors, Fonts, Sizes } from '../../styles'
-const Logo = ({ navigate }) => {
- return (
- navigate('Home')}>
- drip.
-
- )
-}
-
-Logo.propTypes = {
- navigate: PropTypes.func.isRequired,
+const Logo = () => {
+ return drip.
}
const styles = StyleSheet.create({
@@ -29,10 +17,4 @@ const styles = StyleSheet.create({
},
})
-const mapDispatchToProps = (dispatch) => {
- return {
- navigate: (page) => dispatch(navigate(page)),
- }
-}
-
-export default connect(null, mapDispatchToProps)(Logo)
+export default Logo
diff --git a/components/header/menu-item.js b/components/header/menu-item.js
index eaadea9..fa5de23 100644
--- a/components/header/menu-item.js
+++ b/components/header/menu-item.js
@@ -4,9 +4,6 @@ import PropTypes from 'prop-types'
import AppText from '../common/app-text'
-import { connect } from 'react-redux'
-import { navigate } from '../../slices/navigation'
-
import { Typography } from '../../styles'
const MenuItem = ({ item, navigate, closeMenu }) => {
@@ -35,10 +32,4 @@ const styles = StyleSheet.create({
},
})
-const mapDispatchToProps = (dispatch) => {
- return {
- navigate: (page) => dispatch(navigate(page)),
- }
-}
-
-export default connect(null, mapDispatchToProps)(MenuItem)
+export default MenuItem
diff --git a/components/menu/index.js b/components/menu/index.js
index 00b607e..ae885ec 100644
--- a/components/menu/index.js
+++ b/components/menu/index.js
@@ -1,12 +1,13 @@
import React from 'react'
import { StyleSheet, View } from 'react-native'
+import PropTypes from 'prop-types'
import MenuItem from './menu-item'
import { Containers } from '../../styles'
import { pages } from '../pages'
-const Menu = () => {
+const Menu = ({ currentPage, navigate }) => {
const menuItems = pages.filter((page) => page.isInMenu)
return (
@@ -14,7 +15,8 @@ const Menu = () => {
{menuItems.map(({ icon, label, component }) => {
return (