Skip to content

Commit db119bf

Browse files
committed
Add more documentation
1 parent 11921e7 commit db119bf

File tree

3 files changed

+84
-17
lines changed

3 files changed

+84
-17
lines changed

PennMobile/src/main/java/com/pennapps/labs/pennmobile/dining/fragments/components/AnimatedDropDown.kt

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/**
2+
* @file AnimatedDropDown.kt
3+
* @brief Provides a generic, stateless, animated dropdown component.
4+
*
5+
* This file contains the `AnimatedPushDropdown` composable, a reusable UI component
6+
* designed to display a title and expandable content. The expansion and collapse are
7+
* animated, and the arrow icon rotates to indicate the current state.
8+
*
9+
* As a stateless component, it hoists its `expanded` state and relies on event callbacks,
10+
* making it highly reusable throughout the application.
11+
*/
112
package com.pennapps.labs.pennmobile.dining.fragments.components
213

314
import androidx.compose.animation.AnimatedVisibility
@@ -28,6 +39,19 @@ import androidx.compose.ui.draw.rotate
2839
import androidx.compose.ui.unit.dp
2940

3041

42+
/**
43+
* A generic, animated dropdown card component.
44+
*
45+
* This composable displays a title row that, when clicked, expands or collapses to reveal
46+
* the content area. The transition is animated, and a dropdown arrow icon rotates to
47+
* reflect the current state.
48+
*
49+
* @param expanded State representing whether the dropdown is currently expanded.
50+
* @param toggleExpandedMode Event lambda invoked when the title row is clicked.
51+
* @param title The composable content to display in the header row of the dropdown.
52+
* @param content The composable content to display in the expandable area.
53+
* @param modifier The [Modifier] to be applied to the Card container.
54+
*/
3155
@Composable
3256
fun AnimatedPushDropdown(
3357
expanded: Boolean,
@@ -94,5 +118,4 @@ fun AnimatedPushDropdown(
94118
) { content() }
95119
}
96120
}
97-
}
98-
121+
}

PennMobile/src/main/java/com/pennapps/labs/pennmobile/dining/fragments/components/DiningHallCard.kt

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/**
2+
* @file DiningHallCard.kt
3+
* @brief Renders a stateless card component for a single dining hall.
4+
*
5+
* This file contains the `DiningHallCard` composable, a UI component that displays
6+
* key information about a dining hall, such as its image, name, open status, hours,
7+
* and whether it is a user favorite.
8+
*
9+
*/
110
package com.pennapps.labs.pennmobile.dining.fragments.components
211

312
import androidx.compose.foundation.Image
@@ -48,6 +57,15 @@ import com.pennapps.labs.pennmobile.dining.classes.Venue
4857
import org.joda.time.Instant
4958
import org.joda.time.Interval
5059

60+
/**
61+
* A card component that displays information about a single dining hall.
62+
*
63+
* @param diningHall State representing the [DiningHall] data to display.
64+
* @param isFavourite State representing whether this dining hall is marked as a favorite.
65+
* @param toggleFavourite Event lambda invoked when the user taps the favorite icon.
66+
* @param openDiningHallMenu Event lambda invoked when the user taps on the card.
67+
* @param modifier The [Modifier] to be applied to the Card container.
68+
*/
5169
@OptIn(ExperimentalMaterial3Api::class)
5270
@Composable
5371
fun DiningHallCard(
@@ -57,7 +75,7 @@ fun DiningHallCard(
5775
openDiningHallMenu: (DiningHall) -> Unit,
5876
modifier: Modifier = Modifier,
5977
) {
60-
val cardHeight = 110.dp
78+
val cardHeight = 130.dp
6179

6280
Card(
6381
modifier = modifier.requiredHeight(cardHeight),
@@ -81,14 +99,7 @@ fun DiningHallCard(
8199
Modifier
82100
.fillMaxHeight()
83101
.aspectRatio(4 / 3f)
84-
.clip(
85-
RoundedCornerShape(
86-
topStart = 0.dp,
87-
bottomStart = 0.dp,
88-
topEnd = 6.dp,
89-
bottomEnd = 8.dp
90-
)
91-
),
102+
.clip(RoundedCornerShape(6.dp)),
92103
contentScale = ContentScale.Crop,
93104
)
94105

@@ -120,8 +131,7 @@ fun DiningHallCard(
120131
} else {
121132
AppColors.LabelRed.copy(alpha = 0.9f)
122133
},
123-
)
124-
.padding(vertical = 1.dp, horizontal = 6.dp),
134+
).padding(vertical = 1.dp, horizontal = 6.dp),
125135
fontSize = 13.sp,
126136
fontFamily = GilroyFontFamily,
127137
)
@@ -165,6 +175,12 @@ fun DiningHallCard(
165175
}
166176
}
167177

