feat:update template

This commit is contained in:
pengfei.zhou 2019-12-06 10:15:55 +08:00
parent 403e7c3a02
commit 458638bd42
5 changed files with 32 additions and 8 deletions

View File

@ -31,4 +31,13 @@ android {
implementation "pub.doric:core:0.1.0"
debugImplementation "pub.doric:core:0.1.0"
}
}
afterEvaluate {
buildJSBundle.exec()
}
task buildJSBundle(type: Exec) {
workingDir project.rootDir.getParent() + "/js"
commandLine 'doric', 'build'
}

View File

@ -5,17 +5,29 @@ import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import pub.doric.DoricPanel;
import pub.doric.utils.DoricUtils;
import pub.doric.DoricFragment;
public class MainActivity extends AppCompatActivity {
private final String BUNDLE_NAME = "__$__";
private DoricFragment doricFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
DoricPanel doricPanel = findViewById(R.id.doric_panel);
doricPanel.config(DoricUtils.readAssetFile(BUNDLE_NAME + ".js"), BUNDLE_NAME);
if (savedInstanceState == null) {
String scheme = "assets://" + BUNDLE_NAME + ".js";
this.doricFragment = DoricFragment.newInstance(scheme, BUNDLE_NAME);
this.getSupportFragmentManager().beginTransaction().add(R.id.root, this.doricFragment).commit();
}
}
@Override
public void onBackPressed() {
if (this.doricFragment.canPop()) {
this.doricFragment.pop();
} else {
super.onBackPressed();
}
}
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<pub.doric.DoricPanel xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/doric_panel"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent" />

View File

@ -1,7 +1,7 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>

View File

@ -1,7 +1,10 @@
import { Panel, Group, vlayout, layoutConfig, Gravity, IVLayout, text, Text, Color } from "doric";
import { Panel, Group, vlayout, layoutConfig, Gravity, IVLayout, text, Text, Color, navbar } from "doric";
@Entry
class __$__ extends Panel {
onShow() {
navbar(context).setTitle("__$__")
}
build(rootView: Group): void {
let number: Text
let count = 0