create-100x-mobile 0.3.2 → 0.3.3
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.
|
@@ -2,13 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addTodoFormTemplate = addTodoFormTemplate;
|
|
4
4
|
function addTodoFormTemplate() {
|
|
5
|
-
return `import React, { useState } from "react";
|
|
6
|
-
import { View, TextInput, TouchableOpacity, StyleSheet } from "react-native";
|
|
7
|
-
import Animated, {
|
|
8
|
-
useSharedValue,
|
|
9
|
-
useAnimatedStyle,
|
|
10
|
-
withSpring,
|
|
11
|
-
} from "react-native-reanimated";
|
|
5
|
+
return `import React, { useState, useRef } from "react";
|
|
6
|
+
import { View, TextInput, TouchableOpacity, StyleSheet, Animated } from "react-native";
|
|
12
7
|
import * as Haptics from "expo-haptics";
|
|
13
8
|
import { Plus } from "lucide-react-native";
|
|
14
9
|
|
|
@@ -18,17 +13,20 @@ interface AddTodoFormProps {
|
|
|
18
13
|
|
|
19
14
|
export function AddTodoForm({ onAddTodo }: AddTodoFormProps) {
|
|
20
15
|
const [text, setText] = useState("");
|
|
21
|
-
const buttonScale =
|
|
22
|
-
|
|
23
|
-
const buttonAnimatedStyle = useAnimatedStyle(() => ({
|
|
24
|
-
transform: [{ scale: buttonScale.value }],
|
|
25
|
-
}));
|
|
16
|
+
const buttonScale = useRef(new Animated.Value(1)).current;
|
|
26
17
|
|
|
27
18
|
const handleSubmit = () => {
|
|
28
19
|
if (text.trim()) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
Animated.sequence([
|
|
21
|
+
Animated.spring(buttonScale, {
|
|
22
|
+
toValue: 0.9,
|
|
23
|
+
useNativeDriver: true,
|
|
24
|
+
}),
|
|
25
|
+
Animated.spring(buttonScale, {
|
|
26
|
+
toValue: 1,
|
|
27
|
+
useNativeDriver: true,
|
|
28
|
+
}),
|
|
29
|
+
]).start();
|
|
32
30
|
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
|
|
33
31
|
onAddTodo(text);
|
|
34
32
|
setText("");
|
|
@@ -48,7 +46,7 @@ export function AddTodoForm({ onAddTodo }: AddTodoFormProps) {
|
|
|
48
46
|
returnKeyType="done"
|
|
49
47
|
multiline={false}
|
|
50
48
|
/>
|
|
51
|
-
<Animated.View style={
|
|
49
|
+
<Animated.View style={{ transform: [{ scale: buttonScale }] }}>
|
|
52
50
|
<TouchableOpacity
|
|
53
51
|
style={[styles.addButton, !text.trim() && styles.addButtonDisabled]}
|
|
54
52
|
onPress={handleSubmit}
|
|
@@ -2,14 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.todoItemTemplate = todoItemTemplate;
|
|
4
4
|
function todoItemTemplate() {
|
|
5
|
-
return `import React from "react";
|
|
6
|
-
import { View, Text, TouchableOpacity, StyleSheet } from "react-native";
|
|
7
|
-
import Animated, {
|
|
8
|
-
FadeInDown,
|
|
9
|
-
useSharedValue,
|
|
10
|
-
useAnimatedStyle,
|
|
11
|
-
withSpring,
|
|
12
|
-
} from "react-native-reanimated";
|
|
5
|
+
return `import React, { useRef } from "react";
|
|
6
|
+
import { View, Text, TouchableOpacity, StyleSheet, Animated } from "react-native";
|
|
13
7
|
import * as Haptics from "expo-haptics";
|
|
14
8
|
import { Check, X } from "lucide-react-native";
|
|
15
9
|
import type { Todo } from "@/app/(tabs)/index";
|
|
@@ -22,16 +16,28 @@ interface TodoItemProps {
|
|
|
22
16
|
}
|
|
23
17
|
|
|
24
18
|
export function TodoItem({ todo, onToggle, onDelete }: TodoItemProps) {
|
|
25
|
-
const checkboxScale =
|
|
19
|
+
const checkboxScale = useRef(new Animated.Value(1)).current;
|
|
20
|
+
const fadeAnim = useRef(new Animated.Value(0)).current;
|
|
26
21
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
React.useEffect(() => {
|
|
23
|
+
Animated.timing(fadeAnim, {
|
|
24
|
+
toValue: 1,
|
|
25
|
+
duration: 300,
|
|
26
|
+
useNativeDriver: true,
|
|
27
|
+
}).start();
|
|
28
|
+
}, []);
|
|
30
29
|
|
|
31
30
|
const handleToggle = () => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
Animated.sequence([
|
|
32
|
+
Animated.spring(checkboxScale, {
|
|
33
|
+
toValue: 0.85,
|
|
34
|
+
useNativeDriver: true,
|
|
35
|
+
}),
|
|
36
|
+
Animated.spring(checkboxScale, {
|
|
37
|
+
toValue: 1,
|
|
38
|
+
useNativeDriver: true,
|
|
39
|
+
}),
|
|
40
|
+
]).start();
|
|
35
41
|
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
|
|
36
42
|
onToggle(todo._id);
|
|
37
43
|
};
|
|
@@ -42,7 +48,7 @@ export function TodoItem({ todo, onToggle, onDelete }: TodoItemProps) {
|
|
|
42
48
|
};
|
|
43
49
|
|
|
44
50
|
return (
|
|
45
|
-
<Animated.View
|
|
51
|
+
<Animated.View style={{ opacity: fadeAnim }}>
|
|
46
52
|
<View style={styles.container}>
|
|
47
53
|
<TouchableOpacity
|
|
48
54
|
style={styles.checkboxHitArea}
|
|
@@ -53,7 +59,7 @@ export function TodoItem({ todo, onToggle, onDelete }: TodoItemProps) {
|
|
|
53
59
|
style={[
|
|
54
60
|
styles.checkbox,
|
|
55
61
|
todo.completed && styles.checkboxCompleted,
|
|
56
|
-
|
|
62
|
+
{ transform: [{ scale: checkboxScale }] },
|
|
57
63
|
]}
|
|
58
64
|
>
|
|
59
65
|
{todo.completed && (
|