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

Feat/alert/UI: AlertScreen UI #24

Merged
merged 77 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
8eda1cc
feat: implement navigation actions and add tests
francelu Oct 8, 2024
3ec1b9c
feat: implement top navigation menu, navigation actions pass my tests
francelu Oct 8, 2024
1e2ce70
fix: removed useless TODO
francelu Oct 8, 2024
9cf2beb
fix: remove useless TODO
francelu Oct 8, 2024
4783ce6
Merge remote-tracking branch 'origin/feat-navigation' into feat-navig…
francelu Oct 8, 2024
5547907
fix: display title using `CenterAlignedTopAppBar`
francelu Oct 8, 2024
254d3b2
feat: add test tags for UI components
francelu Oct 8, 2024
3c5c356
feat: create UI for "create profile" screen
Harrish92 Oct 8, 2024
f535ab4
style: Resize profile picture logo for better visibility
Harrish92 Oct 8, 2024
3044197
feat: integrate supabase into the project for data query
Harrish92 Oct 9, 2024
8023e90
chore: merge main into feature-branch
francelu Oct 9, 2024
85ca9b5
feat: update navigation with `BottomNavigationMenu`
francelu Oct 9, 2024
c37dd9d
Add option for user to choose profile picture
Harrish92 Oct 10, 2024
dd13f3f
feat: add `TopAppBar` component to standardize screen UI and update n…
francelu Oct 10, 2024
4922555
fix: remove preview of [Scaffold] component to prepare for pull request
francelu Oct 10, 2024
6d6ccf9
fix: remove failing example test causing CI failures
francelu Oct 10, 2024
d932537
fix: comment out tests referencing "Auth Screen" to troubleshoot CI f…
francelu Oct 10, 2024
2acc890
fix: reformat code using ktfmt
francelu Oct 10, 2024
c8865c4
test: Ensure that UI elements are present and profile picture respond…
Harrish92 Oct 10, 2024
2bd81f4
feat: implement UI for AlertScreen with dropdowns and text fields
agonzalez-r Oct 10, 2024
47e1fa0
test: add UI tests for Alert Screen components
agonzalez-r Oct 10, 2024
8bf686b
fix: comment out navigation in `PeriodPalsApp` to avoid CI failures
francelu Oct 10, 2024
7f12bdd
fix: comment out Auth calls to avoid CI failures
francelu Oct 10, 2024
17cf680
fix: delete sample test file causing problems with the CI
agonzalez-r Oct 11, 2024
e013a74
fix: remove redundant test class to fix CI failure
francelu Oct 11, 2024
d0c96d4
fix: align versions of dependencies to make build work
Harrish92 Oct 11, 2024
84f61f2
fix: change android emulator task in ci
coaguila Oct 11, 2024
bbbc532
fix: modify force avd creation to true to fix crashing android emulator
coaguila Oct 11, 2024
dccbb7f
fix: recenter the button so that it is more visible to the user
Harrish92 Oct 11, 2024
af7ba85
test: comment out part of test that fails the CI
Harrish92 Oct 11, 2024
4b16ef5
style: format code to ktfmt
Harrish92 Oct 11, 2024
bbd6696
fix: correcting CI's AVD cache setup and emulator plugin
coaguila Oct 12, 2024
85393f9
feat: CI runs on setup and feat branches on push
coaguila Oct 12, 2024
0639dd6
fix: adding a manual Android SDK setup in CI
coaguila Oct 12, 2024
9b06e60
fix: switch android emulator runner
coaguila Oct 12, 2024
7b23cae
test: add check for valid date when filling the form
Harrish92 Oct 12, 2024
66e1ac1
fix: update cmdline-tools-version
coaguila Oct 12, 2024
f16e524
fix: change avd script
coaguila Oct 12, 2024
a7ad2bb
fix: add tests and reduce code for 80% of CI coverage
Harrish92 Oct 12, 2024
a8f0644
fix: replace function call with indexed accessor for save_button
Harrish92 Oct 12, 2024
87ab835
fix: separate Test functions for maintainability and readability
agonzalez-r Oct 12, 2024
cb974e2
fix: removed deprecated supabase code
coaguila Oct 12, 2024
0ffd936
style: format ktfmt (i forgot to do it last time :)))))
coaguila Oct 12, 2024
ea3417d
fix: corrected sonar property for the project
coaguila Oct 12, 2024
2b6183b
Merge pull request #29 from PeriodPals/setup/ci-android-env
coaguila Oct 12, 2024
bf1b00a
chore: merge with main
francelu Oct 12, 2024
6a64ec7
fix: remove unused imports and apply ktfmt formatting
francelu Oct 13, 2024
c3338e0
fix: update dependencies and resolve issues
francelu Oct 13, 2024
c7cb82a
chore: update mockito dependency to version 5.4.0
charliemangano Oct 13, 2024
dfa6681
chore: add mockito.kotlin dependency
charliemangano Oct 13, 2024
fd4579c
fix: fix imports for `any()` and `eq()` in `NavigationActionsTest.kt`
charliemangano Oct 13, 2024
ae0c64a
Merge remote-tracking branch 'origin' into feat/profile/create
Harrish92 Oct 13, 2024
0729554
fix: improve validation logic for date of birth in CreateProfile screen
Harrish92 Oct 13, 2024
58bbb5b
test: add UI tests for BottomNavigationMenu
francelu Oct 13, 2024
c898ec1
test: add UI tests for TopAppBar
francelu Oct 13, 2024
3c9ecc7
Merge pull request #20 from PeriodPals/feat/profile/create
Harrish92 Oct 13, 2024
e7a6982
fix: throw exception on back button press without action
francelu Oct 13, 2024
ef404e5
style: format ktfmt
francelu Oct 13, 2024
ed38556
chore: merge with main
francelu Oct 13, 2024
f7d0011
chore: clean up dependencies in `libs.versions.toml`
francelu Oct 13, 2024
159793e
feat: implement UI for AlertScreen with dropdowns and text fields
agonzalez-r Oct 10, 2024
c5589bf
test: add UI tests for Alert Screen components
agonzalez-r Oct 10, 2024
981b869
fix: delete sample test file causing problems with the CI
agonzalez-r Oct 11, 2024
d59ec5d
fix: separate Test functions for maintainability and readability
agonzalez-r Oct 12, 2024
3203d68
Merge remote-tracking branch 'origin/feat/alert/ui' into feat/alert/ui
agonzalez-r Oct 14, 2024
4c260e4
fix: change AGP version in `libs.versions.toml` for compatibility (#33)
charliemangano Oct 14, 2024
bfa0cb9
feat: implement UI for AlertScreen with dropdowns and text fields
agonzalez-r Oct 10, 2024
85f311d
test: add UI tests for Alert Screen components
agonzalez-r Oct 10, 2024
fba0dff
fix: delete sample test file causing problems with the CI
agonzalez-r Oct 11, 2024
0b106d1
fix: separate Test functions for maintainability and readability
agonzalez-r Oct 12, 2024
0a807e2
Merge remote-tracking branch 'origin/feat/alert/ui' into feat/alert/ui
agonzalez-r Oct 14, 2024
2803775
chore: merge with main
francelu Oct 14, 2024
17719dd
Merge pull request #21 from PeriodPals/feat/navigation
francelu Oct 14, 2024
038d82e
feat: implement UI for AlertScreen with dropdowns and text fields
agonzalez-r Oct 10, 2024
8a364a8
test: add UI tests for Alert Screen components
agonzalez-r Oct 10, 2024
48a46f3
fix: separate Test functions for maintainability and readability
agonzalez-r Oct 12, 2024
f24563f
Merge remote-tracking branch 'origin/feat/alert/ui' into feat/alert/ui
agonzalez-r Oct 14, 2024
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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.android.periodpals.ui.alert

import androidx.compose.material3.MaterialTheme
import androidx.compose.ui.test.*
import androidx.compose.ui.test.junit4.createComposeRule
import org.junit.Rule
import org.junit.Test

class AlertScreenTest {

@get:Rule val composeTestRule = createComposeRule()

@Test
fun testAlertScreenUI() {
// Start the composable in the test environment
composeTestRule.setContent { MaterialTheme { AlertScreen() } }

// Check if the instruction text is displayed
composeTestRule.onNodeWithTag("alertInstruction").assertIsDisplayed()

// Check if the product dropdown is displayed and clickable
composeTestRule
.onNodeWithTag("alertProduct")
.assertIsDisplayed()
.performClick() // To expand the dropdown menu

// Check if urgency dropdown is displayed and clickable
composeTestRule.onNodeWithTag("alertUrgency").assertIsDisplayed().performClick()

// Enter text in the location field
composeTestRule
.onNodeWithTag("alertLocation")
.assertIsDisplayed()
.performTextInput("Rolex Learning Center")

// Enter text in the message field
composeTestRule
.onNodeWithTag("alertMessage")
.assertIsDisplayed()
.performTextInput("I need help finding a tampon! I'll be at rolex until 2pm")

// Check if the submit button is displayed and perform a click
composeTestRule
.onNodeWithTag("alertSubmit")
.assertIsDisplayed()
.assertHasClickAction() // Ensure the button is clickable
}
}
134 changes: 134 additions & 0 deletions app/src/main/java/com/android/periodpals/ui/alert/AlertScreen.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
package com.android.periodpals.ui.alert

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material3.Button
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExposedDropdownMenuBox
import androidx.compose.material3.ExposedDropdownMenuDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp

@Preview
@Composable
fun AlertScreen() {
var location by remember { mutableStateOf("") }
var message by remember { mutableStateOf("") }

// TODO("TOP APP BAR and BOTTOM NAVIGATION")
Scaffold(
modifier = Modifier.testTag("alertScreen"),
content = { paddingValues ->
Column(
modifier = Modifier.fillMaxSize().padding(16.dp).padding(paddingValues),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.SpaceEvenly) {
// Text Instruction
Text(
"Push a notification that will be received by users around you so that they can help you find the period product that you need",
agonzalez-r marked this conversation as resolved.
Show resolved Hide resolved
modifier = Modifier.testTag("alertInstruction"),
textAlign = TextAlign.Center,
style = MaterialTheme.typography.titleSmall)

// Product selection
ExposedDropdownMenuSample(
listOf("Tampons", "Pads", "No Preference"), "Product Needed", "alertProduct")

// Urgency indicator
ExposedDropdownMenuSample(
listOf("!!! High", "!! Medium", "! Low"), "Urgency level", "alertUrgency")

// Location
OutlinedTextField(
value = location,
onValueChange = { location = it },
label = { Text("Location") },
placeholder = { Text("Enter your location") },
modifier = Modifier.fillMaxWidth().testTag("alertLocation"))

// Message Box
OutlinedTextField(
value = message,
onValueChange = { message = it },
label = { Text("Message") },
placeholder = { Text("Write a message for the other users") },
modifier = Modifier.fillMaxWidth().height(150.dp).testTag("alertMessage"))

// Submit Button
Button(
onClick = {
// TODO("Save alert on supabase + navigation to
// AlertListScreen")
},
modifier =
Modifier.width(300.dp).height(100.dp).testTag("alertSubmit").padding(16.dp),
// colors
) {
Text("Ask for help", style = MaterialTheme.typography.headlineMedium)
}
}
})
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ExposedDropdownMenuSample(list: List<String>, label: String, testTag: String) {
var options = list
var expanded by remember { mutableStateOf(false) }
var text by remember { mutableStateOf("Please choose one option") }

ExposedDropdownMenuBox(
modifier = Modifier.testTag(testTag),
expanded = expanded,
onExpandedChange = { expanded = it },
) {
TextField(
// The `menuAnchor` modifier must be passed to the text field to handle
// expanding/collapsing the menu on click. A read-only text field has
// the anchor type `PrimaryNotEditable`.
modifier = Modifier.menuAnchor(),
value = text,
onValueChange = {},
readOnly = true,
singleLine = true,
label = { Text(label) },
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = expanded) },
colors = ExposedDropdownMenuDefaults.textFieldColors(),
)
ExposedDropdownMenu(
expanded = expanded,
onDismissRequest = { expanded = false },
) {
options.forEach { option ->
DropdownMenuItem(
text = { Text(option) },
onClick = {
text = option
expanded = false
},
contentPadding = ExposedDropdownMenuDefaults.ItemContentPadding,
)
}
}
}
}