Git Product home page Git Product logo

rn-native-base's Introduction

rn-native-base

native-base wrapper for Clojurescript

Clojars

Full usage tutorial

Create a Clojurescript react-native project. For the detailed info how to do it, check the rn-native-base-example-todo example project using this library.

Short usage info

Add Clojurscript rn-native-base dependency

Add rn-native-base as a dependency to your project.

[rn-native-base "<Latest-Version>"]

Add native-base dependency to react-native

You can use both npm and yarn tools

yarn add native-base
npm install --save native-base

After installing you need to link it to your project

npx react-native link

Code

Import rn-native base and start coding. The example below is from rn-native-base-example-todo example project. Check it's source code for the sample working code.

(ns rn.native-base-example-todo.todo-screen
  (:require [steroid.rn.core :as rn]
            [re-frame.core :as rf]
            [reagent.core :as r]
            [rn.native-base.core :as nb]
            [rn.native-base.easy-grid :as eg]))

(defn- todo-item [{:keys [key text checked]}]
  [nb/list-item {:key key}
   [nb/check-box {:checked  checked
                  :on-press #(rf/dispatch [:todos/check key])}]
   [nb/body {:style {:flex 1}}
    [nb/text {:style {:font-size 17 :font-weight :bold :text-decoration-line (if checked :line-through :none)}}
     (str text)]]
   [rn/touchable-opacity {:on-press #(rf/dispatch [:todos/delete key])}
    [nb/icon {:name "trash" :style {:font-size 30 :color :red}}]]])

(defn- todos []
  (let [todos (rf/subscribe [:todos/all])]
    [rn/flat-list {:data @todos :render-fn todo-item}]))

(defn- input-container []
  (let [value (r/atom "")]
    (fn []
      [nb/list-item {:no-indent true :style {:border-bottom-width 3}}
       [nb/input {:multiline      true
                  :placeholder    "What do you want to do today?" :placeholder-text-color "#abbabb"
                  :value          @value
                  :on-change-text (fn [v] (reset! value v) (r/flush))}]
       [rn/touchable-opacity {:on-press (fn [] (rf/dispatch [:todos/add @value]) (reset! value ""))}
        [nb/icon {:name  :add :type "MaterialIcons"
                  :style {:font-size 30 :color :blue}}]]])))

(defn screen []
  [nb/container
   [nb/header {:transparent true}
    [nb/left]
    [nb/body
     [nb/h1 {:style {:color :red}} "Todo List"]]]
   [nb/view
    [input-container]
    [todos]]])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.