Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
Remove rpe picker bottom sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
AnkitSuda committed Nov 15, 2022
1 parent 54dc5ae commit 497da60
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 498 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,32 @@ import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController
import com.ankitsuda.common.compose.collectEvent
import com.ankitsuda.navigation.*
import com.ankitsuda.rebound.ui.measure.MeasureScreen
import com.ankitsuda.rebound.ui.exercise_details.ExerciseDetailScreen
import com.ankitsuda.rebound.ui.exercises.ExercisesScreen
import com.ankitsuda.rebound.ui.calendar.CalendarScreen
import com.ankitsuda.rebound.ui.components.workouteditor.rpeselector.RpeSelectorBottomSheet
import com.ankitsuda.rebound.ui.components.workouteditor.supersetselector.SupersetSelectorBottomSheet
import com.ankitsuda.rebound.ui.create_exercise.CreateExerciseScreen
import com.ankitsuda.rebound.ui.customizeplates.CustomizePlatesScreen
import com.ankitsuda.rebound.ui.customizeplates.edit.PlateEditBottomSheet
import com.ankitsuda.rebound.ui.exercise_details.ExerciseDetailScreen
import com.ankitsuda.rebound.ui.exercises.ExercisesScreen
import com.ankitsuda.rebound.ui.history.HistoryScreen
import com.ankitsuda.rebound.ui.home.HomeScreen
import com.ankitsuda.rebound.ui.keyboard.ReboundSetKeyboardDemoScreen
import com.ankitsuda.rebound.ui.measure.MeasureScreen
import com.ankitsuda.rebound.ui.measure.part.add_sheet.AddPartMeasurementBottomSheet
import com.ankitsuda.rebound.ui.measure.part.overview.PartMeasurementsScreen
import com.ankitsuda.rebound.ui.more.MoreScreen
import com.ankitsuda.rebound.ui.resttimer.RestTimerScreen
import com.ankitsuda.rebound.ui.settings.SettingsScreen
import com.ankitsuda.rebound.ui.settings.personalization.ColorPickerDemoScreen
import com.ankitsuda.rebound.ui.settings.personalization.PersonalizationScreen
import com.ankitsuda.rebound.ui.settings.personalization.botom_bar.BottomBarPersonalizationScreen
import com.ankitsuda.rebound.ui.settings.personalization.card.CardPersonalizationScreen
import com.ankitsuda.rebound.ui.settings.personalization.charts.ChartsPersonalizationScreen
import com.ankitsuda.rebound.ui.settings.personalization.keyboard.KeyboardPersonalizationScreen
import com.ankitsuda.rebound.ui.settings.personalization.main_colors.MainColorsPersonalizationScreen
import com.ankitsuda.rebound.ui.settings.personalization.presets.ThemePresetsPersonalizationScreen
import com.ankitsuda.rebound.ui.settings.personalization.shapes.ShapesPersonalizationScreen
import com.ankitsuda.rebound.ui.settings.personalization.top_bar.TopBarPersonalizationScreen
import com.ankitsuda.rebound.ui.measure.part.add_sheet.AddPartMeasurementBottomSheet
import com.ankitsuda.rebound.ui.measure.part.overview.PartMeasurementsScreen
import com.ankitsuda.rebound.ui.resttimer.RestTimerScreen
import com.ankitsuda.rebound.ui.settings.SettingsScreen
import com.ankitsuda.rebound.ui.settings.personalization.keyboard.KeyboardPersonalizationScreen
import com.ankitsuda.rebound.ui.settings.personalization.presets.ThemePresetsPersonalizationScreen
import com.ankitsuda.rebound.ui.workout.WorkoutScreen
import com.ankitsuda.rebound.ui.workout.addfolder.TemplatesFolderEditBottomSheet
import com.ankitsuda.rebound.ui.workout_details.SessionScreen
Expand Down Expand Up @@ -128,7 +127,6 @@ internal fun AppNavigation(
addExercisesBottomSheet(navController)
addRestTimer(navController)
addSupersetSelector(navController)
addRpeSelector(navController)
}
}

Expand Down Expand Up @@ -403,13 +401,6 @@ private fun NavGraphBuilder.addSupersetSelector(navController: NavController) {
}
}

private fun NavGraphBuilder.addRpeSelector(navController: NavController) {
bottomSheetScreen(LeafScreen.RpeSelector()) {
RpeSelectorBottomSheet(navController)
}
}


