@gluestack-ui/themed-native-base

中文文档
0.1.108发布于 2024/05/20ISCTypeScriptCommonJS近 30 天下载 5932

React 本地, Next.js 和 React 的通用主题组件

中文使用文档
文档目录6 节
  1. 导言
  2. 安装
  3. 使用量
  4. 中断更改
  5. 捐款
  6. 许可证

@gluestack-ui/主题本土基础

gluestack-ui logo

导言

@gluestack-ui/主题本土基础 是一个即时替换 native-base。 。 。 .

安装

用于 native-base 组件 gluestack-ui, (中文(简体) ),

  • 以下列出这些版本的第一次更新,并更新这些软件包的任何其他依赖性或受扶养人.
react >= 18
react-dom >= 18
react-native >= 0.72
react-native-web >= 0.18
react-native-svg >= 13.4.0
native-base == 3.4.* (other versions will work, but styling and config will defer)
  • 确保您的项目在更新后运行 .

  • 安装 @gluestack-ui/themed-native-base 软件包 :

$ yarn add @gluestack-ui/themed-native-base [email protected]

# or

$ npm i @gluestack-ui/themed-native-base [email protected]

使用量

只要改变您的导入从 native-base 改为 @gluestack-ui/themed-native-base,所有组件和提供者将一如既往地发挥作用. 你也可以用Babel或其他任何网络包装或捆绑机来做这个.

下一个 JS

  • 如果您想要与下一个 JS( 页面路由器) 工作, 您需要更新 next.config.js 像这样的文件
const { withNativebase } = require("@native-base/next-adapter");
const path = require("path");

module.exports = withNativebase({
  dependencies: ["@native-base/icons", "react-native-web-linear-gradient"],
  nextConfig: {
    webpack: (config, options) => {
      config.module.rules.push({
        test: /\.ttf$/,
        loader: "url-loader", // or directly file-loader
        include: path.resolve(__dirname, "node_modules/@native-base/icons"),
      });
      config.resolve.alias = {
        ...(config.resolve.alias || {}),
        "react-native$": "react-native-web",
        "react-native-linear-gradient": "react-native-web-linear-gradient",
      };
      config.resolve.extensions = [
        ".web.js",
        ".web.ts",
        ".web.tsx",
        ...config.resolve.extensions,
      ];
      return config;
    },
    images: {
      domains: ["https://b.zmtcdn.com/web_assets", "upload.wikimedia.org/"],
    },
  },
});
  • 为了这个
const path = require("path");

const { withExpo } = require("@expo/next-adapter");
const withPlugins = require("next-compose-plugins");

const withTM = require("next-transpile-modules")([
  "react-native-web",
  "react-native",

  "@expo/vector-icons",

  "@gluestack-style/react",
  "@gluestack-style/legend-motion-animation-driver",
  "@gluestack-style/animation-plugin",
  "@gluestack-style/animation-resolver",
  "@gluestack-style/legend-motion-animation-driver",
  "@legendapp/motion",

  "@expo/html-elements",

  "react-native-svg",
  "@react-native-aria/interactions",
  "@react-native-aria/checkbox",
  "@react-native-aria/focus",
  "@react-native-aria/overlays",
  "@react-native-aria/radio",
  "@react-native-aria/slider",
  "@react-stately/slider",
  "@react-native-aria/toggle",
  "@react-native-aria/utils",
  "@react-native-aria/menu",
  "@gluestack-ui/actionsheet",
  "@gluestack-ui/form-control",
  "@gluestack-ui/avatar",
  "@gluestack-ui/modal",
  "@gluestack-ui/button",
  "@gluestack-ui/checkbox",
  "@gluestack-ui/divider",
  "@gluestack-ui/fab",
  "@gluestack-ui/hooks",
  "@gluestack-ui/hstack",
  "@gluestack-ui/icon",
  "@gluestack-ui/input",
  "@gluestack-ui/link",
  "@gluestack-ui/menu",
  "@gluestack-ui/modal",
  "@gluestack-ui/overlay",
  "@gluestack-ui/popover",
  "@gluestack-ui/progress",
  "@gluestack-ui/provider",
  "@gluestack-ui/radio",
  "@gluestack-ui/select",
  "@gluestack-ui/slider",
  "@gluestack-ui/spinner",

  "@gluestack-ui/switch",
  "@gluestack-ui/textarea",
  "@gluestack-ui/toast",
  "@gluestack-ui/tooltip",
  "@gluestack-ui/vstack",
  "@gluestack-ui/transitions",
  "@gluestack-ui/utils",
  "@gluestack-ui/tabs",
  "@gluestack-ui/react-native-aria",
  "@gluestack-ui/alert-dialog",
  "@gluestack-ui/pressable",
  "@gluestack-ui/themed-native-base",
  "@native-base/icons",
  "react-native-vector-icons",
  "@native-base/next-adapter",
  "react-native-web-linear-gradient",
]);

