@umituz/react-native-video-editor 1.1.62 → 1.1.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/infrastructure/services/base/base-layer-operations.service.ts +201 -0
- package/src/infrastructure/services/image-layer-operations.service.ts +36 -101
- package/src/infrastructure/services/shape-layer-operations.service.ts +38 -47
- package/src/infrastructure/services/text-layer-operations.service.ts +45 -97
- package/src/infrastructure/utils/data-clone.utils.ts +32 -51
- package/src/infrastructure/utils/video-calculations.utils.ts +7 -25
- package/src/presentation/components/CollageEditorCanvas.tsx +23 -232
- package/src/presentation/components/SubtitleListPanel.tsx +46 -252
- package/src/presentation/components/collage/CollageCanvas.tsx +94 -0
- package/src/presentation/components/collage/CollageControls.tsx +115 -0
- package/src/presentation/components/collage/CollageLayoutSelector.tsx +100 -0
- package/src/presentation/components/subtitle/SubtitleListHeader.tsx +58 -0
- package/src/presentation/components/subtitle/SubtitleListItem.tsx +96 -0
- package/src/presentation/components/subtitle/SubtitleModal.tsx +162 -0
- package/src/presentation/components/subtitle/useSubtitleForm.ts +95 -0
- package/src/presentation/hooks/generic/use-layer-form.hook.ts +124 -0
- package/src/presentation/hooks/useImageLayerForm.ts +25 -22
- package/src/presentation/hooks/useTextLayerForm.ts +35 -45
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Manages form state for text layer editor
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { useState, useCallback } from "react";
|
|
7
6
|
import { useAppDesignTokens } from "@umituz/react-native-design-system/theme";
|
|
8
7
|
import type { TextLayer } from "../../domain/entities/video-project.types";
|
|
8
|
+
import { useLayerForm, type UseLayerFormConfig } from "./generic/use-layer-form.hook";
|
|
9
9
|
|
|
10
10
|
export interface TextLayerFormState {
|
|
11
11
|
text: string;
|
|
@@ -14,6 +14,7 @@ export interface TextLayerFormState {
|
|
|
14
14
|
fontWeight: "normal" | "bold" | "300" | "700";
|
|
15
15
|
color: string;
|
|
16
16
|
textAlign: "left" | "center" | "right";
|
|
17
|
+
[key: string]: unknown;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
interface UseTextLayerFormReturn {
|
|
@@ -36,65 +37,54 @@ export function useTextLayerForm(
|
|
|
36
37
|
): UseTextLayerFormReturn {
|
|
37
38
|
const tokens = useAppDesignTokens();
|
|
38
39
|
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const setText = useCallback((text: string) => {
|
|
50
|
-
setFormState((prev: TextLayerFormState) => ({ ...prev, text }));
|
|
51
|
-
}, []);
|
|
52
|
-
|
|
53
|
-
const setFontSize = useCallback((size: number) => {
|
|
54
|
-
setFormState((prev: TextLayerFormState) => ({ ...prev, fontSize: size }));
|
|
55
|
-
}, []);
|
|
56
|
-
|
|
57
|
-
const setFontFamily = useCallback((family: string) => {
|
|
58
|
-
setFormState((prev: TextLayerFormState) => ({ ...prev, fontFamily: family }));
|
|
59
|
-
}, []);
|
|
60
|
-
|
|
61
|
-
const setFontWeight = useCallback(
|
|
62
|
-
(weight: "normal" | "bold" | "300" | "700") => {
|
|
63
|
-
setFormState((prev: TextLayerFormState) => ({ ...prev, fontWeight: weight }));
|
|
40
|
+
const config: UseLayerFormConfig<TextLayerFormState> = {
|
|
41
|
+
initialValues: {
|
|
42
|
+
text: initialLayer?.content || "",
|
|
43
|
+
fontSize: initialLayer?.fontSize || 48,
|
|
44
|
+
fontFamily: initialLayer?.fontFamily || "System",
|
|
45
|
+
fontWeight:
|
|
46
|
+
(initialLayer?.fontWeight as "normal" | "bold" | "300" | "700") || "bold",
|
|
47
|
+
color: initialLayer?.color || tokens.colors.textInverse,
|
|
48
|
+
textAlign: initialLayer?.textAlign || "center",
|
|
64
49
|
},
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}, []);
|
|
75
|
-
|
|
76
|
-
const buildLayerData = useCallback((): Partial<TextLayer> => {
|
|
77
|
-
return {
|
|
50
|
+
validators: {
|
|
51
|
+
text: (value: unknown) => {
|
|
52
|
+
if (!value || (typeof value === "string" && value.trim().length === 0)) {
|
|
53
|
+
return "Text content is required";
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
buildData: (formState) => ({
|
|
78
59
|
content: formState.text,
|
|
79
60
|
fontSize: formState.fontSize,
|
|
80
61
|
fontFamily: formState.fontFamily,
|
|
81
62
|
fontWeight: formState.fontWeight,
|
|
82
63
|
color: formState.color,
|
|
83
64
|
textAlign: formState.textAlign,
|
|
84
|
-
}
|
|
85
|
-
}
|
|
65
|
+
} as Partial<TextLayer>),
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const form = useLayerForm<TextLayerFormState, Partial<TextLayer>>(config);
|
|
86
69
|
|
|
87
|
-
const
|
|
70
|
+
const setText = (text: string) => form.updateField("text", text);
|
|
71
|
+
const setFontSize = (size: number) => form.updateField("fontSize", size);
|
|
72
|
+
const setFontFamily = (family: string) => form.updateField("fontFamily", family);
|
|
73
|
+
const setFontWeight = (weight: "normal" | "bold" | "300" | "700") =>
|
|
74
|
+
form.updateField("fontWeight", weight);
|
|
75
|
+
const setColor = (color: string) => form.updateField("color", color);
|
|
76
|
+
const setTextAlign = (align: "left" | "center" | "right") =>
|
|
77
|
+
form.updateField("textAlign", align);
|
|
88
78
|
|
|
89
79
|
return {
|
|
90
|
-
formState,
|
|
80
|
+
formState: form.formState,
|
|
91
81
|
setText,
|
|
92
82
|
setFontSize,
|
|
93
83
|
setFontFamily,
|
|
94
84
|
setFontWeight,
|
|
95
85
|
setColor,
|
|
96
86
|
setTextAlign,
|
|
97
|
-
buildLayerData,
|
|
98
|
-
isValid,
|
|
87
|
+
buildLayerData: form.buildLayerData,
|
|
88
|
+
isValid: form.isValid,
|
|
99
89
|
};
|
|
100
90
|
}
|