0.1.107-alpha2 • Published 3 months ago

@gluestack-ui/themed-native-base v0.1.107-alpha2

Weekly downloads
-
License
ISC
Repository
-
Last release
3 months ago

@gluestack-ui/themed-native-base

Introduction

@gluestack-ui/themed-native-base is a drop-in replacement for native-base.

Installation

To use native-base components with gluestack-ui,

  • First update these version listed below and update any other dependancy or dependants for these packages.
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)
  • Make sure your project runs as it should after update.

  • Install the @gluestack-ui/themed-native-base package:

$ yarn add @gluestack-ui/themed-native-base react-native-svg@13.4.0

# or

$ npm i @gluestack-ui/themed-native-base react-native-svg@13.4.0

Usage

Just change your import from native-base to @gluestack-ui/themed-native-base, and all the components along with provider will work as is. You could also use babel or any other webpack or bundler for this.

NextJS

  • If you want it to work with nextJS (page router) you will need to update the next.config.js file from something like this
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/"],
    },
  },
});
  • To this
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,
  }
);
  • Add gs className to Html tag and add flush function from @gluestack-style/react in your _document file. Modify you file from something like this
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;
  • To this
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;

Breaking Changes

Functional variants in extendTheme is not supported yet and will be ignored if passed.

Contributing

We welcome contributions to the @gluestack-ui/themed-native-base. If you have an idea for a bug fix or a better approach, please read our contributing guide instructions on how to submit a pull request.

License

Licensed under the MIT License, Copyright © 2023 GeekyAnts.

0.1.107-alpha2

3 months ago

0.1.107-alpha1

3 months ago

0.1.107

3 months ago

0.1.106

3 months ago

0.1.105

3 months ago

0.1.104

3 months ago

0.1.90

3 months ago

0.1.91

3 months ago

0.1.85

3 months ago

0.1.86

3 months ago

0.1.87

3 months ago

0.1.88

3 months ago

0.1.89

3 months ago

0.1.103

3 months ago

0.1.102

3 months ago

0.1.101

3 months ago

0.1.100

3 months ago

0.1.84

4 months ago

0.1.83

4 months ago

0.1.80

4 months ago

0.1.81

4 months ago

0.1.82

4 months ago

0.1.76

4 months ago

0.1.77

4 months ago

0.1.78

4 months ago

0.1.79

4 months ago

0.1.75

4 months ago

0.1.74

5 months ago

0.1.73

5 months ago

0.1.72

5 months ago

0.1.70

5 months ago

0.1.71

5 months ago

0.1.66

5 months ago

0.1.67

5 months ago

0.1.68

5 months ago

0.1.69

5 months ago

0.1.65

5 months ago

0.1.63

5 months ago

0.1.64

5 months ago

0.1.61

5 months ago

0.1.62

5 months ago

0.1.60

5 months ago

0.1.57

5 months ago

0.1.58

5 months ago

0.1.59

5 months ago

0.1.57-alpha.8

5 months ago

0.1.57-alpha.9

5 months ago

0.1.57-alpha.12

5 months ago

0.1.57-alpha.11

5 months ago

0.1.57-alpha.13

5 months ago

0.1.57-alpha.10

5 months ago

0.1.53

5 months ago

0.1.54

5 months ago

0.1.55

5 months ago

0.1.56

5 months ago

0.1.55-alpha0.1

5 months ago

0.1.55-alpha0.2

5 months ago

0.1.57-alpha.6

5 months ago

0.1.57-alpha.4

5 months ago

0.1.57-alpha.5

5 months ago

0.1.57-alpha.2

5 months ago

0.1.57-alpha.3

5 months ago

0.1.57-alpha.0

5 months ago

0.1.57-alpha.1

5 months ago

0.1.52

5 months ago

0.1.50

5 months ago

0.1.51

5 months ago

0.1.49-alpha0.1

5 months ago

0.1.49

5 months ago

0.1.48

5 months ago

0.1.42

5 months ago

0.1.43

5 months ago

0.1.44

5 months ago

0.1.45

5 months ago

0.1.46

5 months ago

0.1.47

5 months ago

0.1.41

5 months ago

0.1.40

5 months ago

0.1.39

5 months ago

0.1.38

5 months ago

0.1.37

5 months ago

0.1.35

5 months ago

0.1.36

5 months ago

0.1.34

5 months ago

0.1.33

5 months ago

0.1.32

5 months ago

0.1.31-alpha.27

6 months ago

0.1.31-alpha.26

6 months ago

0.1.31-alpha.25

6 months ago

0.1.31-alpha.24

6 months ago

0.1.31-alpha.23

6 months ago

0.1.31-alpha.22

6 months ago

0.1.31-alpha.21

6 months ago

0.1.31-alpha.20

6 months ago

0.1.31-alpha.19

6 months ago

0.1.31-alpha.18

6 months ago

0.1.31-alpha.17

6 months ago

0.1.31-alpha.16

6 months ago

0.1.31-alpha.15

6 months ago

0.1.31-alpha.14

6 months ago

0.1.31-alpha.13

6 months ago

0.1.31-alpha.12

6 months ago

0.1.31-alpha.11

6 months ago

0.1.31-alpha.10

6 months ago

0.1.31-alpha.8

6 months ago

0.1.31-alpha.7

7 months ago

0.1.31-alpha.6

7 months ago

0.1.31-alpha.5

7 months ago

0.1.31-alpha.4

7 months ago

0.1.31-alpha.3

7 months ago

0.1.31-alpha.2

7 months ago

0.1.31-alpha.1

7 months ago

0.1.31-alpha.0

7 months ago

0.1.30-alpha.5

7 months ago

0.1.31

7 months ago

0.1.30-alpha.4

7 months ago

0.1.30-alpha.3

7 months ago

0.1.30-alpha.2

7 months ago

0.1.30-alpha.1

7 months ago

0.1.30-alpha.0

7 months ago

0.1.30

7 months ago

0.1.29

7 months ago

0.1.28

7 months ago

0.1.27

7 months ago

0.1.26

7 months ago

0.1.25

7 months ago

0.1.24

7 months ago

0.1.23

7 months ago

0.1.22

7 months ago

0.1.21

7 months ago

0.1.20

7 months ago

0.1.19

7 months ago

0.1.18

8 months ago

0.1.17

8 months ago

0.1.16

8 months ago

0.1.15

8 months ago

0.1.14

8 months ago

0.1.13

8 months ago

0.1.12

8 months ago

0.1.11-alpha.2

8 months ago

0.1.11-alpha.1

8 months ago

0.1.10

8 months ago

0.1.9

8 months ago

0.1.8

9 months ago

0.1.7

9 months ago

0.1.6

9 months ago

0.1.5

9 months ago

0.1.4

9 months ago

0.1.3

9 months ago

0.1.1

9 months ago

0.1.0

9 months ago