Browse Source

Fixing modal datamenu ScrollView height bug.

master
GabrielTrettel 3 years ago
parent
commit
1aef0e1fe2
  1. 73
      src/app/components/MapDataMenu.js
  2. 8
      src/app/components/SelfClosingModal.js
  3. 2
      src/app/config/colors.js

73
src/app/components/MapDataMenu.js

@ -92,7 +92,7 @@ function DataOriginSelector({ dataOriginToShow, setDataOriginToShow }) {
); );
} }
// FIXME: Change icon values in the future
// FIXME: Change icon values in the future
const dataOptions = { const dataOptions = {
oficial: [ oficial: [
{ {
@ -146,24 +146,34 @@ function Border() {
return ( return (
<View <View
style={{ style={{
width: 0.95 * screen_width,
width: 0.91 * screen_width,
alignSelf: "center", alignSelf: "center",
height: 2, height: 2,
borderRadius: 2, borderRadius: 2,
paddingHorizontal: 16, paddingHorizontal: 16,
backgroundColor: colors.lightestGray,
// backgroundColor: colors.separatorGray,
}} }}
/> />
); );
} }
function ListDataOptions(dataOptionsToShow, dataOriginToShow, setDataOptionsToShow, option) {
function ListDataOptions(
dataOptionsToShow,
dataOriginToShow,
setDataOptionsToShow,
option
) {
const item = dataOptionsToShow[dataOriginToShow][option.code]; const item = dataOptionsToShow[dataOriginToShow][option.code];
const dataOptionObject = {...dataOptionsToShow, [dataOriginToShow]: {...dataOptionsToShow[dataOriginToShow], [option.code]: !item}};
const dataOptionObject = {
...dataOptionsToShow,
[dataOriginToShow]: {
...dataOptionsToShow[dataOriginToShow],
[option.code]: !item,
},
};
return ( return (
<View>
<View key={option.code}>
<View <View
style={{ style={{
flex: 1, flex: 1,
@ -197,9 +207,10 @@ function ListDataOptions(dataOptionsToShow, dataOriginToShow, setDataOptionsToSh
)} )}
</View> </View>
<TouchableOpacity <TouchableOpacity
onPress={() => {setDataOptionsToShow(dataOptionObject)}}
onPress={() => {
setDataOptionsToShow(dataOptionObject);
}}
> >
<View <View
style={{ style={{
@ -208,12 +219,10 @@ function ListDataOptions(dataOptionsToShow, dataOriginToShow, setDataOptionsToSh
height: 36, height: 36,
justifyContent: "center", justifyContent: "center",
borderRadius: 6, borderRadius: 6,
backgroundColor: item ? colors.activated : colors.notActivated,
backgroundColor: item ? colors.activated : colors.notActivated,
}} }}
> >
<Text style={styles.text}>
{item ? "ADICIONAR" : "REMOVER"}
</Text>
<Text style={styles.text}>{item ? "ADICIONAR" : "REMOVER"}</Text>
</View> </View>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
@ -222,13 +231,32 @@ function ListDataOptions(dataOptionsToShow, dataOriginToShow, setDataOptionsToSh
); );
} }
function DataOriginOptions({ dataOriginToShow, dataOptionsToShow, setDataOptionsToShow }) {
function DataOriginOptions({
dataOriginToShow,
dataOptionsToShow,
setDataOptionsToShow,
}) {
return ( return (
<View paddingTop={8} height={"100%"}>
<ScrollView >
<View
style={{
paddingTop: 8,
flexDirection: "column",
}}
>
<ScrollView
height={270}
automaticallyAdjustContentInsets={true}
>
<View>
{dataOptions[dataOriginToShow].map((option) => {dataOptions[dataOriginToShow].map((option) =>
ListDataOptions(dataOptionsToShow, dataOriginToShow, setDataOptionsToShow, option)
ListDataOptions(
dataOptionsToShow,
dataOriginToShow,
setDataOptionsToShow,
option
)
)} )}
</View>
</ScrollView> </ScrollView>
</View> </View>
); );
@ -249,13 +277,10 @@ function DataMenuBody({ setShowModal }) {
riverFlood: true, riverFlood: true,
}, },
}); });
console.log(dataOptionsToShow)
return ( return (
<View <View
style={{
height: "60%",
backgroundColor: colors.white,
}}
backgroundColor={colors.grayBG}
> >
<DataMenuHeader setShowModal={setShowModal} /> <DataMenuHeader setShowModal={setShowModal} />
<DataOriginSelector <DataOriginSelector
@ -274,12 +299,14 @@ function DataMenuBody({ setShowModal }) {
export default function MapDataMenu(props) { export default function MapDataMenu(props) {
const [showModal, setShowModal] = useState(null); const [showModal, setShowModal] = useState(null);
return ( return (
<View>
<View
>
<Button <Button
title={"VISUALIZAR DADOS NO MAPA"} title={"VISUALIZAR DADOS NO MAPA"}
onPress={() => setShowModal(true)} onPress={() => setShowModal(true)}
/> />
<SelfClosingModal <SelfClosingModal
style={{position:"absolute"}}
animationType="slide" animationType="slide"
transparent={true} transparent={true}
showModal={showModal} showModal={showModal}

8
src/app/components/SelfClosingModal.js

@ -5,12 +5,13 @@ import {
StyleSheet, StyleSheet,
TouchableWithoutFeedback, TouchableWithoutFeedback,
} from "react-native"; } from "react-native";
import { screen_height, screen_width } from "../config/dimensions";
import { screen_width } from "../config/dimensions";
import colors from "../config/colors";
export default function SelfClosingModal(props) { export default function SelfClosingModal(props) {
return ( return (
<View style={styles.centeredView}>
<View style={[styles.centeredView, props.style]}>
<Modal <Modal
animationType={props.animationType} animationType={props.animationType}
transparent={props.transparent} transparent={props.transparent}
@ -36,12 +37,13 @@ const styles = StyleSheet.create({
justifyContent: "flex-end", justifyContent: "flex-end",
alignItems: "center", alignItems: "center",
marginTop: 22, marginTop: 22,
marginBottom: 49,
}, },
modalView: { modalView: {
flexShrink: 1, flexShrink: 1,
margin: 20, margin: 20,
width: screen_width, width: screen_width,
backgroundColor: "white",
backgroundColor: colors.grayBG,
borderTopLeftRadius: 10, borderTopLeftRadius: 10,
borderTopRightRadius: 10, borderTopRightRadius: 10,
marginBottom: 0, marginBottom: 0,

2
src/app/config/colors.js

@ -11,10 +11,12 @@ export default {
activated: "rgba(26, 138, 17, 0.63)", activated: "rgba(26, 138, 17, 0.63)",
lightGray: "#C4C4C4", lightGray: "#C4C4C4",
gray: "#999999", gray: "#999999",
separatorGray: "#D9D9D9",
subText: "#8B8C8C", subText: "#8B8C8C",
lightestGray: "#F0F0F0", lightestGray: "#F0F0F0",
lightBlue: "#1976D2", lightBlue: "#1976D2",
gold: "#ffd700", gold: "#ffd700",
toggle: "#e5eff4", toggle: "#e5eff4",
grayBG: "#EEECEC",
}; };
Loading…
Cancel
Save