Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/login singup onboarding #12

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
alias(libs.plugins.spezikt.application)
alias(libs.plugins.spezikt.compose)
alias(libs.plugins.spezikt.hilt)
alias(libs.plugins.google.gms.google.services)
}

android {
Expand Down Expand Up @@ -41,4 +42,6 @@ dependencies {
implementation(libs.hilt.navigation.compose)

implementation(project(":core:bluetooth"))
implementation(project(":spezi-module:onboarding"))
implementation(project(":core:coroutines"))
}
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.SpeziKt">
Expand Down
Basler182 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package edu.stanford.spezikt.onboarding

import edu.stanford.spezikt.core.design.R
import edu.stanford.spezikt.coroutines.di.Dispatching
import edu.stanford.spezikt.spezi_module.onboarding.onboarding.Area
import edu.stanford.spezikt.spezi_module.onboarding.onboarding.OnboardingRepository
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.withContext
import javax.inject.Inject

class DefaultOnboardingRepository @Inject constructor(
@Dispatching.IO private val scope: CoroutineScope,
Basler182 marked this conversation as resolved.
Show resolved Hide resolved
) : OnboardingRepository {

override suspend fun getAreas(): Result<List<Area>> = withContext(scope.coroutineContext) {
Basler182 marked this conversation as resolved.
Show resolved Hide resolved
try {
Basler182 marked this conversation as resolved.
Show resolved Hide resolved
Result.success(
listOf(
Area(
title = "Join the Study",
iconId = R.drawable.ic_groups,
description = "Connect to your study via an invitation code from the researchers."
),
Area(
title = "Complete Health Checks",
iconId = R.drawable.ic_assignment,
description = "Record and report health data automatically according to a schedule set by the research team."
),
Area(
title = "Visualize Data",
iconId = R.drawable.ic_vital_signs,
description = "Visualize your heart health progress throughout participation in the study."
)
)
)
} catch (e: Exception) {
Result.failure(e)
}
}

override suspend fun getTitle(): Result<String> = withContext(scope.coroutineContext) {
try {
Result.success("Welcome to ENGAGE-HF")
} catch (e: Exception) {
Result.failure(e)
}
}

override suspend fun getSubtitle(): Result<String> = withContext(scope.coroutineContext) {
try {
Result.success("Remote study participation made easy.")
} catch (e: Exception) {
Result.failure(e)
}
}
}
Basler182 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package edu.stanford.spezikt.onboarding

import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import edu.stanford.spezikt.coroutines.di.Dispatching
import edu.stanford.spezikt.spezi_module.onboarding.onboarding.OnboardingRepository
import kotlinx.coroutines.CoroutineScope
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object OnboardingModule {
Basler182 marked this conversation as resolved.
Show resolved Hide resolved

@Provides
@Singleton
Basler182 marked this conversation as resolved.
Show resolved Hide resolved
fun provideOnboardingRepository(
@Dispatching.IO ioCoroutineScope: CoroutineScope
): OnboardingRepository {
return DefaultOnboardingRepository(ioCoroutineScope)
Basler182 marked this conversation as resolved.
Show resolved Hide resolved
}
}
5 changes: 5 additions & 0 deletions app/src/main/res/xml/network_security_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">10.0.2.2</domain>
</domain-config>
</network-security-config>
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
alias(libs.plugins.hilt.android) version libs.versions.hiltVersion apply false
alias(libs.plugins.google.devtools.ksp) version libs.versions.kspVersion apply false
alias(libs.plugins.dokka) version libs.versions.dokka
alias(libs.plugins.google.gms.google.services) apply false
}

