|  | @@ -1,11 +1,15 @@
 | 
	
		
			
			| 1 | 1 |  package com.reactnativenavigation.presentation;
 | 
	
		
			
			| 2 | 2 |  
 | 
	
		
			
			| 3 | 3 |  import android.content.Context;
 | 
	
		
			
			|  | 4 | +import android.graphics.drawable.Drawable;
 | 
	
		
			
			|  | 5 | +import android.support.annotation.NonNull;
 | 
	
		
			
			| 4 | 6 |  import android.support.annotation.VisibleForTesting;
 | 
	
		
			
			| 5 | 7 |  import android.support.v4.content.ContextCompat;
 | 
	
		
			
			| 6 | 8 |  
 | 
	
		
			
			| 7 | 9 |  import com.reactnativenavigation.parse.BottomTabOptions;
 | 
	
		
			
			| 8 | 10 |  import com.reactnativenavigation.parse.Options;
 | 
	
		
			
			|  | 11 | +import com.reactnativenavigation.utils.ImageLoader;
 | 
	
		
			
			|  | 12 | +import com.reactnativenavigation.utils.ImageLoadingListenerAdapter;
 | 
	
		
			
			| 9 | 13 |  import com.reactnativenavigation.viewcontrollers.ViewController;
 | 
	
		
			
			| 10 | 14 |  import com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabFinder;
 | 
	
		
			
			| 11 | 15 |  import com.reactnativenavigation.views.BottomTabs;
 | 
	
	
		
			
			|  | @@ -14,6 +18,8 @@ import com.reactnativenavigation.views.Component;
 | 
	
		
			
			| 14 | 18 |  import java.util.List;
 | 
	
		
			
			| 15 | 19 |  
 | 
	
		
			
			| 16 | 20 |  public class BottomTabPresenter {
 | 
	
		
			
			|  | 21 | +    private final Context context;
 | 
	
		
			
			|  | 22 | +    private ImageLoader imageLoader;
 | 
	
		
			
			| 17 | 23 |      private Options defaultOptions;
 | 
	
		
			
			| 18 | 24 |      private final BottomTabFinder bottomTabFinder;
 | 
	
		
			
			| 19 | 25 |      private BottomTabs bottomTabs;
 | 
	
	
		
			
			|  | @@ -21,9 +27,11 @@ public class BottomTabPresenter {
 | 
	
		
			
			| 21 | 27 |      private final int defaultTextColor;
 | 
	
		
			
			| 22 | 28 |      private final List<ViewController> tabs;
 | 
	
		
			
			| 23 | 29 |  
 | 
	
		
			
			| 24 |  | -    public BottomTabPresenter(Context context, List<ViewController> tabs, Options defaultOptions) {
 | 
	
		
			
			|  | 30 | +    public BottomTabPresenter(Context context, List<ViewController> tabs, ImageLoader imageLoader, Options defaultOptions) {
 | 
	
		
			
			| 25 | 31 |          this.tabs = tabs;
 | 
	
		
			
			|  | 32 | +        this.context = context;
 | 
	
		
			
			| 26 | 33 |          this.bottomTabFinder = new BottomTabFinder(tabs);
 | 
	
		
			
			|  | 34 | +        this.imageLoader = imageLoader;
 | 
	
		
			
			| 27 | 35 |          this.defaultOptions = defaultOptions;
 | 
	
		
			
			| 28 | 36 |          defaultSelectedTextColor = defaultOptions.bottomTabOptions.selectedIconColor.get(ContextCompat.getColor(context, com.aurelhubert.ahbottomnavigation.R.color.colorBottomNavigationAccent));
 | 
	
		
			
			| 29 | 37 |          defaultTextColor = defaultOptions.bottomTabOptions.iconColor.get(ContextCompat.getColor(context, com.aurelhubert.ahbottomnavigation.R.color.colorBottomNavigationInactive));
 | 
	
	
		
			
			|  | @@ -55,14 +63,21 @@ public class BottomTabPresenter {
 | 
	
		
			
			| 55 | 63 |      public void mergeChildOptions(Options options, Component child) {
 | 
	
		
			
			| 56 | 64 |          int index = bottomTabFinder.findByComponent(child);
 | 
	
		
			
			| 57 | 65 |          if (index >= 0) {
 | 
	
		
			
			| 58 |  | -            BottomTabOptions withDefaultOptions = options.withDefaultOptions(defaultOptions).bottomTabOptions;
 | 
	
		
			
			| 59 |  | -            if (withDefaultOptions.badge.hasValue()) bottomTabs.setBadge(index, withDefaultOptions.badge.get());
 | 
	
		
			
			| 60 |  | -            if (withDefaultOptions.badgeColor.hasValue()) bottomTabs.setBadgeColor(withDefaultOptions.badgeColor.get());
 | 
	
		
			
			| 61 |  | -            if (withDefaultOptions.fontFamily != null) bottomTabs.setTitleTypeface(index, withDefaultOptions.fontFamily);
 | 
	
		
			
			| 62 |  | -            if (withDefaultOptions.selectedIconColor.hasValue()) bottomTabs.setIconActiveColor(index, withDefaultOptions.selectedIconColor.get());
 | 
	
		
			
			| 63 |  | -            if (withDefaultOptions.iconColor.hasValue()) bottomTabs.setIconInactiveColor(index, withDefaultOptions.iconColor.get());
 | 
	
		
			
			| 64 |  | -            if (withDefaultOptions.selectedTextColor.hasValue()) bottomTabs.setTitleActiveColor(index, withDefaultOptions.selectedTextColor.get());
 | 
	
		
			
			| 65 |  | -            if (withDefaultOptions.textColor.hasValue()) bottomTabs.setTitleInactiveColor(index, withDefaultOptions.textColor.get());
 | 
	
		
			
			|  | 66 | +            BottomTabOptions bto = options.bottomTabOptions;
 | 
	
		
			
			|  | 67 | +            if (bto.badge.hasValue()) bottomTabs.setBadge(index, bto.badge.get());
 | 
	
		
			
			|  | 68 | +            if (bto.badgeColor.hasValue()) bottomTabs.setBadgeColor(bto.badgeColor.get());
 | 
	
		
			
			|  | 69 | +            if (bto.fontFamily != null) bottomTabs.setTitleTypeface(index, bto.fontFamily);
 | 
	
		
			
			|  | 70 | +            if (bto.selectedIconColor.hasValue()) bottomTabs.setIconActiveColor(index, bto.selectedIconColor.get());
 | 
	
		
			
			|  | 71 | +            if (bto.iconColor.hasValue()) bottomTabs.setIconInactiveColor(index, bto.iconColor.get());
 | 
	
		
			
			|  | 72 | +            if (bto.selectedTextColor.hasValue()) bottomTabs.setTitleActiveColor(index, bto.selectedTextColor.get());
 | 
	
		
			
			|  | 73 | +            if (bto.textColor.hasValue()) bottomTabs.setTitleInactiveColor(index, bto.textColor.get());
 | 
	
		
			
			|  | 74 | +            if (bto.text.hasValue()) bottomTabs.setText(index, bto.text.get());
 | 
	
		
			
			|  | 75 | +            if (bto.icon.hasValue()) imageLoader.loadIcon(context, bto.icon.get(), new ImageLoadingListenerAdapter() {
 | 
	
		
			
			|  | 76 | +                @Override
 | 
	
		
			
			|  | 77 | +                public void onComplete(@NonNull Drawable drawable) {
 | 
	
		
			
			|  | 78 | +                    bottomTabs.setIcon(index, drawable);
 | 
	
		
			
			|  | 79 | +                }
 | 
	
		
			
			|  | 80 | +            });
 | 
	
		
			
			| 66 | 81 |          }
 | 
	
		
			
			| 67 | 82 |      }
 | 
	
		
			
			| 68 | 83 |  
 |