Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions examples/react-native-app/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
ios
android
.expo
.vscode
ignite/ignite.json
package.json
.eslintignore
105 changes: 105 additions & 0 deletions examples/react-native-app/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// https://docs.expo.dev/guides/using-eslint/
module.exports = {
root: true,
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:react-native/all',
// `expo` must come after `standard` or its globals configuration will be overridden
'expo',
// `jsx-runtime` must come after `expo` or it will be overridden
'plugin:react/jsx-runtime',
'prettier',
],
plugins: ['reactotron', 'prettier'],
rules: {
'prettier/prettier': 'error',
// typescript-eslint
'@typescript-eslint/array-type': 0,
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/no-require-imports': 0,
'@typescript-eslint/no-empty-object-type': 0,
// eslint
'no-use-before-define': 0,
'no-restricted-imports': [
'error',
{
paths: [
// Prefer named exports from 'react' instead of importing `React`
{
name: 'react',
importNames: ['default'],
message: "Import named exports from 'react' instead.",
},
{
name: 'react-native',
importNames: ['SafeAreaView'],
message: "Use the SafeAreaView from 'react-native-safe-area-context' instead.",
},
{
name: 'react-native',
importNames: ['Text', 'Button', 'TextInput'],
message: "Use the custom wrapper component from '@/components'.",
},
],
},
],
// react
'react/prop-types': 0,
// react-native
'react-native/no-raw-text': 0,
// reactotron
'reactotron/no-tron-in-production': 'error',
// eslint-config-standard overrides
'comma-dangle': 0,
'no-global-assign': 0,
'quotes': 0,
'space-before-function-paren': 0,
// eslint-import
'import/order': [
'error',
{
'alphabetize': {
order: 'asc',
caseInsensitive: true,
},
'newlines-between': 'always',
'groups': [['builtin', 'external'], 'internal', 'unknown', ['parent', 'sibling'], 'index'],
'distinctGroup': false,
'pathGroups': [
{
pattern: 'react',
group: 'external',
position: 'before',
},
{
pattern: 'react-native',
group: 'external',
position: 'before',
},
{
pattern: 'expo{,-*}',
group: 'external',
position: 'before',
},
{
pattern: '@/**',
group: 'unknown',
position: 'after',
},
],
'pathGroupsExcludedImportTypes': ['react', 'react-native', 'expo', 'expo-*'],
},
],
'import/newline-after-import': 1,
},
}
97 changes: 97 additions & 0 deletions examples/react-native-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
ios/.xcode.env.local

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml
*.hprof
.cxx/

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
*.keystore
!debug.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

**/fastlane/report.xml
**/fastlane/Preview.html
**/fastlane/screenshots
**/fastlane/test_output

# Bundle artifact
*.jsbundle

# Ignite-specific items below
# You can safely replace everything above this comment with whatever is
# in the default .gitignore generated by React-Native CLI

# VS Code
.vscode