subprojects {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package edu.stanford.spezikt.core.design.component

import android.content.res.Configuration
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import edu.stanford.spezikt.core.design.theme.SpeziTheme

@Composable
fun SpeziValidatedOutlinedTextField(
Basler182 marked this conversation as resolved.
Show resolved Hide resolved
onValueChange: (String) -> Unit,
Basler182 marked this conversation as resolved.
Show resolved Hide resolved
modifier: Modifier = Modifier,
value: String,
labelText: String,
errorText: String?,
isValid: Boolean
Basler182 marked this conversation as resolved.
Show resolved Hide resolved
) {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
OutlinedTextField(
modifier = modifier.fillMaxWidth(),
value = value,
onValueChange = {
Basler182 marked this conversation as resolved.
Show resolved Hide resolved
onValueChange(it)
},
label = { Text(labelText) },
singleLine = true,
keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Next),
isError = !isValid,
)
if (!isValid) {
Text(
text = errorText ?: "",
style = MaterialTheme.typography.labelSmall,
Basler182 marked this conversation as resolved.
Show resolved Hide resolved
color = MaterialTheme.colorScheme.error
)
}
}
}

@Preview(
name = "Light Mode",
uiMode = Configuration.UI_MODE_NIGHT_NO
)
@Preview(
name = "Dark Mode",
uiMode = Configuration.UI_MODE_NIGHT_YES
)
@Composable
fun SpeziValidatedOutlinedTextFieldPreview(
Basler182 marked this conversation as resolved.
Show resolved Hide resolved
@PreviewParameter(SpeziValidatedOutlinedTextFieldProvider::class) params: SpeziValidatedOutlinedTextFieldParams
) {
SpeziTheme {
SpeziValidatedOutlinedTextField(
onValueChange = {},
value = params.value,
labelText = params.labelText,
errorText = params.errorText,
isValid = params.isValid
)
}
}

class SpeziValidatedOutlinedTextFieldProvider :
PreviewParameterProvider<SpeziValidatedOutlinedTextFieldParams> {
override val values = sequenceOf(
SpeziValidatedOutlinedTextFieldParams(
Basler182 marked this conversation as resolved.
Show resolved Hide resolved
value = "",
labelText = "Label",
errorText = "The input is invalid",
isValid = false
),
SpeziValidatedOutlinedTextFieldParams(
value = "",
labelText = "Label",
errorText = "",
isValid = true
)
)
}

