1. Agora, vamos começar a criar o restante da página “HabitPage”.

  2. Nós iremos receber todo o objeto de hábito via rota, para poder colocarmos as informações na página, como por exemplo a área do hábito. “Pages → HabitPage → index.jsx”

    import React, { useEffect, useRef, useState } from "react";
    import {
      View,
      Text,
      StyleSheet,
      Image,
      TouchableOpacity,
      ScrollView,
    } from "react-native";
    
    import { useNavigation } from "@react-navigation/native";
    
    export default function HabitPage({ route }) {
    	const navigation = useNavigation();
    
    	const { create, habit } = route.params;
    
      return (
        <View style={styles.container}>
          <ScrollView>
            <View>
              <TouchableOpacity
                style={styles.bakcPageBtn}
                onPress={() => navigation.goBack()}
              >
                <Image
                  source={require("../../assets/icons/arrowBack.png")}
                  style={styles.arrowBack}
                />
              </TouchableOpacity>
              <View style={styles.mainContent}>
                <Text style={styles.title}>Configurações {"\\n"} de hábito</Text>
                <Text style={styles.inputText}>Área</Text>
                <View style={styles.inputContainer}>
                  <Text style={styles.area}>{habit?.habitArea}</Text>
                </View>
              </View>
            </View>
          </ScrollView>
        </View>
      );
    }
    
    const styles = StyleSheet.create({
      container: {
        flex: 1,
        backgroundColor: "rgba(21, 21, 21, 0.98)",
      },
      bakcPageBtn: {
        width: 40,
        height: 40,
        margin: 25,
      },
      arrowBack: {
        width: 40,
        height: 40,
      },
      mainContent: {
        width: 250,
        alignSelf: "center",
      },
      title: {
        fontWeight: "bold",
        textAlign: "center",
        color: "white",
        fontSize: 30,
      },
      inputText: {
        color: "white",
        fontSize: 16,
        marginTop: 35,
        marginBottom: 10,
        marginLeft: 5,
      },
      inputContainer: {
        borderWidth: 1,
        borderColor: "#FFFFFF",
        borderRadius: 10,
        paddingHorizontal: 20,
        paddingVertical: 15,
      },
      area: {
        color: "#BBBBBB",
        fontSize: 15,
      },
    });
    
  3. Agora, nós vamos para o nosso botão de criar hábito, para poder manipular ele e fazer com que, ao clicar nele a gente seja mandado para a página “HabitPage”. “Components → Home → CreateHabit → index.jsx”

    import React from "react";
    import { StyleSheet, Text, TouchableOpacity } from "react-native";
    import { useNavigation } from "@react-navigation/native";
    
    export default function CreateHabit({ habitArea, borderColor }) {
      const navigation = useNavigation();
    
      function handleCreate() {
        navigation.navigate("HabitPage", {
          create: true,
          habit: { habitArea: habitArea },
        });
      }
    
      return (
        <TouchableOpacity
          activeOpacity={0.8}
          style={[styles.button, { borderColor: borderColor }]}
          onPress={handleCreate}
        >
          <Text style={styles.habitTitle}>
            Adicionar meta {habitArea === "Mente" ? "da" : "do"} {habitArea}
          </Text>
        </TouchableOpacity>
      );
    }
    
    const styles = StyleSheet.create({
      button: {
        width: 315,
        marginVertical: 10,
        paddingVertical: 10,
        paddingHorizontal: 20,
        borderWidth: 2,
        borderStyle: "dotted",
        borderColor: "white",
        borderRadius: 5,
        justifyContent: "center",
        alignItems: "center",
      },
      habitTitle: {
        color: "white",
        fontSize: 16,
        fontWeight: "bold",
      },
    });
    
  4. Agora ao clicar em algum botão de criação, nós vamos ser mandados para a página “HabitPage”, que terá já o botão e também a área do hábito que estamos enviando.