Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coli integration #8

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions example/node/package.json → example/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "example",
"version": "0.0.0",
"license": "MIT",
"dependencies": {
"@bridged.xyz/flutter-builder": "file:../.."
"@bridged.xyz/flutter-builder": "1.23.0-7.0.pre.40"
},
"devDependencies": {
"ts-node": "^9.0.0",
"typescript": "^4.0.5"
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"esModuleInterop": true,
"experimentalDecorators": true
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions flutter-builder/lib/builder/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { AstBuildableTree } from "@coli.codes/dart-builder";
import { AstBuildingTree } from "@coli.codes/dart-builder";

export { AstBuildableTree as BuildableTree, AstBuildingTree as BuildingTree };
File renamed without changes.
File renamed without changes.
32 changes: 32 additions & 0 deletions flutter-builder/lib/dart-ui/color.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { BuildableTree } from "../builder";
import { defaultParam } from "@coli.codes/builder-annotations";
import { Snippet } from "coli";

/**
* https://api.flutter.dev/flutter/dart-ui/Color-class.html
*/
export class Color extends BuildableTree {
@defaultParam()
value: Snippet | number;
constructor(value?: number) {
super();
if (value) {
this.value = Snippet.fromStatic<Snippet>("0x" + value?.toString(16));
} else {
throw "the value:number provided must be a valid color value";
}
}

static fromHex(hex: string): Color {
try {
hex = hex.replace("#", "");
return new Color(parseInt(hex, 16));
} catch (e) {
return undefined;
}
}

static fromRGBO(r: number, g: number, b: number, o: number): Color {
throw "not implemented";
}
}
9 changes: 9 additions & 0 deletions flutter-builder/lib/dart-ui/font-style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { EnumClass, EnumField } from "@coli.codes/builder/snippet/utils/enum";

/**
* https://api.flutter.dev/flutter/dart-ui/FontStyle-class.html
*/
export class FontStyle extends EnumClass {
static readonly italic = EnumField.fromStatic("FontStyle.italic");
static readonly normal = EnumField.fromStatic("FontStyle.normal");
}
36 changes: 36 additions & 0 deletions flutter-builder/lib/dart-ui/font-weight.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { EnumClass, EnumField } from "@coli.codes/builder/snippet/utils/enum";

export class FontWeight extends EnumClass {
/// Thin, the least thick
static w100 = EnumField.fromStatic("FontWeight.w100");

/// Extra-light
static w200 = EnumField.fromStatic("FontWeight.w200");

/// Light
static w300 = EnumField.fromStatic("FontWeight.w300");

/// Normal / regular / plain
static w400 = EnumField.fromStatic("FontWeight.w400");

/// Medium
static w500 = EnumField.fromStatic("FontWeight.w500");

/// Semi-bold
static w600 = EnumField.fromStatic("FontWeight.w600");

/// Bold
static w700 = EnumField.fromStatic("FontWeight.w700");

/// Extra-bold
static w800 = EnumField.fromStatic("FontWeight.w800");

/// Black, the most thick
static w900 = EnumField.fromStatic("FontWeight.w900");

/// The default font weight.
static normal = EnumField.fromStatic("FontWeight.normal");

/// A commonly used font weight that is heavier than normal.
static bold = EnumField.fromStatic("FontWeight.bold");
}
File renamed without changes.
19 changes: 19 additions & 0 deletions flutter-builder/lib/dart-ui/offset.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { double } from "@coli.codes/dart-builder";
import { defaultParam } from "@coli.codes/builder-annotations";
import { BuildableTree } from "../builder";

/**
* https://api.flutter.dev/flutter/dart-ui/Offset-class.html
*/
export class Offset extends BuildableTree {
@defaultParam()
dx: double;
@defaultParam()
dy: double;

constructor(dx: double, dy: double) {
super();
this.dx = dx;
this.dy = dy;
}
}
19 changes: 19 additions & 0 deletions flutter-builder/lib/dart-ui/radius.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Snippet } from "coli";
import { BuildableTree } from "../builder";
import { double } from "@coli.codes/dart-builder";
export class Radius extends BuildableTree {
static circular(radius: double): Radius {
return new Radius().extendWithFactory("circular").overrideArguments({
__default__: radius,
});
}

static elliptical(x: double, y: double): Radius {
return new Radius().extendWithFactory("elliptical").overrideArguments({
__default__x: x,
__default__y: y,
});
}

static readonly zero = Snippet.fromStatic("Radius.zero");
}
27 changes: 27 additions & 0 deletions flutter-builder/lib/dart-ui/rect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* https://api.flutter.dev/flutter/dart-ui/Rect-class.html
*/

import { double } from "@coli.codes/dart-builder";
import { Offset } from "./offset";
import { Size } from "./size";

export class Rect {
bottom: double;
bottomCenter: Offset;
bottomLeft: Offset;
bottomRight: Offset;
center: Offset;
centerLeft: Offset;
centerRight: Offset;
height: double;
left: double;
right: double;
shortestSide: double;
size: Size;
top: double;
topCenter: Offset;
topLeft: Offset;
topRight: Offset;
width: double;
}
13 changes: 13 additions & 0 deletions flutter-builder/lib/dart-ui/size.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { BuildableTree } from "../builder";
import { double } from "@coli.codes/dart-builder";

export class Size extends BuildableTree {
width: double;
height: double;

constructor(width: double, height: double) {
super();
this.width = width;
this.height = height;
}
}
13 changes: 13 additions & 0 deletions flutter-builder/lib/dart-ui/text-align.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Snippet } from "coli";

