mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-18 19:01:38 +03:00
commit
dc7f8f4193
@ -1,5 +1,5 @@
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import { Alert, AlertButton, ButtonProps } from 'react-native';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import {AlertButton, ButtonProps } from 'react-native';
|
||||
import { Source } from 'react-native-fast-image';
|
||||
import { useSelector, useDispatch } from 'react-redux';
|
||||
import { ActionModalView } from '..';
|
||||
@ -19,22 +19,23 @@ const ActionModalContainer = ({ navigation }) => {
|
||||
const dispatch = useDispatch();
|
||||
const actionModalRef = useRef<ActionModalRef>();
|
||||
|
||||
const actionModalVisible = useSelector(
|
||||
(state) => state.ui.actionModalVisible,
|
||||
);
|
||||
|
||||
const actionModalData:ActionModalData = useSelector(state => state.ui.actionModalData)
|
||||
|
||||
const actionModalVisible = useSelector((state) => state.ui.actionModalVisible);
|
||||
const actionModalData:ActionModalData = useSelector(state => state.ui.actionModalData)
|
||||
|
||||
const [modalToken, setModalToken] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
if (actionModalVisible) {
|
||||
if (actionModalVisible && actionModalVisible !== modalToken) {
|
||||
actionModalRef.current?.showModal();
|
||||
setModalToken(actionModalVisible);
|
||||
}
|
||||
}, [actionModalVisible]);
|
||||
|
||||
|
||||
const _onClose = () => {
|
||||
actionModalData.onClosed();
|
||||
if(actionModalData.onClosed){
|
||||
actionModalData.onClosed();
|
||||
}
|
||||
dispatch(hideActionModal());
|
||||
};
|
||||
|
||||
|
@ -9,9 +9,14 @@ export default EStyleSheet.create({
|
||||
paddingBottom:8,
|
||||
},
|
||||
|
||||
sheetContent: {
|
||||
sheetContent: {
|
||||
backgroundColor: '$primaryBackgroundColor',
|
||||
},
|
||||
position:'absolute',
|
||||
bottom:0,
|
||||
left:0,
|
||||
right:0,
|
||||
zIndex:999
|
||||
},
|
||||
|
||||
container:{
|
||||
marginTop:16,
|
||||
|
@ -66,7 +66,7 @@ const ActionModalView = ({onClose, data}: ActionModalViewProps, ref) => {
|
||||
|
||||
|
||||
<View style={styles.actionPanel}>
|
||||
{
|
||||
{buttons ? (
|
||||
buttons.map((props)=>(
|
||||
<TextButton
|
||||
key={props.text}
|
||||
@ -79,6 +79,17 @@ const ActionModalView = ({onClose, data}: ActionModalViewProps, ref) => {
|
||||
textStyle={styles.btnText}
|
||||
/>
|
||||
))
|
||||
):(
|
||||
<TextButton
|
||||
key='default'
|
||||
text='OK'
|
||||
onPress={()=>{
|
||||
sheetModalRef.current?.setModalVisible(false);
|
||||
}}
|
||||
style={styles.button}
|
||||
textStyle={styles.btnText}
|
||||
/>
|
||||
)
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { ButtonProps } from 'react-native';
|
||||
|
||||
import { AlertButton } from 'react-native';
|
||||
import {
|
||||
TOAST_NOTIFICATION,
|
||||
UPDATE_ACTIVE_BOTTOM_TAB,
|
||||
@ -20,9 +21,9 @@ export const toastNotification = (payload:string) => ({
|
||||
type: TOAST_NOTIFICATION,
|
||||
});
|
||||
|
||||
export const showActionModal = (title:string, body:string, buttons:ButtonProps[], headerImage:any, onClosed:()=>void) => ({
|
||||
export const showActionModal = (title:string, body?:string, buttons?:AlertButton[], headerImage?:any, onClosed?:()=>void) => ({
|
||||
payload: {
|
||||
actionModalVisible: true,
|
||||
actionModalVisible: new Date().getTime(),
|
||||
actionModalData: {
|
||||
title,
|
||||
body,
|
||||
|
Loading…
Reference in New Issue
Block a user