Skip to content

Commit

Permalink
Improve project setup (#111)
Browse files Browse the repository at this point in the history
* remove react-native-ble-plx

* update dependencies and readme

* update README with BLE info

* fix lint

* add lint in CI match config with start-ui-web
  • Loading branch information
HugoPerard authored Jan 27, 2025
1 parent b9445e6 commit 84fa4d0
Show file tree
Hide file tree
Showing 75 changed files with 1,070 additions and 1,338 deletions.
9 changes: 7 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"env": {
"es6": true
},
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:sonarjs/recommended"
Expand All @@ -9,7 +12,8 @@
{ "argsIgnorePattern": "^_" }
],
"sonarjs/no-duplicate-string": "off",
"sonarjs/cognitive-complexity": ["warn", 50]
"sonarjs/cognitive-complexity": ["warn", 50],
"sonarjs/prefer-immediate-return": "warn"
},
"overrides": [
{
Expand All @@ -22,5 +26,6 @@
"import/no-anonymous-default-export": "off"
}
}
]
],
"ignorePatterns": ["node_modules/", "android/"]
}
60 changes: 60 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: 🔎 Code Quality

on:
push:
branches:
- master
- main
- develop
- staging
pull_request:

env:
API_URL: https://demo.start-ui.com/api/rest
OPEN_API_URL: https://demo.start-ui.com/api/openapi.json

jobs:
lint-code:
timeout-minutes: 10
name: Lint and Type Check
runs-on: ubuntu-latest

strategy:
matrix:
node: [20, 22, 'lts/*']

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}

- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Cache node modules
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-${{ env.cache-name }}-
${{ runner.os }}-pnpm-store-
${{ runner.os }}-
- name: Install dependencies
run: pnpm install

- name: TypeScript check
run: pnpm lint:staged
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,27 @@ pnpm android # Launch on your android device if detected, or an Android emulator
pnpm ios # Launch on your iOS device if detected, or an iOS emulator
```

### Development

```bash
# Install dependencies and generate api client
pnpm install

# With Expo Go
pnpm dev
# * press s to swith to Expo Go
# * scan the QR Code with your phone

# With Android Emulator
pnpm android # Launch on your android device if detected, or an Android emulator

