NativePlugins: Implement sidebar sections in java
Summary: Changes sidebar from just a bucket of json, to be a list of SidebarSections. Currently implemented sections are Json, and Toolbar. Reviewed By: passy Differential Revision: D14620095 fbshipit-source-id: 6ba57f6f1ad954373c0bbb79570d779787e5d4db
This commit is contained in:
committed by
Facebook Github Bot
parent
ff6988ddaf
commit
ddd06971f1
@@ -0,0 +1,22 @@
|
||||
package com.facebook.flipper.nativeplugins.components;
|
||||
|
||||
import com.facebook.flipper.core.FlipperObject;
|
||||
|
||||
public class JsonSidebarSection implements SidebarSection {
|
||||
private final String title;
|
||||
private final FlipperObject content;
|
||||
|
||||
public JsonSidebarSection(String title, FlipperObject content) {
|
||||
this.title = title;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlipperObject serialize() {
|
||||
return new FlipperObject.Builder()
|
||||
.put("title", title)
|
||||
.put("type", "json")
|
||||
.put("content", content)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.facebook.flipper.nativeplugins.components;
|
||||
|
||||
import com.facebook.flipper.core.FlipperArray;
|
||||
import com.facebook.flipper.core.FlipperObject;
|
||||
|
||||
public class ToolbarSidebarSection implements SidebarSection {
|
||||
FlipperArray.Builder items = new FlipperArray.Builder();
|
||||
|
||||
public ToolbarSidebarSection addLink(String label, String destination) {
|
||||
items.put(
|
||||
new FlipperObject.Builder()
|
||||
.put("type", "link")
|
||||
.put("label", label)
|
||||
.put("destination", destination));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlipperObject serialize() {
|
||||
return new FlipperObject.Builder().put("type", "toolbar").put("items", items.build()).build();
|
||||
}
|
||||
}
|
||||
@@ -122,6 +122,7 @@ public abstract class TablePlugin extends NativePlugin {
|
||||
.build());
|
||||
}
|
||||
});
|
||||
this.onConnected();
|
||||
}
|
||||
|
||||
protected abstract void onConnected();
|
||||
|
||||
@@ -35,6 +35,19 @@ public abstract class TableRow {
|
||||
}
|
||||
}
|
||||
|
||||
public static class BooleanValue implements Value {
|
||||
private boolean val;
|
||||
|
||||
public BooleanValue(boolean i) {
|
||||
this.val = i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlipperObject serialize() {
|
||||
return new FlipperObject.Builder().put("type", "boolean").put("value", val).build();
|
||||
}
|
||||
}
|
||||
|
||||
public static class TimeValue implements Value {
|
||||
private long millis;
|
||||
|
||||
@@ -71,7 +84,7 @@ public abstract class TableRow {
|
||||
this.sidebar = sidebar;
|
||||
}
|
||||
|
||||
FlipperObject serialize() {
|
||||
final FlipperObject serialize() {
|
||||
FlipperObject.Builder columnsObject = new FlipperObject.Builder();
|
||||
for (Map.Entry<TablePlugin.Column, ? extends Value> e : values.entrySet()) {
|
||||
columnsObject.put(e.getKey().id, e.getValue().serialize());
|
||||
|
||||
Reference in New Issue
Block a user