{"id":17035156,"url":"https://github.com/chandu0101/scalajs-react-native","last_synced_at":"2025-03-22T17:31:20.255Z","repository":{"id":29687885,"uuid":"33230450","full_name":"chandu0101/scalajs-react-native","owner":"chandu0101","description":"build native mobile applications using scala.js and react-native - please check https://github.com/chandu0101/sri where future work is going to take place :) ","archived":false,"fork":false,"pushed_at":"2017-04-17T09:13:37.000Z","size":4962,"stargazers_count":79,"open_issues_count":2,"forks_count":11,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-18T13:51:16.903Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chandu0101.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-01T06:24:41.000Z","updated_at":"2022-08-24T08:02:50.000Z","dependencies_parsed_at":"2022-09-05T16:20:38.010Z","dependency_job_id":null,"html_url":"https://github.com/chandu0101/scalajs-react-native","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chandu0101%2Fscalajs-react-native","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chandu0101%2Fscalajs-react-native/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chandu0101%2Fscalajs-react-native/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chandu0101%2Fscalajs-react-native/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chandu0101","download_url":"https://codeload.github.com/chandu0101/scalajs-react-native/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244995113,"owners_count":20544287,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T08:45:47.302Z","updated_at":"2025-03-22T17:31:19.874Z","avatar_url":"https://github.com/chandu0101.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Please check https://github.com/chandu0101/sri (this is where future work is going to take place)\n\n# scalajs-react-native\nScalaJS wrapper for [react-native](https://facebook.github.io/react-native/) .This project depends on [scalajs-react](https://github.com/japgolly/scalajs-react) , so you must be familiar with scalajs-react in order to use this library.\n\n![movies](examples/images/movies.gif) \n\n\n# Index \n\n- [Setup](#setup)\n- [Styles](#styles)\n- [Examples](#examples)\n- [Project Template](#template)\n\n# Setup\n\nadd this to your sbt build file\n\n```scala\n\nlibraryDependencies += \"com.github.chandu0101.scalajs-react-native\" %%% \"core\" % \"0.2.0\"\n\n```\n\nimports \n\n```scala\nimport chandu0101.scalajs.rn._ // to import core builderReactNativeComponentB etc \nimport chandu0101.scalajs.rn.components._ // for all native components\nimport chandu0101.scalajs.rn.apis._ // for native API calls\n\n\n```\n\nscalajs-react-native comes with ReactNativeComponentB (its clone of scalajs-react ReactComponentB with native dependencies and extra helper methods ).\n\n#### Defining Components :\n\nto define components just follow ReactComponentB guide lines\n\nexample : \n\n```scala\n val HelloNative = ReactNativeComponentB[Unit](\"HelloNative\")\n    .render(P =\u003e {\n    View(style = styles.container)(\n       Text(style = styles.text)(\"Welcome to Scala-JS ReactNative\"),\n       Text(style = styles.text)(\"To get started, edit HelloNative.scala \")\n    )\n  }).buildU\n\n```\n\n#### Defining Root Component : \n\nto define root component use buildNative method from builder .\n\nexample : \n\n```scala\n\n  val ScalaJSReactNative = ReactNativeComponentB[Unit](\"ScalaJSReactNative\")\n      .render((P) =\u003e {\n        HelloNative()\n    }).buildNative //If your component is going to be render by other third party component then use buildNative\n\n    ReactNative.AppRegistry.registerComponent(\"ScalaJSReactNative\", () =\u003e ScalaJSReactNative)\n    \n```\n\n\n# Styles\n\nReact Native doesn't implement CSS but instead relies on JavaScript to let you style your application. You can define styles in dynamic/typesafe way \n\n##### Dynamic Way :\n \n Use js.Dynamic.literal to define js styles\n \nExample : \n\n```scala\n import scala.scalajs.js.Dynamic.{literal =\u003e json}\n  val styles = ReactNative.StyleSheet.create(\n    json(\n      container = json(flex = 1,\n        backgroundColor = \"#F5FCFF\"),\n      textCenter = json(textAlign = \"center\",marginTop = 10)\n    )\n  )\n  \n  //access styles \n   View(style = styles.container)(..)\n```  \n\n###### TypeSafe Way :  \n\n In order to define styles in type safe manner you need styles module\n \n ```scala\n libraryDependencies += \"com.github.chandu0101.scalajs-react-native\" %%% \"styles\" % \"0.2.0\"\n \n ```\n \n extend ``trait NativeStyleSheet`` to define style sheets . NativeStyleSheet comes with two methods ``style`` (which takes attr value pairs)and ``styleE`` (this is used to extend already defined styles).\n \n Example : \n \n```scala \n  object styles extends NativeStyleSheet {\n    val centering = style(\n      alignItems.center,\n      justifyContent.center\n    )\n    val gray = style(backgroundColor := \"#cccccc\")\n    val horizontal = style(flexDirection.row, justifyContent.center)\n    val default = styleE(centering, gray)(height := 40)\n  }\n  \n ```\n  \n#Examples\n\nNumber of examples can be found in [examples](https://github.com/chandu0101/scalajs-react-native/tree/master/examples) module\n\n#### How to run examples :\n\n```scala\n\n sbt ~fullOptIOS\n \n // open new terminal tab/window\n cd examples\n npm install\n npm run start // start react-native package\n \n Open ScalaJSReactNative.xcodeproj using latest xcode\n \n Cmd+R - to run project\n \n Cmd+D - to debug project\n \n Cmd+B - to build\n \n Cmd+Shift+K - to cleanup\n\n```\n\n#Template\n\nA basic scalajs-react-native skeleton app can be found here\n\nhttps://github.com/chandu0101/scalajs-react-native-template\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchandu0101%2Fscalajs-react-native","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchandu0101%2Fscalajs-react-native","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchandu0101%2Fscalajs-react-native/lists"}