Skip to content

Commit

Permalink
Animated FAB in Novel Screen (Closes #839)
Browse files Browse the repository at this point in the history
  • Loading branch information
rajarsheechatterjee committed Jan 7, 2024
1 parent c3543f8 commit e4ca751
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/screens/novel/NovelScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import {
Appbar,
IconButton,
Menu,
FAB,
Snackbar,
AnimatedFAB,
} from 'react-native-paper';
import { useDispatch, useSelector } from 'react-redux';
import * as Haptics from 'expo-haptics';
Expand Down Expand Up @@ -86,6 +86,7 @@ const Novel = ({ route, navigation }) => {
const [selected, setSelected] = useState([]);
const [downloadMenu, showDownloadMenu] = useState(false);
const [extraMenu, showExtraMenu] = useState(false);
const [isFabExtended, setIsFabExtended] = useState(true);

let flatlistRef = useRef(null);
let novelBottomSheetRef = useRef(null);
Expand Down Expand Up @@ -126,6 +127,9 @@ const Novel = ({ route, navigation }) => {
const onPageScroll = event => {
const y = event.nativeEvent.contentOffset.y;
headerOpacity.value = withTiming(y > 10 ? 1 : 0, { duration: 200 });

const currentScrollPosition = Math.floor(y) ?? 0;
setIsFabExtended(currentScrollPosition <= 0);
};

useEffect(() => {
Expand Down Expand Up @@ -679,12 +683,12 @@ const Novel = ({ route, navigation }) => {
/>
</View>
{useFabForContinueReading && chapters.length > 0 && lastReadChapter && (
<FAB
<AnimatedFAB
style={[
styles.fab,
{ backgroundColor: theme.primary, marginBottom: bottomInset },
]}
small
extended={isFabExtended}
color={theme.onPrimary}
uppercase={false}
label={novel.unread ? 'Start' : 'Resume'}
Expand Down

1 comment on commit e4ca751

@Palloxin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMG_20240122_132149
I forgot to menzion this should stay.

Please sign in to comment.