在 IOS 上 React Native Paper Dark 主题

时间:2021-02-18 23:54:39

标签: ios react-native ios-darkmode react-native-paper

我想在我的应用程序上使用 react-native-paper 深色主题,但是,我所有的 <View> 仍然具有白色背景并导致所有 Text 组件不可读,因为文本在深色模式下变为白色。我没有使用自定义主题,因为文档提到:

<块引用>

如果您不使用自定义主题,Paper 将根据设备设置自动打开/关闭动画。

这是我在 App.js 中的代码:

import React from 'react';
import {Provider as PaperProvider} from 'react-native-paper';
import Home from './src/Home';

const App = () => {
  return (
    <PaperProvider>
      <Home />
    </PaperProvider>
  );
};

export default App;

这是在我的 Home.js 中:

import React from 'react';
import {View} from 'react-native';
import {Appbar, Card, Title} from 'react-native-paper';

const Home = () => {
  return (
    <View style={{flex: 1}}>
      <Appbar.Header>
        <Appbar.BackAction onPress={() => console.log('back')} />
        <Appbar.Content title="Title" subtitle={'Subtitle'} />
      </Appbar.Header>
      <View>
        <Title>Hello World</Title>
        <Card
          style={{margin: 15, padding: 15}}
          onPress={() => console.log('press card')}>
          <Title>This is Card</Title>
        </Card>
      </View>
    </View>
  );
};

export default Home;

结果如下: The view still white and the Title also white due to dark mode

It working fine on android

文字变成白色是因为这是暗模式的行为,但为什么我的<View>仍然是白色的?这仅在 iOS 上发生,在 android 上运行良好。

这是一个新的 react native 项目,基于 react-native-paper 中的文档,它会自动转换深色主题。所以,如果我在 iOS 上设置这个项目时遗漏了什么,我需要帮助。任何帮助将不胜感激。

  • 反应:16.13.1
  • 反应原生:0.63.4
  • react-native-paper:^4.7.1
  • react-native-vector-icons: ^8.0.0

0 个答案:

没有答案