From 62d419917e629d5a8d4004329f4ffeb35a3f54aa Mon Sep 17 00:00:00 2001 From: Reza_ashrafi Date: Sat, 23 Apr 2022 14:58:30 +0430 Subject: [PATCH] reza fixed alert modal theme --- src/components/AlertModal.js | 241 ++++++++++++++------------ src/screens/Home/components/Scroll.js | 6 +- 2 files changed, 133 insertions(+), 114 deletions(-) diff --git a/src/components/AlertModal.js b/src/components/AlertModal.js index 1e48606..03eee00 100644 --- a/src/components/AlertModal.js +++ b/src/components/AlertModal.js @@ -1,8 +1,15 @@ -import React, { useState } from "react" -import AwesomeAlert from 'react-native-awesome-alerts'; -const ReactNative = require('react-native'); +import React, { useState } from "react"; +import { Dimensions } from "react-native"; +import { connect } from "react-redux"; +import AwesomeAlert from "react-native-awesome-alerts"; -const AlertModal = props => { +//style +import Colors from "../constants/Colors"; + +//variables +const { width } = Dimensions.get("window"); + +const AlertModal = (props) => { const [alert, setAlert] = useState({ show: false, showProgress: false, @@ -15,12 +22,9 @@ const AlertModal = props => { cancelText: "بیخیال", confirmText: "باشه", confirmButtonColor: "#2980b9", - onCancel: () => { - }, - onConfirm: () => { - - }, - }) + onCancel: () => {}, + onConfirm: () => {}, + }); const [apiAlert, setApiAlert] = useState({ show: false, showProgress: false, @@ -33,121 +37,136 @@ const AlertModal = props => { cancelText: "بیخیال", confirmText: "باشه", confirmButtonColor: "#2980b9", - onCancel: () => { - }, - onConfirm: () => { - }, - }) + onCancel: () => {}, + onConfirm: () => {}, + }); global.globalAlert = (params) => { setAlert({ ...alert, - ...params - }) - } + ...params, + }); + }; global.globalApiAlert = (params) => { - setApiAlert({ ...apiAlert, - ...params - }) - } + ...params, + }); + }; function hideAlert() { - setAlert({ ...alert, show: false }) + setAlert({ ...alert, show: false }); } - function onApiCancelPressed(){ - globalApiAlert({ show: false }) + function onApiCancelPressed() { + globalApiAlert({ show: false }); - apiAlert.onCancel() + apiAlert.onCancel(); } - function onApiConfirmPressed(){ - globalApiAlert({ show: false }) - apiAlert.onConfirm() + function onApiConfirmPressed() { + globalApiAlert({ show: false }); + apiAlert.onConfirm(); } - function onCancelPressed(){ - hideAlert() - alert.onCancel() + function onCancelPressed() { + hideAlert(); + alert.onCancel(); } - function onConfirmPressed(){ - hideAlert() - alert.onConfirm() + function onConfirmPressed() { + hideAlert(); + alert.onConfirm(); } - return <> - - - + return ( + <> + + + + ); +}; -} +const mapStateToProps = (state) => ({ + theme: state.publicApi.theme, +}); -export default AlertModal; +export default connect(mapStateToProps)(AlertModal); diff --git a/src/screens/Home/components/Scroll.js b/src/screens/Home/components/Scroll.js index 54289f5..fccf3ea 100644 --- a/src/screens/Home/components/Scroll.js +++ b/src/screens/Home/components/Scroll.js @@ -25,8 +25,8 @@ function Scroll({ books, mobile }) { style={[ tw("mr-1 overflow-hidden"), { - width: position === 0 ? mobile ? 163 : 240 : mobile ? 84 : 125, - height: position === 0 ? mobile ? 245 : 350 : mobile ? 118 : 170, + width: position === 0 ? mobile ? 170 : 240 : mobile ? 84 : 125, + height: position === 0 ? mobile ? 240 : 350 : mobile ? 118 : 170, marginLeft : position === 0 ? 16 : 4, }, ]} @@ -47,7 +47,7 @@ function Scroll({ books, mobile }) { ios ? "flex-wrap" : "flex-wrap-reverse" }` ), - { height: mobile ? 245 : 350, direction: "rtl" }, + { height: mobile ? 242 : 350, direction: "rtl" }, ]} > {books.slice(0,14).map((book, index) => (