From 4d7fef774fef5c4474b98644f99db02a311b13e7 Mon Sep 17 00:00:00 2001 From: ByteZhang Date: Fri, 20 Oct 2023 17:32:22 +0800 Subject: [PATCH] fix: lint --- .easignore | 9 + apps/mobile/android/app/build.gradle | 3 + .../build-logic/convention/build.gradle.kts | 8 +- .../main/kotlin/so/onekey/apps/EnvManager.kt | 28 ++- apps/mobile/eas.json | 2 +- apps/mobile/package.json | 9 +- apps/mobile/scripts/eas-build-pre-install.sh | 8 + development/copy-injected.sh | 18 +- package.json | 3 +- .../src/Provider/hooks/useDeviceScreenSize.ts | 2 - .../TabView/NativeTabView/NestedTabView.tsx | 2 +- .../kit/src/provider/NavigationProvider.tsx | 2 +- packages/kit/src/provider/ThemeProvider.tsx | 4 +- packages/kit/src/routes/Gallery/index.tsx | 2 +- .../Components/stories/CollapsibleTabView.tsx | 206 ------------------ .../Modal/DemoCoverageModal.tsx | 8 +- .../NavigatorRoute/Tab/View/DemoRootHome.tsx | 66 +++--- 17 files changed, 100 insertions(+), 280 deletions(-) create mode 100644 .easignore create mode 100644 apps/mobile/scripts/eas-build-pre-install.sh delete mode 100644 packages/kit/src/views/Components/stories/CollapsibleTabView.tsx diff --git a/.easignore b/.easignore new file mode 100644 index 00000000000..4d0224da1c2 --- /dev/null +++ b/.easignore @@ -0,0 +1,9 @@ +node_modules +__generated__ + +.expo-shared +.expo +dist +build-electron +.next +build diff --git a/apps/mobile/android/app/build.gradle b/apps/mobile/android/app/build.gradle index bc2b10b7912..da23906016a 100644 --- a/apps/mobile/android/app/build.gradle +++ b/apps/mobile/android/app/build.gradle @@ -117,6 +117,9 @@ android { shrinkResources (findProperty('android.enableShrinkResourcesInReleaseBuilds')?.toBoolean() ?: false) minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" + ndk { + abiFilters "arm64-v8a" + } } } } diff --git a/apps/mobile/android/build-logic/convention/build.gradle.kts b/apps/mobile/android/build-logic/convention/build.gradle.kts index 7f49a6b1d68..1a8c3ed404e 100644 --- a/apps/mobile/android/build-logic/convention/build.gradle.kts +++ b/apps/mobile/android/build-logic/convention/build.gradle.kts @@ -22,15 +22,15 @@ plugins { group = "so.onekey.apps.buildlogic" -// Configure the build-logic plugins to target JDK 17 +// Configure the build-logic plugins to target JDK 11 // This matches the JDK used to build the project, and is not related to what is running on device. java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 } tasks.withType().configureEach { kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() + jvmTarget = JavaVersion.VERSION_11.toString() } } diff --git a/apps/mobile/android/build-logic/convention/src/main/kotlin/so/onekey/apps/EnvManager.kt b/apps/mobile/android/build-logic/convention/src/main/kotlin/so/onekey/apps/EnvManager.kt index 254846b3cd2..4bb5d4fe4fb 100644 --- a/apps/mobile/android/build-logic/convention/src/main/kotlin/so/onekey/apps/EnvManager.kt +++ b/apps/mobile/android/build-logic/convention/src/main/kotlin/so/onekey/apps/EnvManager.kt @@ -22,18 +22,30 @@ object EnvManager { } fun readRootEnvFile(fileName: String): Properties { - // base file path: apps/mobile/android/ - val rootEnvPath = "./../../../" + val maxDepth = 8 + var currentDepth = 0 + var currentPath = "./" val props = Properties() - try { - File(rootEnvPath + File.separator + fileName).inputStream().use { stream -> - props.load(stream) + while (currentDepth < maxDepth) { + val potentialFile = File(currentPath + fileName) + if (potentialFile.exists()) { + try { + potentialFile.inputStream().use { stream -> + props.load(stream) + } + println("Success Load $fileName at ${potentialFile.absolutePath}") + } catch (ignore: Exception) { + // ignore + } + return props } - } catch (ignore: Exception) { - // ignore + + currentPath += "../" // Go one directory up + currentDepth++ } - return props + + return props // Return empty properties if file wasn't found } } diff --git a/apps/mobile/eas.json b/apps/mobile/eas.json index 3befce1219a..2c7126f797b 100644 --- a/apps/mobile/eas.json +++ b/apps/mobile/eas.json @@ -1,6 +1,6 @@ { "cli": { - "version": ">= 0.37.0" + "version": ">= 5.4.0" }, "build": { "base": { diff --git a/apps/mobile/package.json b/apps/mobile/package.json index 6319de73777..3a7dd9503dc 100644 --- a/apps/mobile/package.json +++ b/apps/mobile/package.json @@ -3,11 +3,14 @@ "version": "1.0.0", "main": "index.js", "scripts": { - "android": "expo run:android", - "android:device": "expo run:android --device", + "android": "NDROID_CHANNEL=direct expo run:android --variant=ProdDebug", + "android:device": "ANDROID_CHANNEL=direct expo run:android --variant=ProdDebug --device", + "android:huawei": "ANDROID_CHANNEL=huawei expo run:android --variant=ProdDebug", + "android:google": "ANDROID_CHANNEL=google expo run:android --variant=GoogleDebug", "ios": "expo run:ios", "ios:device": "expo run:ios --device", - "native-bundle": "react-native start" + "native-bundle": "react-native start", + "eas-build-pre-install": "bash ./scripts/eas-build-pre-install.sh" }, "private": true, "devDependencies": { diff --git a/apps/mobile/scripts/eas-build-pre-install.sh b/apps/mobile/scripts/eas-build-pre-install.sh new file mode 100644 index 00000000000..8a677a3b658 --- /dev/null +++ b/apps/mobile/scripts/eas-build-pre-install.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# EAS Environment Secrets +# Run Path: apps/mobile + +echo "@onekeyhq:registry=https://npm.pkg.github.com\n//npm.pkg.github.com/:_authToken=${NPM_TOKEN}" > ~/.npmrc + +# Install Secret Keys +echo $IOS_SECRET | base64 -d > .env diff --git a/development/copy-injected.sh b/development/copy-injected.sh index c1abdb12fe0..8fa74ad3808 100644 --- a/development/copy-injected.sh +++ b/development/copy-injected.sh @@ -3,11 +3,11 @@ set -x # copy to Desktop preload.js -cp ./node_modules/@onekeyfe/cross-inpage-provider-injected/dist/injected/injectedDesktop.js ./packages/desktop/public/static/preload.js +cp ./node_modules/@onekeyfe/cross-inpage-provider-injected/dist/injected/injectedDesktop.js ./apps/desktop/public/static/preload.js # copy to Extension injected.js -cp ./node_modules/@onekeyfe/cross-inpage-provider-injected/dist/injected/injectedExtension.js ./packages/ext/src/entry/injected.js -cp ./packages/ext/src/entry/injected.js ./packages/ext/src/entry/injected.text-js +cp ./node_modules/@onekeyfe/cross-inpage-provider-injected/dist/injected/injectedExtension.js ./apps/ext/src/entry/injected.js +cp ./apps/ext/src/entry/injected.js ./apps/ext/src/entry/injected.text-js # copy to Native injectedCode cp ./node_modules/@onekeyfe/cross-inpage-provider-injected/dist/injected/injectedNative.js ./packages/kit/src/components/WebView/injectedNative.text-js @@ -16,14 +16,6 @@ cp ./node_modules/@onekeyfe/cross-inpage-provider-injected/dist/injected/injecte cp ./packages/shared/src/web/index.html.ejs ./packages/shared/src/web/index.html # copy hardware js-sdk iframe files to desktop -mkdir -p ./packages/desktop/public/static/js-sdk/ -rsync ./node_modules/@onekeyfe/hd-web-sdk/build/ ./packages/desktop/public/static/js-sdk/ --checksum --recursive --verbose - -# build and copy web-embed -if [ "$EAS_BUILD" == "true" ]; - then - yarn workspace @onekeyhq/web-embed build - elif [ ! -d "packages/web-embed/web-build" ]; then - yarn workspace @onekeyhq/web-embed build -fi +mkdir -p ./apps/desktop/public/static/js-sdk/ +rsync ./node_modules/@onekeyfe/hd-web-sdk/build/ ./apps/desktop/public/static/js-sdk/ --checksum --recursive --verbose diff --git a/package.json b/package.json index 6498d79adaa..5f44d42ba7a 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "node": ">=16" }, "scripts": { - "postinstall": "patch-package", + "postinstall": "patch-package && yarn copy:inject", + "copy:inject": "bash development/copy-injected.sh", "app:desktop": "yarn workspace @onekeyhq/desktop start", "app:ext": "yarn workspace @onekeyhq/ext start", "app:ext:v3": "yarn workspace @onekeyhq/ext start:v3", diff --git a/packages/components/src/Provider/hooks/useDeviceScreenSize.ts b/packages/components/src/Provider/hooks/useDeviceScreenSize.ts index fe60a960ae9..87682462ea6 100644 --- a/packages/components/src/Provider/hooks/useDeviceScreenSize.ts +++ b/packages/components/src/Provider/hooks/useDeviceScreenSize.ts @@ -1,5 +1,3 @@ -import { useMemo } from 'react'; - import useProviderDeviceScreenSize from './useProviderDeviceScreenSize'; export default function useDeviceScreenSize() { diff --git a/packages/components/src/TabView/NativeTabView/NestedTabView.tsx b/packages/components/src/TabView/NativeTabView/NestedTabView.tsx index 0ba73f501ee..07469e04232 100644 --- a/packages/components/src/TabView/NativeTabView/NestedTabView.tsx +++ b/packages/components/src/TabView/NativeTabView/NestedTabView.tsx @@ -15,13 +15,13 @@ import { Stack } from '../../Stack'; import NativeNestedTabView from './NativeNestedTabView'; -import type { Route } from '../types'; import type { PagerViewViewManagerType } from './NativeNestedTabView'; import type { NestedTabViewProps, OnPageChangeEvent, OnPageScrollStateChangeEvent, } from './types'; +import type { Route } from '../types'; import type { LayoutChangeEvent } from 'react-native'; export type ForwardRefHandle = { diff --git a/packages/kit/src/provider/NavigationProvider.tsx b/packages/kit/src/provider/NavigationProvider.tsx index 440640d4185..26d5e679e82 100644 --- a/packages/kit/src/provider/NavigationProvider.tsx +++ b/packages/kit/src/provider/NavigationProvider.tsx @@ -3,8 +3,8 @@ import { createRef, memo, useEffect } from 'react'; import { NavigationContainer } from '@react-navigation/native'; import { useTheme } from 'tamagui'; -import { RootNavigator } from '@onekeyhq/kit/src/routes'; import { setBackgroundColor } from '@onekeyhq/components/src/Navigation/utils/StatusBarUtils'; +import { RootNavigator } from '@onekeyhq/kit/src/routes'; export const navigationRef = createRef(); global.$navigationRef = navigationRef as any; diff --git a/packages/kit/src/provider/ThemeProvider.tsx b/packages/kit/src/provider/ThemeProvider.tsx index ce3901837c4..7a9d764dd69 100644 --- a/packages/kit/src/provider/ThemeProvider.tsx +++ b/packages/kit/src/provider/ThemeProvider.tsx @@ -2,13 +2,13 @@ import type { ComponentProps, FC } from 'react'; import { memo, useEffect } from 'react'; import { Provider } from '@onekeyhq/components'; - -import { useThemeProviderVariant } from '../hooks/useThemeVariant'; import { setDarkContent, setLightContent, } from '@onekeyhq/components/src/Navigation/utils/StatusBarUtils'; +import { useThemeProviderVariant } from '../hooks/useThemeVariant'; + const ThemeApp: FC = ({ children }) => { const { themeVariant, localeVariant } = useThemeProviderVariant(); diff --git a/packages/kit/src/routes/Gallery/index.tsx b/packages/kit/src/routes/Gallery/index.tsx index cadb3b2ac66..250d5c37dd1 100644 --- a/packages/kit/src/routes/Gallery/index.tsx +++ b/packages/kit/src/routes/Gallery/index.tsx @@ -4,7 +4,6 @@ import ActionListGallery from '@onekeyhq/kit/src/views/Components/stories/Action import BadgeGallery from '@onekeyhq/kit/src/views/Components/stories/Badge'; import ButtonGallery from '@onekeyhq/kit/src/views/Components/stories/Button'; import CheckboxGallery from '@onekeyhq/kit/src/views/Components/stories/Checkbox'; -import TabViewGallery from '@onekeyhq/kit/src/views/Components/stories/TabView'; import DialogGallery from '@onekeyhq/kit/src/views/Components/stories/Dialog'; import EmptyGallery from '@onekeyhq/kit/src/views/Components/stories/Empty'; import IconGallery from '@onekeyhq/kit/src/views/Components/stories/Icon'; @@ -18,6 +17,7 @@ import RadioGallery from '@onekeyhq/kit/src/views/Components/stories/Radio'; import SelectGallery from '@onekeyhq/kit/src/views/Components/stories/Select'; import SliderGallery from '@onekeyhq/kit/src/views/Components/stories/Slider'; import SwitchGallery from '@onekeyhq/kit/src/views/Components/stories/Switch'; +import TabViewGallery from '@onekeyhq/kit/src/views/Components/stories/TabView'; import ToastGallery from '@onekeyhq/kit/src/views/Components/stories/Toast'; import ToggleGroupGallery from '@onekeyhq/kit/src/views/Components/stories/ToggleGroup'; import TooltipGallery from '@onekeyhq/kit/src/views/Components/stories/Tooltip'; diff --git a/packages/kit/src/views/Components/stories/CollapsibleTabView.tsx b/packages/kit/src/views/Components/stories/CollapsibleTabView.tsx deleted file mode 100644 index 2f88a01b292..00000000000 --- a/packages/kit/src/views/Components/stories/CollapsibleTabView.tsx +++ /dev/null @@ -1,206 +0,0 @@ -import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'; - -import { FlatList } from 'react-native'; -import { ScrollView, XStack } from 'tamagui'; - -import { Badge, Button, Icon, Stack, Tabs, Text } from '@onekeyhq/components'; -import useIsActiveTab from '@onekeyhq/components/src/CollapsibleTabView/hooks/useIsActiveTab'; -import type { ForwardRefHandle } from '@onekeyhq/components/src/CollapsibleTabView/NativeNestedTabView/NestedTabView'; - -import { Layout } from './utils/Layout'; -import { TabsFocusTools } from './utils/NavigationTools'; -import { FreezeProbe, useFreezeProbe } from './utils/RenderTools'; - -type Network = { - id: string; - name: string; - impl: string; - tokenDisplayDecimals: number; -}; - -function getNetworks(begin = 0) { - const networks: Network[] = []; - for (let i = begin; i < begin + 100; i += 1) { - networks.push({ - id: `${i}`, - name: `Network ${i}`, - impl: `Network ${i}`, - tokenDisplayDecimals: i, - }); - } - return networks; -} - -function TokenList({ networks, name }: { networks: Network[]; name: string }) { - const isActiveTab = useIsActiveTab(name); - - useFreezeProbe(name, { pause: !isActiveTab }); - - useEffect(() => { - console.log('=====>> TokenList', name, isActiveTab); - }, [isActiveTab, name]); - - const renderItem = useCallback( - ({ item }: { item: Network }) => ( - {}}> - - {item.name} - - {item.impl.toUpperCase()} - - - ), - [], - ); - - return useMemo( - () => ( - `${item.id}-${index}`} - /> - ), - [networks, renderItem], - ); -} - -function CollapsibleTabView() { - const [showNetworks, setShowNetworks] = useState(getNetworks()); - - const [headerHighMode, setHeaderHighMode] = useState(true); - const tabsViewRef = useRef(null); - - const headerHeightCall = useCallback(() => { - setHeaderHighMode((pre) => !pre); - }, []); - - const loadMoreDataCall = useCallback(() => { - setShowNetworks((pre) => [...pre, ...getNetworks(pre.length)]); - }, []); - - useEffect(() => { - setTimeout(() => { - tabsViewRef?.current?.setPageIndex(0); - }); - }, []); - - const headerView = useMemo( - () => ( - - Header View Simple - {`Header Height ${headerHighMode.toString()}`} - {`Item Count ${showNetworks.length}`} - {headerHighMode && 我个子很高} - - - - ), - [headerHighMode, showNetworks.length, headerHeightCall, loadMoreDataCall], - ); - - return useMemo( - () => ( - - - - - - - - 我是一个内容 - - ), - }, - ]} - /> - - - - - - - - - - - Network 1 - - - Network 2 - - - End - - - - - - {showNetworks.flatMap((item, index) => ( - - {`${item.name}`} - - ))} - - - - - - - - - - ScrollView Simple - {showNetworks.flatMap((item, index) => ( - {}} key={`tab5-network-${index}`}> - - {item.name} - {item.tokenDisplayDecimals} - - {item.impl.toUpperCase()} - - - ))} - End - - - - - ), - [headerView, showNetworks], - ); -} - -export default memo(CollapsibleTabView); diff --git a/packages/kit/src/views/Components/stories/NavigatorRoute/Modal/DemoCoverageModal.tsx b/packages/kit/src/views/Components/stories/NavigatorRoute/Modal/DemoCoverageModal.tsx index eae10e198be..bb5d2fe26ef 100644 --- a/packages/kit/src/views/Components/stories/NavigatorRoute/Modal/DemoCoverageModal.tsx +++ b/packages/kit/src/views/Components/stories/NavigatorRoute/Modal/DemoCoverageModal.tsx @@ -123,10 +123,10 @@ function DemoCoverageDialogModal() { ), }, - // { - // title: 'Open Modal by Button', - // element: , - // }, + { + title: 'Open Modal by Button', + element: , + }, { title: 'Open Modal by Api', element: ( diff --git a/packages/kit/src/views/Components/stories/NavigatorRoute/Tab/View/DemoRootHome.tsx b/packages/kit/src/views/Components/stories/NavigatorRoute/Tab/View/DemoRootHome.tsx index cc003c90f01..bd6828062e6 100644 --- a/packages/kit/src/views/Components/stories/NavigatorRoute/Tab/View/DemoRootHome.tsx +++ b/packages/kit/src/views/Components/stories/NavigatorRoute/Tab/View/DemoRootHome.tsx @@ -16,24 +16,24 @@ import { DemoHomeTabRoutes } from '../Routes'; import type { DemoHomeTabParamList } from '../RouteParamTypes'; -// const useStorage = platformEnv.isNative -// ? (key: AppSettingKey, initialValue?: boolean) => { -// const [data, setData] = useState( -// initialValue || appStorage.getSettingBoolean(key), -// ); -// const setNewData = (value: boolean) => { -// appStorage.setSetting(key, value); -// setData(value); -// }; -// return [data, setNewData]; -// } -// : useCookie; +const useStorage = platformEnv.isNative + ? (key: AppSettingKey, initialValue?: boolean) => { + const [data, setData] = useState( + initialValue || appStorage.getSettingBoolean(key), + ); + const setNewData = (value: boolean) => { + appStorage.setSetting(key, value); + setData(value); + }; + return [data, setNewData]; + } + : useCookie; const DemoRootHome = () => { const navigation = useDemoAppNavigation>(); - // const [rrtStatus, changeRRTStatus] = useStorage(AppSettingKey.rrt); + const [rrtStatus, changeRRTStatus] = useStorage(AppSettingKey.rrt); return ( { element: (