index.tsx 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. import {
  2. Fragment,
  3. useState,
  4. useRef
  5. } from "react";
  6. import {
  7. View
  8. } from "react-native";
  9. import stylesheet from "./stylesheet";
  10. import {
  11. NCoreUIKitBottomSheet,
  12. NotificationIndicator,
  13. getNCoreUIKitVersion,
  14. type IBottomSheetRef,
  15. NCoreUIKitSnackBar,
  16. NCoreUIKitDialog,
  17. NCoreUIKitToast,
  18. NCoreUIKitTheme,
  19. PageContainer,
  20. TextAreaInput,
  21. BottomSheet,
  22. RadioButton,
  23. TextInput,
  24. SelectBox,
  25. CheckBox,
  26. RowCard,
  27. Button,
  28. Dialog,
  29. Switch,
  30. Text
  31. } from "ncore-ui-kit-mobile";
  32. import {
  33. useNavigation
  34. } from "@react-navigation/native";
  35. import type {
  36. NativeStackNavigationProp
  37. } from "@react-navigation/native-stack";
  38. import type RootStackParamList from "../../navigation/type";
  39. import {
  40. ChevronRight as ChevronRightIcon,
  41. HomeIcon
  42. } from "lucide-react-native";
  43. const X = [
  44. {
  45. t: "xdfç.öhfdşkhdfşlhkfdşlhkdfşklhjmdfkhl3",
  46. p: "ydfguıy8ı*pğ34erdx",
  47. n: 90
  48. },
  49. {
  50. t: "3t4uh5ıe6ıo6eıo6eoke6ıoke6ker6kr4ok",
  51. p: "y3w46pjbd57ykdr",
  52. n: 91
  53. },
  54. {
  55. t: "xr*-0k4wkh-5w40k0*wek95ujk9*",
  56. p: "y467o5*3evghe5",
  57. n: 92
  58. },
  59. {
  60. t: "x-40*tyg*0w4kyh*w0ko45u*ko0w",
  61. p: "y3şçwl78570*fg",
  62. n: 93
  63. },
  64. {
  65. t: "*wrüsjh*ü9kws4*h0okdfhdhdfurdkex",
  66. p: "yt7ıtot7ot",
  67. n: 94
  68. },
  69. {
  70. t: "x2-0*4woy-*w4opyu-*23wou*0wık*0jk",
  71. p: "yasfa33",
  72. n: 95
  73. },
  74. {
  75. t: "x vmönöpwoı6-pğfş -*235*çda",
  76. p: "ydfasdfasf",
  77. n: 96
  78. },
  79. {
  80. t: "x vmönöpwoı6-pğfş -*235*çda",
  81. p: "ydfasdfasf",
  82. n: 96
  83. },
  84. {
  85. t: "x vmönöpwoı6-pğfş -*235*çda",
  86. p: "ydfasdfasf",
  87. n: 96
  88. },
  89. {
  90. t: "x vmönöpwoı6-pğfş -*235*çda",
  91. p: "ydfasdfasf",
  92. n: 96
  93. },
  94. {
  95. t: "x vmönöpwoı6-pğfş -*235*çda",
  96. p: "ydfasdfasf",
  97. n: 96
  98. },
  99. {
  100. t: "x vmönöpwoı6-pğfş -*235*çda",
  101. p: "ydfasdfasf",
  102. n: 96
  103. },
  104. {
  105. t: "x vmönöpwoı6-pğfş -*235*çda",
  106. p: "ydfasdfasf",
  107. n: 96
  108. },
  109. {
  110. t: "x vmönöpwoı6-pğfş -*235*çda",
  111. p: "ydfasdfasf",
  112. n: 96
  113. },
  114. {
  115. t: "x vmönöpwoı6-pğfş -*235*çda",
  116. p: "ydfasdfasf",
  117. n: 96
  118. },
  119. {
  120. t: "x vmönöpwoı6-pğfş -*235*çda",
  121. p: "ydfasdfasf",
  122. n: 96
  123. },
  124. {
  125. t: "x vmönöpwoı6-pğfş -*235*çda",
  126. p: "ydfasdfasf",
  127. n: 96
  128. },
  129. {
  130. t: "x vmönöpwoı6-pğfş -*235*çda",
  131. p: "ydfasdfasf",
  132. n: 96
  133. },
  134. {
  135. t: "x vmönöpwoı6-pğfş -*235*çda",
  136. p: "ydfasdfasf",
  137. n: 96
  138. },
  139. {
  140. t: "x vmönöpwoı6-pğfş -*235*çda",
  141. p: "ydfasdfasf",
  142. n: 96
  143. },
  144. {
  145. t: "x vmönöpwoı6-pğfş -*235*çda",
  146. p: "ydfasdfasf",
  147. n: 96
  148. },
  149. {
  150. t: "x vmönöpwoı6-pğfş -*235*çda",
  151. p: "ydfasdfasf",
  152. n: 96
  153. },
  154. {
  155. t: "x vmönöpwoı6-pğfş -*235*çda",
  156. p: "ydfasdfasf",
  157. n: 96
  158. },
  159. {
  160. t: "x vmönöpwoı6-pğfş -*235*çda",
  161. p: "ydfasdfasf",
  162. n: 96
  163. },
  164. {
  165. t: "x vmönöpwoı6-pğfş -*235*çda",
  166. p: "ydfasdfasf",
  167. n: 96
  168. },
  169. {
  170. t: "x vmönöpwoı6-pğfş -*235*çda",
  171. p: "ydfasdfasf",
  172. n: 96
  173. },
  174. {
  175. t: "x vmönöpwoı6-pğfş -*235*çda",
  176. p: "ydfasdfasf",
  177. n: 96
  178. },
  179. {
  180. t: "x vmönöpwoı6-pğfş -*235*çda",
  181. p: "ydfasdfasf",
  182. n: 96
  183. },
  184. {
  185. t: "x vmönöpwoı6-pğfş -*235*çda",
  186. p: "ydfasdfasf",
  187. n: 96
  188. },
  189. {
  190. t: "x vmönöpwoı6-pğfş -*235*çda",
  191. p: "ydfasdfasf",
  192. n: 96
  193. },
  194. {
  195. t: "x vmönöpwoı6-pğfş -*235*çda",
  196. p: "ydfasdfasf",
  197. n: 96
  198. }
  199. ];
  200. const Home = () => {
  201. const {
  202. colors
  203. } = NCoreUIKitTheme.useContext();
  204. const bottomSheetRef = useRef<IBottomSheetRef>(null);
  205. const navigation = useNavigation<NativeStackNavigationProp<RootStackParamList>>();
  206. const [
  207. isCheckboxActive,
  208. setIsCheckboxActive
  209. ] = useState<"partially" | "checked" | null>("checked");
  210. const [
  211. isDialogActive,
  212. setIsDialogActive
  213. ] = useState(false);
  214. const [
  215. isRadioActive,
  216. setIsRadioActive
  217. ] = useState(false);
  218. const [
  219. isSwitchActive,
  220. setIsSwitchActive
  221. ] = useState(false);
  222. return <PageContainer
  223. isScrollable={true}
  224. scrollViewStyle={stylesheet.container}
  225. scrollViewProps={{
  226. contentContainerStyle: {
  227. backgroundColor: colors.content.container.default,
  228. ...stylesheet.contentContainer
  229. }
  230. }}
  231. renderOverlays={() => {
  232. return <Fragment>
  233. <Dialog
  234. isVisible={isDialogActive}
  235. content="etgweı09gı9w0eg"
  236. title="Merhaba Dünya!"
  237. modalProps={{
  238. isWorkWithPortal: false
  239. }}
  240. onOverlayPress={({
  241. closeAnimation
  242. }) => {
  243. closeAnimation(() => setIsDialogActive(false));
  244. }}
  245. variant="info"
  246. secondaryButtonProps={{
  247. title: "sdfgsdg",
  248. onPress: () => {
  249. }
  250. }}
  251. primaryButtonProps={{
  252. onPress: ({
  253. closeAnimation
  254. }) => {
  255. closeAnimation(() => setIsDialogActive(false));
  256. }
  257. }}
  258. />
  259. <BottomSheet
  260. ref={bottomSheetRef}
  261. renderHeader={() => {
  262. return <View
  263. style={[
  264. {
  265. backgroundColor: "blue",
  266. padding: 20
  267. }
  268. ]}
  269. >
  270. <Text>Burası header.</Text>
  271. </View>;
  272. }}
  273. isCanFullScreenOnSwipe={true}
  274. isWorkWithPortal={false}
  275. snapPoint={300}
  276. key="ahmet"
  277. >
  278. <Button
  279. title="Open Toast"
  280. variant="filled"
  281. type="warning"
  282. onPress={() => {
  283. NCoreUIKitToast.open({
  284. title: "sdgfsdgsdg",
  285. type: "danger"
  286. });
  287. }}
  288. />
  289. <Button
  290. onPress={() => {
  291. navigation.navigate("TestSubPage");
  292. }}
  293. title="Git."
  294. />
  295. {[
  296. 0,
  297. 1,
  298. 2,
  299. 3,
  300. 4,
  301. 5,
  302. 6,
  303. 7,
  304. 8,
  305. 9,
  306. 10,
  307. 11,
  308. 12,
  309. 13,
  310. 14,
  311. 15,
  312. 16,
  313. 17,
  314. 18,
  315. 19,
  316. 20,
  317. 21,
  318. 22,
  319. 23,
  320. 24,
  321. 25,
  322. 26,
  323. 27,
  324. 28,
  325. 29,
  326. 30,
  327. 31,
  328. 32,
  329. 33,
  330. 34,
  331. 35
  332. ].map((it) => {
  333. return <View
  334. key={`fds-${it}`}
  335. style={{
  336. backgroundColor: `rgb(${it * 10}, ${it > 30 ? it * 5 : "0"}, ${it > 20 ? it * 4 : "0"})`,
  337. height: 150
  338. }}
  339. />;
  340. })}
  341. <Text>Deneme 123</Text>
  342. <Text>Deneme 123</Text>
  343. <Text>Deneme 123</Text>
  344. <Text>Deneme 123</Text>
  345. <Text>Deneme 123</Text>
  346. <Text>Deneme 123</Text>
  347. <Text>Deneme 123</Text>
  348. <Text>Deneme 123</Text>
  349. </BottomSheet>
  350. </Fragment>;
  351. }}
  352. >
  353. <NotificationIndicator
  354. type="danger"
  355. title={53}
  356. >
  357. <Button
  358. size="small"
  359. icon={({
  360. color
  361. }) => <HomeIcon
  362. color={colors.content.icon[color]}
  363. />}
  364. onPress={() => {
  365. }}
  366. />
  367. </NotificationIndicator>
  368. <Switch
  369. spreadBehaviour="stretch"
  370. isActive={isSwitchActive}
  371. title="dsgojksdgpojk"
  372. subTitle="SJFAJdfa"
  373. isDisabled={false}
  374. onPress={() => {
  375. setIsSwitchActive(!isSwitchActive);
  376. }}
  377. />
  378. <RowCard
  379. title="Merhaba"
  380. icon={({
  381. color
  382. }) => <HomeIcon
  383. color={colors.content.icon[color]}
  384. />}
  385. rightIcon={({
  386. color
  387. }) => <ChevronRightIcon
  388. color={colors.content.icon[color]}
  389. />}
  390. />
  391. <RadioButton
  392. isChecked={isRadioActive}
  393. title="sadfasfsafasf"
  394. isDisabled={false}
  395. subTitle="asfgsaf"
  396. onPress={() => {
  397. setIsRadioActive(!isRadioActive);
  398. }}
  399. />
  400. <CheckBox
  401. isChecked={isCheckboxActive}
  402. title="sadfasfsafasf"
  403. isDisabled={false}
  404. subTitle="asfgsaf"
  405. onPress={() => {
  406. setIsCheckboxActive(isCheckboxActive === "checked" ? null : isCheckboxActive === null ? "partially" : "checked");
  407. }}
  408. />
  409. <TextAreaInput
  410. isUpdateOnRealtime={true}
  411. spreadBehaviour="stretch"
  412. placeholder="efsdg"
  413. maxLength={300}
  414. title="Merhaba"
  415. type="success"
  416. isCleanEnabled={true}
  417. icon={({
  418. color
  419. }) => <HomeIcon
  420. color={colors.content.icon[color]}
  421. />}
  422. />
  423. <SelectBox
  424. keyExtractor={(data, index) => `${data.t}-${index}`}
  425. titleExtractor={(data) => data.t}
  426. subTitle="Deneme Subtitle"
  427. // isWorkWithRealtime={false}
  428. hintText="Test deneme"
  429. isShowSubTitle={true}
  430. isMultipleSelect={true}
  431. isWorkWithRealtime={false}
  432. maxChoice={-1}
  433. minChoice={0}
  434. initialSelectedItems={[{
  435. __title: X[0]?.t as string,
  436. __key: `${X[0]?.t}-0`
  437. }]}
  438. isSearchable={true}
  439. title="Deneme Box"
  440. isRequired={true}
  441. data={X}
  442. onMoreLoad={(props) => {
  443. console.log("More Loaded:", props);
  444. }}
  445. />
  446. <TextInput
  447. variant="hidden"
  448. placeholder="dsagdsag"
  449. />
  450. <Text>Version: v{getNCoreUIKitVersion()}</Text>
  451. <Button
  452. onPress={() => {
  453. navigation.navigate("TestSubPage");
  454. }}
  455. title="Open Test Sub Page"
  456. variant="filled"
  457. spreadBehaviour="stretch"
  458. />
  459. <Button
  460. onPress={() => {
  461. bottomSheetRef.current?.open();
  462. }}
  463. type="success"
  464. title="Open Local BottomSheet"
  465. variant="filled"
  466. />
  467. <Button
  468. onPress={() => {
  469. NCoreUIKitBottomSheet.open({
  470. children: <View>
  471. <Text>Deneme 123</Text>
  472. <Text>Deneme 123</Text>
  473. <Text>Deneme 123</Text>
  474. <Text>Deneme 123</Text>
  475. <Text>Deneme 123</Text>
  476. <Text>Deneme 123</Text>
  477. </View>
  478. });
  479. }}
  480. type="success"
  481. title="Open BottomSheet"
  482. variant="filled"
  483. />
  484. <Button
  485. onPress={() => {
  486. setIsDialogActive(!isDialogActive);
  487. }}
  488. type="neutral"
  489. title="Open Local Dialog"
  490. variant="filled"
  491. />
  492. <Button
  493. title="Open Snackbar"
  494. variant="filled"
  495. type="danger"
  496. onPress={() => {
  497. NCoreUIKitSnackBar.open({
  498. title: "sdgdsgs",
  499. icon: ({
  500. color
  501. }) => <HomeIcon color={colors.content.icon[color ? color : "default"]}/>
  502. });
  503. }}
  504. />
  505. <Button
  506. onPress={() => {
  507. NCoreUIKitDialog.open({
  508. content: "etgweı09gı9w0eg",
  509. title: "Merhaba Dünya!",
  510. isVisible: true,
  511. onOverlayPress: ({
  512. closeAnimation
  513. }) => {
  514. closeAnimation();
  515. },
  516. variant: "info",
  517. secondaryButtonProps: {
  518. title: "sdfgsdg",
  519. onPress: () => {
  520. }
  521. },
  522. primaryButtonProps: {
  523. onPress: ({
  524. closeAnimation
  525. }) => {
  526. closeAnimation();
  527. }
  528. }
  529. });
  530. }}
  531. type="neutral"
  532. title="Open Dialog"
  533. variant="filled"
  534. />
  535. <Button
  536. title="Open Toast"
  537. variant="filled"
  538. type="warning"
  539. onPress={() => {
  540. NCoreUIKitToast.open({
  541. title: "sdgfsdgsdafs sdlşlgkdfşiklh",
  542. subTitle: "tr9uıdgfss 0dgklsd",
  543. isShowAction: true,
  544. icon: ({
  545. color
  546. }) => <HomeIcon color={colors.content.icon[color ? color : "default"]}/>
  547. });
  548. }}
  549. />
  550. </PageContainer>;
  551. };
  552. export default Home;