Skip to content

Commit

Permalink
updates to be in line with new topbar handeling
Browse files Browse the repository at this point in the history
  • Loading branch information
SvenLindstrom committed Oct 29, 2024
1 parent 76b632e commit 351eafc
Show file tree
Hide file tree
Showing 11 changed files with 179 additions and 163 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class NetworkSettings private constructor(val port: Int, val scheme: String, val
)

val development = NetworkSettings(
port = 7036, scheme = "http", tumbleUrl = "10.0.2.2"
port = 7036, scheme = "https", tumbleUrl = "10.0.2.2"
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ private fun NavGraphBuilder.bookmarksDetails(navController: NavHostController, s
}
) { backStackEntry ->
val id = backStackEntry.arguments?.getString("id")
EventDetailsSheet(event = AppController.shared.eventSheet!!.event)
EventDetailsSheet(event = AppController.shared.eventSheet!!.event, setTopNavState)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,11 @@ class ResourceViewModel @Inject constructor(
private val _allResources = MutableStateFlow<List<NetworkResponse.KronoxResourceElement>?>(null)
val allResources: StateFlow<List<NetworkResponse.KronoxResourceElement>?> = _allResources

// private val _allResourcesTypes = MutableStateFlow<List<NetworkResponse.KronoxResourceElement>?>(null)
// val allResourcesTypes: StateFlow<List<NetworkResponse.KronoxResourceElement>?> = _allResourcesTypes

//val allResources: List<NetworkResponse.KronoxResourceElement>? = null

// private val _resourceSelectionModel = MutableStateFlow<ResourceSelectionModel?>(null)
// var resourceSelectionModel by mutableStateOf<ResourceSelectionModel?>(null)

// private val _resourceSelectioned = MutableStateFlow<NetworkResponse.KronoxResourceElement?>(null)
// var resourceSelectioned = mutableStateOf<NetworkResponse.KronoxResourceElement?>(null)

fun setBookingDate(newDate: Date){
_selectedPickerDate.value = newDate
viewModelScope.launch { getAllResources(isoDateFormatterDate.format(newDate)) }
viewModelScope.launch { getAllResources(newDate) }
}

// fun setResourceSelection(resource: NetworkResponse.KronoxResourceElement){
// resourceSelectioned.value = resource
// }

fun getUserEventsForPage(){
viewModelScope.launch {
_eventBookingPageState.value = PageState.LOADING
Expand Down Expand Up @@ -143,10 +128,11 @@ class ResourceViewModel @Inject constructor(
}
}

fun getAllResources(date: String = isoDateFormatterDate.format(Date())){
fun getAllResources(date: Date = Date()){
val dateString = isoDateFormatterDate.format(date)
viewModelScope.launch {
try {
val endpoint = Endpoint.AllResources(dataStoreManager.authSchoolId.value.toString(), date)
val endpoint = Endpoint.AllResources(dataStoreManager.authSchoolId.value.toString(), dateString)
val refreshToken = authManager.getRefreshToken() ?: return@launch
val response: ApiResponse<List<NetworkResponse.KronoxResourceElement>> = kronoxManager.getAllResources(endpoint, refreshToken, null)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.compose.material.Scaffold
import androidx.compose.material.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.compose.material.Divider
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
Expand All @@ -26,23 +27,42 @@ import tumble.app.tumble.R
import tumble.app.tumble.extensions.models.getAvailabilityValues
import tumble.app.tumble.extensions.models.getFirstTimeSlotWithAvailability
import tumble.app.tumble.observables.AppController
import tumble.app.tumble.presentation.components.buttons.BackButton
import tumble.app.tumble.presentation.viewmodels.ResourceViewModel
import tumble.app.tumble.presentation.views.general.Info
import tumble.app.tumble.presentation.views.navigation.AppBarState
import tumble.app.tumble.utils.isoVerboseDateFormatter

@RequiresApi(Build.VERSION_CODES.O)
@Composable
fun ResourceSelection(
parentViewModel: ResourceViewModel = hiltViewModel(),
navController: NavController
navController: NavController,
setTopNavState: (AppBarState) -> Unit

) {
val pageTitle = stringResource(R.string.rooms)
val backTitle = stringResource(R.string.resources)

val resource = AppController.shared.resourceModel!!.resource
val selectedTimeIndex = remember { mutableIntStateOf(resource.availabilities.getFirstTimeSlotWithAvailability(resource.timeSlots!!.size)) }
val availabilityValues = remember {
mutableStateOf(resource.availabilities.getAvailabilityValues(timelotId = selectedTimeIndex.intValue))
}
val selectedPickerDate = AppController.shared.resourceModel!!.date
val timeslots = resource.timeSlots
LaunchedEffect(key1 = true) {
setTopNavState(
AppBarState(
title = pageTitle,
navigationAction = {
BackButton(backTitle) {
navController.popBackStack()
}
}
)
)
}
Column(
modifier = Modifier
.fillMaxSize()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package tumble.app.tumble.presentation.views.account.User.ResourceSection.Booking.Sheets

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.MaterialTheme
Expand All @@ -16,75 +13,80 @@ import androidx.compose.material.icons.filled.Info
import androidx.compose.material.icons.filled.Timelapse
import androidx.compose.material.icons.filled.Title
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import tumble.app.tumble.R
import tumble.app.tumble.domain.models.network.NetworkResponse
import tumble.app.tumble.extensions.presentation.convertToHoursAndMinutesISOString
import tumble.app.tumble.extensions.presentation.formatDate
import tumble.app.tumble.presentation.components.sheets.SheetHeader
import tumble.app.tumble.presentation.components.buttons.CloseCoverButton
import tumble.app.tumble.presentation.views.bookmarks.EventDetails.DetailsBuilder
import tumble.app.tumble.presentation.views.navigation.AppBarState

@Composable
fun EventDetailsSheet(
event: NetworkResponse.AvailableKronoxUserEvent,
onClose: () -> Unit
//sheetContent: @Composable () -> Unit
onClose: () -> Unit,
setTopNavState: (AppBarState) -> Unit
) {
val title = stringResource(R.string.event_details)
LaunchedEffect(key1 = true) {
setTopNavState(
AppBarState(
title = title,
actions = {
CloseCoverButton {
onClose()
}
}
)
)
}

Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState())
.background(MaterialTheme.colors.background)
) {
SheetHeader(title = stringResource(R.string.event_details), onClose = onClose)
Box {
Column(
modifier = Modifier
.verticalScroll(rememberScrollState())
.background(MaterialTheme.colors.background)
) {
DetailsBuilder(title = stringResource(R.string.title), image = Icons.Default.Title) {

DetailsBuilder(title = stringResource(R.string.title), image = Icons.Default.Title) {
Text(
text = event.title,
fontSize = 16.sp,
color = MaterialTheme.colors.onSurface
)

Text(
text = event.title,
fontSize = 16.sp,
color = MaterialTheme.colors.onSurface
)

}
DetailsBuilder(title = stringResource(R.string.type), image = Icons.Default.Info) {
Text(
text = event.type,
fontSize = 16.sp,
color = MaterialTheme.colors.onSurface
)
}
}
DetailsBuilder(title = stringResource(R.string.type), image = Icons.Default.Info) {
Text(
text = event.type,
fontSize = 16.sp,
color = MaterialTheme.colors.onSurface
)
}

DetailsBuilder(title = stringResource(R.string.date), image = Icons.Default.CalendarMonth) {
val eventDate = event.eventStart.formatDate()
val eventStart = event.eventStart.convertToHoursAndMinutesISOString()
val eventEnd = event.eventEnd.convertToHoursAndMinutesISOString()
Text(
text = "$eventDate, from $eventStart to $eventEnd"
,
fontSize = 16.sp,
color = MaterialTheme.colors.onSurface
)
}
DetailsBuilder(title = stringResource(R.string.date), image = Icons.Default.CalendarMonth) {
val eventDate = event.eventStart.formatDate()
val eventStart = event.eventStart.convertToHoursAndMinutesISOString()
val eventEnd = event.eventEnd.convertToHoursAndMinutesISOString()
Text(
text = "$eventDate, from $eventStart to $eventEnd"
,
fontSize = 16.sp,
color = MaterialTheme.colors.onSurface
)
}

DetailsBuilder(title = stringResource(R.string.available_until), image = Icons.Default.Timelapse) {
Text(
text = event.lastSignupDate.formatDate().orEmpty()
,
fontSize = 16.sp,
color = MaterialTheme.colors.onSurface
)
}
Spacer(modifier = Modifier.height(60.dp))
}
DetailsBuilder(title = stringResource(R.string.available_until), image = Icons.Default.Timelapse) {
Text(
text = event.lastSignupDate.formatDate().orEmpty()
,
fontSize = 16.sp,
color = MaterialTheme.colors.onSurface
)
}
}
}
Loading

0 comments on commit 351eafc

Please sign in to comment.