package com.reactnativenavigation.params.parsers;

import android.os.Bundle;

import com.reactnativenavigation.params.ContextualMenuButtonParams;
import com.reactnativenavigation.params.StyleParams;
import com.reactnativenavigation.react.ImageLoader;

import java.util.List;

public class ContextualMenuButtonParamsParser extends TitleBarButtonParamsParser {
    public List<ContextualMenuButtonParams> parseContextualMenuButtons(Bundle params) {
        return parseBundle(params, new ParseStrategy<ContextualMenuButtonParams>() {
            @Override
            public ContextualMenuButtonParams parse(Bundle button) {
                return parseSingleContextualMenuButton(button);
            }
        });
    }

    private ContextualMenuButtonParams parseSingleContextualMenuButton(Bundle button) {
        ContextualMenuButtonParams result = new ContextualMenuButtonParams();
        result.icon = ImageLoader.loadImage(button.getString("icon"));
        result.showAsAction = parseShowAsAction(button.getString("showAsAction"));
        result.color = StyleParams.Color.parse(button, "color");
        result.label = button.getString("label");
        result.index = (int) button.getDouble("index");
        return result;
    }
}

@@ -1174,14 +1174,8 @@
 ex =
- (int)
  but
@@ -1185,14 +1185,11 @@
 .get
-Double
+Int
 (%22in

Fix contextual menu wrong index (#541)