# Expo
.expo/*
bin/Exponent.app


expo-env.d.ts

## Secrets
npm-debug.*
*.jks
*.p8
*.p12
*.key
*.mobileprovision
*.orig.*
web-build/

# Configurations
!env.js

/coverage

# Yarn
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
57 changes: 57 additions & 0 deletions examples/react-native-app/.maestro/shared/_OnFlowStart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# flow: Shared _OnFlowStart
#intent:
# launch the app with a completely clear state, wait for animations to settle,
# and click through the expo dev screens if needed.
# These conditionals slow the app launch down a little but are necessary because the expo
# dev server and launch screen are only shown when the new architecture is turned off in expo 53.
# So we check to see if we need to connect to the metro server... that loads the app and then we
# check if the dev menu is showing and dismiss it if necessary.
# Then the app is then launched and ready for the maestro tests to run.
#
# This flow should be included in every maestro test header as `onFlowStart` to ensure expo screens
# are bypassed if necessary. Example:
#
# appId: ${MAESTRO_APP_ID}
# onFlowStart:
# - runFlow: ../shared/_OnFlowStart.yaml
# ---
# [your maestro flow]
#
appId: ${MAESTRO_APP_ID}
---
# launch the app with a clean slate
- launchApp:
clearState: true
clearKeychain: true
stopApp: true

- waitForAnimationToEnd

# conditionally run the dev client flow if the words "Development servers" is present.
# this uses the default maestro timeout and moves on if it doesn't see the text.
- runFlow:
when:
visible: 'Development servers'
commands:
# this regex allows for different hosts and ports
- tapOn: "http://.*:.*"
- waitForAnimationToEnd

- runFlow:
when:
platform: Android
visible:
id: "${MAESTRO_APP_ID}:id/bottom_sheet" # id of the android bottom sheet we want to dismiss
commands:
- swipe:
direction: DOWN
- waitForAnimationToEnd
- runFlow:
when:
platform: iOS
visible:
id: "SBSwitcherWindow:Main" # id of the iOS bottom sheet we want to dismiss
commands:
- swipe:
direction: DOWN
- waitForAnimationToEnd
9 changes: 9 additions & 0 deletions examples/react-native-app/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
ios
android
.expo
.vscode
ignite/ignite.json
package.json
.eslintignore
*.ejs
7 changes: 7 additions & 0 deletions examples/react-native-app/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"printWidth": 100,
"semi": false,
"singleQuote": true,
"trailingComma": "all",
"quoteProps": "consistent"
}
91 changes: 91 additions & 0 deletions examples/react-native-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# React Native OpenID Connect example

This example shows how to authenticate users in a React Native (Expo) app using OpenID Connect,
via [`react-native-app-auth`](https://github.com/openid/AppAuth-JS) (`login`/`logout` in
[`app/utils/useAuth.ts`](./app/utils/useAuth.ts)).

## OIDC setup

Register a **native/public** OIDC client at your identity provider with this redirect URI:

```
react-native-app://oauthredirect
```

Then set `oidcClientId` (and `oidcIssuer`/`oidcRedirectUrl` if different) in
[`app/config/config.base.ts`](./app/config/config.base.ts). Until `oidcClientId` is set, `login()`
logs an error instead of opening the auth screen.

This app is built with Expo + Ignite. Below is the standard Ignite boilerplate documentation.

- [Quick start documentation](https://github.com/infinitered/ignite/blob/master/docs/boilerplate/Boilerplate.md)
- [Full documentation](https://github.com/infinitered/ignite/blob/master/docs/README.md)

## Getting Started

```bash
npm install
npm run start
```

To make things work on your local simulator, or on your phone, you need first to [run `eas build`](https://github.com/infinitered/ignite/blob/master/docs/expo/EAS.md). We have many shortcuts on `package.json` to make it easier:

```bash
npm run build:ios:sim # build for ios simulator
npm run build:ios:dev # build for ios device
npm run build:ios:prod # build for ios device
```

### `./assets` directory

This directory is designed to organize and store various assets, making it easy for you to manage and use them in your application. The assets are further categorized into subdirectories, including `icons` and `images`:

```tree
assets
├── icons
└── images
```

**icons**
This is where your icon assets will live. These icons can be used for buttons, navigation elements, or any other UI components. The recommended format for icons is PNG, but other formats can be used as well.

Ignite comes with a built-in `Icon` component. You can find detailed usage instructions in the [docs](https://github.com/infinitered/ignite/blob/master/docs/boilerplate/app/components/Icon.md).

**images**
This is where your images will live, such as background images, logos, or any other graphics. You can use various formats such as PNG, JPEG, or GIF for your images.

Another valuable built-in component within Ignite is the `AutoImage` component. You can find detailed usage instructions in the [docs](https://github.com/infinitered/ignite/blob/master/docs/Components-AutoImage.md).

How to use your `icon` or `image` assets:

```typescript
import { Image } from 'react-native';

const MyComponent = () => {
return (
<Image source={require('assets/images/my_image.png')} />
);
};
```

## Running Maestro end-to-end tests

Follow our [Maestro Setup](https://ignitecookbook.com/docs/recipes/MaestroSetup) recipe.

## Next Steps

### Ignite Cookbook

[Ignite Cookbook](https://ignitecookbook.com/) is an easy way for developers to browse and share code snippets (or “recipes”) that actually work.

### Upgrade Ignite boilerplate

Read our [Upgrade Guide](https://ignitecookbook.com/docs/recipes/UpdatingIgnite) to learn how to upgrade your Ignite project.

## Community

⭐️ Help us out by [starring on GitHub](https://github.com/infinitered/ignite), filing bug reports in [issues](https://github.com/infinitered/ignite/issues) or [ask questions](https://github.com/infinitered/ignite/discussions).

💬 Join us on [Slack](https://join.slack.com/t/infiniteredcommunity/shared_invite/zt-1f137np4h-zPTq_CbaRFUOR_glUFs2UA) to discuss.

📰 Make our Editor-in-chief happy by [reading the React Native Newsletter](https://reactnativenewsletter.com/).
16 changes: 16 additions & 0 deletions examples/react-native-app/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# OSX
#
.DS_Store

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml
*.hprof
.cxx/

# Bundle artifacts
*.jsbundle
Loading
Loading