inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

[리뉴얼] 맛집 지도앱 만들기 (React Native & NestJS)

react-native-date-picker darkmode 적용 관련 공유

해결된 질문

296

김용민

작성한 질문수 74

2

다크모드를 어떻게 적용시킬까 고민하다가, 찾아보니 theme이라는 프로퍼티를 사용해서 아래와 같이 코드를 작성하면 다크모드가 적용이 됩니다!!

 

import {colors} from '@/constants';
import useThemeStore from '@/store/useThemeStore';
import {ThemeMode} from '@/types/common';
import React from 'react';
import {
  StyleSheet,
  View,
  Modal,
  SafeAreaView,
  Pressable,
  Text,
} from 'react-native';
import DatePicker from 'react-native-date-picker';

interface DatePickerOptionProps {
  isVisible: boolean;
  date: Date;
  onChangeDate: (date: Date) => void;
  onConfirmDate: () => void;
}

const DatePickerOption = ({
  isVisible,
  date,
  onChangeDate,
  onConfirmDate,
}: DatePickerOptionProps) => {
  const {theme} = useThemeStore();
  const styles = styling(theme);

  return (
    <Modal visible={isVisible} transparent animationType="slide">
      <SafeAreaView style={styles.optionBackground}>
        <View style={styles.optionContainer}>
          <View style={styles.pickerContainer}>
            <DatePicker
              mode="date"
              date={date}
              onDateChange={onChangeDate}
              locale="ko"
              theme={theme === 'dark' ? 'dark' : 'light'}
            />
          </View>
        </View>
        <View style={styles.optionContainer}>
          <Pressable style={styles.optionButton} onPress={onConfirmDate}>
            <Text style={styles.optionText}>확인</Text>
          </Pressable>
        </View>
      </SafeAreaView>
    </Modal>
  );
};

const styling = (theme: ThemeMode) =>
  StyleSheet.create({
    pickerContainer: {
      alignItems: 'center',
    },
    optionBackground: {
      flex: 1,
      justifyContent: 'flex-end',
      backgroundColor: 'rgba(0, 0, 0 / 0.5)',
    },
    optionContainer: {
      borderRadius: 15,
      marginHorizontal: 10,
      marginBottom: 10,
      backgroundColor: colors[theme].GRAY_100,
      overflow: 'hidden',
    },
    optionButton: {
      flexDirection: 'row',
      alignItems: 'center',
      justifyContent: 'center',
      height: 50,
      gap: 5,
    },
    optionText: {
      color: colors[theme].BLUE_500,
      fontSize: 17,
      fontWeight: '500',
    },
  });

export default DatePickerOption;

react-native typescript nestjs react-query zustand

답변 1

0

Kyo

네 바로 아래질문글에도 공유해주신분이 있는데, 5버전부터는 textColor가 제거되어 theme prop을 사용하면 됩니다!

react-native-screens 버전 호환 문제

2

155

1

안드로이드 실행 중 Drawer네비게이션과 MapView 성능 문제

0

104

2

해당 강의 부분은 실제 활용하기에 부족해 제가 해결한 방법입니다.

0

97

1

소스코드가 강의 순서랑 다른가요?

0

74

2

현재 Windows에서 VsCode로 작업 중인데 추후에 IOS도 가능하게 하려면

0

116

2

react-native-fast-image는 react 19 버전에서 설치가 안되나요?

0

209

2

SQL Shell의 역할이 무엇인가요?

0

92

1

혹시 해당 강의에서invalidateQueries를 사용한 이유가 있을까요?

0

79

2

빠르게 실행해보고싶습니다.

0

84

1

강의 수강 순서 관련

0

72

1

애뮬레이터 실행 방법

0

101

2

무료 Apple ID로 실기기 테스트 가능한가요?

0

92

2

ios 실기기 연결

0

70

2

npm run ios에러

0

76

1

10월 삭제 예정인 강의는 이유를 알 수 있을까요?

0

102

1

캘린더 개발 후에 navigation 에 대해서 궁금한 점이 있습니다.

0

52

1

안드로이드 위치 권한 이슈 2가지 문의

0

72

1

지도가 보이려면 음.. 작성해주신 스타일과 다르게

0

75

0

제대로 설치한거같은데 안드로이드랑 ios 둘다 앱실행이 안되는것같아요

0

83

3

강의 내용을 보면 전체적으로 function 함수 키워드를 사용하시는데

0

70

2

강의 3-9 에서 useGetRefreshToken 훅 안에 즉시 함수로 처리하는 이유가 궁금합니다!

0

83

2

사내에서 figma.com 업로드 안되나요?

0

97

1

AWS EC2 + RDS 설정

0

86

2

안드로이드 안켜집니다.

0

92

2