# With IOS Emulator
pnpm ios # Launch on your iOS device if detected, or an iOS emulator
# If that doesn't work maybe try to:
# * run pod install on ios folder
# * run project from xcode (maybe you should select a team for the project)
```

## Storybook Integration

Start UI Native is equipped with Storybook, enhancing component development with an isolated and interactive environment. Storybook is essential for UI development, allowing you to build and test components independently from the app's main user interface.
Expand Down Expand Up @@ -92,3 +113,10 @@ Instead of a separate `stories` directory, we create stories alongside our compo
> EAS Build is a hosted service for building app binaries for your Expo and React Native projects.
[Follow the steps here to setup and install the eas cli](https://docs.expo.dev/build/setup/#prerequisites).


### BLE / Bluetooth

Bluetooth feature has been removed to simplify expo project setup.

If you want to use this feature, you can find [an expo article](https://expo.dev/blog/how-to-build-a-bluetooth-low-energy-powered-expo-app) that explains how to add it, or you can check the deletion commit of the feature [here](https://github.com/BearStudio/start-ui-native/pull/111/commits/a8d437fff1065f1450113b71a4bd962868f8b4be)
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,4 @@ dependencies {
} else {
implementation jscFlavor
}
}
}
10 changes: 1 addition & 9 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.bearstudio.startuinative" xmlns:tools="http://schemas.android.com/tools">
<uses-permission-sdk-23 android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" tools:targetApi="31"/>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
<queries>
<intent>
<action android:name="android.intent.action.VIEW"/>
Expand Down Expand Up @@ -38,6 +31,5 @@
<data android:scheme="exp+start-ui-native"/>
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false"/>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.bearstudio.startuinative

import android.os.Build
import android.os.Bundle

import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
import com.facebook.react.defaults.DefaultReactActivityDelegate

import expo.modules.ReactActivityDelegateWrapper

class MainActivity : ReactActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
// Set the theme to AppTheme BEFORE onCreate to support
Expand All @@ -18,13 +18,13 @@ class MainActivity : ReactActivity() {
setTheme(R.style.AppTheme);
super.onCreate(null)
}

/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
override fun getMainComponentName(): String = "main"

/**
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
Expand All @@ -39,7 +39,7 @@ class MainActivity : ReactActivity() {
fabricEnabled
){})
}

/**
* Align the back button behavior with Android S
* where moving root activities to background instead of finishing activities.
Expand All @@ -53,9 +53,9 @@ class MainActivity : ReactActivity() {
}
return
}

// Use the default back button implementation on Android S
// because it's doing more than [Activity.moveTaskToBack] in fact.
super.invokeDefaultOnBackPressed()
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions android/app/src/main/res/drawable/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/splashscreen_background"/>
<item>
<bitmap android:gravity="center" android:src="@drawable/splashscreen_logo"/>
</item>
</layer-list>
Binary file removed android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
2 changes: 1 addition & 1 deletion android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<string name="app_name">Start UI Native</string>
<string name="expo_splash_screen_resize_mode" translatable="false">contain</string>
<string name="expo_splash_screen_status_bar_translucent" translatable="false">false</string>
<string name="expo_runtime_version">1.1.0</string>
<string name="expo_system_ui_user_interface_style" translatable="false">light</string>
<string name="expo_runtime_version">1.1.0</string>
</resources>
1 change: 0 additions & 1 deletion android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<item name="android:editTextStyle">@style/ResetEditText</item>
<item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:statusBarColor">#ffffff</item>
</style>
<style name="ResetEditText" parent="@android:style/Widget.EditText">
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ allprojects {
mavenCentral()
maven { url 'https://www.jitpack.io' }
}
}
}
4 changes: 1 addition & 3 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,4 @@ EX_DEV_CLIENT_NETWORK_INSPECTOR=true
# Use legacy packaging to compress native libraries in the resulting APK.
expo.useLegacyPackaging=false

android.extraMavenRepos=[]

org.gradle.jvmargs=-Xmx4096m
android.extraMavenRepos=[]
4 changes: 3 additions & 1 deletion android/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down
2 changes: 2 additions & 0 deletions android/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
4 changes: 2 additions & 2 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pluginManagement {
includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json')"].execute(null, rootDir).text.trim()).getParentFile().toString())
includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile().toString())
}
plugins { id("com.facebook.react.settings") }

Expand Down Expand Up @@ -35,4 +35,4 @@ apply from: new File(["node", "--print", "require.resolve('expo/package.json')"]
useExpoModules()

include ':app'
includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile())
includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile())
24 changes: 2 additions & 22 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"assetBundlePatterns": [
"**/*"
],
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.bearstudio.startuinative"
Expand All @@ -24,11 +22,6 @@
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
},
"permissions": [
"android.permission.BLUETOOTH",
"android.permission.BLUETOOTH_ADMIN",
"android.permission.BLUETOOTH_CONNECT"
],
"package": "com.bearstudio.startuinative"
},
"scheme": "start-ui-native",
Expand All @@ -41,20 +34,7 @@
}
}
],
[
"@config-plugins/react-native-ble-plx",
{
"isBackgroundEnabled": true,
"modes": [
"peripheral",
"central"
],
"bluetoothAlwaysPermission": "Allow $(PRODUCT_NAME) to connect to bluetooth devices"
}
],
[
"expo-router"
],
"expo-router",
"expo-font",
"expo-localization"
],
Expand Down
2 changes: 1 addition & 1 deletion ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ target 'StartUINative' do
end
end
end
end
end
Loading

0 comments on commit 84fa4d0

Please sign in to comment.