index.tsx 18 KB

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