data class SpeziValidatedOutlinedTextFieldParams(
Basler182 marked this conversation as resolved.
Show resolved Hide resolved
val value: String,
val labelText: String,
val errorText: String,
val isValid: Boolean
)
11 changes: 11 additions & 0 deletions core/design/src/main/res/drawable/ic_assignment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:tint="?attr/colorControlNormal"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="#FF000000"
android:pathData="M200,840Q167,840 143.5,816.5Q120,793 120,760L120,200Q120,167 143.5,143.5Q167,120 200,120L368,120Q381,84 411.5,62Q442,40 480,40Q518,40 548.5,62Q579,84 592,120L760,120Q793,120 816.5,143.5Q840,167 840,200L840,760Q840,793 816.5,816.5Q793,840 760,840L200,840ZM200,760L760,760Q760,760 760,760Q760,760 760,760L760,200Q760,200 760,200Q760,200 760,200L200,200Q200,200 200,200Q200,200 200,200L200,760Q200,760 200,760Q200,760 200,760ZM280,680L560,680L560,600L280,600L280,680ZM280,520L680,520L680,440L280,440L280,520ZM280,360L680,360L680,280L280,280L280,360ZM480,170Q493,170 501.5,161.5Q510,153 510,140Q510,127 501.5,118.5Q493,110 480,110Q467,110 458.5,118.5Q450,127 450,140Q450,153 458.5,161.5Q467,170 480,170ZM200,760Q200,760 200,760Q200,760 200,760L200,200Q200,200 200,200Q200,200 200,200L200,200Q200,200 200,200Q200,200 200,200L200,760Q200,760 200,760Q200,760 200,760L200,760Z" />
</vector>
9 changes: 9 additions & 0 deletions core/design/src/main/res/drawable/ic_google.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="30dp"
android:height="30dp"
android:viewportWidth="30"
android:viewportHeight="30">
<path
android:fillColor="#FF000000"
android:pathData="M15.004,3C8.375,3 3,8.373 3,15C3,21.627 8.375,27 15.004,27C25.014,27 27.269,17.707 26.33,13L25,13L22.732,13L15,13L15,17L22.738,17C21.849,20.448 18.726,23 15,23C10.582,23 7,19.418 7,15C7,10.582 10.582,7 15,7C17.009,7 18.839,7.746 20.244,8.969L23.086,6.129C20.952,4.185 18.117,3 15.004,3z" />
</vector>
10 changes: 10 additions & 0 deletions core/design/src/main/res/drawable/ic_groups.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="#FF000000"
android:pathData="M0,720L0,657Q0,614 44,587Q88,560 160,560Q173,560 185,560.5Q197,561 208,563Q194,584 187,607Q180,630 180,655L180,720L0,720ZM240,720L240,655Q240,623 257.5,596.5Q275,570 307,550Q339,530 383.5,520Q428,510 480,510Q533,510 577.5,520Q622,530 654,550Q686,570 703,596.5Q720,623 720,655L720,720L240,720ZM780,720L780,655Q780,629 773.5,606Q767,583 754,563Q765,561 776.5,560.5Q788,560 800,560Q872,560 916,586.5Q960,613 960,657L960,720L780,720ZM325,640L636,640L636,640Q626,620 580.5,605Q535,590 480,590Q425,590 379.5,605Q334,620 325,640L325,640ZM160,520Q127,520 103.5,496.5Q80,473 80,440Q80,406 103.5,383Q127,360 160,360Q194,360 217,383Q240,406 240,440Q240,473 217,496.5Q194,520 160,520ZM800,520Q767,520 743.5,496.5Q720,473 720,440Q720,406 743.5,383Q767,360 800,360Q834,360 857,383Q880,406 880,440Q880,473 857,496.5Q834,520 800,520ZM480,480Q430,480 395,445Q360,410 360,360Q360,309 395,274.5Q430,240 480,240Q531,240 565.5,274.5Q600,309 600,360Q600,410 565.5,445Q531,480 480,480ZM480,400Q497,400 508.5,388.5Q520,377 520,360Q520,343 508.5,331.5Q497,320 480,320Q463,320 451.5,331.5Q440,343 440,360Q440,377 451.5,388.5Q463,400 480,400ZM481,640L481,640Q481,640 481,640Q481,640 481,640Q481,640 481,640Q481,640 481,640L481,640L481,640ZM480,360Q480,360 480,360Q480,360 480,360Q480,360 480,360Q480,360 480,360Q480,360 480,360Q480,360 480,360Q480,360 480,360Q480,360 480,360Z" />
</vector>
4 changes: 2 additions & 2 deletions core/design/src/main/res/drawable/ic_medication.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
xmlns:tools="http://schemas.android.com/tools"
android:width="24dp"
android:height="24dp"
android:alpha="0.6"
android:tint="#333333"
android:viewportWidth="960"
android:alpha="1"
android:tint="#333333"
android:viewportHeight="960">
<path
android:fillColor="@android:color/white"
Expand Down
10 changes: 10 additions & 0 deletions core/design/src/main/res/drawable/ic_vital_signs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="#FF000000"
android:pathData="M360,800Q341,800 326,789Q311,778 304,761L212,520L40,520L40,440L268,440L360,684L544,199Q551,182 566,171Q581,160 600,160Q619,160 634,171Q649,182 656,199L748,440L920,440L920,520L692,520L600,276L416,761Q409,778 394,789Q379,800 360,800Z" />
</vector>
16 changes: 13 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ coreKtx = "1.13.0"
coroutinesVersion = "1.6.4"
dokka = "1.9.20"
espressoCore = "3.5.1"
firebaseAuth = "23.0.0"
firebaseFirestoreKtx = "25.0.0"
firebaseFunctionsKtx = "21.0.0"
firebaseStorageKtx = "21.0.0"
googleGmsGoogleServices = "4.4.1"
hiltNavigation = "1.2.0"
hiltVersion = "2.51"
junit = "4.13.2"
Expand All @@ -24,7 +29,7 @@ targetSdk = "34"
timberVersion = "5.0.1"
truth = "1.4.2"

