Skip to content

Commit

Permalink
Fix andriod date taking up the screen
Browse files Browse the repository at this point in the history
  • Loading branch information
adityapawar1 committed Oct 4, 2023
1 parent 4a3d744 commit 7f9f305
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"eslint-plugin-react-hooks": "^4.6.0",
"husky": "^8.0.3",
"prettier": "^2.8.8",
"typescript": "^4.2.0"
"typescript": "^5.1.3"
},
"private": true
}
26 changes: 15 additions & 11 deletions src/components/Account.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState, useEffect } from 'react';
import { StyleSheet, View, Alert, ScrollView } from 'react-native';
import { StyleSheet, View, Alert, ScrollView, Platform } from 'react-native';
import { Button, Input } from 'react-native-elements';
import { Session } from '@supabase/supabase-js';
import DateTimePicker from '@react-native-community/datetimepicker';
Expand Down Expand Up @@ -28,6 +28,7 @@ export default function Account({ session }: { session: Session }) {
const [birthday, setBirthday] = useState(new Date());
const [gender, setGender] = useState('');
const [raceEthnicity, setRaceEthnicity] = useState('');
const [showDatePicker, setShowDatePicker] = useState(Platform.OS === 'ios');

const getProfile = async () => {
try {
Expand Down Expand Up @@ -131,16 +132,19 @@ export default function Account({ session }: { session: Session }) {
value={raceEthnicity}
onChange={setRaceEthnicity}
/>
<DateTimePicker
testID="dateTimePicker"
value={birthday}
mode="date"
onChange={date => {
if (date.nativeEvent.timestamp) {
setBirthday(new Date(date.nativeEvent.timestamp));
}
}}
/>
{showDatePicker && (
<DateTimePicker
testID="dateTimePicker"
value={birthday}
mode="date"
onChange={date => {
setShowDatePicker(Platform.OS === 'ios');
if (date.nativeEvent.timestamp) {
setBirthday(new Date(date.nativeEvent.timestamp));
}
}}
/>
)}
<View style={[styles.verticallySpaced, styles.mt20]}>
<Button
title={loading ? 'Loading ...' : 'Update'}
Expand Down

0 comments on commit 7f9f305

Please sign in to comment.