From fc50228df10a2ba79f17ef90b708909dc46260ab Mon Sep 17 00:00:00 2001 From: Srivathsan Date: Fri, 20 Sep 2024 18:07:09 +0800 Subject: [PATCH] committed --- .editorconfig | 9 - .gitattributes | 1 - .github/codeql/codeql-config.yml | 3 - .github/workflows/codeql-analysis.yml | 32 - .../workflows/renovate-config-validator.yml | 22 - .github/workflows/test.yaml | 70 - .gitignore | 26 +- CONTRIBUTING.md | 28 - DEVELOPING.md | 4 - README.md | 45 +- app.json | 42 + app/(tabs)/_layout.tsx | 58 + app/(tabs)/index.tsx | 57 + app/(tabs)/resources.tsx | 68 + app/(tabs)/sos.tsx | 119 + app/+html.tsx | 39 + app/+not-found.tsx | 32 + app/_layout.tsx | 56 + app/meditation/index.tsx | 120 + app/onboarding/index.tsx | 132 + babel.config.js | 6 + components/Activities.tsx | 51 + components/ContactCard.tsx | 57 + components/Goals.tsx | 40 + components/MoodScale.tsx | 36 + components/Quote.tsx | 54 + components/TelegramCard.tsx | 71 + components/ThemedText.tsx | 60 + components/ThemedView.tsx | 14 + components/__tests__/ThemedText-test.tsx | 10 + .../__snapshots__/ThemedText-test.tsx.snap | 24 + components/navigation/TabBarIcon.tsx | 9 + constants/Colors.ts | 26 + eas.json | 18 + hooks/useColorScheme.ts | 1 + hooks/useColorScheme.web.ts | 8 + hooks/useThemeColor.ts | 22 + lerna.json | 7 - package-lock.json | 31036 ++++++---------- package.json | 66 +- packages/frontend/.gitignore | 35 - packages/frontend/app.json | 52 - .../assets/home_explore_mental_health.svg | 1 - .../frontend/assets/home_explore_others.svg | 1 - .../frontend/assets/home_explore_self.svg | 1 - .../assets/home_explore_self_care.svg | 1 - .../frontend/assets/home_mindful_minutes.svg | 1 - .../frontend/assets/placeholders/400x400.svg | 1 - packages/frontend/global.css | 0 packages/frontend/metro.config.js | 13 - packages/frontend/package.json | 58 - packages/frontend/postcss.config.js | 5 - .../scripts/process-markdown-to-json.py | 105 - packages/frontend/scripts/update-deps.sh | 7 - packages/frontend/shadow-cljs.edn | 22 - .../frontend/src/main/component/articles.cljs | 9 - .../src/main/component/helplines.cljs | 61 - packages/frontend/src/main/data/events.cljs | 144 - .../frontend/src/main/frontend/about.cljs | 5 - packages/frontend/src/main/frontend/app.cljs | 20 - .../src/main/frontend/home-screen.cljs | 47 - .../src/main/screen/article-testme.cljs | 3 - .../frontend/src/main/screen/article.cljs | 21 - packages/frontend/src/main/screen/auth.cljs | 63 - .../frontend/src/main/screen/explore.cljs | 62 - packages/frontend/src/main/screen/home.cljs | 146 - .../src/main/screen/mindfulpause.cljs | 23 - .../frontend/src/main/screen/resources.cljs | 80 - packages/frontend/src/main/screen/sos.cljs | 59 - packages/frontend/src/main/shell.cljs | 60 - packages/frontend/tsconfig.json | 4 - renovate.json | 6 - scripts/reset-project.js | 73 + tsconfig.json | 17 + 74 files changed, 12171 insertions(+), 21614 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .gitattributes delete mode 100644 .github/codeql/codeql-config.yml delete mode 100644 .github/workflows/codeql-analysis.yml delete mode 100644 .github/workflows/renovate-config-validator.yml delete mode 100644 .github/workflows/test.yaml delete mode 100644 CONTRIBUTING.md delete mode 100644 DEVELOPING.md create mode 100644 app.json create mode 100644 app/(tabs)/_layout.tsx create mode 100644 app/(tabs)/index.tsx create mode 100644 app/(tabs)/resources.tsx create mode 100644 app/(tabs)/sos.tsx create mode 100644 app/+html.tsx create mode 100644 app/+not-found.tsx create mode 100644 app/_layout.tsx create mode 100644 app/meditation/index.tsx create mode 100644 app/onboarding/index.tsx create mode 100644 babel.config.js create mode 100644 components/Activities.tsx create mode 100644 components/ContactCard.tsx create mode 100644 components/Goals.tsx create mode 100644 components/MoodScale.tsx create mode 100644 components/Quote.tsx create mode 100644 components/TelegramCard.tsx create mode 100644 components/ThemedText.tsx create mode 100644 components/ThemedView.tsx create mode 100644 components/__tests__/ThemedText-test.tsx create mode 100644 components/__tests__/__snapshots__/ThemedText-test.tsx.snap create mode 100644 components/navigation/TabBarIcon.tsx create mode 100644 constants/Colors.ts create mode 100644 eas.json create mode 100644 hooks/useColorScheme.ts create mode 100644 hooks/useColorScheme.web.ts create mode 100644 hooks/useThemeColor.ts delete mode 100644 lerna.json delete mode 100644 packages/frontend/.gitignore delete mode 100755 packages/frontend/app.json delete mode 100644 packages/frontend/assets/home_explore_mental_health.svg delete mode 100644 packages/frontend/assets/home_explore_others.svg delete mode 100644 packages/frontend/assets/home_explore_self.svg delete mode 100644 packages/frontend/assets/home_explore_self_care.svg delete mode 100644 packages/frontend/assets/home_mindful_minutes.svg delete mode 100644 packages/frontend/assets/placeholders/400x400.svg delete mode 100644 packages/frontend/global.css delete mode 100644 packages/frontend/metro.config.js delete mode 100644 packages/frontend/package.json delete mode 100644 packages/frontend/postcss.config.js delete mode 100644 packages/frontend/scripts/process-markdown-to-json.py delete mode 100755 packages/frontend/scripts/update-deps.sh delete mode 100644 packages/frontend/shadow-cljs.edn delete mode 100644 packages/frontend/src/main/component/articles.cljs delete mode 100644 packages/frontend/src/main/component/helplines.cljs delete mode 100644 packages/frontend/src/main/data/events.cljs delete mode 100644 packages/frontend/src/main/frontend/about.cljs delete mode 100644 packages/frontend/src/main/frontend/app.cljs delete mode 100644 packages/frontend/src/main/frontend/home-screen.cljs delete mode 100644 packages/frontend/src/main/screen/article-testme.cljs delete mode 100644 packages/frontend/src/main/screen/article.cljs delete mode 100644 packages/frontend/src/main/screen/auth.cljs delete mode 100644 packages/frontend/src/main/screen/explore.cljs delete mode 100644 packages/frontend/src/main/screen/home.cljs delete mode 100644 packages/frontend/src/main/screen/mindfulpause.cljs delete mode 100644 packages/frontend/src/main/screen/resources.cljs delete mode 100644 packages/frontend/src/main/screen/sos.cljs delete mode 100644 packages/frontend/src/main/shell.cljs delete mode 100644 packages/frontend/tsconfig.json delete mode 100644 renovate.json create mode 100644 scripts/reset-project.js create mode 100644 tsconfig.json diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0f112c3..0000000 --- a/.editorconfig +++ /dev/null @@ -1,9 +0,0 @@ -root = true - -[*] -end_of_line = lf -insert_final_newline = true -charset = utf-8 -indent_style = space -indent_size = 2 -max_line_length = 80 diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 6313b56..0000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* text=auto eol=lf diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml deleted file mode 100644 index 6857cd5..0000000 --- a/.github/codeql/codeql-config.yml +++ /dev/null @@ -1,3 +0,0 @@ -paths-ignore: - - '**/__tests__/**' - - '**/tests/**' diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 6724c3e..0000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: CodeQL - -on: - pull_request: - branches: - - main - schedule: - - cron: '0 13 * * 6' # At 13:00 on Saturday - -permissions: {} - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - - permissions: - # See: https://github.com/github/codeql-action/blob/008b2cc71c4cf3401f45919d8eede44a65b4a322/README.md#usage - security-events: write - - steps: - - name: Checkout repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - - name: Initialize CodeQL - uses: github/codeql-action/init@3ab4101902695724f9365a384f86c1074d94e18c # v3.24.7 - with: - languages: 'javascript' - config-file: ./.github/codeql/codeql-config.yml - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@3ab4101902695724f9365a384f86c1074d94e18c # v3.24.7 diff --git a/.github/workflows/renovate-config-validator.yml b/.github/workflows/renovate-config-validator.yml deleted file mode 100644 index 0efe4e2..0000000 --- a/.github/workflows/renovate-config-validator.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Renovate Config Validator - -on: - pull_request: - paths: - - './renovate.json' - -permissions: {} - -jobs: - main: - name: Main - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - with: - fetch-depth: 0 - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 - with: - node-version: 20 # LTS - - name: Validate Renovate config - run: npx -p renovate --yes renovate-config-validator diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml deleted file mode 100644 index 35ff493..0000000 --- a/.github/workflows/test.yaml +++ /dev/null @@ -1,70 +0,0 @@ -name: Test - -on: - pull_request: - branches: - - main - schedule: - - cron: '0 13 * * 6' # At 13:00 on Saturday - -permissions: {} - -jobs: - test: - name: Android - runs-on: ubuntu-latest - permissions: {} - - steps: - - name: Harden Runner - uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0 - with: - disable-sudo: true - egress-policy: block - allowed-endpoints: > - dl.google.com:443 - github.com:443 - objects.githubusercontent.com:443 - oss.sonatype.org:443 - plugins-artifacts.gradle.org:443 - plugins.gradle.org:443 - registry.npmjs.org:443 - repo.clojars.org:443 - repo.maven.apache.org:443 - repo1.maven.org:443 - services.gradle.org:443 - - - name: Checkout Repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - - name: Setup Java - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 - with: - distribution: temurin - java-version: 17 - - - name: Setup Node.js - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 - with: - node-version: 20 - cache: npm - - - name: Setup Android SDK - uses: android-actions/setup-android@00854ea68c109d98c75d956347303bf7c45b0277 # v3.2.1 - - - name: Bootstrap Dependencies - run: npm ci - - - name: Build Android APK - run: | - cd packages/frontend - npm exec \ - --package=shadow-cljs \ - -- \ - shadow-cljs compile app - npm exec \ - --package=expo \ - -- \ - expo prebuild --platform=android - cd android - ./gradlew assembleRelease diff --git a/.gitignore b/.gitignore index 42a51c9..23d083a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,20 @@ node_modules/ -.clj-kondo/ -.lsp/ .expo/ -*~ -\#*# -.\#* -.m2 dist/ -packages/frontend/android/ -packages/frontend/ios/ -packages/frontend/dist +npm-debug.* +*.jks +*.p8 +*.p12 +*.key +*.mobileprovision +*.orig.* +web-build/ +assets/ +# macOS +.DS_Store + +# @generated expo-cli sync-2b81b286409207a5da26e14c78851eb30d8ccbdb +# The following patterns were generated by expo-cli + +expo-env.d.ts +# @end expo-cli \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 29cc57f..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,28 +0,0 @@ -# Contributing - -Thanks for your interest in contibuting to the project! Unfortunately, we are not currently accepting external pull requests. - -This document explains the internal workflow adopted by the maintainers of this project. - -## Contribution workflow - -This project uses a pull request-based workflow. - -The following branches are protected from direct push of commits: - -- `main` (default branch) - This branch will contain the latest deployable (though not necessarily released) version of the project - -- `.x` - Branches where `` is replaced with a version number (e.g. `1.x`) are branches which carry an deployable (though not necessarily released), older or upcoming major version of the project. - -All contributions are done on a fork or a separate branch with the parent being one of the above. The parent branch will be dependent on the major version that you'd wish to submit changes to. - -## Writing a commit - -This project uses Conventional Commits. - -## Creating a pull request - -#TODO - diff --git a/DEVELOPING.md b/DEVELOPING.md deleted file mode 100644 index 94ec2b6..0000000 --- a/DEVELOPING.md +++ /dev/null @@ -1,4 +0,0 @@ -# Developing - -This document details how to develop and build this project. - diff --git a/README.md b/README.md index 6a415a0..7d80d10 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,25 @@ # SBE Mental Health App -A proof of concept application created by the SBE Innovation Team, part of the SBE NSF Council. +## Installation -## Prerequisites +1. Install dependencies -- Node.js 20 -- Java 17 -- Android CLI Tools -- ADB with a connected Android device/emulator + ```bash + npm install + ``` -## Getting Started +2. Start the app -To quickly deploy the mobile app to an Android device with Expo: + ```bash + npx expo start + ``` -```sh -$ git clone https://github.com/safsbe/mental-health-app -$ cd mental-health-app -$ npm ci -$ npm run -w '@safsbe/mental-health-frontend' watch:common -$ npm run -w '@safsbe/mental-health-frontend' watch:android:expo +In the output, you'll find options to open the app in a -# Press 's' to switch to Expo Go builds -``` +- [development build](https://docs.expo.dev/develop/development-builds/introduction/) +- [Android emulator](https://docs.expo.dev/workflow/android-studio-emulator/) +- [iOS simulator](https://docs.expo.dev/workflow/ios-simulator/) +- [Expo Go](https://expo.dev/go), a limited sandbox for trying out app development with Expo -## Security +You can start developing by editing the files inside the **app** directory. This project uses [file-based routing](https://docs.expo.dev/router/introduction). -See [SECURITY.md](./SECURITY.md). - -### Long-Term Support - -This project does not adopt any long term support policy. - -## Contributing - -External pull requests are not currently being accepted. Our internal contribution workflow is documented in [CONTIRBUTING.md](./CONTRIBUTING.md). - -## Developing - -Instructions for building and developing this appication is provided in [DEVELOPING.md](./DEVELOPING.md). diff --git a/app.json b/app.json new file mode 100644 index 0000000..7d706fa --- /dev/null +++ b/app.json @@ -0,0 +1,42 @@ +{ + "expo": { + "name": "mental-health-app", + "slug": "mental-health-app", + "version": "1.0.0", + "orientation": "portrait", + "icon": "./assets/images/icon.png", + "scheme": "mental-health-app", + "userInterfaceStyle": "automatic", + "splash": { + "image": "./assets/images/splash.png", + "resizeMode": "contain", + "backgroundColor": "#ffffff" + }, + "ios": { + "supportsTablet": true + }, + "android": { + "adaptiveIcon": { + "foregroundImage": "./assets/images/adaptive-icon.png", + "backgroundColor": "#ffffff" + }, + "package": "com.safsbe.mentalhealthapp" + }, + "web": { + "bundler": "metro", + "output": "static", + "favicon": "./assets/images/favicon.png" + }, + "plugins": [ + "expo-router" + ], + "experiments": { + "typedRoutes": true + }, + "extra": { + "eas": { + "projectId": "81a6b904-d7b1-48a1-8e97-03ad1aaab1fa" + } + } + } +} diff --git a/app/(tabs)/_layout.tsx b/app/(tabs)/_layout.tsx new file mode 100644 index 0000000..60889c3 --- /dev/null +++ b/app/(tabs)/_layout.tsx @@ -0,0 +1,58 @@ +import { Tabs } from "expo-router"; + +import { TabBarIcon } from "@/components/navigation/TabBarIcon"; +import { Image } from "react-native"; +import { Colors } from "@/constants/Colors"; +import { useColorScheme } from "@/hooks/useColorScheme"; +import MaterialIcons from "@expo/vector-icons/MaterialIcons"; +import Octicons from "@expo/vector-icons/Octicons"; + +export default function TabLayout() { + const colorScheme = useColorScheme(); + + return ( + + ( + + ), + }} + /> + ( + + ), + }} + /> + ( + + ), + }} + /> + + ); +} diff --git a/app/(tabs)/index.tsx b/app/(tabs)/index.tsx new file mode 100644 index 0000000..c149fdb --- /dev/null +++ b/app/(tabs)/index.tsx @@ -0,0 +1,57 @@ +import React, { useState, useEffect } from 'react'; +import { View, Text, TouchableOpacity, Image, StyleSheet } from 'react-native'; +import AsyncStorage from '@react-native-async-storage/async-storage'; +import MoodScale from '@/components/MoodScale'; +import Quote from '@/components/Quote'; +import Activities from '@/components/Activities'; + +export default function Index() { + const [name, setName] = useState(''); + const [mood, setMood] = useState(0); + + useEffect(() => { + const fetchUserData = async () => { + const storedName = await AsyncStorage.getItem('alias'); + setName(storedName || ''); + }; + + fetchUserData(); + }, []); + + const handleMoodSelect = async (selectedMood: number) => { + setMood(selectedMood); + const currentDate = new Date().toISOString().split('T')[0]; // date formatted as YYYY-MM-DD + await AsyncStorage.setItem('mood', JSON.stringify({ date: currentDate, mood: selectedMood })); + }; + + return ( + + Welcome, {name} + How are you feeling today? + + Quote of the day + + Activities + + + ); +} + +const styles = StyleSheet.create({ + container: { + padding: 20, + marginTop: 20, + }, + welcome: { + fontSize: 24, + }, + subtext: { + fontSize: 14, + marginVertical: 10, + }, + boldText: { + fontSize: 18, + fontWeight: 'bold', + marginVertical: 15, + }, +}); diff --git a/app/(tabs)/resources.tsx b/app/(tabs)/resources.tsx new file mode 100644 index 0000000..9baa657 --- /dev/null +++ b/app/(tabs)/resources.tsx @@ -0,0 +1,68 @@ +import { ScrollView, Text, StyleSheet } from 'react-native'; +import TelegramCard from '@/components/TelegramCard'; +import ContactCard from '@/components/ContactCard'; + +export default function ResourcesScreen() { + return ( + + {/* Large text */} + Stay updated + + {/* Small text */} + Telegram + + {/* Telegram Card */} + + + Useful Contacts + + + + + + ); +} + +const styles = StyleSheet.create({ + container: { + flexGrow: 1, + justifyContent: 'flex-start', + alignItems: 'center', + paddingTop:50, + paddingHorizontal:20, + paddingBottom:30, + }, + largeText: { + fontSize: 32, + fontWeight: 'bold', + marginBottom: 20, + alignSelf: 'center', + }, + smallText: { + fontSize: 18, + marginBottom: 20, + alignSelf: 'flex-start', + }, +}); \ No newline at end of file diff --git a/app/(tabs)/sos.tsx b/app/(tabs)/sos.tsx new file mode 100644 index 0000000..757dd9a --- /dev/null +++ b/app/(tabs)/sos.tsx @@ -0,0 +1,119 @@ +import { View, Text, TouchableOpacity, Linking, StyleSheet, ScrollView } from 'react-native'; +import ContactCard from '@/components/ContactCard'; + +export default function SOSScreen() { + const handleSOSPress = () => { + Linking.openURL('tel:+123456789'); // Replace with the actual telephone number + }; + + return ( + + {/* Large text placeholder1 */} + You are not alone. + We're here to help. + + {/* Text placeholder2 */} + You will remain anonymous + + {/* SOS Button */} + + SOS + Samaritans of Singapore + Helpline 1767 + + + {/* Contact Cards for General Mental */} + General Mental Well-Being + + {/* Contact Card for IMH*/} + + + {/* Contact Card for SOS*/} + + + {/* Contact Card for NCH*/} + + + {/* Contact Card for SRS*/} + + + Services Helpline + + + + + + + ); +} + +const styles = StyleSheet.create({ + container: { + flexGrow: 1, + justifyContent: 'flex-start', + alignItems: 'center', + paddingTop:50, + paddingHorizontal:20, + paddingBottom:30, + }, + largeText: { + fontSize: 30, + fontWeight: 'bold', + marginBottom: 8, + }, + text: { + fontSize: 18, + marginBottom: 20, + }, + sosButton: { + backgroundColor: 'orange', + paddingVertical: 55, + paddingHorizontal: 15, + borderRadius: 5000, // Rounded button + marginBottom: 20, + alignItems: 'center', + }, + sosButtonBigText: { + fontSize: 30, + color: 'white', + fontWeight: 'bold', + }, + sosButtonSmallText: { + fontSize: 15, + color: 'white', + + }, + leftText: { + fontSize: 18, + marginBottom: 20, + alignSelf: 'flex-start', // Align text to the left + }, +}); \ No newline at end of file diff --git a/app/+html.tsx b/app/+html.tsx new file mode 100644 index 0000000..8b92456 --- /dev/null +++ b/app/+html.tsx @@ -0,0 +1,39 @@ +import { ScrollViewStyleReset } from 'expo-router/html'; +import { type PropsWithChildren } from 'react'; + +/** + * This file is web-only and used to configure the root HTML for every web page during static rendering. + * The contents of this function only run in Node.js environments and do not have access to the DOM or browser APIs. + */ +export default function Root({ children }: PropsWithChildren) { + return ( + + + + + + + {/* + Disable body scrolling on web. This makes ScrollView components work closer to how they do on native. + However, body scrolling is often nice to have for mobile web. If you want to enable it, remove this line. + */} + + + {/* Using raw CSS styles as an escape-hatch to ensure the background color never flickers in dark-mode. */} +