Fixed layouts
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.codex
|
||||||
@@ -3,12 +3,15 @@ import { useRouter } from "expo-router";
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
|
KeyboardAvoidingView,
|
||||||
Platform,
|
Platform,
|
||||||
|
ScrollView,
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
Text,
|
Text,
|
||||||
TextInput,
|
TextInput,
|
||||||
View,
|
View,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
|
import { SafeAreaView } from "react-native-safe-area-context";
|
||||||
|
|
||||||
export default function SimpleForm() {
|
export default function SimpleForm() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -29,42 +32,64 @@ export default function SimpleForm() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<SafeAreaView style={styles.safeArea} edges={["top", "bottom"]}>
|
||||||
<Text style={styles.label}>Name:</Text>
|
<KeyboardAvoidingView
|
||||||
<TextInput
|
style={styles.keyboardContainer}
|
||||||
style={styles.input}
|
behavior={Platform.OS === "ios" ? "padding" : undefined}
|
||||||
placeholder="Enter your name"
|
>
|
||||||
value={name}
|
<ScrollView
|
||||||
onChangeText={setName}
|
contentContainerStyle={styles.scrollContent}
|
||||||
/>
|
keyboardShouldPersistTaps="handled"
|
||||||
|
>
|
||||||
|
<View style={styles.formCard}>
|
||||||
|
<Text style={styles.label}>Name:</Text>
|
||||||
|
<TextInput
|
||||||
|
style={styles.input}
|
||||||
|
placeholder="Enter your name"
|
||||||
|
value={name}
|
||||||
|
onChangeText={setName}
|
||||||
|
/>
|
||||||
|
|
||||||
<Text style={styles.label}>Date:</Text>
|
<Text style={styles.label}>Date:</Text>
|
||||||
<Button title="Select Date" onPress={() => setShowPicker(true)} />
|
<Button title="Select Date" onPress={() => setShowPicker(true)} />
|
||||||
|
|
||||||
<Text style={styles.dateText}>{date.toDateString()}</Text>
|
<Text style={styles.dateText}>{date.toDateString()}</Text>
|
||||||
|
|
||||||
{showPicker && (
|
{showPicker && (
|
||||||
<DateTimePicker
|
<DateTimePicker
|
||||||
value={date}
|
value={date}
|
||||||
mode="date"
|
mode="date"
|
||||||
display="default"
|
display="default"
|
||||||
onChange={onChangeDate}
|
onChange={onChangeDate}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Button title="Submit" onPress={handleSubmit} />
|
<Button title="Submit" onPress={handleSubmit} />
|
||||||
</View>
|
</View>
|
||||||
|
</ScrollView>
|
||||||
|
</KeyboardAvoidingView>
|
||||||
|
</SafeAreaView>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
safeArea: {
|
||||||
|
flex: 1,
|
||||||
|
backgroundColor: "#fff",
|
||||||
|
},
|
||||||
|
keyboardContainer: {
|
||||||
|
flex: 1,
|
||||||
|
},
|
||||||
|
scrollContent: {
|
||||||
|
flexGrow: 1,
|
||||||
|
justifyContent: "center",
|
||||||
padding: 20,
|
padding: 20,
|
||||||
marginTop: 50,
|
},
|
||||||
|
formCard: {
|
||||||
|
gap: 12,
|
||||||
},
|
},
|
||||||
label: {
|
label: {
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
marginBottom: 5,
|
|
||||||
},
|
},
|
||||||
input: {
|
input: {
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
@@ -74,7 +99,7 @@ const styles = StyleSheet.create({
|
|||||||
borderRadius: 5,
|
borderRadius: 5,
|
||||||
},
|
},
|
||||||
dateText: {
|
dateText: {
|
||||||
marginVertical: 10,
|
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
|
marginBottom: 8,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,22 +1,26 @@
|
|||||||
import { StyleSheet } from "react-native";
|
import { StyleSheet, View } from "react-native";
|
||||||
|
import { SafeAreaView } from "react-native-safe-area-context";
|
||||||
|
|
||||||
import { BirthdayList } from "@/components/birthdate-list";
|
import { BirthdayList } from "@/components/birthdate-list";
|
||||||
import ScrollView from "@/components/scroll-view";
|
|
||||||
import { View } from "react-native";
|
|
||||||
|
|
||||||
export default function HomeScreen() {
|
export default function HomeScreen() {
|
||||||
return (
|
return (
|
||||||
<ScrollView>
|
<SafeAreaView style={styles.screen} edges={["top", "bottom"]}>
|
||||||
<View style={styles.titleContainer}>
|
<View style={styles.content}>
|
||||||
<BirthdayList></BirthdayList>
|
<BirthdayList />
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</SafeAreaView>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
titleContainer: {
|
screen: {
|
||||||
gap: 8,
|
flex: 1,
|
||||||
margin: 20,
|
backgroundColor: "#fff",
|
||||||
|
},
|
||||||
|
content: {
|
||||||
|
flex: 1,
|
||||||
|
paddingHorizontal: 16,
|
||||||
|
paddingTop: 12,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export function BirthdayList() {
|
|||||||
const groupedData = groupBirthdaysByDate(DATA);
|
const groupedData = groupBirthdaysByDate(DATA);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View>
|
<View style={styles.container}>
|
||||||
<View style={styles.titleContainer}>
|
<View style={styles.titleContainer}>
|
||||||
<Text style={{ fontSize: 24, fontWeight: "bold" }}>
|
<Text style={{ fontSize: 24, fontWeight: "bold" }}>
|
||||||
Upcoming Birthdays
|
Upcoming Birthdays
|
||||||
@@ -61,6 +61,8 @@ export function BirthdayList() {
|
|||||||
renderItem={({ item }) => (
|
renderItem={({ item }) => (
|
||||||
<BirthdayItem name={item.name} date={item.date} />
|
<BirthdayItem name={item.name} date={item.date} />
|
||||||
)}
|
)}
|
||||||
|
style={styles.list}
|
||||||
|
contentContainerStyle={styles.listContent}
|
||||||
showsVerticalScrollIndicator={false}
|
showsVerticalScrollIndicator={false}
|
||||||
renderSectionHeader={({ section: { title } }) => (
|
renderSectionHeader={({ section: { title } }) => (
|
||||||
<View style={styles.headerContainer}>
|
<View style={styles.headerContainer}>
|
||||||
@@ -96,13 +98,23 @@ function groupBirthdaysByDate(data: BirthdayItemData[]): SectionData[] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
flex: 1,
|
||||||
|
},
|
||||||
titleContainer: {
|
titleContainer: {
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
|
gap: 12,
|
||||||
paddingHorizontal: 5,
|
paddingHorizontal: 5,
|
||||||
paddingVertical: 10,
|
paddingVertical: 10,
|
||||||
},
|
},
|
||||||
|
list: {
|
||||||
|
flex: 1,
|
||||||
|
},
|
||||||
|
listContent: {
|
||||||
|
paddingBottom: 20,
|
||||||
|
},
|
||||||
addButton: {
|
addButton: {
|
||||||
width: 40,
|
width: 40,
|
||||||
height: 40,
|
height: 40,
|
||||||
|
|||||||
Reference in New Issue
Block a user