Skip to content

Commit

Permalink
compilacion de codigo y creacion de tipos
Browse files Browse the repository at this point in the history
  • Loading branch information
everskyblue committed Apr 3, 2023
1 parent d9963a0 commit 4099c60
Show file tree
Hide file tree
Showing 27 changed files with 210 additions and 15 deletions.
1 change: 1 addition & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ function addView(...widgets) {
return navigation.append(...widgets);
}
exports.default = addView;
__exportStar(require("./modal"), exports);
__exportStar(require("./navigation"), exports);
__exportStar(require("./preference"), exports);
4 changes: 2 additions & 2 deletions dist/modal/animation-time.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ class AnimationTime {
}
exports.default = AnimationTime;
AnimationTime.LONG = 3000;
AnimationTime.MEDIUM = 2000;
AnimationTime.SHORT = 1000;
AnimationTime.MEDIUM = 2100;
AnimationTime.SHORT = 1500;
19 changes: 14 additions & 5 deletions dist/modal/animation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.animate = exports.animateHidden = exports.animateShow = void 0;
function animateShow(element, delay, duration) {
Expand All @@ -17,14 +26,14 @@ function animateHidden(element, delay, duration) {
}, {
delay,
duration,
easing: "ease-in-out",
easing: "ease-out",
});
}
exports.animateHidden = animateHidden;
function animate(element, delay, duration) {
return Promise.all([
animateShow(element, delay, duration),
animateHidden(element, delay, duration),
]);
return __awaiter(this, void 0, void 0, function* () {
yield animateShow(element, delay, 300);
yield animateHidden(element, duration, duration);
});
}
exports.animate = animate;
4 changes: 2 additions & 2 deletions dist/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Modal {
const modal_content_scrollable = new tabris_1.ScrollView({
layoutData: "stretchX",
}).appendTo(modal_content);
modal_container.onBoundsChanged(({ value, target }) => {
modal_container.onBoundsChanged(({ value }) => {
const { height: contentViewHeight } = tabris_1.contentView.bounds;
if (contentViewHeight < value.height) {
modal_container.layoutData = Object.assign(Object.assign({}, properties_modal_container), { height: value.height > contentViewHeight
Expand Down Expand Up @@ -105,7 +105,7 @@ class Modal {
});
Object.defineProperty(this, "show", {
configurable: false,
value: (view) => {
value: () => {
if (!isAddButtons) {
isAddButtons = true;
modal_container.append(new tabris_1.Composite({
Expand Down
9 changes: 6 additions & 3 deletions dist/modal/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const tabris_1 = require("tabris");
const animation_time_1 = require("./animation-time");
const animation_1 = require("./animation");
class Toast extends animation_time_1.default {
constructor(message) {
constructor(message, duration) {
super();
const size = tabris_1.sizeMeasurement.measureTextsSync([
{ text: message, font: "12px" },
Expand All @@ -37,12 +37,15 @@ class Toast extends animation_time_1.default {
const modal = (0, tabris_1.Composite)(Object.assign({ background: "black", padding: 10, cornerRadius: 10, bottom: 30, opacity: 0 }, props)).append(textview);
Object.defineProperty(this, "show", {
configurable: false,
value: (time) => __awaiter(this, void 0, void 0, function* () {
value: () => __awaiter(this, void 0, void 0, function* () {
tabris_1.contentView.append(modal);
yield (0, animation_1.animate)(modal, time, Toast.SHORT);
yield (0, animation_1.animate)(modal, 0, duration);
modal.dispose();
}),
});
}
static makeText(msg, duration = Toast.SHORT) {
return new Toast(msg, duration);
}
}
exports.default = Toast;
5 changes: 2 additions & 3 deletions dist/navigation/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ class MenuItem extends tabris_1.Composite {
});
}
}
function menuDrawer(menu, eventSelectMenu) {
function menuDrawer(menus, eventSelectMenu) {
const layoutMenu = (0, tabris_1.ScrollView)({
id: "scrollableLayoutMenuDrawer",
top: tabris_1.Constraint.prev,
left: 0,
right: 0,
bottom: 0,
}).append(Object.keys(menu).map((key) => {
const data = menu[key];
}).append(menus.map((data) => {
const row = (0, tabris_1.Row)({
layoutData: "stretch",
alignment: "centerY",
Expand Down
7 changes: 7 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { NavigationView } from "tabris";
import type { Page, Action, SearchAction } from "tabris";
declare function addView(...widgets: (Page | Action | SearchAction)[]): NavigationView<import("tabris").widgets.Page, import("tabris").widgets.Action>;
export default addView;
export * from "./modal";
export * from "./navigation";
export * from "./preference";
5 changes: 5 additions & 0 deletions types/modal/animation-time.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default class AnimationTime {
static LONG: number;
static MEDIUM: number;
static SHORT: number;
}
4 changes: 4 additions & 0 deletions types/modal/animation.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type { Widget } from "tabris";
export declare function animateShow(element: Widget<any>, delay: number, duration: number): Promise<void>;
export declare function animateHidden(element: Widget<any>, delay: number, duration: number): Promise<void>;
export declare function animate(element: Widget<any>, delay: number, duration: number): Promise<void>;
4 changes: 4 additions & 0 deletions types/modal/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { default as AnimationTime } from './animation-time';
export * from './animation';
export { default as Modal } from './modal';
export { default as Toast } from './toast';
16 changes: 16 additions & 0 deletions types/modal/modal.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Button, Listeners, Widget } from "tabris";
export default class Modal {
[k: string]: any;
remove: () => any;
show: () => any;
setButtonAccept: (text: string) => Listeners<{
target: Button;
}>;
setButtonCancel: (text: string) => Listeners<{
target: Button;
}>;
addView: (...view: Widget<any>[]) => any;
removeView: () => any;
removeButtons: () => any;
constructor(attrs?: any);
}
6 changes: 6 additions & 0 deletions types/modal/toast.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import AnimationTime from "./animation-time";
export default class Toast extends AnimationTime {
show: (time: number) => any;
constructor(message: string, duration: number);
static makeText(msg: string, duration?: number): Toast;
}
20 changes: 20 additions & 0 deletions types/navigation/CoordinatePage.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { NavigationView, Properties as PropertiesTabris } from "tabris";
type TypeWidget = any[] | Array<any[]>;
/**
* @description
* utilizar en JSX <CoordinatePageComponent></CoordinatePageComponent>
* encapsula la logica del menu de acciones del AppBar
* cuando se añade un Page con Action o SearchAction
* estas acciones desapareceran si la no es visible
* haciendo que la nueva pagina no tenga los menus anteriores
*/
export declare class CoordinatePageComponent extends NavigationView {
constructor(props: PropertiesTabris<CoordinatePageComponent>);
append(...widgets: TypeWidget): this;
}
/**
* @description
* encapsula en un proxy cuando se ejecute como funcion o instancia
*/
export declare const CoordinatePage: import("../utils/proxy").Callback<CoordinatePageComponent>;
export {};
2 changes: 2 additions & 0 deletions types/navigation/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './CoordinatePage';
export * from './menu';
12 changes: 12 additions & 0 deletions types/navigation/menu.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Composite } from "tabris";
type MenuItemOf = MenuItem;
interface IMenuItemOption {
id: string;
text: string;
image?: string;
}
declare class MenuItem extends Composite {
constructor(id: string);
}
export type { MenuItemOf };
export declare function menuDrawer(menus: IMenuItemOption[], eventSelectMenu: (menu: MenuItem) => void): void;
7 changes: 7 additions & 0 deletions types/preference/AbstractCheked.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { CheckBox, Properties, RadioButton, Switch } from "tabris";
import ItemPreference from "./AbstractItemPreference";
export declare abstract class Checked extends ItemPreference {
constructor(props: Pick<any, any>);
addListener(checkButton: RadioButton | Switch | CheckBox, originalOnSelect: Function): void;
abstract _getButton(props: Properties<CheckBox | Switch | RadioButton>): CheckBox | Switch | RadioButton;
}
19 changes: 19 additions & 0 deletions types/preference/AbstractItemPreference.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import "string-tocapitalize";
import { Composite, Properties, WidgetTapEvent } from "tabris";
export interface PreferenceParams {
key: string;
value: string | number | boolean;
title: string;
summary: string;
}
type SelectEvent = (event: WidgetTapEvent<ItemPreference>) => any;
export default abstract class ItemPreference extends Composite implements PreferenceParams {
title: string;
summary: string;
key: string;
value: string | number | boolean;
set onSelect(fn: (event: SelectEvent) => any);
get onSelect(): (event: SelectEvent) => any;
constructor(props: Properties<ItemPreference>);
}
export {};
7 changes: 7 additions & 0 deletions types/preference/CheckBoxPreference.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Properties } from "tabris";
import { Checked } from "./AbstractCheked";
export declare class CheckBoxPreferenceComponent extends Checked {
constructor(props: Properties<CheckBoxPreferenceComponent>);
_getButton(props: Properties<CheckBoxPreferenceComponent>): import("tabris").widgets.CheckBox;
}
export declare const CheckBoxPreference: import("../utils/proxy").Callback<CheckBoxPreferenceComponent>;
16 changes: 16 additions & 0 deletions types/preference/ListPreference.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { RadioButton, Properties } from "tabris";
import { Checked } from "./AbstractCheked";
export interface IEntry {
id?: string;
text: string;
checked?: boolean;
}
export declare class ListPreferenceComponent extends Checked {
entries: IEntry[];
textButtonAccept: string;
_getButton(): RadioButton;
constructor(props: Properties<ListPreferenceComponent> & {
onSelect?: any;
});
}
export declare const ListPreference: import("../utils/proxy").Callback<ListPreferenceComponent>;
5 changes: 5 additions & 0 deletions types/preference/PreferenceScreen.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Page, Properties } from "tabris";
export declare class PreferenceScreenComponent extends Page {
constructor(props?: Properties<PreferenceScreenComponent>);
}
export declare const PreferenceScreen: import("../utils/proxy").Callback<PreferenceScreenComponent>;
8 changes: 8 additions & 0 deletions types/preference/SwitchPreference.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Properties } from "tabris";
import { Checked } from "./AbstractCheked";
export declare class SwitchPreferenceComponent extends Checked {
onChange: any;
constructor(props: Properties<SwitchPreferenceComponent>);
_getButton(props: Properties<SwitchPreferenceComponent>): import("tabris").widgets.Switch;
}
export declare const SwitchPreference: import("../utils/proxy").Callback<SwitchPreferenceComponent>;
6 changes: 6 additions & 0 deletions types/preference/TextPreference.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { TextView, Properties } from "tabris";
import ItemPreference from "./AbstractItemPreference";
export declare class TextPreferenceComponent extends ItemPreference {
constructor(props: Properties<TextView>);
}
export declare const TextPreference: import("../utils/proxy").Callback<TextPreferenceComponent>;
8 changes: 8 additions & 0 deletions types/preference/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export * from './AbstractCheked';
export { default as AbstractItemPreference } from './AbstractItemPreference';
export * from './CheckBoxPreference';
export * from './SwitchPreference';
export * from './TextPreference';
export * from './PreferenceScreen';
export * from './storage';
export * from './ListPreference';
5 changes: 5 additions & 0 deletions types/preference/storage.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export declare const name_key_pref = "voir-native-preference";
export declare const $preference: any;
export declare const setPreference: (key: string, value: any) => void;
export declare const getValuePreference: (key: string) => any;
export declare const existsKeyPreference: (key: string) => boolean;
3 changes: 3 additions & 0 deletions types/utils/define-property.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { AnyWidget } from "tabris";
declare const _default: (widget: AnyWidget, name: string, props: any) => void;
export default _default;
3 changes: 3 additions & 0 deletions types/utils/helpers.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { CallbackInstance } from "./proxy";
import type { Composite } from "tabris";
export declare function createInstance<ClassType extends Composite>(props: any, $Class: CallbackInstance<ClassType>): ClassType;
20 changes: 20 additions & 0 deletions types/utils/proxy.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { PreferenceParams } from "../preference/AbstractItemPreference";
import { CoordinatePageComponent } from "../navigation";
import { IEntry, ListPreferenceComponent, PreferenceScreenComponent } from "../preference";
import type { AnyWidget, CheckBox, Composite, JSXAttributes, PropertyChangedEvent, RadioButton, RadioButtonSelectEvent, Switch } from "tabris";
type CallbackAppend = (widgets: any[]) => any;
type OptionalAtrributes<T> = {
[K in keyof T]?: T[K];
};
type Attributes<View> = View extends PreferenceScreenComponent | CoordinatePageComponent ? JSXAttributes<View> & {
children?: AnyWidget[];
} : OptionalAtrributes<PreferenceParams> & {
onSelect?: (event: View extends RadioButton ? RadioButtonSelectEvent : PropertyChangedEvent<RadioButton | Switch | CheckBox, boolean>) => any;
} & (View extends ListPreferenceComponent ? {
entries: IEntry[];
} : {});
export type CallbackInstance<View extends AnyWidget> = new (props: Attributes<View>) => View;
export type Callable<View extends AnyWidget> = (props?: Attributes<View>) => View;
export type Callback<View extends AnyWidget> = CallbackInstance<View> | Callable<View>;
export declare function createProxies<T extends Composite>(funReceivedProxy: Callback<T>, funAppend?: CallbackAppend): Callback<T>;
export {};

0 comments on commit 4099c60

Please sign in to comment.