Search in sources :

Example 1 with ThemeColour

use of com.reactnativenavigation.options.params.ThemeColour in project react-native-navigation by wix.

the class ButtonPresenterTest method applyOptions_shouldChangeIconColorBackground.

@Test
public void applyOptions_shouldChangeIconColorBackground() {
    IconBackgroundDrawable mockD = mock(IconBackgroundDrawable.class);
    initUUt(ImageLoaderMock.mock(mockD));
    button.enabled = new Bool(true);
    button.icon = new Text("icon");
    button.color = new ThemeColour(new Colour(Color.RED), new Colour(Color.RED));
    IconBackgroundOptions iconBackground = new IconBackgroundOptions();
    iconBackground.color = new ThemeColour(new Colour(Color.GREEN), new Colour(Color.GREEN));
    button.iconBackground = iconBackground;
    MenuItem menuItem = spy(addMenuButton());
    uut.applyOptions(titleBar, menuItem, buttonController::getView);
    Drawable icon = menuItem.getIcon();
    assertThat(icon).isNotNull();
    assertThat(icon).isInstanceOf(IconBackgroundDrawable.class);
    IconBackgroundDrawable modifed = (IconBackgroundDrawable) icon;
    verify(modifed.getWrappedDrawable()).setColorFilter(new PorterDuffColorFilter(Color.RED, PorterDuff.Mode.SRC_IN));
    assertThat(modifed.getBackgroundColor()).isEqualTo(Color.GREEN);
}
Also used : IconBackgroundDrawable(com.reactnativenavigation.views.stack.topbar.titlebar.IconBackgroundDrawable) Bool(com.reactnativenavigation.options.params.Bool) Drawable(android.graphics.drawable.Drawable) IconBackgroundDrawable(com.reactnativenavigation.views.stack.topbar.titlebar.IconBackgroundDrawable) Text(com.reactnativenavigation.options.params.Text) MenuItem(android.view.MenuItem) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) ThemeColour(com.reactnativenavigation.options.params.ThemeColour) IconBackgroundOptions(com.reactnativenavigation.options.IconBackgroundOptions) Colour(com.reactnativenavigation.options.params.Colour) ThemeColour(com.reactnativenavigation.options.params.ThemeColour) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 2 with ThemeColour

use of com.reactnativenavigation.options.params.ThemeColour in project react-native-navigation by wix.

the class ButtonPresenterTest method applyOptions_appliesColorOnButtonTextView.

@Test
public void applyOptions_appliesColorOnButtonTextView() {
    button.color = new ThemeColour(new Colour(Color.RED), new Colour(Color.RED));
    addButtonAndApplyOptions();
    assertThat(findButtonView().getCurrentTextColor()).isEqualTo(Color.RED);
}
Also used : ThemeColour(com.reactnativenavigation.options.params.ThemeColour) Colour(com.reactnativenavigation.options.params.Colour) ThemeColour(com.reactnativenavigation.options.params.ThemeColour) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 3 with ThemeColour

use of com.reactnativenavigation.options.params.ThemeColour in project react-native-navigation by wix.

the class ButtonPresenterTest method applyOptions_shouldChangeIconColorTint.

@Test
public void applyOptions_shouldChangeIconColorTint() {
    IconBackgroundDrawable mockD = mock(IconBackgroundDrawable.class);
    initUUt(ImageLoaderMock.mock(mockD));
    button.enabled = new Bool(true);
    button.icon = new Text("icon");
    button.color = new ThemeColour(new Colour(Color.RED), new Colour(Color.RED));
    MenuItem menuItem = spy(addMenuButton());
    uut.applyOptions(titleBar, menuItem, buttonController::getView);
    Drawable icon = menuItem.getIcon();
    assertThat(icon).isNotNull();
    verify(icon).setColorFilter(new PorterDuffColorFilter(Color.RED, PorterDuff.Mode.SRC_IN));
}
Also used : IconBackgroundDrawable(com.reactnativenavigation.views.stack.topbar.titlebar.IconBackgroundDrawable) Bool(com.reactnativenavigation.options.params.Bool) Drawable(android.graphics.drawable.Drawable) IconBackgroundDrawable(com.reactnativenavigation.views.stack.topbar.titlebar.IconBackgroundDrawable) Text(com.reactnativenavigation.options.params.Text) MenuItem(android.view.MenuItem) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) ThemeColour(com.reactnativenavigation.options.params.ThemeColour) Colour(com.reactnativenavigation.options.params.Colour) ThemeColour(com.reactnativenavigation.options.params.ThemeColour) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 4 with ThemeColour

use of com.reactnativenavigation.options.params.ThemeColour in project react-native-navigation by wix.

the class ButtonPresenterTest method applyOptions_shouldChangeIconDisabledColorBackground.

