animations

This commit is contained in:
2021-11-01 22:38:46 +01:00
parent 42be0512bf
commit 85a808e834
12 changed files with 95 additions and 51 deletions

View File

@@ -8,7 +8,14 @@ import { WrapperButtons, WrapperAddItem, WrapperAddList, WrapperRemove, WrapperS
import { useSelector, useDispatch } from 'react-redux'
import { itemsRemoved, checkAll } from '../../../redux/slices/groceryList/itemsSlice'
import { selectOpenListId } from '../../../redux/slices/groceryList/listsSlice'
import { Alert } from 'react-native'
import { Alert, LayoutAnimation, Platform, UIManager } from 'react-native'
if (
Platform.OS === "android" &&
UIManager.setLayoutAnimationEnabledExperimental
) {
UIManager.setLayoutAnimationEnabledExperimental(true);
}
const SelectAllItemsButton = (props) => {
const dispatch = useDispatch()
@@ -52,11 +59,20 @@ const RemoveItemsButton = (props) => {
export const ContainerButtons = (props) => {
const [visible, setVisible] = useState(false);
const toggleAnimation = () => {
LayoutAnimation.configureNext({
duration: 500,
create: { type: 'linear', property: 'opacity' },
update: { type: 'spring', springDamping: 0.8 },
delete: { type: 'linear', property: 'opacity' }
})
setVisible(!visible)
}
return (
<>
<SelectAllItemsButton visible={visible} />
<RemoveItemsButton visible={visible} />
<WrapperButtons toggle={visible} onPress={() => setVisible(!visible)}>
<WrapperButtons toggle={visible} onPress={toggleAnimation}>
<MenuIcon />
</WrapperButtons >
</>