2024-12-04 02:35:06 +08:00
|
|
|
import { HttpClient } from "core/http";
|
|
|
|
import { CapabilityService } from "core/capability";
|
|
|
|
import { Serializable } from "interface/serializableType";
|
2024-12-08 00:55:12 +08:00
|
|
|
import { createElement, memo } from 'react';
|
2024-12-03 01:37:02 +08:00
|
|
|
|
|
|
|
export class Layout {
|
|
|
|
private http: HttpClient;
|
|
|
|
private capability: CapabilityService;
|
2024-12-08 00:55:12 +08:00
|
|
|
private readonly MemoizedElement: React.MemoExoticComponent<(props: {
|
|
|
|
children: React.ReactNode;
|
|
|
|
args?: Serializable;
|
|
|
|
onTouchStart?: (e: TouchEvent) => void;
|
|
|
|
onTouchEnd?: (e: TouchEvent) => void;
|
|
|
|
}) => React.ReactNode>;
|
2024-12-03 01:37:02 +08:00
|
|
|
|
|
|
|
constructor(
|
|
|
|
public element: (props: {
|
|
|
|
children: React.ReactNode;
|
|
|
|
args?: Serializable;
|
2024-12-05 16:58:57 +08:00
|
|
|
onTouchStart?: (e: TouchEvent) => void;
|
|
|
|
onTouchEnd?: (e: TouchEvent) => void;
|
2024-12-03 01:37:02 +08:00
|
|
|
}) => React.ReactNode,
|
|
|
|
services?: {
|
|
|
|
http?: HttpClient;
|
|
|
|
capability?: CapabilityService;
|
2024-12-04 02:35:06 +08:00
|
|
|
},
|
2024-12-03 01:37:02 +08:00
|
|
|
) {
|
|
|
|
this.http = services?.http || HttpClient.getInstance();
|
|
|
|
this.capability = services?.capability || CapabilityService.getInstance();
|
2024-12-08 00:55:12 +08:00
|
|
|
this.MemoizedElement = memo(element);
|
2024-12-03 01:37:02 +08:00
|
|
|
}
|
|
|
|
|
2024-12-05 16:58:57 +08:00
|
|
|
render(props: {
|
|
|
|
children: React.ReactNode;
|
|
|
|
args?: Serializable;
|
|
|
|
onTouchStart?: (e: TouchEvent) => void;
|
|
|
|
onTouchEnd?: (e: TouchEvent) => void;
|
|
|
|
}) {
|
2024-12-08 00:55:12 +08:00
|
|
|
return createElement(this.MemoizedElement, {
|
2024-12-05 16:58:57 +08:00
|
|
|
...props,
|
|
|
|
onTouchStart: props.onTouchStart,
|
|
|
|
onTouchEnd: props.onTouchEnd
|
|
|
|
});
|
2024-12-03 01:37:02 +08:00
|
|
|
}
|
2024-12-04 02:35:06 +08:00
|
|
|
}
|