diff --git a/app/build.gradle b/app/build.gradle index e51a04c..c13b5f3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -54,6 +54,7 @@ dependencies { implementation "androidx.compose.ui:ui:$compose_ui_version" implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version" implementation 'androidx.compose.material:material:1.2.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' diff --git a/app/src/main/java/com/medmapper/v33001/MainActivity.kt b/app/src/main/java/com/medmapper/v33001/MainActivity.kt index a5822eb..2152863 100644 --- a/app/src/main/java/com/medmapper/v33001/MainActivity.kt +++ b/app/src/main/java/com/medmapper/v33001/MainActivity.kt @@ -1,6 +1,7 @@ package com.medmapper.v33001 import android.os.Bundle +import android.widget.Toast import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.foundation.layout.fillMaxSize @@ -8,14 +9,32 @@ import androidx.compose.material.MaterialTheme import androidx.compose.material.Surface import androidx.compose.material.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.livedata.observeAsState import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview +import com.google.firebase.auth.FirebaseAuth +import com.google.firebase.auth.FirebaseUser +import com.medmapper.v33001.dto.User import com.medmapper.v33001.ui.theme.MedMapperTheme +import org.koin.androidx.viewmodel.ext.android.viewModel + class MainActivity : ComponentActivity() { + + private var firebaseUser: FirebaseUser? = FirebaseAuth.getInstance().currentUser + private val viewModel: MainViewModel by viewModel() + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { + firebaseUser?.let { + val user = User(it.uid, "") + viewModel.user = user + viewModel.listenToMedicine() + } + val medicine by viewModel.medicine.observeAsState(initial = emptyList()) MedMapperTheme { // A surface container using the 'background' color from the theme Surface( @@ -30,8 +49,44 @@ class MainActivity : ComponentActivity() { } @Composable -fun Greeting(name: String) { - Text(text = "Hello $name!") +fun SpecimenFacts(name:String) { + var medicineName by remember {mutableStateOf("")} + var prescriptionStrength by by remember{mutableStateOf( "")} + var startDate by remember{mutableStateOf( "")} + var intakeFrequency by remember{mutableStateOf("")} + var prescriptionLength by remember{mutableStateOf("")} + val context=LocalContext.current + Column { + OutlinedTextField ( + value = medicineName, + onValueChange = {medicineName= it}, + label= {Text(stringResource(R.string.medicineName))} + ) + OutlinedTextField ( + value = prescriptionStrength + onValueChange = {prescriptionStrength= it}, + label= {Text(stringResource(R.string.prescriptionStrength))} + ) + OutlinedTextField ( + value = startDate, + onValueChange = {startDate= it}, + label= {Text(stringResource(R.string.startDate))} + ) + OutlinedTextField ( + value = intakeFrequency, + onValueChange = {intakeFrequency= it}, + label= {Text(stringResource(R.string.intakeFrequency))} + ) + OutlinedTextField ( + value = prescriptionLength, + onValueChange = {prescriptionLength it}, + label= {Text(stringResource(R.string.prescriptionLength))} + ) + Button ( + onClick = { Toast.makeText(context,text: "$medicineName $prescriptionStrength $startDate $intakeFrequency $prescriptionLength", + Toast.LENGTH_LONG).show()}) + {Text(text="Save Info ")} + } @Preview(showBackground = true) diff --git a/app/src/main/res/layout/layout.xml b/app/src/main/res/layout/layout.xml index 9d27e8e..5ef1a27 100644 --- a/app/src/main/res/layout/layout.xml +++ b/app/src/main/res/layout/layout.xml @@ -1,17 +1,17 @@ - - -// buttons info, my schedule, my medication, share your schedule + android:layout_height="match_parent" + android:background="#6892d4" + tools:ignore="ExtraText">