Skip to content

Commit

Permalink
Merge pull request #274 from SwEnt-Group13/docs/add-missing-coments#2
Browse files Browse the repository at this point in the history
Docs/add missing coments#2
  • Loading branch information
Redd87 authored Dec 9, 2024
2 parents 88d4f28 + 7a2acf6 commit ac309d0
Show file tree
Hide file tree
Showing 29 changed files with 516 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import com.android.unio.model.strings.test_tags.UserEditionTestTags
import com.android.unio.model.user.User
import com.android.unio.ui.navigation.NavigationAction
import com.android.unio.ui.navigation.Screen
import com.android.unio.ui.user.UserProfileEditionScreenContent
import com.android.unio.ui.user.UserProfileEditionScreenScaffold
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import io.mockk.MockKAnnotations
Expand Down Expand Up @@ -74,7 +74,7 @@ class UserProfileEditionTest : TearDown() {
every { getSystemService(any(), ConnectivityManager::class.java) } returns connectivityManager

composeTestRule.setContent {
UserProfileEditionScreenContent(
UserProfileEditionScreenScaffold(
user,
{ navigationAction.goBack() },
{ uri, method -> method("") },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,6 @@ private fun AssociationDescription(association: Association) {
* Component that display the header of the association profile screen. It display the image of the
* association, the number of followers and the number of members. It also display a button to
* follow the association.
*
* !!! The follow button do not have any action and should be implemented when follow feature is
* implemented !!!
*/
@Composable
private fun AssociationHeader(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ import com.android.unio.model.search.SearchViewModel
import com.android.unio.model.strings.test_tags.ExploreContentTestTags
import com.android.unio.ui.theme.AppTypography

/**
* A search bar that allows users to search for associations. The last 2 parameters are used to
* handle the expandable state of the search bar. For an example of how to use this, see Explore.kt
*
* @param searchViewModel [SearchViewModel] that provides the search results.
* @param onAssociationSelected Callback when an association is selected.
* @param shouldCloseExpandable Whether the search bar should close the expandable when it is
* expanded.
* @param onOutsideClickHandled Callback when the outside click is handled.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AssociationSearchBar(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.size
import androidx.compose.material.TextButton
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowForwardIos
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.android.unio.model.association.Association
import com.android.unio.ui.theme.AppTypography

/**
* A small association item that can be used in a list of associations.
*
* @param association The association to display.
* @param onClick Callback when the association is clicked.
*/
@Composable
fun AssociationSmall(association: Association, onClick: () -> Unit) {
TextButton(onClick = onClick, modifier = Modifier.fillMaxWidth()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ import com.android.unio.ui.navigation.Screen
import com.android.unio.ui.utils.ToastUtils
import kotlinx.coroutines.launch

/**
* Screen for editing an association.
*
* @param associationViewModel [AssociationViewModel] that provides the association to edit.
* @param navigationAction [NavigationAction] that handles navigation.
*/
@Composable
fun EditAssociationScreen(
associationViewModel: AssociationViewModel,
Expand Down Expand Up @@ -84,6 +90,13 @@ fun EditAssociationScreen(
})
}

/**
* Scaffold for editing an association.
*
* @param association The [Association] to edit.
* @param onCancel Callback when the user cancels the edit.
* @param onSave Callback when the user saves the edit.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun EditAssociationScaffold(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ import com.google.firebase.Firebase
import com.google.firebase.auth.auth
import kotlinx.coroutines.flow.MutableStateFlow

/**
* The AccountDetailsScreen composable is used to create the account creation screen, and calls the
* AccountDetailsContent composable to display the content of the screen.
*
* @param navigationAction The navigation action to navigate to different screens.
* @param userViewModel The view model for the user.
* @param imageViewModel The view model for the image.
*/
@Composable
fun AccountDetailsScreen(
navigationAction: NavigationAction,
Expand Down Expand Up @@ -239,6 +247,18 @@ fun AccountDetailsContent(
}
}

/**
* The [UserTextFields] composable is used to create the text fields for the user to input their
* first name, last name, and biography.
*
* @param isErrors The set of errors that the user has made.
* @param firstName The first name of the user.
* @param lastName The last name of the user.
* @param bio The biography of the user.
* @param onFirstNameChange The lambda function to change the first name.
* @param onLastNameChange The lambda function to change the last name.
* @param onBioChange The lambda function to change the biography.
*/
@Composable
private fun UserTextFields(
isErrors: MutableSet<AccountDetailsError>,
Expand Down Expand Up @@ -350,6 +370,13 @@ private fun UserTextFields(
value = bio)
}

/**
* The [InterestButtonAndFlowRow] composable contains the button to add interests and display the
* row of interests that the user has selected.
*
* @param interestsFlow The flow of interests that the user has selected.
* @param onShowInterests The lambda function to show the interests overlay.
*/
@OptIn(ExperimentalLayoutApi::class)
@Composable
private fun InterestButtonAndFlowRow(
Expand Down Expand Up @@ -379,6 +406,13 @@ private fun InterestButtonAndFlowRow(
}
}

/**
* The [SocialButtonAndFlowRow] composable contains the button to add socials and display the row of
* socials that the user has selected.
*
* @param userSocialFlow The flow of socials that the user has selected.
* @param onShowSocials The lambda function to show the socials overlay.
*/
@OptIn(ExperimentalLayoutApi::class)
@Composable
private fun SocialButtonAndFlowRow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ import com.android.unio.ui.utils.ToastUtils
import com.google.firebase.Firebase
import com.google.firebase.auth.auth

/**
* A screen that allows users to verify their email.
*
* @param navigationAction The navigation action to use.
* @param userViewModel The [UserViewModel] to use.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun EmailVerificationScreen(navigationAction: NavigationAction, userViewModel: UserViewModel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ import com.android.unio.model.user.isValidEmail
import com.android.unio.ui.navigation.NavigationAction
import com.android.unio.ui.theme.AppTypography

/**
* A screen that allows users to reset their password. This screen is filled with
* ResetPasswordContent.
*
* @param navigationAction The navigation action to use.
* @param authViewModel The [AuthViewModel] to use.
*/
@Composable
fun ResetPasswordScreen(navigationAction: NavigationAction, authViewModel: AuthViewModel) {

Expand Down Expand Up @@ -62,6 +69,12 @@ fun ResetPasswordScreen(navigationAction: NavigationAction, authViewModel: AuthV
onDismiss = { navigationAction.goBack() })
}

/**
* The content of the Reset Password screen.
*
* @param onDismiss Callback when the dialog is dismissed.
* @param onChangePassword Callback when the password is changed.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ResetPasswordContent(
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/com/android/unio/ui/authentication/Welcome.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ import com.google.firebase.Firebase
import com.google.firebase.auth.EmailAuthProvider
import com.google.firebase.auth.auth

/**
* A screen that allows users to sign in or sign up.
*
* @param navigationAction The navigation action to use.
* @param userViewModel The [UserViewModel] to use.
*/
@Composable
fun WelcomeScreen(navigationAction: NavigationAction, userViewModel: UserViewModel) {
val context = LocalContext.current
Expand Down Expand Up @@ -173,6 +179,13 @@ fun WelcomeScreen(navigationAction: NavigationAction, userViewModel: UserViewMod
})
}

/**
* Handles the authentication process for the user.
*
* @param email The email to use.
* @param password The password to use.
* @param context The context to use.
*/
fun handleAuthentication(email: String, password: String, context: Context) {

// Check internet connectivity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ import com.android.unio.model.strings.test_tags.InterestsOverlayTestTags
import com.android.unio.model.user.Interest
import com.android.unio.ui.theme.AppTypography

/**
* A dialog that allows users to select their interests.
*
* @param onDismiss Callback when the dialog is dismissed.
* @param onSave Callback when the changes are saved.
* @param interests The list of pairs of [Interest] and their selected state.
*/
@Composable
fun InterestOverlay(
onDismiss: () -> Unit,
Expand Down Expand Up @@ -116,6 +123,11 @@ fun InterestOverlay(
}
}

/**
* A row that displays an interest and a checkbox to select it.
*
* @param pair The pair of [Interest] and its selected state.
*/
@Composable
private fun InterestsOverlayInterestRow(
pair: Pair<Interest, MutableState<Boolean>>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ import com.android.unio.model.utils.Utils
import com.android.unio.ui.theme.AppTypography
import kotlinx.coroutines.flow.MutableStateFlow

/**
* A dialog that allows users to add and remove their socials.
*
* @param onDismiss Callback when the dialog is dismissed.
* @param onSave Callback when the changes are saved.
* @param userSocials The list of [UserSocial] to display.
*/
@Composable
fun SocialOverlay(
onDismiss: () -> Unit,
Expand Down Expand Up @@ -148,6 +155,12 @@ fun SocialOverlay(
}
}

/**
* A row that displays a social and a close icon to remove it.
*
* @param userSocial The [UserSocial] to display.
* @param onRemoveSocial Callback when the social is removed.
*/
@Composable
private fun SocialsOverlaySocialRow(
userSocial: UserSocial,
Expand Down Expand Up @@ -180,6 +193,12 @@ private fun SocialsOverlaySocialRow(
}
}

/**
* The bottom buttons for the social overlay.
*
* @param onAddSocial Callback when the add social button is clicked.
* @param onSave Callback when the save button is clicked.
*/
@Composable
private fun SocialOverlayBottomButtons(onAddSocial: () -> Unit, onSave: () -> Unit) {
val context = LocalContext.current
Expand All @@ -204,6 +223,12 @@ private fun SocialOverlayBottomButtons(onAddSocial: () -> Unit, onSave: () -> Un
}
}

/**
* A dialog that allows users to add a social.
*
* @param onDismiss Callback when the dialog is dismissed.
* @param onSave Callback when the changes are saved.
*/
@Composable
fun SocialPrompt(
onDismiss: () -> Unit,
Expand Down Expand Up @@ -297,6 +322,13 @@ fun SocialPrompt(
}
}

/**
* A drop down menu to choose which social to add.
*
* @param selectedSocial The currently selected [Social].
* @param socialsList The list of [Social] to display.
* @param onSwitchSelectedSocial Callback when a social is selected.
*/
@OptIn(ExperimentalMaterialApi::class)
@Composable
private fun SocialsPromptDropDownMenu(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ import com.android.unio.ui.image.AsyncImageWrapper
import com.android.unio.ui.theme.primaryLight
import kotlinx.coroutines.launch

/**
* A composable function to display the profile picture with the option to remove it.
*
* @param profilePictureUri The URI of the profile picture.
* @param onRemove Lambda to handle the removal of the profile picture.
*/
@Composable
private fun ProfilePictureWithRemoveIcon(
profilePictureUri: Uri,
Expand All @@ -64,6 +70,13 @@ private fun ProfilePictureWithRemoveIcon(
}
}

/**
* A composable function that allows the user to select a profile picture.
*
* @param profilePictureUri The URI of the profile picture.
* @param onProfilePictureUriChange Lambda to handle the change of the profile picture URI.
* @param testTag The test tag to use for the icon.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ProfilePicturePicker(
Expand Down Expand Up @@ -118,6 +131,12 @@ fun ProfilePicturePicker(
}
}

/**
* A specific implementation of the [InputChip] for interests.
*
* @param pair The pair of [Interest] and its selected state.
* @param testTag The test tag to use for the chip.
*/
@Composable
fun InterestInputChip(pair: Pair<Interest, MutableState<Boolean>>, testTag: String) {
val context = LocalContext.current
Expand All @@ -135,6 +154,13 @@ fun InterestInputChip(pair: Pair<Interest, MutableState<Boolean>>, testTag: Stri
})
}

/**
* A specific implementation of the [InputChip] for [UserSocial]s.
*
* @param userSocial The [UserSocial] to display.
* @param onRemove Lambda to handle the removal of the social.
* @param testTag The test tag to use for the chip.
*/
@Composable
fun SocialInputChip(userSocial: UserSocial, onRemove: () -> Unit, testTag: String) {
val context = LocalContext.current
Expand Down
Loading

0 comments on commit ac309d0

Please sign in to comment.