/**
* https://api.flutter.dev/flutter/dart-ui/TextAlign-class.html
*/
export class TextAlign extends Snippet {
static readonly center = Snippet.fromStatic("TextAlign.center");
static readonly end = Snippet.fromStatic("TextAlign.end");
static readonly justify = Snippet.fromStatic("TextAlign.justify");
static readonly left = Snippet.fromStatic("TextAlign.left");
static readonly right = Snippet.fromStatic("TextAlign.right");
static readonly start = Snippet.fromStatic("TextAlign.start");
}
12 changes: 12 additions & 0 deletions flutter-builder/lib/dart-ui/text-decoration-style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { EnumClass, EnumField } from "@coli.codes/builder/snippet/utils/enum";

/**
* https://api.flutter.dev/flutter/dart-ui/TextDecorationStyle-class.html
*/
export class TextDecorationStyle extends EnumClass {
static readonly dashed = EnumField.fromStatic("TextDecorationStyle.dashed");
static readonly dotted = EnumField.fromStatic("TextDecorationStyle.dotted");
static readonly double = EnumField.fromStatic("TextDecorationStyle.double");
static readonly solid = EnumField.fromStatic("TextDecorationStyle.solid");
static readonly wavy = EnumField.fromStatic("TextDecorationStyle.wavy");
}
13 changes: 13 additions & 0 deletions flutter-builder/lib/dart-ui/text-decoration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { EnumClass, EnumField } from "@coli.codes/builder/snippet/utils/enum";

/**
* https://api.flutter.dev/flutter/dart-ui/TextDecoration-class.html
*/
export class TextDecoration extends EnumClass {
static readonly lineThrough = EnumField.fromStatic(
"TextDecoration.lineThrough"
);
static readonly none = EnumField.fromStatic("TextDecoration.none");
static readonly overline = EnumField.fromStatic("TextDecoration.overline");
static readonly underline = EnumField.fromStatic("TextDecoration.underline");
}
9 changes: 9 additions & 0 deletions flutter-builder/lib/dart-ui/text-direction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { EnumClass, EnumField } from "@coli.codes/builder/snippet/utils/enum";

/**
* https://api.flutter.dev/flutter/dart-ui/TextDirection-class.html
*/
export class TextDirection extends EnumClass {
static readonly ltr = EnumField.fromStatic("TextDirection.ltr");
static readonly rtl = EnumField.fromStatic("TextDirection.rtl");
}
10 changes: 10 additions & 0 deletions flutter-builder/lib/dart-ui/tile-mode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { EnumClass, EnumField } from "@coli.codes/builder/snippet/utils/enum";

/**
* https://api.flutter.dev/flutter/dart-ui/TileMode-class.html
*/
export class TileMode extends EnumClass {
static readonly clamp = EnumField.fromStatic("TileMode.clamp");
static readonly mirror = EnumField.fromStatic("TileMode.mirror");
static readonly repeated = EnumField.fromStatic("TileMode.repeated");
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions flutter-builder/lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export * from "./widgets";
export * from "./dart-ui";
export * from "./vector-math-64";
export * from "./painting";
export * from "./material";
export * from "./rendering";
export * from "./dynamic";
export * from "./composer";
46 changes: 46 additions & 0 deletions flutter-builder/lib/material/chip.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { ShapeBorder, Widget } from "..";
import { Color, VoidCallback } from "../dart-ui";
import { TextStyle } from "../painting";
/**
* https://api.flutter.dev/flutter/material/Chip-class.html
*/
export class Chip extends Widget {
// onSelected?: VoidCallback
onDeleted?: VoidCallback;
deleteIcon?: Widget;
avartar?: Widget;
label: Widget;
labelStyle?: TextStyle;
backgroundColor?: Color;
splashColor?: Color;
shape?: ShapeBorder;
// height?: double

/**
* https://api.flutter.dev/flutter/material/Chip/Chip.html
*/
constructor(args: {
// onSelected?: VoidCallback
onDeleted?: VoidCallback;
deleteIcon?: Widget;
avartar?: Widget;
label: Widget;
labelStyle?: TextStyle;
backgroundColor?: Color;
splashColor?: Color;
shape?: ShapeBorder;
// height?: double
}) {
super();
// this.onSelected = args?.onSelected
this.onDeleted = args?.onDeleted;
this.deleteIcon = args?.deleteIcon;
this.avartar = args?.avartar;
this.label = args?.label;
this.labelStyle = args?.labelStyle;
this.backgroundColor = args?.backgroundColor;
this.splashColor = args?.splashColor;
this.shape = args?.shape;
// this.height = args?.height
}
}
19 changes: 19 additions & 0 deletions flutter-builder/lib/material/colors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Snippet } from "coli";
import { Color } from "../dart-ui/color";

/**
* https://api.flutter.dev/flutter/material/Colors-class.html
*/
export class Colors extends Snippet {
static get white(): Color {
return new Color(0xffffffffff).overrideSnippet("Colors.white");
}

static get black(): Color {
return new Color(0xff000000).overrideSnippet("Colors.black");
}

static get transparent(): Color {
return new Color(0xff000000).overrideSnippet("Colors.transparent");
}
}
28 changes: 28 additions & 0 deletions flutter-builder/lib/material/divider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Widget } from "..";
import { double } from "@coli.codes/dart-builder";
import { Color } from "../dart-ui";

/**
* https://api.flutter.dev/flutter/material/Divider-class.html
*/
export class Divider extends Widget {
height: double;
thickness: double;
indent?: double;
endIndent?: double;
color: Color;
constructor(args: {
height: double;
thickness: double;
indent?: double;
endIndent?: double;
color: Color;
}) {
super();
this.height = args.height;
this.thickness = args.thickness;
this.indent = args.indent;
this.endIndent = args.endIndent;
this.color = args.color;
}
}
Loading