@Test
public void applyOptions_shouldChangeIconDisabledColorBackground() {
    IconBackgroundDrawable mockD = mock(IconBackgroundDrawable.class);
    initUUt(ImageLoaderMock.mock(mockD));
    button.enabled = new Bool(false);
    button.icon = new Text("icon");
    button.color = new ThemeColour(new Colour(Color.RED), new Colour(Color.RED));
    button.disabledColor = new ThemeColour(new Colour(Color.YELLOW), new Colour(Color.YELLOW));
    IconBackgroundOptions iconBackground = new IconBackgroundOptions();
    iconBackground.color = new ThemeColour(new Colour(Color.GREEN), new Colour(Color.GREEN));
    iconBackground.disabledColor = new ThemeColour(new Colour(Color.CYAN), new Colour(Color.CYAN));
    button.iconBackground = iconBackground;
    MenuItem menuItem = spy(addMenuButton());
    uut.applyOptions(titleBar, menuItem, buttonController::getView);
    Drawable icon = menuItem.getIcon();
    assertThat(icon).isNotNull();
    assertThat(icon).isInstanceOf(IconBackgroundDrawable.class);
    IconBackgroundDrawable modifed = (IconBackgroundDrawable) icon;
    verify(modifed.getWrappedDrawable()).setColorFilter(new PorterDuffColorFilter(Color.YELLOW, PorterDuff.Mode.SRC_IN));
    assertThat(modifed.getBackgroundColor()).isEqualTo(Color.CYAN);
}
Also used : IconBackgroundDrawable(com.reactnativenavigation.views.stack.topbar.titlebar.IconBackgroundDrawable) Bool(com.reactnativenavigation.options.params.Bool) Drawable(android.graphics.drawable.Drawable) IconBackgroundDrawable(com.reactnativenavigation.views.stack.topbar.titlebar.IconBackgroundDrawable) Text(com.reactnativenavigation.options.params.Text) MenuItem(android.view.MenuItem) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) ThemeColour(com.reactnativenavigation.options.params.ThemeColour) IconBackgroundOptions(com.reactnativenavigation.options.IconBackgroundOptions) Colour(com.reactnativenavigation.options.params.Colour) ThemeColour(com.reactnativenavigation.options.params.ThemeColour) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 5 with ThemeColour

use of com.reactnativenavigation.options.params.ThemeColour in project react-native-navigation by wix.

the class ButtonPresenterTest method applyOptions_shouldChangeIconDisabledColorTint.

@Test
public void applyOptions_shouldChangeIconDisabledColorTint() {
    IconBackgroundDrawable mockD = mock(IconBackgroundDrawable.class);
    initUUt(ImageLoaderMock.mock(mockD));
    button.enabled = new Bool(false);
    button.icon = new Text("icon");
    button.color = new ThemeColour(new Colour(Color.RED), new Colour(Color.RED));
    button.disabledColor = new ThemeColour(new Colour(Color.YELLOW), new Colour(Color.YELLOW));
    MenuItem menuItem = spy(addMenuButton());
    uut.applyOptions(titleBar, menuItem, buttonController::getView);
    Drawable icon = menuItem.getIcon();
    assertThat(icon).isNotNull();
    verify(icon).setColorFilter(new PorterDuffColorFilter(Color.YELLOW, PorterDuff.Mode.SRC_IN));
}
Also used : IconBackgroundDrawable(com.reactnativenavigation.views.stack.topbar.titlebar.IconBackgroundDrawable) Bool(com.reactnativenavigation.options.params.Bool) Drawable(android.graphics.drawable.Drawable) IconBackgroundDrawable(com.reactnativenavigation.views.stack.topbar.titlebar.IconBackgroundDrawable) Text(com.reactnativenavigation.options.params.Text) MenuItem(android.view.MenuItem) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) ThemeColour(com.reactnativenavigation.options.params.ThemeColour) Colour(com.reactnativenavigation.options.params.Colour) ThemeColour(com.reactnativenavigation.options.params.ThemeColour) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Aggregations

ThemeColour (com.reactnativenavigation.options.params.ThemeColour)18 Colour (com.reactnativenavigation.options.params.Colour)17 BaseTest (com.reactnativenavigation.BaseTest)13 Test (org.junit.Test)13 Text (com.reactnativenavigation.options.params.Text)8 MenuItem (android.view.MenuItem)7 Bool (com.reactnativenavigation.options.params.Bool)6 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)4 Drawable (android.graphics.drawable.Drawable)4 Options (com.reactnativenavigation.options.Options)4 DontApplyColour (com.reactnativenavigation.options.params.DontApplyColour)4 NullThemeColour (com.reactnativenavigation.options.params.NullThemeColour)4 IconBackgroundDrawable (com.reactnativenavigation.views.stack.topbar.titlebar.IconBackgroundDrawable)4 NullText (com.reactnativenavigation.options.params.NullText)3 ButtonOptions (com.reactnativenavigation.options.ButtonOptions)2 IconBackgroundOptions (com.reactnativenavigation.options.IconBackgroundOptions)2 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Number (com.reactnativenavigation.options.params.Number)1 CommandListenerAdapter (com.reactnativenavigation.react.CommandListenerAdapter)1 NotNull (org.jetbrains.annotations.NotNull)1