index.tsx 17 KB

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