Skip to content

Commit

Permalink
typescript navigation error corrected
Browse files Browse the repository at this point in the history
  • Loading branch information
Holat committed Jul 24, 2023
1 parent 3d973fe commit 182cc9e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 22 deletions.
26 changes: 4 additions & 22 deletions app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,22 @@ import {
import React, { useState } from "react";
import { FontAwesome5, Ionicons } from "@expo/vector-icons";
import { Link } from "expo-router";
import { useNavigation } from "expo-router";

import Header from "../components/Header";
import CreateScrn from "../components/CreateScrn";
import List from "../components/List";
import FONT from "../constants/FONT";
import { listProp, showCreateProp } from "../types/type";
import { light, dark } from "../constants/Colors";
import Head from "../components/Head";

const Home = () => {
const navigation = useNavigation();
const [create, showCreate] = useState(false);
const [taskItem, setTaskItem] = useState<listProp[]>([]);
const DarkMode = useColorScheme() === "dark";

const handlePress = () => {
showCreate(true);
};

const Head = ({ showCreate }: showCreateProp) => {
return (
<View style={{ flexDirection: "row", alignItems: "center", gap: 5 }}>
<Pressable onPress={() => showCreate(false)}>
<Ionicons
name="arrow-back-circle-outline"
size={30}
color={DarkMode ? dark.text2 : light.text2}
/>
</Pressable>
<Text style={[styles.header1Txt, DarkMode && { color: dark.text }]}>
Create To-do
</Text>
</View>
);
};

return (
<View
style={[styles.cont, DarkMode && { backgroundColor: dark.background2 }]}
Expand All @@ -66,7 +48,7 @@ const Home = () => {
]}
>
<Pressable
onPress={handlePress}
onPress={() => showCreate(true)}
style={[create ? styles.header1 : styles.header]}
>
{create ? (
Expand Down
14 changes: 14 additions & 0 deletions app/loginScreen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { StyleSheet, Text, View } from "react-native";
import React from "react";

const LoginScreen = () => {
return (
<View>
<Text>LoginScreen</Text>
</View>
);
};

export default LoginScreen;

const styles = StyleSheet.create({});
42 changes: 42 additions & 0 deletions components/Head.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import {
View,
Text,
StyleSheet,
Pressable,
useColorScheme,
} from "react-native";
import React from "react";
import { Ionicons } from "@expo/vector-icons";

import { light, dark } from "../constants/Colors";
import { showCreateProp } from "../types/type";
import FONT from "../constants/FONT";

const Head = ({ showCreate }: showCreateProp) => {
const DarkMode = useColorScheme() === "dark";
return (
<View style={{ flexDirection: "row", alignItems: "center", gap: 5 }}>
<Pressable onPress={() => showCreate(false)}>
<Ionicons
name="arrow-back-circle-outline"
size={30}
color={DarkMode ? dark.text2 : light.text2}
/>
</Pressable>
<Text style={[styles.header1Txt, DarkMode && { color: dark.text }]}>
Create To-do
</Text>
</View>
);
};

export default Head;

const styles = StyleSheet.create({
header1Txt: {
fontFamily: FONT.JBold,
fontSize: 30,
color: "black",
textAlign: "left",
},
});

0 comments on commit 182cc9e

Please sign in to comment.