/**
* Adds an [NavController.OnDestinationChangedListener] to this [NavController] and updates the
* returned [State] which is updated as the destination changes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import androidx.compose.material.icons.outlined.Close
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand All @@ -42,14 +41,11 @@ import com.ankitsuda.rebound.domain.entities.ExerciseSetGroupNote
import com.ankitsuda.rebound.domain.entities.ExerciseWorkoutJunction
import com.ankitsuda.rebound.domain.entities.LogEntriesWithExerciseJunction
import com.ankitsuda.rebound.ui.components.AppTextField
import com.ankitsuda.rebound.ui.components.workouteditor.rpeselector.models.RpeSelectorResult
import com.ankitsuda.rebound.ui.components.workouteditor.supersetselector.models.SupersetSelectorResult
import com.ankitsuda.rebound.ui.components.workouteditor.warmupcalculator.toExerciseLogEntries
import com.ankitsuda.rebound.ui.keyboard.LocalReboundSetKeyboard
import com.ankitsuda.rebound.ui.theme.ReboundTheme
import com.google.accompanist.insets.LocalWindowInsets
import timber.log.Timber
import kotlin.math.log

@OptIn(ExperimentalComposeUiApi::class, ExperimentalFoundationApi::class)
@Composable
Expand Down Expand Up @@ -89,12 +85,6 @@ fun WorkoutEditorComponent(
?.getStateFlow<SupersetSelectorResult?>(RESULT_SUPERSET_SELECTOR_SUPERSET_ID_KEY, null)
?.collectAsState()

// Observes results when RPE Selector changes value of arg
val rpeSelectorResult = navController.currentBackStackEntry
?.savedStateHandle
?.getStateFlow<RpeSelectorResult?>(RESULT_RPE_SELECTOR_KEY, null)
?.collectAsState()

val navigationBarHeight =
with(LocalDensity.current) { if (addNavigationBarPadding) LocalWindowInsets.current.navigationBars.bottom.toDp() else 0.dp }

Expand Down Expand Up @@ -125,26 +115,6 @@ fun WorkoutEditorComponent(
}
}

LaunchedEffect(key1 = rpeSelectorResult?.value) {
rpeSelectorResult?.value?.let { result ->

logEntriesWithJunction.flatMap { it.logEntries }.find {
it.entryId == result.entryId
}?.let {
onUpdateLogEntry(
it.copy(
rpe = result.rpe
)
)
}

navController.currentBackStackEntry?.savedStateHandle?.set(
RESULT_RPE_SELECTOR_KEY,
null
)
}
}

val keyboardController = LocalSoftwareKeyboardController.current
val reboundKeyboard = LocalReboundSetKeyboard.current
fun hideKeyboard() {
Expand Down Expand Up @@ -249,15 +219,6 @@ fun WorkoutEditorComponent(
junctionId = logEntriesWithJunctionItem.junction.id,
)
)
},
onRequestRpeSelector = {
hideKeyboard()
navigator.navigate(
LeafScreen.RpeSelector.createRoute(
it.entryId,
it.rpe
)
)
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

package com.ankitsuda.rebound.ui.components.workouteditor

import android.view.inputmethod.InputConnection
import androidx.compose.animation.*
import androidx.compose.animation.core.*
import androidx.compose.foundation.ExperimentalFoundationApi
Expand All @@ -25,15 +24,13 @@ import androidx.compose.foundation.lazy.LazyItemScope
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.*
import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.scale
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
Expand All @@ -57,9 +54,7 @@ import com.ankitsuda.rebound.ui.components.workouteditor.warmupcalculator.WarmUp
import com.ankitsuda.rebound.ui.components.workouteditor.warmupcalculator.WarmUpSet
import com.ankitsuda.rebound.ui.keyboard.enums.ReboundKeyboardType
import com.ankitsuda.rebound.ui.keyboard.field.ReboundSetTextField
import com.ankitsuda.rebound.ui.keyboard.getText
import com.ankitsuda.rebound.ui.theme.ReboundTheme
import timber.log.Timber
import java.util.*

private val ExerciseLogEntryComparator = Comparator<ExerciseLogEntry> { left, right ->
Expand All @@ -80,7 +75,6 @@ fun LazyListScope.workoutExerciseItemAlt(
onChangeNote: (ExerciseSetGroupNote) -> Unit,
onAddToSuperset: () -> Unit,
onRemoveFromSuperset: () -> Unit,
onRequestRpeSelector: (ExerciseLogEntry) -> Unit,
) {

val supersetId = logEntriesWithJunction.junction.supersetId
Expand Down Expand Up @@ -321,7 +315,6 @@ fun LazyListScope.workoutExerciseItemAlt(
onSwipeDelete = {
onSwipeDelete(it)
},
onRequestRpeSelector = onRequestRpeSelector
)
}
}
Expand Down Expand Up @@ -361,7 +354,6 @@ private fun LazyItemScope.SetItem(
exerciseLogEntry: ExerciseLogEntry,
onChange: (ExerciseLogEntry) -> Unit,
onSwipeDelete: (ExerciseLogEntry) -> Unit,
onRequestRpeSelector: (ExerciseLogEntry) -> Unit,
) {
var mLogEntry by rememberSaveable {
mutableStateOf(exerciseLogEntry)
Expand Down Expand Up @@ -491,7 +483,6 @@ private fun LazyItemScope.SetItem(
onRpeChange = { _, value ->
handleOnChange(mLogEntry.copy(rpe = value))
},
onRequestRpeSelector = onRequestRpeSelector
)
}
}
Expand All @@ -511,7 +502,6 @@ private fun SetItemLayout(
onCompleteChange: (ExerciseLogEntry, Boolean) -> Unit,
onSetTypeChange: (ExerciseLogEntry, LogSetType) -> Unit,
onRpeChange: (ExerciseLogEntry, Float?) -> Unit,
onRequestRpeSelector: (ExerciseLogEntry) -> Unit,
) {
val typeOfSet = exerciseLogEntry.setType ?: LogSetType.NORMAL
var isSetTypeChangerExpanded by rememberSaveable {
Expand Down Expand Up @@ -662,27 +652,6 @@ private fun SetItemLayout(
bgColor = bgColor,
reboundKeyboardType = ReboundKeyboardType.RPE
)
// Box(
// modifier = Modifier
// .defaultMinSize(minHeight = 32.dp)
// .padding(start = 8.dp, end = 8.dp)
// .weight(0.75f)
// .clip(RoundedCornerShape(12.dp))
// .background(bgColor.lighterOrDarkerColor(0.10f))
// .clickable {
// onRequestRpeSelector(exerciseLogEntry)
// },
// contentAlignment = Alignment.Center
// ) {
// Text(
// exerciseLogEntry.rpe?.toReadableString() ?: "",
// style = LocalTextStyle.current.copy(
// textAlign = TextAlign.Center,
// fontSize = 14.sp,
// color = contentColor
// )
// )
// }
}

IconButton(
Expand Down

This file was deleted.

Loading

0 comments on commit 497da60

Please sign in to comment.