# Please keep [libraries] block sorted. Select all items and in Android Studio `File > Sort Lines`
# Please keep [libraries] block sorted. Select all items and in Android Studio `Edit > Sort Lines`
[libraries]
android-gradle = { group = "com.android.tools.build", name = "gradle", version.ref = "agp" }
android-tools-common = { group = "com.android.tools", name = "common", version.ref = "androidTools" }
Expand All @@ -47,6 +52,10 @@ compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling
coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "coroutinesVersion" }
coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "coroutinesVersion" }
coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "coroutinesVersion" }
firebase-auth = { group = "com.google.firebase", name = "firebase-auth", version.ref = "firebaseAuth" }
firebase-firestore-ktx = { group = "com.google.firebase", name = "firebase-firestore-ktx", version.ref = "firebaseFirestoreKtx" }
firebase-functions-ktx = { group = "com.google.firebase", name = "firebase-functions-ktx", version.ref = "firebaseFunctionsKtx" }
firebase-storage-ktx = { group = "com.google.firebase", name = "firebase-storage-ktx", version.ref = "firebaseStorageKtx" }
google-truth = { group = "com.google.truth", name = "truth", version.ref = "truth" }
hilt-compiler = { group = "com.google.dagger", name = "hilt-compiler", version.ref = "hiltVersion" }
hilt-core = { group = "com.google.dagger", name = "hilt-android", version.ref = "hiltVersion" }
Expand All @@ -62,12 +71,13 @@ mockk-android = { group = "io.mockk", name = "mockk-android", version.ref = "moc
mockk-core = { group = "io.mockk", name = "mockk", version.ref = "mockKVersion" }
timber = { group = "com.jakewharton.timber", name = "timber", version.ref = "timberVersion" }

# Please keep [plugins] block sorted. Select all items and in Android Studio `File > Sort Lines`
# Please keep [plugins] block sorted. Select all items and in Android Studio `Edit > Sort Lines`
[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
google-devtools-ksp = { id = "com.google.devtools.ksp", version.ref = "kspVersion" }
google-gms-google-services = { id = "com.google.gms.google-services", version.ref = "googleGmsGoogleServices" }
hilt-android = { id = "com.google.dagger.hilt.android", version.ref = "hiltVersion" }
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
spezikt-application = { id = "spezikt.application", version = "unspecified" }
Expand All @@ -76,7 +86,7 @@ spezikt-compose = { id = "spezikt.compose", version = "unspecified" }
spezikt-hilt = { id = "spezikt.hilt", version = "unspecified" }
spezikt-library = { id = "spezikt.library", version = "unspecified" }

# Please keep [bundles] block sorted. Select all items and in Android Studio `File > Sort Lines`
# Please keep [bundles] block sorted. Select all items and in Android Studio `Edit > Sort Lines`
[bundles]
compose = ["compose-ui", "compose-material3", "compose-ui-tooling-preview", "compose-ui-tooling", "androidx-core-ktx", "androidx-appcompat", "androidx-activity-compose"]
compose-androidTest = ["junit", "androidx-espresso-core", "compose-ui-test", "mockk-agent-core", "mockk-android", "google-truth"]
Expand Down
14 changes: 14 additions & 0 deletions spezi-module/onboarding/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
plugins {
alias(libs.plugins.spezikt.library)
alias(libs.plugins.spezikt.compose)
alias(libs.plugins.spezikt.hilt)
alias(libs.plugins.google.gms.google.services)
}

android {
namespace = "edu.stanford.spezikt.spezi_module.onboarding"
}

dependencies {
implementation(libs.firebase.functions.ktx)
implementation(libs.hilt.navigation.compose)
implementation(libs.firebase.auth)

implementation(project(":core:coroutines"))

testImplementation(libs.bundles.unit.testing)

androidTestImplementation(libs.bundles.compose.androidTest)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Module onboarding

Loading
Loading