Merge branch 'feature/slider' into 'master'
Feature/slider See merge request !17
This commit is contained in:
commit
baa0b7092c
@ -53,7 +53,7 @@ public class DemoActivity extends AppCompatActivity {
|
|||||||
FrameLayout frameLayout = new FrameLayout(this);
|
FrameLayout frameLayout = new FrameLayout(this);
|
||||||
addContentView(frameLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
addContentView(frameLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT));
|
ViewGroup.LayoutParams.MATCH_PARENT));
|
||||||
doricContext = DoricContext.create(this, DoricUtils.readAssetFile("demo/" + source), "test");
|
doricContext = DoricContext.create(this, DoricUtils.readAssetFile("demo/" + source), source);
|
||||||
doricContext.init(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
doricContext.init(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||||
doricContext.getRootNode().setRootView(frameLayout);
|
doricContext.getRootNode().setRootView(frameLayout);
|
||||||
}
|
}
|
||||||
|
@ -28,15 +28,24 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
import org.greenrobot.eventbus.ThreadMode;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
import pub.doric.DoricDriver;
|
||||||
|
import pub.doric.dev.DevPanel;
|
||||||
|
import pub.doric.dev.event.EnterDebugEvent;
|
||||||
|
import pub.doric.dev.event.QuitDebugEvent;
|
||||||
|
import pub.doric.engine.ChangeEngineCallback;
|
||||||
import pub.doric.utils.DoricUtils;
|
import pub.doric.utils.DoricUtils;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
private DevPanel devPanel = new DevPanel();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -48,6 +57,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
try {
|
try {
|
||||||
String[] demos = getAssets().list("demo");
|
String[] demos = getAssets().list("demo");
|
||||||
List<String> ret = new ArrayList<>();
|
List<String> ret = new ArrayList<>();
|
||||||
|
ret.add("Debug Kit");
|
||||||
for (String str : demos) {
|
for (String str : demos) {
|
||||||
if (str.endsWith("js")) {
|
if (str.endsWith("js")) {
|
||||||
ret.add(str);
|
ret.add(str);
|
||||||
@ -59,7 +69,38 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MyAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
@Override
|
||||||
|
public void onAttachedToWindow() {
|
||||||
|
super.onAttachedToWindow();
|
||||||
|
|
||||||
|
EventBus.getDefault().register(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
EventBus.getDefault().unregister(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
|
public void onEnterDebugEvent(EnterDebugEvent enterDebugEvent) {
|
||||||
|
DoricDriver.getInstance().changeJSEngine(false, new ChangeEngineCallback() {
|
||||||
|
@Override
|
||||||
|
public void changed() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
|
public void onQuitDebugEvent(QuitDebugEvent quitDebugEvent) {
|
||||||
|
DoricDriver.getInstance().changeJSEngine(true, new ChangeEngineCallback() {
|
||||||
|
@Override
|
||||||
|
public void changed() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MyAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
|
||||||
private final String[] data;
|
private final String[] data;
|
||||||
|
|
||||||
@ -91,6 +132,10 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
tv.setOnClickListener(new View.OnClickListener() {
|
tv.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
if (position == 0) {
|
||||||
|
devPanel.show(getSupportFragmentManager(), "DevPanel");
|
||||||
|
return;
|
||||||
|
}
|
||||||
Intent intent = new Intent(tv.getContext(), DemoActivity.class);
|
Intent intent = new Intent(tv.getContext(), DemoActivity.class);
|
||||||
intent.putExtra("source", data[position]);
|
intent.putExtra("source", data[position]);
|
||||||
tv.getContext().startActivity(intent);
|
tv.getContext().startActivity(intent);
|
||||||
|
@ -4,4 +4,5 @@ export default [
|
|||||||
'src/ListDemo',
|
'src/ListDemo',
|
||||||
'src/ScrollerDemo',
|
'src/ScrollerDemo',
|
||||||
'src/SliderDemo',
|
'src/SliderDemo',
|
||||||
|
'src/LayoutDemo',
|
||||||
]
|
]
|
464
demo/src/LayoutDemo.ts
Normal file
464
demo/src/LayoutDemo.ts
Normal file
@ -0,0 +1,464 @@
|
|||||||
|
|
||||||
|
import { Group, Panel, Text, text, gravity, Color, Stack, LayoutSpec, list, NativeCall, listItem, log, vlayout, Gravity, hlayout, slider, slideItem, scroller, IVLayout, IHLayout } from "doric";
|
||||||
|
import { O_TRUNC } from "constants";
|
||||||
|
|
||||||
|
const colors = [
|
||||||
|
"#f0932b",
|
||||||
|
"#eb4d4b",
|
||||||
|
"#6ab04c",
|
||||||
|
"#e056fd",
|
||||||
|
"#686de0",
|
||||||
|
"#30336b",
|
||||||
|
]
|
||||||
|
|
||||||
|
function box(idx = 0) {
|
||||||
|
return (new Stack).also(it => {
|
||||||
|
it.width = it.height = 20
|
||||||
|
it.bgColor = Color.parse(colors[idx || 0])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
function boxStr(str: string, idx = 0) {
|
||||||
|
return (new Text).also(it => {
|
||||||
|
it.width = it.height = 20
|
||||||
|
it.text = str
|
||||||
|
it.textColor = Color.parse('#ffffff')
|
||||||
|
it.bgColor = Color.parse(colors[idx || 0])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
function label(str: string) {
|
||||||
|
return text({
|
||||||
|
text: str,
|
||||||
|
textSize: 16,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@Entry
|
||||||
|
class LayoutDemo extends Panel {
|
||||||
|
build(rootView: Group) {
|
||||||
|
scroller(
|
||||||
|
hlayout([
|
||||||
|
vlayout([
|
||||||
|
label("Horizontal Layout(Align to Top)"),
|
||||||
|
hlayout([
|
||||||
|
box().apply({
|
||||||
|
height: 20
|
||||||
|
}),
|
||||||
|
box().apply({
|
||||||
|
height: 40
|
||||||
|
}),
|
||||||
|
box().apply({
|
||||||
|
height: 60
|
||||||
|
}),
|
||||||
|
box().apply({
|
||||||
|
height: 40
|
||||||
|
}),
|
||||||
|
box().apply({
|
||||||
|
height: 20
|
||||||
|
}),
|
||||||
|
]).also(it => {
|
||||||
|
it.space = 20
|
||||||
|
}),
|
||||||
|
label("Horizontal Layout(Align to Bottom)"),
|
||||||
|
hlayout([
|
||||||
|
box().apply({
|
||||||
|
height: 20
|
||||||
|
}),
|
||||||
|
box().apply({
|
||||||
|
height: 40
|
||||||
|
}),
|
||||||
|
box().apply({
|
||||||
|
height: 60
|
||||||
|
}),
|
||||||
|
box().apply({
|
||||||
|
height: 40
|
||||||
|
}),
|
||||||
|
box().apply({
|
||||||
|
height: 20
|
||||||
|
}),
|
||||||
|
]).also(it => {
|
||||||
|
it.space = 20
|
||||||
|
it.gravity = gravity().bottom()
|
||||||
|
}),
|
||||||
|
label("Horizontal Layout(Align to Center)"),
|
||||||
|
hlayout([
|
||||||
|
box().apply({
|
||||||
|
height: 20
|
||||||
|
}),
|
||||||
|
box().apply({
|
||||||
|
height: 40
|
||||||
|
}),
|
||||||
|
box().apply({
|
||||||
|
height: 60
|
||||||
|
}),
|
||||||
|
box().apply({
|
||||||
|
height: 40
|
||||||
|
}),
|
||||||
|
box().apply({
|
||||||
|
height: 20
|
||||||
|
}),
|
||||||
|
]).also(it => {
|
||||||
|
it.space = 20
|
||||||
|
it.gravity = gravity().center()
|
||||||
|
}),
|
||||||
|
label("Horizontal Layout(Weight)"),
|
||||||
|
hlayout([
|
||||||
|
boxStr('weight=1', 3).apply({
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.EXACTLY,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
weight: 1,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
box(2),
|
||||||
|
box(4),
|
||||||
|
]).apply({
|
||||||
|
width: 200,
|
||||||
|
height: 30,
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.EXACTLY,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
},
|
||||||
|
bgColor: Color.parse('#eeeeee'),
|
||||||
|
gravity: gravity().center(),
|
||||||
|
} as IHLayout),
|
||||||
|
hlayout([
|
||||||
|
box(3),
|
||||||
|
boxStr('weight=1', 2).apply({
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.EXACTLY,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
weight: 1,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
box(4),
|
||||||
|
]).apply({
|
||||||
|
width: 200,
|
||||||
|
height: 30,
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.EXACTLY,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
},
|
||||||
|
bgColor: Color.parse('#eeeeee'),
|
||||||
|
gravity: gravity().center(),
|
||||||
|
} as IHLayout),
|
||||||
|
hlayout([
|
||||||
|
box(3),
|
||||||
|
box(2),
|
||||||
|
boxStr('weight=1', 4).apply({
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.EXACTLY,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
weight: 1,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
]).apply({
|
||||||
|
width: 200,
|
||||||
|
height: 30,
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.EXACTLY,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
},
|
||||||
|
bgColor: Color.parse('#eeeeee'),
|
||||||
|
gravity: gravity().center(),
|
||||||
|
} as IHLayout),
|
||||||
|
hlayout([
|
||||||
|
boxStr('weight=1', 3).apply({
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.EXACTLY,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
weight: 1,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
boxStr('weight=1', 2).apply({
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.EXACTLY,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
weight: 1,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
box(4),
|
||||||
|
]).apply({
|
||||||
|
width: 200,
|
||||||
|
height: 30,
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.EXACTLY,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
},
|
||||||
|
bgColor: Color.parse('#eeeeee'),
|
||||||
|
gravity: gravity().center(),
|
||||||
|
} as IHLayout),
|
||||||
|
hlayout([
|
||||||
|
boxStr('weight=1', 3).apply({
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.EXACTLY,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
weight: 1,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
boxStr('weight=1', 2).apply({
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.EXACTLY,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
weight: 1,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
boxStr('weight=1', 4).apply({
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.EXACTLY,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
weight: 1,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
]).apply({
|
||||||
|
width: 200,
|
||||||
|
height: 30,
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.EXACTLY,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
},
|
||||||
|
bgColor: Color.parse('#eeeeee'),
|
||||||
|
gravity: gravity().center(),
|
||||||
|
} as IHLayout),
|
||||||
|
]).also(it => {
|
||||||
|
it.space = 20
|
||||||
|
it.gravity = gravity().center()
|
||||||
|
}),
|
||||||
|
vlayout([
|
||||||
|
label("Vertical Layout(Algin to Left)"),
|
||||||
|
vlayout([
|
||||||
|
box(1).apply({
|
||||||
|
width: 20
|
||||||
|
}),
|
||||||
|
box(1).apply({
|
||||||
|
width: 40
|
||||||
|
}),
|
||||||
|
box(1).apply({
|
||||||
|
width: 60
|
||||||
|
}),
|
||||||
|
box(1).apply({
|
||||||
|
width: 40
|
||||||
|
}),
|
||||||
|
box(1).apply({
|
||||||
|
width: 20
|
||||||
|
}),
|
||||||
|
]).apply({
|
||||||
|
space: 20
|
||||||
|
} as IVLayout),
|
||||||
|
label("Vertical Layout(Algin to Right)"),
|
||||||
|
vlayout([
|
||||||
|
box(1).apply({
|
||||||
|
width: 20
|
||||||
|
}),
|
||||||
|
box(1).apply({
|
||||||
|
width: 40
|
||||||
|
}),
|
||||||
|
box(1).apply({
|
||||||
|
width: 60
|
||||||
|
}),
|
||||||
|
box(1).apply({
|
||||||
|
width: 40
|
||||||
|
}),
|
||||||
|
box(1).apply({
|
||||||
|
width: 20
|
||||||
|
}),
|
||||||
|
]).apply({
|
||||||
|
space: 20,
|
||||||
|
gravity: gravity().right(),
|
||||||
|
} as IVLayout),
|
||||||
|
label("Vertical Layout(Algin to Center)"),
|
||||||
|
vlayout([
|
||||||
|
box(1).apply({
|
||||||
|
width: 20
|
||||||
|
}),
|
||||||
|
box(1).apply({
|
||||||
|
width: 40
|
||||||
|
}),
|
||||||
|
box(1).apply({
|
||||||
|
width: 60
|
||||||
|
}),
|
||||||
|
box(1).apply({
|
||||||
|
width: 40
|
||||||
|
}),
|
||||||
|
box(1).apply({
|
||||||
|
width: 20
|
||||||
|
}),
|
||||||
|
]).apply({
|
||||||
|
space: 20,
|
||||||
|
gravity: gravity().center(),
|
||||||
|
} as IVLayout),
|
||||||
|
label("Vertical Layout(Weight)"),
|
||||||
|
hlayout([
|
||||||
|
|
||||||
|
vlayout([
|
||||||
|
boxStr('weight=1', 3).apply({
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.AT_MOST,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
weight: 1,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
box(2).apply({
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.AT_MOST,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
box(4).apply({
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.AT_MOST,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
]).apply({
|
||||||
|
width: 100,
|
||||||
|
height: 200,
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.EXACTLY,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
},
|
||||||
|
bgColor: Color.parse('#eeeeee'),
|
||||||
|
gravity: gravity().center(),
|
||||||
|
} as IVLayout),
|
||||||
|
vlayout([
|
||||||
|
box(3).apply({
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.AT_MOST,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
boxStr('weight=1', 2).apply({
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.AT_MOST,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
weight: 1,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
box(4).apply({
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.AT_MOST,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
]).apply({
|
||||||
|
width: 100,
|
||||||
|
height: 200,
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.EXACTLY,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
},
|
||||||
|
bgColor: Color.parse('#eeeeee'),
|
||||||
|
gravity: gravity().center(),
|
||||||
|
} as IVLayout),
|
||||||
|
vlayout([
|
||||||
|
box(3).apply({
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.AT_MOST,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
box(2).apply({
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.AT_MOST,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
boxStr('weight=1', 4).apply({
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.AT_MOST,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
weight: 1,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
]).apply({
|
||||||
|
width: 100,
|
||||||
|
height: 200,
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.EXACTLY,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
},
|
||||||
|
bgColor: Color.parse('#eeeeee'),
|
||||||
|
gravity: gravity().center(),
|
||||||
|
} as IVLayout),
|
||||||
|
vlayout([
|
||||||
|
boxStr('weight=1', 3).apply({
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.AT_MOST,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
weight: 1,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
boxStr('weight=1', 2).apply({
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.AT_MOST,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
weight: 1,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
box(4).apply({
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.AT_MOST,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
]).apply({
|
||||||
|
width: 100,
|
||||||
|
height: 200,
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.EXACTLY,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
},
|
||||||
|
bgColor: Color.parse('#eeeeee'),
|
||||||
|
gravity: gravity().center(),
|
||||||
|
} as IVLayout),
|
||||||
|
vlayout([
|
||||||
|
boxStr('weight=1', 3).apply({
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.AT_MOST,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
weight: 1,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
boxStr('weight=1', 2).apply({
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.AT_MOST,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
weight: 1,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
boxStr('weight=1', 4).apply({
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.AT_MOST,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
weight: 1,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
]).apply({
|
||||||
|
width: 100,
|
||||||
|
height: 200,
|
||||||
|
layoutConfig: {
|
||||||
|
widthSpec: LayoutSpec.EXACTLY,
|
||||||
|
heightSpec: LayoutSpec.EXACTLY,
|
||||||
|
},
|
||||||
|
bgColor: Color.parse('#eeeeee'),
|
||||||
|
gravity: gravity().center(),
|
||||||
|
} as IVLayout),
|
||||||
|
]).also(it => {
|
||||||
|
it.space = 20
|
||||||
|
}),
|
||||||
|
|
||||||
|
]).also(it => {
|
||||||
|
it.space = 20
|
||||||
|
it.gravity = gravity().left()
|
||||||
|
})
|
||||||
|
]).also(it => {
|
||||||
|
it.space = 20
|
||||||
|
}),
|
||||||
|
).also(it => {
|
||||||
|
it.layoutConfig = {
|
||||||
|
widthSpec: LayoutSpec.WRAP_CONTENT,
|
||||||
|
heightSpec: LayoutSpec.WRAP_CONTENT,
|
||||||
|
alignment: gravity().centerX(),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.in(rootView)
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
import { Group, Panel, List, text, gravity, Color, Stack, LayoutSpec, list, NativeCall, listItem, log, vlayout, Gravity, hlayout } from "doric";
|
import { Group, Panel, List, text, gravity, Color, Stack, LayoutSpec, list, NativeCall, listItem, log, vlayout, Gravity, hlayout, Text } from "doric";
|
||||||
const colors = [
|
const colors = [
|
||||||
"#f0932b",
|
"#f0932b",
|
||||||
"#eb4d4b",
|
"#eb4d4b",
|
||||||
@ -10,7 +10,7 @@ const colors = [
|
|||||||
@Entry
|
@Entry
|
||||||
class ListPanel extends Panel {
|
class ListPanel extends Panel {
|
||||||
build(rootView: Group): void {
|
build(rootView: Group): void {
|
||||||
rootView.addChild(vlayout([
|
vlayout([
|
||||||
text({
|
text({
|
||||||
text: "ListDemo",
|
text: "ListDemo",
|
||||||
layoutConfig: {
|
layoutConfig: {
|
||||||
@ -26,6 +26,7 @@ class ListPanel extends Panel {
|
|||||||
list({
|
list({
|
||||||
itemCount: 1000,
|
itemCount: 1000,
|
||||||
renderItem: (idx: number) => {
|
renderItem: (idx: number) => {
|
||||||
|
let counter!: Text
|
||||||
return listItem(
|
return listItem(
|
||||||
hlayout([
|
hlayout([
|
||||||
text({
|
text({
|
||||||
@ -39,43 +40,40 @@ class ListPanel extends Panel {
|
|||||||
textColor: Color.parse("#ffffff"),
|
textColor: Color.parse("#ffffff"),
|
||||||
textSize: 20,
|
textSize: 20,
|
||||||
height: 50,
|
height: 50,
|
||||||
bgColor: Color.parse('#00ff00'),
|
|
||||||
}),
|
}),
|
||||||
text({
|
text({
|
||||||
layoutConfig: {
|
|
||||||
widthSpec: LayoutSpec.EXACTLY,
|
|
||||||
heightSpec: LayoutSpec.EXACTLY,
|
|
||||||
alignment: gravity().center(),
|
|
||||||
weight: 1,
|
|
||||||
},
|
|
||||||
text: `Right`,
|
|
||||||
textAlignment: gravity().right(),
|
|
||||||
textColor: Color.parse("#ffffff"),
|
textColor: Color.parse("#ffffff"),
|
||||||
textSize: 20,
|
textSize: 20,
|
||||||
height: 50,
|
|
||||||
bgColor: Color.parse('#00ffff'),
|
|
||||||
}).also(it => {
|
}).also(it => {
|
||||||
let start = 0
|
counter = it
|
||||||
it.onClick = () => {
|
it.layoutConfig = {
|
||||||
log(`clicked text:${start}`)
|
widthSpec: LayoutSpec.WRAP_CONTENT,
|
||||||
it.text = `${start++}`
|
heightSpec: LayoutSpec.WRAP_CONTENT,
|
||||||
|
margin: {
|
||||||
|
left: 10,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}),
|
})
|
||||||
]).also(it => {
|
]).also(it => {
|
||||||
it.layoutConfig = {
|
it.layoutConfig = {
|
||||||
widthSpec: LayoutSpec.AT_MOST,
|
widthSpec: LayoutSpec.AT_MOST,
|
||||||
heightSpec: LayoutSpec.WRAP_CONTENT,
|
heightSpec: LayoutSpec.WRAP_CONTENT,
|
||||||
alignment: gravity().center(),
|
margin: {
|
||||||
|
bottom: 2,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
it.gravity = gravity().center()
|
||||||
|
it.bgColor = Color.parse(colors[idx % colors.length])
|
||||||
|
let clicked = 0
|
||||||
|
it.onClick = () => {
|
||||||
|
counter.text = `Item Clicked ${++clicked}`
|
||||||
}
|
}
|
||||||
it.bgColor = Color.parse('#ffffff')
|
|
||||||
})
|
})
|
||||||
).also(it => {
|
).also(it => {
|
||||||
it.bgColor = Color.parse(colors[idx % colors.length])
|
|
||||||
it.layoutConfig = {
|
it.layoutConfig = {
|
||||||
widthSpec: LayoutSpec.AT_MOST,
|
widthSpec: LayoutSpec.AT_MOST,
|
||||||
heightSpec: LayoutSpec.EXACTLY,
|
heightSpec: LayoutSpec.WRAP_CONTENT,
|
||||||
}
|
}
|
||||||
it.height = 100
|
|
||||||
it.onClick = () => {
|
it.onClick = () => {
|
||||||
log(`Click item at ${idx}`)
|
log(`Click item at ${idx}`)
|
||||||
it.height += 10
|
it.height += 10
|
||||||
@ -99,6 +97,7 @@ class ListPanel extends Panel {
|
|||||||
widthSpec: LayoutSpec.AT_MOST,
|
widthSpec: LayoutSpec.AT_MOST,
|
||||||
heightSpec: LayoutSpec.AT_MOST,
|
heightSpec: LayoutSpec.AT_MOST,
|
||||||
}
|
}
|
||||||
}))
|
it.bgColor = Color.WHITE
|
||||||
|
}).in(rootView)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -51,7 +51,7 @@
|
|||||||
C043B7BA79339ABA1CF46881 /* libPods-Example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Example.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
C043B7BA79339ABA1CF46881 /* libPods-Example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Example.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
D751D19E97EF4EDD7588FEBE /* DemoVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DemoVC.m; sourceTree = "<group>"; };
|
D751D19E97EF4EDD7588FEBE /* DemoVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DemoVC.m; sourceTree = "<group>"; };
|
||||||
D751DDEC114E037231257E64 /* DemoVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DemoVC.h; sourceTree = "<group>"; };
|
D751DDEC114E037231257E64 /* DemoVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DemoVC.h; sourceTree = "<group>"; };
|
||||||
E2334AEB22E9D2060098A085 /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
E2334AEB22E9D2060098A085 /* Doric Playground.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Doric Playground.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
E2334AEE22E9D2060098A085 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
E2334AEE22E9D2060098A085 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||||
E2334AEF22E9D2060098A085 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
E2334AEF22E9D2060098A085 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
||||||
E2334AF122E9D2060098A085 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
|
E2334AF122E9D2060098A085 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
|
||||||
@ -136,7 +136,7 @@
|
|||||||
E2334AEC22E9D2060098A085 /* Products */ = {
|
E2334AEC22E9D2060098A085 /* Products */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
E2334AEB22E9D2060098A085 /* Example.app */,
|
E2334AEB22E9D2060098A085 /* Doric Playground.app */,
|
||||||
E2334B0322E9D2070098A085 /* ExampleTests.xctest */,
|
E2334B0322E9D2070098A085 /* ExampleTests.xctest */,
|
||||||
E2334B0E22E9D2070098A085 /* ExampleUITests.xctest */,
|
E2334B0E22E9D2070098A085 /* ExampleUITests.xctest */,
|
||||||
);
|
);
|
||||||
@ -200,7 +200,7 @@
|
|||||||
);
|
);
|
||||||
name = Example;
|
name = Example;
|
||||||
productName = Example;
|
productName = Example;
|
||||||
productReference = E2334AEB22E9D2060098A085 /* Example.app */;
|
productReference = E2334AEB22E9D2060098A085 /* Doric Playground.app */;
|
||||||
productType = "com.apple.product-type.application";
|
productType = "com.apple.product-type.application";
|
||||||
};
|
};
|
||||||
E2334B0222E9D2070098A085 /* ExampleTests */ = {
|
E2334B0222E9D2070098A085 /* ExampleTests */ = {
|
||||||
@ -603,7 +603,7 @@
|
|||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = pub.doric.Example;
|
PRODUCT_BUNDLE_IDENTIFIER = pub.doric.Example;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "Doric Playground";
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
@ -621,7 +621,7 @@
|
|||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = pub.doric.Example;
|
PRODUCT_BUNDLE_IDENTIFIER = pub.doric.Example;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "Doric Playground";
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "E2334AEA22E9D2060098A085"
|
BlueprintIdentifier = "E2334AEA22E9D2060098A085"
|
||||||
BuildableName = "Example.app"
|
BuildableName = "Doric Playground.app"
|
||||||
BlueprintName = "Example"
|
BlueprintName = "Example"
|
||||||
ReferencedContainer = "container:Example.xcodeproj">
|
ReferencedContainer = "container:Example.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
@ -27,6 +27,15 @@
|
|||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||||
|
<MacroExpansion>
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "E2334AEA22E9D2060098A085"
|
||||||
|
BuildableName = "Doric Playground.app"
|
||||||
|
BlueprintName = "Example"
|
||||||
|
ReferencedContainer = "container:Example.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</MacroExpansion>
|
||||||
<Testables>
|
<Testables>
|
||||||
<TestableReference
|
<TestableReference
|
||||||
skipped = "NO">
|
skipped = "NO">
|
||||||
@ -49,17 +58,6 @@
|
|||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
</TestableReference>
|
</TestableReference>
|
||||||
</Testables>
|
</Testables>
|
||||||
<MacroExpansion>
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "E2334AEA22E9D2060098A085"
|
|
||||||
BuildableName = "Example.app"
|
|
||||||
BlueprintName = "Example"
|
|
||||||
ReferencedContainer = "container:Example.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</MacroExpansion>
|
|
||||||
<AdditionalOptions>
|
|
||||||
</AdditionalOptions>
|
|
||||||
</TestAction>
|
</TestAction>
|
||||||
<LaunchAction
|
<LaunchAction
|
||||||
buildConfiguration = "Debug"
|
buildConfiguration = "Debug"
|
||||||
@ -76,13 +74,11 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "E2334AEA22E9D2060098A085"
|
BlueprintIdentifier = "E2334AEA22E9D2060098A085"
|
||||||
BuildableName = "Example.app"
|
BuildableName = "Doric Playground.app"
|
||||||
BlueprintName = "Example"
|
BlueprintName = "Example"
|
||||||
ReferencedContainer = "container:Example.xcodeproj">
|
ReferencedContainer = "container:Example.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
</BuildableProductRunnable>
|
</BuildableProductRunnable>
|
||||||
<AdditionalOptions>
|
|
||||||
</AdditionalOptions>
|
|
||||||
</LaunchAction>
|
</LaunchAction>
|
||||||
<ProfileAction
|
<ProfileAction
|
||||||
buildConfiguration = "Release"
|
buildConfiguration = "Release"
|
||||||
@ -95,7 +91,7 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "E2334AEA22E9D2060098A085"
|
BlueprintIdentifier = "E2334AEA22E9D2060098A085"
|
||||||
BuildableName = "Example.app"
|
BuildableName = "Doric Playground.app"
|
||||||
BlueprintName = "Example"
|
BlueprintName = "Example"
|
||||||
ReferencedContainer = "container:Example.xcodeproj">
|
ReferencedContainer = "container:Example.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
|
@ -252,8 +252,16 @@ export abstract class View implements Modeling, IView {
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apply(config: IView) {
|
||||||
|
for (let key in config) {
|
||||||
|
Reflect.set(this, key, Reflect.get(config, key, config), this)
|
||||||
|
}
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
in(group: Group) {
|
in(group: Group) {
|
||||||
group.addChild(this)
|
group.addChild(this)
|
||||||
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
nativeChannel(context: any, name: string) {
|
nativeChannel(context: any, name: string) {
|
||||||
|
@ -13,37 +13,6 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
// import { View, Stack, VLayout, HLayout } from "../ui/view"
|
|
||||||
|
|
||||||
// export type ViewBlock = () => View
|
|
||||||
|
|
||||||
// export function stack(blocks: ViewBlock[]) {
|
|
||||||
// return takeAlso(new Stack)(
|
|
||||||
// it => {
|
|
||||||
// for (let block of blocks) {
|
|
||||||
// it.addChild(block())
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
|
|
||||||
// export function vlayout(blocks: ViewBlock[]) {
|
|
||||||
// return takeAlso(new VLayout)(
|
|
||||||
// it => {
|
|
||||||
// for (let block of blocks) {
|
|
||||||
// it.addChild(block())
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
|
|
||||||
// export function hlayout(blocks: ViewBlock[]) {
|
|
||||||
// return takeAlso(new HLayout)(
|
|
||||||
// it => {
|
|
||||||
// for (let block of blocks) {
|
|
||||||
// it.addChild(block())
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
|
|
||||||
export function take<T>(target: T) {
|
export function take<T>(target: T) {
|
||||||
return (block: (p: T) => void) => {
|
return (block: (p: T) => void) => {
|
||||||
block(target)
|
block(target)
|
||||||
|
@ -35,7 +35,7 @@ export class Color implements Modeling {
|
|||||||
_value: number = 0
|
_value: number = 0
|
||||||
|
|
||||||
constructor(v: number) {
|
constructor(v: number) {
|
||||||
this._value = v
|
this._value = v | 0x0
|
||||||
}
|
}
|
||||||
|
|
||||||
static parse(str: string) {
|
static parse(str: string) {
|
||||||
|
Reference in New Issue
Block a user