178+
/**
179+
* Provides a preview of the [DiningHallCard] component for development purposes.
180+
*
181+
* This composable is annotated with `@Preview` and sets up the [DiningHallCard] with
182+
* sample data to be rendered in Android Studio's preview pane, for both light and dark themes.
183+
*/
168184
@Preview(name = "Light Mode", showBackground = true)
169185
@Preview(
170186
name = "Dark Mode",
@@ -194,4 +210,4 @@ private fun PreviewDiningHallCard() {
194210
toggleFavourite = { },
195211
openDiningHallMenu = {}
196212
)
197-
}
213+
}

PennMobile/src/main/java/com/pennapps/labs/pennmobile/dining/fragments/components/SortDropdown.kt

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/**
2+
* @file SortDropdown.kt
3+
* @brief Renders a stateless dropdown menu component for selecting a sort order.
4+
*
5+
* This file contains the `SortDropdown` composable, a UI component that allows users
6+
* to view the current sort option and expand a list to select a new one. It is designed
7+
* to be stateless, receiving its state and event handlers from a parent ViewModel.
8+
*
9+
* It utilizes the generic `AnimatedPushDropdown` to manage its animation and layout.
10+
* This file also includes preview functions for both light and dark modes.
11+
*/
112
package com.pennapps.labs.pennmobile.dining.fragments.components
213

314
import androidx.compose.foundation.clickable
@@ -24,6 +35,19 @@ import com.pennapps.labs.pennmobile.compose.presentation.theme.GilroyFontFamily
2435
import com.pennapps.labs.pennmobile.compose.presentation.theme.googleSansFontFamily
2536
import com.pennapps.labs.pennmobile.dining.classes.DiningHallSortOrder
2637

38+
/**
39+
* A dropdown component that displays sorting options for the dining hall list.
40+
*
41+
* It displays the currently selected sort order and, when tapped, expands to show a list of
42+
* available sorting options.
43+
*
44+
* @param sortMenuExpanded State representing whether the dropdown is currently expanded.
45+
* @param toggleExpandedMode Event lambda to be invoked when the user taps to expand or collapse the dropdown.
46+
* @param currentSortOption State representing the currently selected [DiningHallSortOrder].
47+
* @param sortOptions The list of all available [DiningHallSortOrder] options to display.
48+
* @param changeSortOption Event lambda to be invoked when the user selects a new sort option.
49+
* @param modifier The [Modifier] to be applied to this component.
50+
*/
2751
@Composable
2852
fun SortDropdown(
2953
sortMenuExpanded: Boolean,
@@ -87,7 +111,12 @@ fun SortDropdown(
87111
)
88112
}
89113

90-
114+
/**
115+
* Provides a preview of the [SortDropdown] component for development purposes.
116+
*
117+
* This composable is annotated with `@Preview` and sets up the [SortDropdown] with
118+
* sample state to be rendered in Android Studio's preview pane.
119+
*/
91120
@Preview(name = "Light Mode", showBackground = true)
92121
@Preview(
93122
name = "Dark Mode",
@@ -111,5 +140,4 @@ private fun PreviewSortDropdown() =
111140
changeSortOption = { sortOption = it },
112141
)
113142
}
114-
}
115-
143+
}

0 commit comments

Comments
 (0)