diff --git a/.eas/workflows/build-eas.yml b/.eas/workflows/build-eas.yml new file mode 100644 index 0000000..d7a70e7 --- /dev/null +++ b/.eas/workflows/build-eas.yml @@ -0,0 +1,70 @@ +name: build + +on: + push: + branches: ['*'] + +jobs: + create-expo-app: + steps: + - uses: eas/checkout # to access the test-screen.tsx file later. This also changes cwd + - name: create a fresh app + run: | + cd .. + echo 'pwd:' + pwd + yarn create expo-app theme-expo-example --no-install --yes --template expo-template-default@sdk-53 + touch theme-expo-example/yarn.lock # make yarn treat theme-expo-example as a completely separate project + + - name: Insert our test screen into the app + run: | + cd .. + echo 'pwd:' + pwd + cp example/src/test-screen.tsx "theme-expo-example/app/(tabs)/index.tsx" + cat "theme-expo-example/app/(tabs)/index.tsx" + + - name: Merge app.json with the tested package's app.json + run: | + pwd + cd ../theme-expo-example + jq '.expo.plugins += ["@vonovak/react-native-theme-control"]' app.json > app.json.tmp && mv app.json.tmp app.json + jq -s '.[0] * .[1]' app.json ../example/test-app.json > app.json.tmp && mv app.json.tmp app.json + cat app.json + + - name: Put eas.json into the test app to allow building with EAS + run: | + cp test-eas.json ../theme-expo-example/eas.json + cat ../theme-expo-example/eas.json + + - name: Install app dependencies and the tested package + run: | + cd ../theme-expo-example + yarn add @vonovak/react-native-theme-control + yarn remove expo-system-ui + + - name: Create default metro config to avoid bundling issues (may not be needed for all projects) + run: | + cd ../theme-expo-example + npx expo customize metro.config.js + + - name: Run expo prebuild + run: | + cd ../theme-expo-example + EXPO_DEBUG=1 npx expo prebuild + + - name: Bundle JS code to verify it builds + run: | + cd ../theme-expo-example + pwd + npx expo export + + # this is wrong + build_app_android: + needs: [create-expo-app] + defaults: + run: + working_directory: ../theme-expo-example + type: build + params: + platform: android diff --git a/example/app.json b/example/app.json index 761b0b1..6023fe3 100644 --- a/example/app.json +++ b/example/app.json @@ -17,6 +17,13 @@ }, "android": { "package": "com.vonovak.themeexpoexample" - } + }, + "//comment": "this is here so eas workflow:run can be executed locally", + "extra": { + "eas": { + "projectId": "348a68a7-b896-4172-ae18-64e4afc32413" + } + }, + "owner": "expo-ci" } } diff --git a/example/src/test-screen.tsx b/example/src/test-screen.tsx new file mode 100644 index 0000000..1e853f3 --- /dev/null +++ b/example/src/test-screen.tsx @@ -0,0 +1,107 @@ +import * as React from 'react'; + +import { + StyleSheet, + Text, + Button, + useColorScheme, + View, + Switch, + ColorValue, +} from 'react-native'; +import { + setThemePreference, + SystemBars, + useThemePreference, +} from '@vonovak/react-native-theme-control'; + +type Props = { + barsBackground: ColorValue; + textColor: ColorValue; + dividerColor?: ColorValue; + bgColor: ColorValue; +}; + +export default function Screen({ + barsBackground, + textColor, + bgColor, + dividerColor, +}: Props) { + const colorScheme = useColorScheme(); + const [persistTheme, togglePersistTheme] = React.useReducer( + (state: boolean) => !state, + true, + ); + const themePreference = useThemePreference(); + + const textColorStyle = { color: textColor }; + + return ( + + +