const nextConfig = {
  webpack: (config, options) => {
    config.module.rules.push({
      test: /\.ttf$/,
      loader: "url-loader", // or directly file-loader
      include: path.resolve(__dirname, "node_modules/@native-base/icons"),
    });
    config.resolve.alias = {
      ...(config.resolve.alias || {}),
      "react-native$": "react-native-web",
      "react-native-linear-gradient": "react-native-web-linear-gradient",
    };
    config.resolve.extensions = [
      ".web.js",
      ".web.ts",
      ".web.tsx",
      ...config.resolve.extensions,
    ];
    return config;
  },
  images: {
    domains: ["https://b.zmtcdn.com/web_assets", "upload.wikimedia.org/"],
  },
};

module.exports = withPlugins(
  [[withTM], [withExpo, { projectRoot: __dirname }]],
  {
    ...nextConfig,
  }
);

  • 添加 gs 类名到 Html 标记并添加从 @gluestack-style/react 在你身边 _document 文档。 从这样的东西修改文件

import { default as NativebaseDocument } from "@native-base/next-adapter/document";
import fontsCSS from "@native-base/icons/FontsCSS";
import { AppRegistry } from "react-native";
import { Main } from "next/document";
import * as React from "react";
import NextDocument, { Html, Head, NextScript } from "next/document";

class Document extends NativebaseDocument {
  // render() {
  //   return (
  //     <Html>
  //       <Head />
  //       <body>
  //         <Main />
  //         <NextScript />
  //       </body>
  //     </Html>
  //   );
  // }
}

async function getInitialProps({ renderPage }) {
  AppRegistry.registerComponent("Main", () => Main);
  const { getStyleElement } = AppRegistry.getApplication("Main");
  const page = await renderPage();
  const styles = [
    <style dangerouslySetInnerHTML={{ __html: fontsCSS }} />,
    getStyleElement(),
  ];
  return { ...page, styles: React.Children.toArray(styles) };
}

Document.getInitialProps = getInitialProps;

export default Document;

  • 为了这个
import fontsCSS from "@native-base/icons/FontsCSS";
import { AppRegistry } from "react-native-web"
import { flush } from "@gluestack-style/react"
import { Main } from "next/document";
import * as React from "react";
import NextDocument, { Html, Head, NextScript } from "next/document";

function Document(){
  return (
    <Html className="gs" lang="en">
      <Head />
      <body>
        <Main />
        <NextScript />
      </body>
    </Html>
  );
}

async function getInitialProps({ renderPage }) {
  AppRegistry.registerComponent("Main", () => Main);
  const { getStyleElement } = AppRegistry.getApplication("Main");
  const page = await renderPage();
  const styles = [
    <style dangerouslySetInnerHTML={{ __html: fontsCSS }} />,
    getStyleElement(),
    ...flush()
  ];
  return { ...page, styles: React.Children.toArray(styles) };
}

Document.getInitialProps = getInitialProps;

export default Document;

中断更改

扩展中的功能变体Theme还没有被支持,如果通过将会被忽略.

捐款

我们欢迎各方为会议提供捐款 @gluestack-ui/themed-native-base。如果您对错误修复或更好的方法有想法,请阅读我们 贡献指南 指示如何提交拉动请求.

许可证

获得麻省理工学院许可,版权2023 Geekynats.

版本与发布记录

@gluestack-ui/themed-native-base 共发布 152 个版本,首次发布于 2023/08/21;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.1.108latest2024/05/202 年前
0.1.107-alpha22024/02/092 年前
0.1.107-alpha1alpha2024/02/092 年前
0.1.1072024/02/072 年前
0.1.1062024/02/052 年前
0.1.1052024/02/052 年前

关于 @gluestack-ui/themed-native-base 的常见问题

@gluestack-ui/themed-native-base 是什么?

React 本地, Next.js 和 React 的通用主题组件

如何安装 @gluestack-ui/themed-native-base?

在项目目录运行 npm install @gluestack-ui/themed-native-base,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=16)、react-dom(>=16)、react-native(>=0.72)、react-native-svg(>=13.4.0)、react-native-web(>=0.19)、@types/react-native(>=0.72)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@gluestack-ui/themed-native-base 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@gluestack-ui/themed-native-base 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@gluestack-ui/themed-native-base 可以商用吗?

@gluestack-ui/themed-native-base 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@gluestack-ui/themed-native-base 的下载量有多少?

根据 npm 官方下载统计,@gluestack-ui/themed-native-base 在 2026/10/17 – 2026/11/15 这 30 天内被下载 5,932 次,日均约 198 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@gluestack-ui/themed-native-base 还在维护吗?

最新版本 0.1.108 发布于 2024/05/20(2 年前);至今共发布 152 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/08/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。