index.tsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. import {
  2. useLayoutEffect
  3. } from "react";
  4. import {
  5. View
  6. } from "react-native";
  7. import stylesheet from "./stylesheet";
  8. import {
  9. NCoreUIKitLocalize,
  10. NCoreUIKitTheme,
  11. PageContainer,
  12. CodeViewer,
  13. Button,
  14. Header,
  15. Text
  16. } from "ncore-ui-kit";
  17. import {
  18. useNavigation
  19. } from "@react-navigation/native";
  20. import type RootStackParamList from "../../navigation/type";
  21. import type {
  22. NativeStackNavigationProp
  23. } from "@react-navigation/native-stack";
  24. import {
  25. ChevronRightIcon,
  26. ChevronLeftIcon
  27. } from "lucide-react-native";
  28. const Implementation = () => {
  29. const {
  30. colors,
  31. spaces
  32. } = NCoreUIKitTheme.useContext();
  33. const {
  34. localize
  35. } = NCoreUIKitLocalize.useContext();
  36. const navigation = useNavigation<NativeStackNavigationProp<RootStackParamList>>();
  37. useLayoutEffect(() => {
  38. navigation.setOptions({
  39. header: () => <Header
  40. title={localize("implementation-title")}
  41. isWrapSafeareaContext={false}
  42. navigation={navigation}
  43. isGoBackEnable={true}
  44. />,
  45. headerShown: true
  46. });
  47. }, []);
  48. const exampleCode = `import {
  49. type NCoreUIKitConfig,
  50. setupNCoreUIKit,
  51. Host
  52. } from "ncore-ui-kit";
  53. // Kendi temanızı ve dil dosyanızı dahil edin
  54. import defaultLocaleJSON from "./variants/locales/default.json";
  55. import defaultThemeJSON from "./variants/themes/default.json";
  56. // NCore konfigürasyonunu oluşturun
  57. const NCoreConfig: NCoreUIKitConfig = {
  58. projectThemes: defaultThemeJSON as NCoreUIKit.Palette,
  59. initialSelectedGapPropagation: "spacious",
  60. projectLocales: defaultLocaleJSON,
  61. initialSelectedPalette: "nibgat",
  62. initialSelectedTheme: "light"
  63. };
  64. // NCoreUIKitBase nesnesini ayağa kaldırın
  65. const NCoreUIKitBase = setupNCoreUIKit(NCoreConfig);
  66. const App = () => {
  67. return <NCoreUIKitBase.Provider>
  68. <Host name="main-header">
  69. {/* Sayfalarınız veya Navigasyon yapınız burada yer almalı */}
  70. </Host>
  71. </NCoreUIKitBase.Provider>;
  72. };
  73. export default App;`;
  74. const expoMetroConfigCode = `// For Expo
  75. const { getDefaultConfig } = require("expo/metro-config");
  76. const { withNCoreUIKit } = require("ncore-ui-kit/metro-config");
  77. const config = getDefaultConfig(__dirname);
  78. module.exports = withNCoreUIKit(config);`;
  79. const bareMetroConfigCode = `// For Bare React Native CLI
  80. const { getDefaultConfig } = require("@react-native/metro-config");
  81. const { withNCoreUIKit } = require("ncore-ui-kit/metro-config");
  82. const config = getDefaultConfig(__dirname);
  83. module.exports = withNCoreUIKit(config);`;
  84. const defaultWebpackCode = `// webpack.config.js
  85. const { createDefaultWebpackConfig } = require("ncore-ui-kit/webpack-config");
  86. module.exports = createDefaultWebpackConfig({
  87. appDirectory: require("path").resolve(__dirname, "./"),
  88. HtmlWebpackPlugin: require("html-webpack-plugin"),
  89. ESLintPlugin: require("eslint-webpack-plugin"),
  90. CopyPlugin: require("copy-webpack-plugin"),
  91. webpack: require("webpack")
  92. });`;
  93. const wrapWebpackCode = `// webpack.config.js
  94. const { withNCoreUIKitWebpack } = require("ncore-ui-kit/webpack-config");
  95. const webpack = require("webpack");
  96. let config = {
  97. // ... existing configuration
  98. };
  99. module.exports = withNCoreUIKitWebpack(config, webpack);`;
  100. const envSetupCode = `npx ncore-type-kit`;
  101. const autoSetupCode = `npx ncore-setup
  102. # Sadece web için: npx ncore-setup-web
  103. # Sadece mobil için: npx ncore-setup-mobile`;
  104. return <PageContainer
  105. isWorkWithHeaderSpace={false}
  106. isScrollable={true}
  107. >
  108. <View
  109. style={[
  110. stylesheet.paddedContainer,
  111. {
  112. padding: spaces.spacingMd
  113. }
  114. ]}
  115. >
  116. <Text
  117. style={{
  118. marginBottom: spaces.spacingMd
  119. }}
  120. variant="bodyMediumSize"
  121. color="mid"
  122. >
  123. {localize("implementation-desc")}
  124. </Text>
  125. <View
  126. style={[
  127. stylesheet.borderedCard,
  128. {
  129. backgroundColor: colors.content.container.default,
  130. borderColor: colors.content.border.subtle,
  131. marginBottom: spaces.spacingMd,
  132. padding: spaces.spacingMd
  133. }
  134. ]}
  135. >
  136. <Text
  137. variant="headlineSmallSize"
  138. >
  139. {localize("your-project-main-directory")}/src/index.tsx
  140. </Text>
  141. <CodeViewer
  142. code={exampleCode}
  143. language="tsx"
  144. />
  145. </View>
  146. <Text
  147. style={{
  148. marginBottom: spaces.spacingMd
  149. }}
  150. variant="bodyMediumSize"
  151. color="mid"
  152. >
  153. Web (Webpack) ve Mobil (Metro) ayarlarınızı NCore UI Kit ile uyumlu hale getirmek için otomatik kurulum komutlarını kullanabilirsiniz:
  154. </Text>
  155. <View
  156. style={[
  157. stylesheet.borderedCard,
  158. {
  159. backgroundColor: colors.content.container.default,
  160. borderColor: colors.content.border.subtle,
  161. marginBottom: spaces.spacingMd,
  162. padding: spaces.spacingMd
  163. }
  164. ]}
  165. >
  166. <Text
  167. variant="headlineSmallSize"
  168. >
  169. Terminal (Otomatik Yapılandırma)
  170. </Text>
  171. <CodeViewer
  172. code={autoSetupCode}
  173. language="bash"
  174. />
  175. </View>
  176. <Text
  177. style={{
  178. marginBottom: spaces.spacingMd
  179. }}
  180. variant="bodyMediumSize"
  181. color="mid"
  182. >
  183. Mobil (React Native / Expo) ortamında kurulum yaparken, otomatik kurulumu tercih etmezseniz metro.config.js dosyanızı NCore UIKit ile manuel sarmalamanız (wrap) gerekir.
  184. </Text>
  185. <View
  186. style={[
  187. stylesheet.borderedCard,
  188. {
  189. backgroundColor: colors.content.container.default,
  190. borderColor: colors.content.border.subtle,
  191. marginBottom: spaces.spacingMd,
  192. padding: spaces.spacingMd
  193. }
  194. ]}
  195. >
  196. <Text
  197. variant="headlineSmallSize"
  198. >
  199. {localize("your-project-main-directory")}/metro.config.js (Expo)
  200. </Text>
  201. <CodeViewer
  202. code={expoMetroConfigCode}
  203. language="javascript"
  204. />
  205. </View>
  206. <View
  207. style={[
  208. stylesheet.borderedCard,
  209. {
  210. backgroundColor: colors.content.container.default,
  211. borderColor: colors.content.border.subtle,
  212. marginBottom: spaces.spacingMd,
  213. padding: spaces.spacingMd
  214. }
  215. ]}
  216. >
  217. <Text
  218. variant="headlineSmallSize"
  219. >
  220. {localize("your-project-main-directory")}/metro.config.js (React Native CLI)
  221. </Text>
  222. <CodeViewer
  223. code={bareMetroConfigCode}
  224. language="javascript"
  225. />
  226. </View>
  227. <Text
  228. style={{
  229. marginBottom: spaces.spacingMd
  230. }}
  231. variant="bodyMediumSize"
  232. color="mid"
  233. >
  234. Web (React Native Web) ortamında derleme yapmak için, otomatik kurulumu kullanmak yerine NCore'un hazır Webpack ayarını kullanabilir veya mevcut ayarınızı manuel sarmalayabilirsiniz.
  235. </Text>
  236. <View
  237. style={[
  238. stylesheet.borderedCard,
  239. {
  240. backgroundColor: colors.content.container.default,
  241. borderColor: colors.content.border.subtle,
  242. marginBottom: spaces.spacingMd,
  243. padding: spaces.spacingMd
  244. }
  245. ]}
  246. >
  247. <Text
  248. variant="headlineSmallSize"
  249. >
  250. {localize("your-project-main-directory")}/webpack.config.js (Hazır Ayar)
  251. </Text>
  252. <CodeViewer
  253. code={defaultWebpackCode}
  254. language="javascript"
  255. />
  256. </View>
  257. <View
  258. style={[
  259. stylesheet.borderedCard,
  260. {
  261. backgroundColor: colors.content.container.default,
  262. borderColor: colors.content.border.subtle,
  263. marginBottom: spaces.spacingMd,
  264. padding: spaces.spacingMd
  265. }
  266. ]}
  267. >
  268. <Text
  269. variant="headlineSmallSize"
  270. >
  271. {localize("your-project-main-directory")}/webpack.config.js (Sarmalama)
  272. </Text>
  273. <CodeViewer
  274. code={wrapWebpackCode}
  275. language="javascript"
  276. />
  277. </View>
  278. <Text
  279. style={{
  280. marginBottom: spaces.spacingMd
  281. }}
  282. variant="bodyMediumSize"
  283. color="mid"
  284. >
  285. Geliştirme ortamınızın (ESLint, TS, VSCode vb.) NCore UI Kit ile aynı standartlara sahip olmasını istiyorsanız tek tıkla projenizi yapılandırabilirsiniz:
  286. </Text>
  287. <View
  288. style={[
  289. stylesheet.borderedCard,
  290. {
  291. backgroundColor: colors.content.container.default,
  292. borderColor: colors.content.border.subtle,
  293. marginBottom: spaces.spacingMd,
  294. padding: spaces.spacingMd
  295. }
  296. ]}
  297. >
  298. <Text
  299. variant="headlineSmallSize"
  300. >
  301. Terminal (Tip ve Lint Ayarları)
  302. </Text>
  303. <CodeViewer
  304. code={envSetupCode}
  305. language="bash"
  306. />
  307. </View>
  308. <View
  309. style={[
  310. stylesheet.rowSpaceBetween,
  311. {
  312. marginTop: spaces.spacingMd
  313. }
  314. ]}
  315. >
  316. <Button
  317. onPress={() => {
  318. navigation.navigate("GettingStarted", {
  319. screen: "Installation"
  320. });
  321. }}
  322. icon={({
  323. color,
  324. size
  325. }) => {
  326. return <ChevronLeftIcon
  327. color={colors.content.icon[color]}
  328. size={size + 3}
  329. />;
  330. }}
  331. title={localize("installation")}
  332. iconDirection="left"
  333. />
  334. <Button
  335. icon={({
  336. color,
  337. size
  338. }) => {
  339. return <ChevronRightIcon
  340. color={colors.content.icon[color]}
  341. size={size + 3}
  342. />;
  343. }}
  344. onPress={() => {
  345. navigation.navigate("CoreFeatures", {
  346. screen: "ToolsUsage"
  347. });
  348. }}
  349. title={localize("coreFeatures")}
  350. iconDirection="right"
  351. />
  352. </View>
  353. </View>
  354. </PageContainer>;
  355. };
  356. export default Implementation;