diff --git a/src/components/Common/CrossFadeView.js b/src/components/Common/CrossFadeView.js index c75f5271..ddbf5b5d 100644 --- a/src/components/Common/CrossFadeView.js +++ b/src/components/Common/CrossFadeView.js @@ -44,7 +44,7 @@ export default class FadeView extends PureComponent { this.mounted = false; } - componentWillReceiveProps({ active, animationDuration }) { + UNSAFE_componentWillReceiveProps({ active, animationDuration }) { let { progress } = this.state; if (active ^ this.props.active) { diff --git a/src/redux/settings/settings.reducer.js b/src/redux/settings/settings.reducer.js index 818bb935..05e45339 100644 --- a/src/redux/settings/settings.reducer.js +++ b/src/redux/settings/settings.reducer.js @@ -74,6 +74,7 @@ const initialState = { showUpdatesTab: true, showLabelsInNav: false, useWebViewForChapter: false, + showBatteryAndTime: false, }; const settingsReducer = (state = initialState, action) => { diff --git a/src/screens/Chapter/Chapter.js b/src/screens/Chapter/Chapter.js index 9a3f9c41..d366e269 100644 --- a/src/screens/Chapter/Chapter.js +++ b/src/screens/Chapter/Chapter.js @@ -10,6 +10,7 @@ import { import { useDispatch } from "react-redux"; import { IconButton, Portal } from "react-native-paper"; +import MaterialCommunityIcons from "react-native-vector-icons/MaterialCommunityIcons"; import { hideNavigationBar, showNavigationBar, @@ -53,6 +54,8 @@ import { SET_LAST_READ } from "../../redux/preferences/preference.types"; import { htmlToText } from "../../sources/helpers/htmlToText"; import { setAppSettings } from "../../redux/settings/settings.actions"; import { cleanHtml } from "../../sources/helpers/cleanHtml"; +import { useBatteryLevel } from "react-native-device-info"; +import moment from "moment"; const Chapter = ({ route, navigation }) => { const { @@ -79,8 +82,11 @@ const Chapter = ({ route, navigation }) => { incognitoMode = false, textSelectable = false, useWebViewForChapter = false, + showBatteryAndTime = false, } = useSettings(); + const batteryLevel = useBatteryLevel(); + const [hidden, setHidden] = useState(true); const { tracker, trackedNovels } = useTrackingStatus(); @@ -156,6 +162,14 @@ const Chapter = ({ route, navigation }) => { setPrevAndNextChap(); }, [chapter]); + const [currentTime, setCurrentTime] = useState(); + + useEffect(() => { + setInterval(() => { + setCurrentTime(new Date().toISOString()); + }, 60000); + }, []); + const isCloseToBottom = useCallback( ({ layoutMeasurement, contentOffset, contentSize }) => { const paddingToBottom = 40; @@ -224,7 +238,12 @@ const Chapter = ({ route, navigation }) => { }, []); const hideHeader = () => { - !hidden && setImmersiveMode(); + if (!hidden) { + setImmersiveMode(); + } else { + StatusBar.setHidden(false); + showNavigationBar(); + } setHidden(!hidden); }; @@ -363,7 +382,6 @@ const Chapter = ({ route, navigation }) => { backgroundColor: readerBackground( reader.theme ), - paddingBottom: 24, }} originWhitelist={["*"]} scalesPageToFit={true} @@ -401,6 +419,7 @@ const Chapter = ({ route, navigation }) => { body { padding-left: ${reader.padding}%; padding-right: ${reader.padding}%; + padding-bottom: 30px; font-size: ${reader.textSize}px; color: ${reader.textColor}; @@ -473,6 +492,7 @@ const Chapter = ({ route, navigation }) => { selectText={textSelectable} useWebViewForChapter={useWebViewForChapter} showScrollPercentage={showScrollPercentage} + showBatteryAndTime={showBatteryAndTime} /> {!useWebViewForChapter && ( @@ -501,18 +521,35 @@ const Chapter = ({ route, navigation }) => { readerSheetRef={readerSheetRef} scrollViewRef={scrollViewRef} /> - {showScrollPercentage && ( - - {scrollPercentage + "%"} - + {showBatteryAndTime && ( + + {Math.ceil(batteryLevel * 100) + "%"} + + )} + {showScrollPercentage && ( + + {scrollPercentage + "%"} + + )} + {showBatteryAndTime && ( + + {moment(currentTime).format("h:mm")} + + )} + )} @@ -523,15 +560,17 @@ export default Chapter; const styles = StyleSheet.create({ screenContainer: { flexGrow: 1 }, - scrollPercentage: { + scrollPercentageContainer: { width: "100%", position: "absolute", - bottom: 0, height: 30, - textAlign: "center", - textAlignVertical: "center", - alignSelf: "center", - fontWeight: "bold", + left: 0, + right: 0, + bottom: 0, zIndex: 1, + flexDirection: "row", + paddingHorizontal: 32, + alignItems: "center", + justifyContent: "space-between", }, }); diff --git a/src/screens/Chapter/components/ReaderSheet.js b/src/screens/Chapter/components/ReaderSheet.js index 3621c316..8b1b8fdd 100644 --- a/src/screens/Chapter/components/ReaderSheet.js +++ b/src/screens/Chapter/components/ReaderSheet.js @@ -39,16 +39,13 @@ const ReaderSheet = ({ dispatch, navigation, bottomSheetRef, + showBatteryAndTime, selectText, useWebViewForChapter, showScrollPercentage, }) => { const [animatedValue] = useState(new Animated.Value(0)); - const [fontMenu, setFontMenu] = useState(false); - const openFontMenu = () => setFontMenu(true); - const closeFontMenu = () => setFontMenu(false); - const presetThemes = [ { value: 2, backgroundColor: "#f5f5fa", textColor: "#111111" }, { value: 3, backgroundColor: "#F7DFC6", textColor: "#593100" }, @@ -84,7 +81,7 @@ const ReaderSheet = ({ ]} > - + + + dispatch( + setAppSettings( + "showBatteryAndTime", + !showBatteryAndTime + ) + ) + } + > + + Show battery and time + + + dispatch( + setAppSettings( + "showBatteryAndTime", + !showBatteryAndTime + ) + ) + } + color={theme.colorAccent} + /> +