Skip to content

Commit

Permalink
feat(mindfulpause): add functioning audio player
Browse files Browse the repository at this point in the history
closes: #15
Signed-off-by: Rifa Achrinza <[email protected]>
  • Loading branch information
achrinza committed Sep 11, 2024
1 parent 96bde5b commit 39eab8b
Show file tree
Hide file tree
Showing 9 changed files with 1,256 additions and 301 deletions.
1,036 changes: 1,021 additions & 15 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"main": "index.js",
"private": true,
"scripts": {
"postinstsall": "patch-package",
"test": "echo \"Error: no test specified\" && exit 1",
"android": "expo run:android",
"ios": "expo run:ios"
Expand All @@ -19,9 +20,11 @@
"url": "https://github.com/safsbe/mental-health-app/issues"
},
"homepage": "https://github.com/safsbe/mental-health-app#readme",
"workspaces": ["packages/*"],
"workspaces": [
"packages/*"
],
"dependencies": {
"lerna": "^8.1.2"
"lerna": "^8.1.2",
"patch-package": "^8.0.0"
}
}

6 changes: 4 additions & 2 deletions packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"ios": "expo run:ios"
},
"devDependencies": {
"@expo/ngrok": "^4.1.3",
"@types/react": "~18.2.79",
"autoprefixer": "^10.4.19",
"expo-doctor": "^1.6.1",
Expand All @@ -39,7 +40,7 @@
"@react-navigation/native-stack": "^6.9.26",
"@ronradtke/react-native-markdown-display": "^8.0.0",
"create-react-class": "^15.7.0",
"expo": "^51.0.22",
"expo": "51.0.22",
"expo-asset": "~10.0.6",
"expo-av": "~14.0.6",
"expo-file-system": "~17.0.1",
Expand All @@ -52,6 +53,7 @@
"react-native-reanimated": "~3.10.1",
"react-native-safe-area-context": "4.10.5",
"react-native-screens": "3.31.1",
"react-native-web": "^0.19.12"
"react-native-web": "^0.19.12",
"react-native-webview": "^13.12.2"
}
}
8 changes: 6 additions & 2 deletions packages/frontend/shadow-cljs.edn
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@
:local-repo "./.m2/repository"

:dependencies
[[reagent "1.2.0"]
[[funcool/promesa "11.0.678"]
[reagent "1.2.0"]
[re-frame "1.4.3"]]

:builds
{:app
{:target :react-native
:init-fn frontend.app/init
:output-dir "app"
:compiler-options {:infer-externs :auto}
:compiler-options
{:infer-externs :auto
:pseudo-names true
:pretty-print true}
:js-options {:node-modules-dir "../../node_modules"}
:devtools
{:autoload true
Expand Down
144 changes: 144 additions & 0 deletions packages/frontend/src/main/data/events.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
(ns data.events
(:require [re-frame.core :as rf]
["@expo/vector-icons" :as evi]))

(defn register-initialize-db []
(rf/reg-event-db
:initialize-db
(fn [db _]
(-> db
(assoc :user-preferred-name nil)
(assoc :user-mode nil)
(assoc :categories {:self
{:name "Self"
:color "#FFF7D6"
:image (js/require "../assets/home_explore_self.svg")}
:self-card
{:name "Self-Care"
:color "#DDE5FF"
:image (js/require "../assets/home_explore_self_care.svg")}
:mental-health
{:name "About Mental Health"
:color "#DEF7E5"
:image (js/require "../assets/home_explore_mental_health.svg")}
:other
{:name "About Others"
:color "#FFE7E7"
:image (js/require "../assets/home_explore_others.svg")}})
(assoc :helpline-groups {:general {:displayName "General Mental Well-being"}
:ns {:displayName "Service Helplines"}})
(assoc :helplines [{:name "Institute of Mental Health"
:contact "6389 2222"
:operating-hours "24Hrs"
:group :general}
{:name "Samaritans of Singapore"
:contact "1767"
:operating-hours "24Hrs"}
{:name "National Care Helpline"
:contact "1800 202 6868"
:operating-hours "Daily 8am-12am"}
{:name "Silver Ribbon Singapore"
:contact "6385 3714"
:operating-hours "Weekdays 9am-5pm"}])
(assoc :mindful-pause {:audio
[{:name "Breathe"
;:audio-file (js/require "../assets/mindful_minutes/breathe.mp3")
:audio-file (js/require "../assets/love_wins_all.mp3") ;since I dont have the other audios yet on 290724
:icon [:> evi/MaterialIcons {:name "air"
:size 20
:color "#A5A5A5"}]}
{:name "Take a sip of tea"
;:audio-file (js/require "../assets/mindful_minutes/sip_tea.mp3")
:audio-file (js/require "../assets/love_wins_all.mp3") ;since I dont have the other audios yet on 290724
:icon [:> evi/SimpleLineIcons {:name "cup"
:size 20
:color "#A5A5A5"}]}
{:name "Take a walk"
;:audio-file "../assets/mindful_minutes/sip_tea.mp3"
:audio-file (js/require "../assets/love_wins_all.mp3") ;since I dont have the other audios yet on 290724
:icon [:> evi/MaterialIcons {:name "directions-walk"
:size 20
:color "#A5A5A5"}]}
{:name "Look at the sky"
;:audio-file "../assets/mindful_minutes/observe_sky.mp3"
:audio-file (js/require "../assets/love_wins_all.mp3") ;since I dont have the other audios yet on 290724
:icon [:> evi/MaterialIcons {:name "cloud"
:size 20
:color "#A5A5A5"}]}]})))))

(defn register-other []
(rf/reg-sub
:user
(fn [db _]
(:user-preferred-name db)))

(rf/reg-sub
:user-mode
(fn [db _]
(:user-mode db)))

(rf/reg-event-db
:set-user-mode
(fn [db [_ user-mode]]
(assoc db :user-mode user-mode)))

(rf/reg-event-db
:set-user-preferred-name
(fn [db, [_ user-preferred-name]]
(assoc db :user-prefered-name user-preferred-name)))

(rf/reg-sub
:user-feeling-scale/rating
(fn [db _]
(:user-feeling-scale/rating db)))

(rf/reg-event-db
:user-feeling-scale/set-rating
(fn [db [_ rating]]
(assoc db :user-feeling-scale/rating rating)))

(rf/reg-sub
:helplines-groups
(fn [db _]
(-> db
(select-keys [:helplines :helpline-groups]))))

(rf/reg-sub
:mindful-pause-audio
(fn [db _]
(-> db
(:mindful-pause)
(:audio))))

(rf/reg-sub
:play-track
(fn [db _]
(-> db
(:av-player/current-track))))

(rf/reg-event-db
:play-track
(fn [db [_ {audio-file :audio-file}]]
(assoc db
:av-player/current-track audio-file)))

(rf/reg-sub
:start-play-track
(fn [db _]
(-> db
(:av-player/playing))))

(rf/reg-event-db
:set-playing-mode
(fn [db playing]
(assoc db :av-player/playing playing)))

(rf/reg-sub
:categories
(fn [db _]
(-> db
:categories))))

(defn register-all []
(register-initialize-db)
(register-other))
Loading

0 comments on commit 39eab8b

Please sign in to comment.