Невозможно переопределить стиль Amplify по умолчанию с помощью Authenticator с помощью настраиваемой темы

Я пытаюсь настроить стиль AWS WithAuthenticator HOC в моем приложении React Native. Я шаг за шагом следовал документации по Amplify. Однако приложение продолжает отображать стиль по умолчанию (оранжевые кнопки) вместо ожидаемого пользовательского цвета.

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import Amplify from '@aws-amplify/core';
import config from './aws-exports';
import { withAuthenticator } from 'aws-amplify-react-native';
import { AmplifyTheme } from 'aws-amplify-react-native';

// custom colors for components 
const Mybutton = Object.assign({}, AmplifyTheme.button, { backgroundColor: '#000', });
//console.log('My own design: ', Mybutton)
const MyTheme = Object.assign({}, AmplifyTheme, { button: Mybutton });


class App extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <Text>You are now signed in!</Text>
      </View>
    );
  }
}

export default withAuthenticator(App, { includeGreetings: true }, false, [], null, MyTheme)

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

Может ли кто-нибудь указать мне, что я делаю не так?


person Y.Henni    schedule 18.11.2018    source источник
comment
Вы когда-нибудь догадывались об этом?   -  person Wyetro    schedule 16.03.2019


Ответы (1)


Вам нужно передать вызов withAuthenticator следующим образом:

export default withAuthenticator(App, {includeGreetings: true, theme: MyTheme});

Тогда все заработает.

person mpaepper    schedule 27.08.2019