@legendapp/list 2.0.0-next.2 → 2.0.0-next.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.
- package/{dist/animated.d.mts → animated.d.mts} +1 -0
- package/{dist/animated.d.ts → animated.d.ts} +1 -0
- package/{dist/index.d.mts → index.d.mts} +8 -1
- package/{dist/index.d.ts → index.d.ts} +8 -1
- package/{dist/index.js → index.js} +50 -4
- package/{dist/index.mjs → index.mjs} +50 -4
- package/{dist/keyboard-controller.d.mts → keyboard-controller.d.mts} +4 -0
- package/{dist/keyboard-controller.d.ts → keyboard-controller.d.ts} +4 -0
- package/package.json +34 -88
- package/.claude/settings.local.json +0 -8
- package/.cursor/rules/changelog.mdc +0 -60
- package/.github/FUNDING.yml +0 -15
- package/.gitignore +0 -5
- package/.prettierrc.json +0 -5
- package/.vscode/settings.json +0 -14
- package/CLAUDE.md +0 -126
- package/biome.json +0 -46
- package/bun.lock +0 -1289
- package/bunfig.toml +0 -2
- package/dist/CHANGELOG.md +0 -119
- package/dist/LICENSE +0 -21
- package/dist/README.md +0 -139
- package/dist/package.json +0 -35
- package/example/README.md +0 -40
- package/example/api/data/genres.json +0 -23
- package/example/api/data/playlist/10402-10749.json +0 -1
- package/example/api/data/playlist/10402-10770.json +0 -1
- package/example/api/data/playlist/10402-37.json +0 -1
- package/example/api/data/playlist/10749-10752.json +0 -1
- package/example/api/data/playlist/10749-10770.json +0 -1
- package/example/api/data/playlist/10749-37.json +0 -1
- package/example/api/data/playlist/10749-878.json +0 -1
- package/example/api/data/playlist/10751-10402.json +0 -1
- package/example/api/data/playlist/10751-10752.json +0 -1
- package/example/api/data/playlist/10751-37.json +0 -1
- package/example/api/data/playlist/10751-53.json +0 -1
- package/example/api/data/playlist/10751-878.json +0 -1
- package/example/api/data/playlist/10751-9648.json +0 -1
- package/example/api/data/playlist/10752-37.json +0 -1
- package/example/api/data/playlist/12-10402.json +0 -1
- package/example/api/data/playlist/12-10749.json +0 -1
- package/example/api/data/playlist/12-18.json +0 -1
- package/example/api/data/playlist/12-27.json +0 -1
- package/example/api/data/playlist/12-35.json +0 -1
- package/example/api/data/playlist/14-36.json +0 -1
- package/example/api/data/playlist/14-878.json +0 -1
- package/example/api/data/playlist/16-10751.json +0 -1
- package/example/api/data/playlist/16-10770.json +0 -1
- package/example/api/data/playlist/16-35.json +0 -1
- package/example/api/data/playlist/16-36.json +0 -1
- package/example/api/data/playlist/16-53.json +0 -1
- package/example/api/data/playlist/18-10751.json +0 -1
- package/example/api/data/playlist/18-10752.json +0 -1
- package/example/api/data/playlist/18-37.json +0 -1
- package/example/api/data/playlist/18-53.json +0 -1
- package/example/api/data/playlist/18-878.json +0 -1
- package/example/api/data/playlist/27-10749.json +0 -1
- package/example/api/data/playlist/27-10770.json +0 -1
- package/example/api/data/playlist/28-10749.json +0 -1
- package/example/api/data/playlist/28-10751.json +0 -1
- package/example/api/data/playlist/28-10770.json +0 -1
- package/example/api/data/playlist/28-16.json +0 -1
- package/example/api/data/playlist/28-18.json +0 -1
- package/example/api/data/playlist/28-36.json +0 -1
- package/example/api/data/playlist/28-37.json +0 -1
- package/example/api/data/playlist/28-53.json +0 -1
- package/example/api/data/playlist/28-80.json +0 -1
- package/example/api/data/playlist/28-99.json +0 -1
- package/example/api/data/playlist/35-10749.json +0 -1
- package/example/api/data/playlist/35-10751.json +0 -1
- package/example/api/data/playlist/35-10752.json +0 -1
- package/example/api/data/playlist/35-27.json +0 -1
- package/example/api/data/playlist/35-36.json +0 -1
- package/example/api/data/playlist/35-53.json +0 -1
- package/example/api/data/playlist/35-80.json +0 -1
- package/example/api/data/playlist/36-37.json +0 -1
- package/example/api/data/playlist/36-878.json +0 -1
- package/example/api/data/playlist/36-9648.json +0 -1
- package/example/api/data/playlist/53-10752.json +0 -1
- package/example/api/data/playlist/80-10770.json +0 -1
- package/example/api/data/playlist/80-14.json +0 -1
- package/example/api/data/playlist/80-18.json +0 -1
- package/example/api/data/playlist/80-37.json +0 -1
- package/example/api/data/playlist/878-37.json +0 -1
- package/example/api/data/playlist/9648-10770.json +0 -1
- package/example/api/data/playlist/9648-37.json +0 -1
- package/example/api/data/playlist/9648-53.json +0 -1
- package/example/api/data/playlist/9648-878.json +0 -1
- package/example/api/data/playlist/99-10749.json +0 -1
- package/example/api/data/playlist/99-14.json +0 -1
- package/example/api/data/playlist/99-18.json +0 -1
- package/example/api/data/playlist/99-27.json +0 -1
- package/example/api/data/playlist/99-53.json +0 -1
- package/example/api/data/playlist/99-9648.json +0 -1
- package/example/api/data/playlist/index.ts +0 -73
- package/example/api/data/rows.json +0 -1
- package/example/api/index.ts +0 -36
- package/example/app/(tabs)/_layout.tsx +0 -60
- package/example/app/(tabs)/cards.tsx +0 -81
- package/example/app/(tabs)/index.tsx +0 -205
- package/example/app/(tabs)/moviesL.tsx +0 -7
- package/example/app/(tabs)/moviesLR.tsx +0 -7
- package/example/app/+not-found.tsx +0 -32
- package/example/app/_layout.tsx +0 -34
- package/example/app/accurate-scrollto/index.tsx +0 -125
- package/example/app/accurate-scrollto-2/index.tsx +0 -52
- package/example/app/accurate-scrollto-huge/index.tsx +0 -128
- package/example/app/add-to-end/index.tsx +0 -82
- package/example/app/ai-chat/index.tsx +0 -236
- package/example/app/bidirectional-infinite-list/index.tsx +0 -133
- package/example/app/cards-columns/index.tsx +0 -37
- package/example/app/cards-flashlist/index.tsx +0 -122
- package/example/app/cards-flatlist/index.tsx +0 -94
- package/example/app/cards-no-recycle/index.tsx +0 -110
- package/example/app/cards-renderItem.tsx +0 -354
- package/example/app/chat-example/index.tsx +0 -167
- package/example/app/chat-infinite/index.tsx +0 -239
- package/example/app/chat-keyboard/index.tsx +0 -248
- package/example/app/chat-resize-outer/index.tsx +0 -247
- package/example/app/columns/index.tsx +0 -78
- package/example/app/countries/index.tsx +0 -182
- package/example/app/countries-flashlist/index.tsx +0 -163
- package/example/app/countries-reorder/index.tsx +0 -187
- package/example/app/extra-data/index.tsx +0 -86
- package/example/app/filter-elements/filter-data-provider.tsx +0 -55
- package/example/app/filter-elements/index.tsx +0 -118
- package/example/app/initial-scroll-index/index.tsx +0 -106
- package/example/app/initial-scroll-index/renderFixedItem.tsx +0 -215
- package/example/app/initial-scroll-index-free-height/index.tsx +0 -70
- package/example/app/initial-scroll-index-keyed/index.tsx +0 -62
- package/example/app/lazy-list/index.tsx +0 -123
- package/example/app/movies-flashlist/index.tsx +0 -7
- package/example/app/mutable-cells/index.tsx +0 -104
- package/example/app/video-feed/index.tsx +0 -119
- package/example/app.config.js +0 -22
- package/example/app.json +0 -45
- package/example/assets/fonts/SpaceMono-Regular.ttf +0 -0
- package/example/assets/images/adaptive-icon.png +0 -0
- package/example/assets/images/favicon.png +0 -0
- package/example/assets/images/icon.png +0 -0
- package/example/assets/images/partial-react-logo.png +0 -0
- package/example/assets/images/react-logo.png +0 -0
- package/example/assets/images/react-logo@2x.png +0 -0
- package/example/assets/images/react-logo@3x.png +0 -0
- package/example/assets/images/splash-icon.png +0 -0
- package/example/autoscroll.sh +0 -101
- package/example/bun.lock +0 -2266
- package/example/bunfig.toml +0 -2
- package/example/components/Breathe.tsx +0 -54
- package/example/components/Circle.tsx +0 -69
- package/example/components/Collapsible.tsx +0 -44
- package/example/components/ExternalLink.tsx +0 -24
- package/example/components/HapticTab.tsx +0 -18
- package/example/components/HelloWave.tsx +0 -37
- package/example/components/Movies.tsx +0 -179
- package/example/components/ParallaxScrollView.tsx +0 -81
- package/example/components/ThemedText.tsx +0 -60
- package/example/components/ThemedView.tsx +0 -14
- package/example/components/__tests__/ThemedText-test.tsx +0 -10
- package/example/components/__tests__/__snapshots__/ThemedText-test.tsx.snap +0 -24
- package/example/components/ui/IconSymbol.ios.tsx +0 -32
- package/example/components/ui/IconSymbol.tsx +0 -43
- package/example/components/ui/TabBarBackground.ios.tsx +0 -22
- package/example/components/ui/TabBarBackground.tsx +0 -6
- package/example/constants/Colors.ts +0 -26
- package/example/constants/constants.ts +0 -5
- package/example/constants/useScrollTest.ts +0 -19
- package/example/hooks/useColorScheme.ts +0 -1
- package/example/hooks/useColorScheme.web.ts +0 -8
- package/example/hooks/useThemeColor.ts +0 -22
- package/example/ios/.xcode.env +0 -11
- package/example/ios/Podfile +0 -64
- package/example/ios/Podfile.lock +0 -2767
- package/example/ios/Podfile.properties.json +0 -5
- package/example/ios/listtest/AppDelegate.swift +0 -70
- package/example/ios/listtest/Images.xcassets/AppIcon.appiconset/App-Icon-1024x1024@1x.png +0 -0
- package/example/ios/listtest/Images.xcassets/AppIcon.appiconset/Contents.json +0 -14
- package/example/ios/listtest/Images.xcassets/Contents.json +0 -6
- package/example/ios/listtest/Images.xcassets/SplashScreenBackground.colorset/Contents.json +0 -20
- package/example/ios/listtest/Images.xcassets/SplashScreenLogo.imageset/Contents.json +0 -23
- package/example/ios/listtest/Images.xcassets/SplashScreenLogo.imageset/image.png +0 -0
- package/example/ios/listtest/Images.xcassets/SplashScreenLogo.imageset/image@2x.png +0 -0
- package/example/ios/listtest/Images.xcassets/SplashScreenLogo.imageset/image@3x.png +0 -0
- package/example/ios/listtest/Info.plist +0 -85
- package/example/ios/listtest/PrivacyInfo.xcprivacy +0 -48
- package/example/ios/listtest/SplashScreen.storyboard +0 -42
- package/example/ios/listtest/Supporting/Expo.plist +0 -12
- package/example/ios/listtest/listtest-Bridging-Header.h +0 -3
- package/example/ios/listtest/listtest.entitlements +0 -5
- package/example/ios/listtest.xcodeproj/project.pbxproj +0 -547
- package/example/ios/listtest.xcodeproj/xcshareddata/xcschemes/listtest.xcscheme +0 -88
- package/example/ios/listtest.xcworkspace/contents.xcworkspacedata +0 -10
- package/example/metro.config.js +0 -16
- package/example/package.json +0 -73
- package/example/scripts/reset-project.js +0 -84
- package/example/tsconfig.json +0 -26
- package/posttsup.ts +0 -24
- package/src/Container.tsx +0 -176
- package/src/Containers.tsx +0 -85
- package/src/ContextContainer.ts +0 -145
- package/src/DebugView.tsx +0 -83
- package/src/LazyLegendList.tsx +0 -41
- package/src/LeanView.tsx +0 -18
- package/src/LegendList.tsx +0 -558
- package/src/ListComponent.tsx +0 -191
- package/src/ScrollAdjust.tsx +0 -24
- package/src/ScrollAdjustHandler.ts +0 -26
- package/src/Separator.tsx +0 -14
- package/src/animated.tsx +0 -6
- package/src/calculateItemsInView.ts +0 -363
- package/src/calculateOffsetForIndex.ts +0 -23
- package/src/calculateOffsetWithOffsetPosition.ts +0 -26
- package/src/checkAllSizesKnown.ts +0 -17
- package/src/checkAtBottom.ts +0 -36
- package/src/checkAtTop.ts +0 -27
- package/src/checkThreshold.ts +0 -30
- package/src/constants.ts +0 -11
- package/src/createColumnWrapperStyle.ts +0 -16
- package/src/doInitialAllocateContainers.ts +0 -40
- package/src/doMaintainScrollAtEnd.ts +0 -34
- package/src/findAvailableContainers.ts +0 -98
- package/src/finishScrollTo.ts +0 -8
- package/src/getId.ts +0 -21
- package/src/getItemSize.ts +0 -52
- package/src/getRenderedItem.ts +0 -34
- package/src/getScrollVelocity.ts +0 -47
- package/src/handleLayout.ts +0 -70
- package/src/helpers.ts +0 -39
- package/src/index.ts +0 -11
- package/src/keyboard-controller.tsx +0 -63
- package/src/onScroll.ts +0 -66
- package/src/prepareMVCP.ts +0 -50
- package/src/reanimated.tsx +0 -63
- package/src/requestAdjust.ts +0 -41
- package/src/scrollTo.ts +0 -40
- package/src/scrollToIndex.ts +0 -34
- package/src/setDidLayout.ts +0 -25
- package/src/setPaddingTop.ts +0 -28
- package/src/state.tsx +0 -304
- package/src/types.ts +0 -610
- package/src/updateAlignItemsPaddingTop.ts +0 -18
- package/src/updateAllPositions.ts +0 -130
- package/src/updateItemSize.ts +0 -203
- package/src/updateTotalSize.ts +0 -44
- package/src/useAnimatedValue.ts +0 -6
- package/src/useCombinedRef.ts +0 -22
- package/src/useInit.ts +0 -17
- package/src/useSyncLayout.tsx +0 -68
- package/src/useValue$.ts +0 -53
- package/src/viewability.ts +0 -279
- package/tsconfig.json +0 -59
- package/tsup.config.ts +0 -21
- /package/{dist/animated.js → animated.js} +0 -0
- /package/{dist/animated.mjs → animated.mjs} +0 -0
- /package/{dist/keyboard-controller.js → keyboard-controller.js} +0 -0
- /package/{dist/keyboard-controller.mjs → keyboard-controller.mjs} +0 -0
- /package/{dist/reanimated.d.mts → reanimated.d.mts} +0 -0
- /package/{dist/reanimated.d.ts → reanimated.d.ts} +0 -0
- /package/{dist/reanimated.js → reanimated.js} +0 -0
- /package/{dist/reanimated.mjs → reanimated.mjs} +0 -0
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
import { LegendList } from "@legendapp/list";
|
|
2
|
-
import { useHeaderHeight } from "@react-navigation/elements";
|
|
3
|
-
import { Fragment, useState } from "react";
|
|
4
|
-
import { KeyboardAvoidingView, Platform, Pressable, StyleSheet, Text, View } from "react-native";
|
|
5
|
-
import { SafeAreaView } from "react-native-safe-area-context";
|
|
6
|
-
|
|
7
|
-
type Message = {
|
|
8
|
-
id: string;
|
|
9
|
-
text: string;
|
|
10
|
-
sender: "user" | "bot";
|
|
11
|
-
timeStamp: number;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
let idCounter = 0;
|
|
15
|
-
const MS_PER_SECOND = 1000;
|
|
16
|
-
|
|
17
|
-
const defaultChatMessages: Message[] = [
|
|
18
|
-
{
|
|
19
|
-
id: String(idCounter++),
|
|
20
|
-
text: "Hi, I have a question about your product",
|
|
21
|
-
sender: "user",
|
|
22
|
-
timeStamp: Date.now() - MS_PER_SECOND * 5,
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
id: String(idCounter++),
|
|
26
|
-
text: "Hello there! How can I assist you today?",
|
|
27
|
-
sender: "bot",
|
|
28
|
-
timeStamp: Date.now() - MS_PER_SECOND * 4,
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
id: String(idCounter++),
|
|
32
|
-
text: "I'm looking for information about pricing plans",
|
|
33
|
-
sender: "user",
|
|
34
|
-
timeStamp: Date.now() - MS_PER_SECOND * 4,
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
id: String(idCounter++),
|
|
38
|
-
text: "We offer several pricing tiers based on your needs",
|
|
39
|
-
sender: "bot",
|
|
40
|
-
timeStamp: Date.now() - MS_PER_SECOND * 4,
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
id: String(idCounter++),
|
|
44
|
-
text: "Our basic plan starts at $9.99 per month",
|
|
45
|
-
sender: "bot",
|
|
46
|
-
timeStamp: Date.now() - MS_PER_SECOND * 4,
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
id: String(idCounter++),
|
|
50
|
-
text: "Do you offer any discounts for annual billing?",
|
|
51
|
-
sender: "user",
|
|
52
|
-
timeStamp: Date.now() - MS_PER_SECOND * 4,
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
id: String(idCounter++),
|
|
56
|
-
text: "Yes! You can save 20% with our annual billing option",
|
|
57
|
-
sender: "bot",
|
|
58
|
-
timeStamp: Date.now() - MS_PER_SECOND * 4,
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
id: String(idCounter++),
|
|
62
|
-
text: "That sounds great. What features are included?",
|
|
63
|
-
sender: "user",
|
|
64
|
-
timeStamp: Date.now() - MS_PER_SECOND * 4,
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
id: String(idCounter++),
|
|
68
|
-
text: "The basic plan includes all core features plus 10GB storage",
|
|
69
|
-
sender: "bot",
|
|
70
|
-
timeStamp: Date.now() - MS_PER_SECOND * 4,
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
id: String(idCounter++),
|
|
74
|
-
text: "Premium plans include priority support and additional tools",
|
|
75
|
-
sender: "bot",
|
|
76
|
-
timeStamp: Date.now() - MS_PER_SECOND * 4,
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
id: String(idCounter++),
|
|
80
|
-
text: "I think the basic plan would work for my needs",
|
|
81
|
-
sender: "user",
|
|
82
|
-
timeStamp: Date.now() - MS_PER_SECOND * 4,
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
id: String(idCounter++),
|
|
86
|
-
text: "Perfect! I can help you get set up with that",
|
|
87
|
-
sender: "bot",
|
|
88
|
-
timeStamp: Date.now() - MS_PER_SECOND * 4,
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
id: String(idCounter++),
|
|
92
|
-
text: "Thanks for your help so far",
|
|
93
|
-
sender: "user",
|
|
94
|
-
timeStamp: Date.now() - MS_PER_SECOND * 4,
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
id: String(idCounter++),
|
|
98
|
-
text: "You're welcome! Is there anything else I can assist with today?",
|
|
99
|
-
sender: "bot",
|
|
100
|
-
timeStamp: Date.now() - MS_PER_SECOND * 3,
|
|
101
|
-
},
|
|
102
|
-
];
|
|
103
|
-
|
|
104
|
-
const ChatResizeOuter = () => {
|
|
105
|
-
const [messages, setMessages] = useState<Message[]>(defaultChatMessages);
|
|
106
|
-
const [inputText, setInputText] = useState("");
|
|
107
|
-
const headerHeight = Platform.OS === "ios" ? useHeaderHeight() : 80;
|
|
108
|
-
const [buttonHeight, setButtonHeight] = useState(40);
|
|
109
|
-
|
|
110
|
-
const sendMessage = () => {
|
|
111
|
-
const text = inputText || "Empty message";
|
|
112
|
-
if (text.trim()) {
|
|
113
|
-
setMessages((messages) => [
|
|
114
|
-
...messages,
|
|
115
|
-
{ id: String(idCounter++), text: text, sender: "user", timeStamp: Date.now() },
|
|
116
|
-
]);
|
|
117
|
-
setInputText("");
|
|
118
|
-
setTimeout(() => {
|
|
119
|
-
setMessages((messages) => [
|
|
120
|
-
...messages,
|
|
121
|
-
{
|
|
122
|
-
id: String(idCounter++),
|
|
123
|
-
text: `Answer: ${text.toUpperCase()}`,
|
|
124
|
-
sender: "bot",
|
|
125
|
-
timeStamp: Date.now(),
|
|
126
|
-
},
|
|
127
|
-
]);
|
|
128
|
-
}, 300);
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
return (
|
|
133
|
-
<SafeAreaView style={styles.container} edges={["bottom"]}>
|
|
134
|
-
<KeyboardAvoidingView
|
|
135
|
-
style={styles.container}
|
|
136
|
-
behavior="padding"
|
|
137
|
-
keyboardVerticalOffset={headerHeight}
|
|
138
|
-
contentContainerStyle={{ flex: 1 }}
|
|
139
|
-
>
|
|
140
|
-
<LegendList
|
|
141
|
-
data={messages}
|
|
142
|
-
contentContainerStyle={styles.contentContainer}
|
|
143
|
-
keyExtractor={(item) => item.id}
|
|
144
|
-
estimatedItemSize={10} // A size that's way too small to check the behavior is correct
|
|
145
|
-
initialScrollIndex={messages.length - 1}
|
|
146
|
-
maintainVisibleContentPosition
|
|
147
|
-
maintainScrollAtEnd
|
|
148
|
-
maintainScrollAtEndThreshold={0.1}
|
|
149
|
-
alignItemsAtEnd
|
|
150
|
-
renderItem={renderItem}
|
|
151
|
-
/>
|
|
152
|
-
</KeyboardAvoidingView>
|
|
153
|
-
<Pressable
|
|
154
|
-
style={{
|
|
155
|
-
height: buttonHeight,
|
|
156
|
-
backgroundColor: "rgba(0, 0, 0, 0.1)",
|
|
157
|
-
alignItems: "center",
|
|
158
|
-
justifyContent: "center",
|
|
159
|
-
}}
|
|
160
|
-
onPress={() => {
|
|
161
|
-
setButtonHeight(buttonHeight === 40 ? 300 : 40);
|
|
162
|
-
}}
|
|
163
|
-
>
|
|
164
|
-
<Text style={{ fontSize: 16, fontWeight: "medium" }}>Resize</Text>
|
|
165
|
-
</Pressable>
|
|
166
|
-
</SafeAreaView>
|
|
167
|
-
);
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
const styles = StyleSheet.create({
|
|
171
|
-
container: {
|
|
172
|
-
flex: 1,
|
|
173
|
-
backgroundColor: "#fff",
|
|
174
|
-
},
|
|
175
|
-
contentContainer: {
|
|
176
|
-
paddingHorizontal: 16,
|
|
177
|
-
},
|
|
178
|
-
messageContainer: {
|
|
179
|
-
padding: 16,
|
|
180
|
-
borderRadius: 16,
|
|
181
|
-
marginVertical: 4,
|
|
182
|
-
},
|
|
183
|
-
messageText: {
|
|
184
|
-
fontSize: 16,
|
|
185
|
-
},
|
|
186
|
-
userMessageText: {
|
|
187
|
-
color: "white",
|
|
188
|
-
},
|
|
189
|
-
inputContainer: {
|
|
190
|
-
flexDirection: "row",
|
|
191
|
-
alignItems: "center",
|
|
192
|
-
padding: 10,
|
|
193
|
-
borderTopWidth: 1,
|
|
194
|
-
borderColor: "#ccc",
|
|
195
|
-
},
|
|
196
|
-
botMessageContainer: {
|
|
197
|
-
backgroundColor: "#f1f1f1",
|
|
198
|
-
},
|
|
199
|
-
userMessageContainer: {
|
|
200
|
-
backgroundColor: "#007AFF",
|
|
201
|
-
},
|
|
202
|
-
botStyle: {
|
|
203
|
-
maxWidth: "75%",
|
|
204
|
-
alignSelf: "flex-start",
|
|
205
|
-
},
|
|
206
|
-
userStyle: {
|
|
207
|
-
maxWidth: "75%",
|
|
208
|
-
alignSelf: "flex-end",
|
|
209
|
-
alignItems: "flex-end",
|
|
210
|
-
},
|
|
211
|
-
input: {
|
|
212
|
-
flex: 1,
|
|
213
|
-
borderWidth: 1,
|
|
214
|
-
borderColor: "#ccc",
|
|
215
|
-
borderRadius: 5,
|
|
216
|
-
padding: 10,
|
|
217
|
-
marginRight: 10,
|
|
218
|
-
},
|
|
219
|
-
timeStamp: {
|
|
220
|
-
marginVertical: 5,
|
|
221
|
-
},
|
|
222
|
-
timeStampText: {
|
|
223
|
-
fontSize: 12,
|
|
224
|
-
color: "#888",
|
|
225
|
-
},
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
export default ChatResizeOuter;
|
|
229
|
-
|
|
230
|
-
const renderItem = ({ item }: { item: Message }) => {
|
|
231
|
-
return (
|
|
232
|
-
<Fragment>
|
|
233
|
-
<View
|
|
234
|
-
style={[
|
|
235
|
-
styles.messageContainer,
|
|
236
|
-
item.sender === "bot" ? styles.botMessageContainer : styles.userMessageContainer,
|
|
237
|
-
item.sender === "bot" ? styles.botStyle : styles.userStyle,
|
|
238
|
-
]}
|
|
239
|
-
>
|
|
240
|
-
<Text style={[styles.messageText, item.sender === "user" && styles.userMessageText]}>{item.text}</Text>
|
|
241
|
-
</View>
|
|
242
|
-
<View style={[styles.timeStamp, item.sender === "bot" ? styles.botStyle : styles.userStyle]}>
|
|
243
|
-
<Text style={styles.timeStampText}>{new Date(item.timeStamp).toLocaleTimeString()}</Text>
|
|
244
|
-
</View>
|
|
245
|
-
</Fragment>
|
|
246
|
-
);
|
|
247
|
-
};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { LegendList } from "@legendapp/list";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import { useEffect } from "react";
|
|
4
|
-
import { LogBox, StyleSheet, Text, View } from "react-native";
|
|
5
|
-
|
|
6
|
-
LogBox.ignoreLogs(["Open debugger"]);
|
|
7
|
-
|
|
8
|
-
const initialData = Array.from({ length: 8 }, (_, index) => ({ id: index.toString() }));
|
|
9
|
-
|
|
10
|
-
export default function Columns() {
|
|
11
|
-
const [data, setData] = useState(initialData);
|
|
12
|
-
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
setTimeout(() => {
|
|
15
|
-
setData(Array.from({ length: 20 }, (_, index) => ({ id: index.toString() })));
|
|
16
|
-
}, 1000);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<View style={styles.container}>
|
|
21
|
-
<LegendList
|
|
22
|
-
data={data}
|
|
23
|
-
renderItem={Item}
|
|
24
|
-
keyExtractor={(item) => item.id}
|
|
25
|
-
numColumns={3}
|
|
26
|
-
columnWrapperStyle={{
|
|
27
|
-
columnGap: 16,
|
|
28
|
-
rowGap: 16,
|
|
29
|
-
}}
|
|
30
|
-
/>
|
|
31
|
-
</View>
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function Item({ item }: { item: { id: string } }) {
|
|
36
|
-
return (
|
|
37
|
-
<View style={styles.redRectangle}>
|
|
38
|
-
<View style={styles.redRectangleInner} />
|
|
39
|
-
<Text>Item {item.id}</Text>
|
|
40
|
-
</View>
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const styles = StyleSheet.create({
|
|
45
|
-
container: {
|
|
46
|
-
flex: 1,
|
|
47
|
-
backgroundColor: "#fff",
|
|
48
|
-
},
|
|
49
|
-
redRectangle: {
|
|
50
|
-
aspectRatio: 1,
|
|
51
|
-
},
|
|
52
|
-
redRectangleInner: {
|
|
53
|
-
height: "100%",
|
|
54
|
-
width: "100%",
|
|
55
|
-
backgroundColor: "red",
|
|
56
|
-
borderRadius: 8,
|
|
57
|
-
},
|
|
58
|
-
columnWrapper: {
|
|
59
|
-
justifyContent: "space-between",
|
|
60
|
-
},
|
|
61
|
-
listHeader: {
|
|
62
|
-
alignSelf: "center",
|
|
63
|
-
height: 100,
|
|
64
|
-
width: 100,
|
|
65
|
-
backgroundColor: "#456AAA",
|
|
66
|
-
borderRadius: 12,
|
|
67
|
-
marginHorizontal: 8,
|
|
68
|
-
marginVertical: 8,
|
|
69
|
-
},
|
|
70
|
-
listEmpty: {
|
|
71
|
-
flex: 1,
|
|
72
|
-
justifyContent: "center",
|
|
73
|
-
alignItems: "center",
|
|
74
|
-
backgroundColor: "#6789AB",
|
|
75
|
-
paddingVertical: 16,
|
|
76
|
-
height: 100,
|
|
77
|
-
},
|
|
78
|
-
});
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { LegendList } from "@legendapp/list";
|
|
2
|
-
import { type TCountryCode, countries, getEmojiFlag } from "countries-list";
|
|
3
|
-
import { useMemo, useState } from "react";
|
|
4
|
-
import { Pressable, StatusBar, StyleSheet, Text, TextInput, View } from "react-native";
|
|
5
|
-
import { SafeAreaProvider, SafeAreaView } from "react-native-safe-area-context";
|
|
6
|
-
|
|
7
|
-
export const unstable_settings = {
|
|
8
|
-
initialRouteName: "index",
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const createTitle = () => "Countries";
|
|
12
|
-
|
|
13
|
-
type Country = {
|
|
14
|
-
id: string;
|
|
15
|
-
name: string;
|
|
16
|
-
flag: string;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// Convert countries object to array and add an id
|
|
20
|
-
const DATA: Country[] = Object.entries(countries)
|
|
21
|
-
.map(([code, country]) => ({
|
|
22
|
-
id: code,
|
|
23
|
-
name: country.name,
|
|
24
|
-
flag: getEmojiFlag(code as TCountryCode),
|
|
25
|
-
}))
|
|
26
|
-
.sort((a, b) => a.name.localeCompare(b.name));
|
|
27
|
-
|
|
28
|
-
type ItemProps = {
|
|
29
|
-
item: Country;
|
|
30
|
-
onPress: () => void;
|
|
31
|
-
isSelected: boolean;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const Item = ({ item, onPress, isSelected }: ItemProps) => (
|
|
35
|
-
<Pressable
|
|
36
|
-
onPress={onPress}
|
|
37
|
-
style={({ pressed }) => [styles.item, isSelected && styles.selectedItem, pressed && styles.pressedItem]}
|
|
38
|
-
>
|
|
39
|
-
<View style={styles.flagContainer}>
|
|
40
|
-
<Text style={styles.flag}>{item.flag}</Text>
|
|
41
|
-
</View>
|
|
42
|
-
<View style={styles.contentContainer}>
|
|
43
|
-
<Text style={[styles.title, isSelected && styles.selectedText]}>
|
|
44
|
-
{item.name}
|
|
45
|
-
<Text style={styles.countryCode}> ({item.id})</Text>
|
|
46
|
-
</Text>
|
|
47
|
-
</View>
|
|
48
|
-
</Pressable>
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
const App = () => {
|
|
52
|
-
const [selectedId, setSelectedId] = useState<string>();
|
|
53
|
-
const [searchQuery, setSearchQuery] = useState("");
|
|
54
|
-
|
|
55
|
-
const filteredData = useMemo(() => {
|
|
56
|
-
const query = searchQuery.toLowerCase();
|
|
57
|
-
return DATA.filter(
|
|
58
|
-
(country) => country.name.toLowerCase().includes(query) || country.id.toLowerCase().includes(query),
|
|
59
|
-
);
|
|
60
|
-
}, [searchQuery]);
|
|
61
|
-
|
|
62
|
-
const renderItem = ({ item }: { item: Country }) => {
|
|
63
|
-
const isSelected = item.id === selectedId;
|
|
64
|
-
return <Item item={item} onPress={() => setSelectedId(item.id)} isSelected={isSelected} />;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
<SafeAreaProvider>
|
|
69
|
-
<SafeAreaView style={styles.container}>
|
|
70
|
-
<View style={styles.searchContainer}>
|
|
71
|
-
<TextInput
|
|
72
|
-
style={styles.searchInput}
|
|
73
|
-
placeholder="Search country or code..."
|
|
74
|
-
value={searchQuery}
|
|
75
|
-
onChangeText={setSearchQuery}
|
|
76
|
-
clearButtonMode="while-editing"
|
|
77
|
-
autoCapitalize="none"
|
|
78
|
-
autoCorrect={false}
|
|
79
|
-
/>
|
|
80
|
-
</View>
|
|
81
|
-
<LegendList
|
|
82
|
-
data={filteredData}
|
|
83
|
-
renderItem={renderItem}
|
|
84
|
-
keyExtractor={(item) => item.id}
|
|
85
|
-
extraData={selectedId}
|
|
86
|
-
estimatedItemSize={70}
|
|
87
|
-
recycleItems
|
|
88
|
-
onStartReachedThreshold={0.1}
|
|
89
|
-
onStartReached={({ distanceFromStart }) => {
|
|
90
|
-
console.log("onStartReached", distanceFromStart);
|
|
91
|
-
}}
|
|
92
|
-
onEndReachedThreshold={0.1}
|
|
93
|
-
onEndReached={({ distanceFromEnd }) => {
|
|
94
|
-
console.log("onEndReached", distanceFromEnd);
|
|
95
|
-
}}
|
|
96
|
-
// ListHeaderComponent={<View style={{ height: 200, backgroundColor: "red" }} />}
|
|
97
|
-
// ListFooterComponent={<View style={{ height: 200, backgroundColor: "blue" }} />}
|
|
98
|
-
// ItemSeparatorComponent={Separator}
|
|
99
|
-
/>
|
|
100
|
-
</SafeAreaView>
|
|
101
|
-
</SafeAreaProvider>
|
|
102
|
-
);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const Separator = () => <View style={{ height: 40, backgroundColor: "green" }} />;
|
|
106
|
-
|
|
107
|
-
export default App;
|
|
108
|
-
|
|
109
|
-
const styles = StyleSheet.create({
|
|
110
|
-
container: {
|
|
111
|
-
flex: 1,
|
|
112
|
-
marginTop: StatusBar.currentHeight || 0,
|
|
113
|
-
backgroundColor: "#f5f5f5",
|
|
114
|
-
},
|
|
115
|
-
searchContainer: {
|
|
116
|
-
padding: 8,
|
|
117
|
-
backgroundColor: "#fff",
|
|
118
|
-
borderBottomWidth: 1,
|
|
119
|
-
borderBottomColor: "#e0e0e0",
|
|
120
|
-
},
|
|
121
|
-
searchInput: {
|
|
122
|
-
height: 40,
|
|
123
|
-
backgroundColor: "#f5f5f5",
|
|
124
|
-
borderRadius: 8,
|
|
125
|
-
paddingHorizontal: 12,
|
|
126
|
-
fontSize: 16,
|
|
127
|
-
},
|
|
128
|
-
item: {
|
|
129
|
-
paddingHorizontal: 16,
|
|
130
|
-
paddingVertical: 6,
|
|
131
|
-
flexDirection: "row",
|
|
132
|
-
alignItems: "center",
|
|
133
|
-
backgroundColor: "#fff",
|
|
134
|
-
borderRadius: 12,
|
|
135
|
-
// shadowColor: "#000",
|
|
136
|
-
// shadowOffset: {
|
|
137
|
-
// width: 0,
|
|
138
|
-
// height: 2,
|
|
139
|
-
// },
|
|
140
|
-
// shadowOpacity: 0.1,
|
|
141
|
-
// shadowRadius: 3,
|
|
142
|
-
// elevation: 3,
|
|
143
|
-
},
|
|
144
|
-
selectedItem: {
|
|
145
|
-
// backgroundColor: "#e3f2fd",
|
|
146
|
-
// borderColor: "#1976d2",
|
|
147
|
-
// borderWidth: 1,
|
|
148
|
-
},
|
|
149
|
-
pressedItem: {
|
|
150
|
-
// backgroundColor: "#f0f0f0",
|
|
151
|
-
},
|
|
152
|
-
flagContainer: {
|
|
153
|
-
marginRight: 16,
|
|
154
|
-
width: 40,
|
|
155
|
-
height: 40,
|
|
156
|
-
borderRadius: 20,
|
|
157
|
-
backgroundColor: "#f8f9fa",
|
|
158
|
-
alignItems: "center",
|
|
159
|
-
justifyContent: "center",
|
|
160
|
-
},
|
|
161
|
-
flag: {
|
|
162
|
-
fontSize: 28,
|
|
163
|
-
},
|
|
164
|
-
contentContainer: {
|
|
165
|
-
flex: 1,
|
|
166
|
-
justifyContent: "center",
|
|
167
|
-
},
|
|
168
|
-
title: {
|
|
169
|
-
fontSize: 16,
|
|
170
|
-
color: "#333",
|
|
171
|
-
fontWeight: "500",
|
|
172
|
-
},
|
|
173
|
-
selectedText: {
|
|
174
|
-
color: "#1976d2",
|
|
175
|
-
fontWeight: "600",
|
|
176
|
-
},
|
|
177
|
-
countryCode: {
|
|
178
|
-
fontSize: 14,
|
|
179
|
-
color: "#666",
|
|
180
|
-
fontWeight: "400",
|
|
181
|
-
},
|
|
182
|
-
});
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { FlashList } from "@shopify/flash-list";
|
|
2
|
-
import { type TCountryCode, countries, getEmojiFlag } from "countries-list";
|
|
3
|
-
import { useMemo, useState } from "react";
|
|
4
|
-
import { Pressable, StatusBar, StyleSheet, Text, TextInput, View } from "react-native";
|
|
5
|
-
import { SafeAreaProvider, SafeAreaView } from "react-native-safe-area-context";
|
|
6
|
-
|
|
7
|
-
export const unstable_settings = {
|
|
8
|
-
initialRouteName: "index",
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const createTitle = () => "Countries";
|
|
12
|
-
|
|
13
|
-
type Country = {
|
|
14
|
-
id: string;
|
|
15
|
-
name: string;
|
|
16
|
-
flag: string;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// Convert countries object to array and add an id
|
|
20
|
-
const DATA: Country[] = Object.entries(countries)
|
|
21
|
-
.map(([code, country]) => ({
|
|
22
|
-
id: code,
|
|
23
|
-
name: country.name,
|
|
24
|
-
flag: getEmojiFlag(code as TCountryCode),
|
|
25
|
-
}))
|
|
26
|
-
.sort((a, b) => a.name.localeCompare(b.name));
|
|
27
|
-
|
|
28
|
-
type ItemProps = {
|
|
29
|
-
item: Country;
|
|
30
|
-
onPress: () => void;
|
|
31
|
-
isSelected: boolean;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const Item = ({ item, onPress, isSelected }: ItemProps) => (
|
|
35
|
-
<Pressable
|
|
36
|
-
onPress={onPress}
|
|
37
|
-
style={({ pressed }) => [styles.item, isSelected && styles.selectedItem, pressed && styles.pressedItem]}
|
|
38
|
-
>
|
|
39
|
-
<View style={styles.flagContainer}>
|
|
40
|
-
<Text style={styles.flag}>{item.flag}</Text>
|
|
41
|
-
</View>
|
|
42
|
-
<View style={styles.contentContainer}>
|
|
43
|
-
<Text style={[styles.title, isSelected && styles.selectedText]}>
|
|
44
|
-
{item.name}
|
|
45
|
-
<Text style={styles.countryCode}> ({item.id})</Text>
|
|
46
|
-
</Text>
|
|
47
|
-
</View>
|
|
48
|
-
</Pressable>
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
const App = () => {
|
|
52
|
-
const [selectedId, setSelectedId] = useState<string>();
|
|
53
|
-
const [searchQuery, setSearchQuery] = useState("");
|
|
54
|
-
|
|
55
|
-
const filteredData = useMemo(() => {
|
|
56
|
-
const query = searchQuery.toLowerCase();
|
|
57
|
-
return DATA.filter(
|
|
58
|
-
(country) => country.name.toLowerCase().includes(query) || country.id.toLowerCase().includes(query),
|
|
59
|
-
);
|
|
60
|
-
}, [searchQuery]);
|
|
61
|
-
|
|
62
|
-
const renderItem = ({ item }: { item: Country }) => {
|
|
63
|
-
const isSelected = item.id === selectedId;
|
|
64
|
-
return <Item item={item} onPress={() => setSelectedId(item.id)} isSelected={isSelected} />;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
<SafeAreaProvider>
|
|
69
|
-
<SafeAreaView style={styles.container}>
|
|
70
|
-
<View style={styles.searchContainer}>
|
|
71
|
-
<TextInput
|
|
72
|
-
style={styles.searchInput}
|
|
73
|
-
placeholder="Search country or code..."
|
|
74
|
-
value={searchQuery}
|
|
75
|
-
onChangeText={setSearchQuery}
|
|
76
|
-
clearButtonMode="while-editing"
|
|
77
|
-
autoCapitalize="none"
|
|
78
|
-
autoCorrect={false}
|
|
79
|
-
/>
|
|
80
|
-
</View>
|
|
81
|
-
<FlashList
|
|
82
|
-
data={filteredData}
|
|
83
|
-
renderItem={renderItem}
|
|
84
|
-
keyExtractor={(item) => item.id}
|
|
85
|
-
extraData={selectedId}
|
|
86
|
-
estimatedItemSize={70}
|
|
87
|
-
//scrollEventThrottle={200}
|
|
88
|
-
disableAutoLayout
|
|
89
|
-
/>
|
|
90
|
-
</SafeAreaView>
|
|
91
|
-
</SafeAreaProvider>
|
|
92
|
-
);
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
export default App;
|
|
96
|
-
|
|
97
|
-
const styles = StyleSheet.create({
|
|
98
|
-
container: {
|
|
99
|
-
flex: 1,
|
|
100
|
-
marginTop: StatusBar.currentHeight || 0,
|
|
101
|
-
backgroundColor: "#f5f5f5",
|
|
102
|
-
},
|
|
103
|
-
searchContainer: {
|
|
104
|
-
padding: 8,
|
|
105
|
-
backgroundColor: "#fff",
|
|
106
|
-
borderBottomWidth: 1,
|
|
107
|
-
borderBottomColor: "#e0e0e0",
|
|
108
|
-
},
|
|
109
|
-
searchInput: {
|
|
110
|
-
height: 40,
|
|
111
|
-
backgroundColor: "#f5f5f5",
|
|
112
|
-
borderRadius: 8,
|
|
113
|
-
paddingHorizontal: 12,
|
|
114
|
-
fontSize: 16,
|
|
115
|
-
},
|
|
116
|
-
item: {
|
|
117
|
-
paddingHorizontal: 16,
|
|
118
|
-
paddingVertical: 6,
|
|
119
|
-
flexDirection: "row",
|
|
120
|
-
alignItems: "center",
|
|
121
|
-
backgroundColor: "#fff",
|
|
122
|
-
borderRadius: 12,
|
|
123
|
-
// elevation: 3,
|
|
124
|
-
},
|
|
125
|
-
selectedItem: {
|
|
126
|
-
// backgroundColor: "#e3f2fd",
|
|
127
|
-
// borderColor: "#1976d2",
|
|
128
|
-
// borderWidth: 1,
|
|
129
|
-
},
|
|
130
|
-
pressedItem: {
|
|
131
|
-
// backgroundColor: "#f0f0f0",
|
|
132
|
-
},
|
|
133
|
-
flagContainer: {
|
|
134
|
-
marginRight: 16,
|
|
135
|
-
width: 40,
|
|
136
|
-
height: 40,
|
|
137
|
-
borderRadius: 20,
|
|
138
|
-
backgroundColor: "#f8f9fa",
|
|
139
|
-
alignItems: "center",
|
|
140
|
-
justifyContent: "center",
|
|
141
|
-
},
|
|
142
|
-
flag: {
|
|
143
|
-
fontSize: 28,
|
|
144
|
-
},
|
|
145
|
-
contentContainer: {
|
|
146
|
-
flex: 1,
|
|
147
|
-
justifyContent: "center",
|
|
148
|
-
},
|
|
149
|
-
title: {
|
|
150
|
-
fontSize: 16,
|
|
151
|
-
color: "#333",
|
|
152
|
-
fontWeight: "500",
|
|
153
|
-
},
|
|
154
|
-
selectedText: {
|
|
155
|
-
color: "#1976d2",
|
|
156
|
-
fontWeight: "600",
|
|
157
|
-
},
|
|
158
|
-
countryCode: {
|
|
159
|
-
fontSize: 14,
|
|
160
|
-
color: "#666",
|
|
161
|
-
fontWeight: "400",
|
|
162
|
-
},
|
|
163
|
-
});
|