Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@file:Suppress("ktlint:standard:no-wildcard-imports")

package com.pennapps.labs.pennmobile

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
Expand All @@ -20,11 +22,14 @@ import androidx.compose.ui.unit.dp
@Suppress("ktlint:standard:function-naming")
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun NotificationSettingsList(settingsList: List<Pair<String, Boolean>>) {
fun NotificationSettingsList(
settingsList: List<Pair<String, Boolean>>,
modifier: Modifier = Modifier,
) {
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())

Scaffold(
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
modifier = modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
topBar = {
Column {
CenterAlignedTopAppBar(
Expand Down Expand Up @@ -102,12 +107,13 @@ fun NotificationSettingsList(settingsList: List<Pair<String, Boolean>>) {
fun NotificationSettingRow(
label: String,
isEnabledInitial: Boolean,
modifier: Modifier = Modifier,
) {
var isEnabled by remember { mutableStateOf(isEnabledInitial) }

Row(
modifier =
Modifier
modifier
.fillMaxWidth()
.padding(horizontal = 32.dp, vertical = 4.dp),
verticalAlignment = Alignment.CenterVertically,
Expand Down Expand Up @@ -141,11 +147,10 @@ fun NotificationSettingRow(
fun saveNotificationSettings() {
}

@Suppress("ktlint:standard:function-naming")
@Preview(showBackground = true)
@Composable
fun AppWithListPreview() {
var settingsList =
private fun AppWithListPreview() {
val settingsList =
listOf(
"Penn Course Alert" to false,
"Laundry" to true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import androidx.compose.material3.SnackbarDuration
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand Down Expand Up @@ -60,6 +62,8 @@ fun AppSnackBar(
contentColor = AppColors.TabTextBlue,
),
) {
val currentDismiss by rememberUpdatedState(dismiss)

val duration =
when (duration) {
SnackbarDuration.Short -> 3000L
Expand All @@ -72,7 +76,7 @@ fun AppSnackBar(

if (duration != Long.MAX_VALUE) {
delay(duration)
dismiss()
currentDismiss()
}
}

Expand Down Expand Up @@ -139,17 +143,6 @@ private fun PreviewAppSnackBar() =
.fillMaxSize()
.background(MaterialTheme.colorScheme.background),
) {
// AppSnackBar(
// snackBarContainerColor = AppColors.LabelRed,
// snackBarContentColor = Color.White,
// message = "Log in to add dining halls to favourites",
// snackBarActionLabel = "Log In",
// dismiss = {},
// performSnackBarAction = { },
// duration = SnackbarDuration.Short,
// modifier = Modifier.align(Alignment.BottomCenter)
// )

AppSnackBar(
snackBarContainerColor = AppColors.LabelRed,
snackBarContentColor = Color.White,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.pennapps.labs.pennmobile.dining.composables

import GilroyExtraBold
import PennMobileTheme
import android.util.Log
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.PaddingValues
Expand All @@ -15,20 +14,24 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import com.pennapps.labs.pennmobile.dining.composables.components.DiningBalancesCard
import com.pennapps.labs.pennmobile.dining.composables.components.DiningPredictionCard
import com.pennapps.labs.pennmobile.dining.viewmodels.DiningInsightsViewModel
import com.pennapps.labs.pennmobile.ui.theme.PennMobileTheme

@Suppress("ktlint:standard:function-naming")
@Composable
fun DiningInsightsScreen(
onLoginRequirement: () -> Unit,
modifier: Modifier = Modifier,
viewModel: DiningInsightsViewModel = hiltViewModel(),
onLoginRequired: () -> Unit,
) {
val currentOnLoginRequirement by rememberUpdatedState(onLoginRequirement)

PennMobileTheme {
LaunchedEffect(Unit) {
viewModel.checkTokenAndFetch()
Expand All @@ -37,7 +40,7 @@ fun DiningInsightsScreen(
val loginRequired by viewModel.loginRequired.collectAsState()
LaunchedEffect(loginRequired) {
if (loginRequired) {
onLoginRequired()
currentOnLoginRequirement()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ class DiningFragment : Fragment() {

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun DiningHallListScreen(viewModel: DiningViewModel = hiltViewModel()) {
fun DiningHallListScreen(
modifier: Modifier = Modifier,
viewModel: DiningViewModel = hiltViewModel(),
) {
val pullToRefreshState = rememberPullToRefreshState()
val isDataRefreshing by viewModel.isRefreshing.collectAsState()
val allDiningHalls by viewModel.allDiningHalls.collectAsState()
Expand All @@ -119,6 +122,7 @@ class DiningFragment : Fragment() {
}

Scaffold(
modifier = modifier,
snackbarHost = {
SnackbarHost(
hostState = snackBarHostState,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package com.pennapps.labs.pennmobile.ui.theme

import AppShapes
import AppTypography
import androidx.compose.foundation.background
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.pennapps.labs.pennmobile.ui.theme.DarkColors
import com.pennapps.labs.pennmobile.ui.theme.LightColors

@Suppress("ktlint:standard:function-naming")
@Composable
fun PennMobileTheme(
modifier: Modifier = Modifier,
darkTheme: Boolean = isSystemInDarkTheme(),
content: @Composable () -> Unit,
) {
Expand All @@ -23,7 +25,7 @@ fun PennMobileTheme(
) {
Box(
modifier =
Modifier
modifier
.fillMaxSize()
.background(colors.background),
) {
Expand Down
Loading