Skip to content

Commit

Permalink
add dividers to edit screens
Browse files Browse the repository at this point in the history
  • Loading branch information
Razeeman committed Apr 21, 2024
1 parent 4a8e9d5 commit 0adffee
Show file tree
Hide file tree
Showing 28 changed files with 171 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fun ChangeRecordParams.Preview.DateTime.toViewData(): TimeMapper.DateTime {
fun TimeMapper.DateTime.toRecordParams(): ChangeRecordParams.Preview.DateTime {
return ChangeRecordParams.Preview.DateTime(
date = date,
time = time
time = time,
)
}

Expand All @@ -77,7 +77,7 @@ fun ChangeRunningRecordParams.Preview.DateTime.toViewData(): TimeMapper.DateTime
fun TimeMapper.DateTime.toRunningRecordParams(): ChangeRunningRecordParams.Preview.DateTime {
return ChangeRunningRecordParams.Preview.DateTime(
date = date,
time = time
time = time,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.core.widget.doAfterTextChanged
import androidx.fragment.app.viewModels
import com.example.util.simpletimetracker.core.base.BaseFragment
import com.example.util.simpletimetracker.core.dialog.ColorSelectionDialogListener
import com.example.util.simpletimetracker.core.extension.addOnBackPressedListener
import com.example.util.simpletimetracker.core.extension.hideKeyboard
import com.example.util.simpletimetracker.core.extension.observeOnce
import com.example.util.simpletimetracker.core.extension.setSharedTransitions
Expand Down Expand Up @@ -108,6 +109,7 @@ class ChangeActivityFilterFragment :
btnChangeActivityFilterSave.setOnClick(viewModel::onSaveClick)
btnChangeActivityFilterDelete.setOnClick(viewModel::onDeleteClick)
buttonsChangeActivityFilterType.listener = viewModel::onFilterTypeClick
addOnBackPressedListener(action = viewModel::onBackPressed)
}

override fun initViewModel(): Unit = with(binding) {
Expand Down Expand Up @@ -182,6 +184,7 @@ class ChangeActivityFilterFragment :
inputChangeActivityFilterName.isVisible = isClosed
btnChangeActivityFilterDelete.isVisible =
viewModel.deleteIconVisibility.value.orFalse() && isClosed
dividerChangeActivityFilterBottom.isVisible = !isClosed

// Chooser fields
fieldChangeActivityFilterColor.isVisible = isClosed || state.current is Color
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import com.example.util.simpletimetracker.core.extension.set
import com.example.util.simpletimetracker.core.interactor.SnackBarMessageNavigationInteractor
import com.example.util.simpletimetracker.core.mapper.ActivityFilterViewDataMapper
import com.example.util.simpletimetracker.core.view.buttonsRowView.ButtonsRowViewData
import com.example.util.simpletimetracker.domain.extension.flip
import com.example.util.simpletimetracker.domain.extension.orTrue
import com.example.util.simpletimetracker.domain.extension.orZero
import com.example.util.simpletimetracker.domain.interactor.ActivityFilterInteractor
import com.example.util.simpletimetracker.domain.interactor.PrefsInteractor
Expand Down Expand Up @@ -178,6 +176,14 @@ class ChangeActivityFilterViewModel @Inject constructor(
}
}

fun onBackPressed() {
if (chooserState.value?.current !is ChangeActivityFilterChooserState.State.Closed) {
onNewChooserState(ChangeActivityFilterChooserState.State.Closed)
} else {
router.back()
}
}

private fun onNewChooserState(
newState: ChangeActivityFilterChooserState.State,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toTopOf="@id/btnChangeActivityFilterSave"
app:layout_constraintBottom_toTopOf="@id/dividerChangeActivityFilterButton"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0">

Expand Down Expand Up @@ -215,6 +215,13 @@

</androidx.cardview.widget.CardView>

<View
android:id="@+id/dividerChangeActivityFilterBottom"
style="@style/EditScreenDivider"
android:layout_width="match_parent"
android:layout_marginTop="@dimen/edit_screen_field_top_margin"
app:layout_constraintTop_toBottomOf="@id/fieldChangeActivityFilterType" />

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.core.widget.NestedScrollView>
Expand All @@ -228,7 +235,7 @@
android:layout_marginTop="8dp"
android:overScrollMode="never"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/btnChangeActivityFilterSave"
app:layout_constraintBottom_toTopOf="@id/dividerChangeActivityFilterButton"
app:layout_constraintTop_toBottomOf="@id/containerChangeActivityFilterMain"
tools:itemCount="3"
tools:listitem="@layout/item_color_layout"
Expand All @@ -241,7 +248,7 @@
android:layout_height="0dp"
android:layout_marginTop="8dp"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/btnChangeActivityFilterSave"
app:layout_constraintBottom_toTopOf="@id/dividerChangeActivityFilterButton"
app:layout_constraintTop_toBottomOf="@id/containerChangeActivityFilterMain"
tools:visibility="gone">

Expand All @@ -255,7 +262,7 @@
android:id="@+id/tvChangeActivityFilterTypeHint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/input_field_margin"
android:layout_marginHorizontal="@dimen/edit_screen_margin_horizontal"
android:gravity="center"
android:text="@string/change_activity_filter_type"
android:textColor="?appTextHintColor"
Expand All @@ -265,7 +272,6 @@
android:id="@+id/buttonsChangeActivityFilterType"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="12dp"
app:layout_scrollFlags="scroll" />

</com.google.android.material.appbar.AppBarLayout>
Expand All @@ -282,6 +288,12 @@

</androidx.coordinatorlayout.widget.CoordinatorLayout>

<View
android:id="@+id/dividerChangeActivityFilterButton"
style="@style/EditScreenDivider"
android:layout_width="match_parent"
app:layout_constraintBottom_toTopOf="@id/btnChangeActivityFilterSave" />

<com.google.android.material.button.MaterialButton
android:id="@+id/btnChangeActivityFilterSave"
style="@style/AppButtonActive"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.example.util.simpletimetracker.feature_base_adapter.divider.DividerVi
import com.example.util.simpletimetracker.core.mapper.RecordTypeViewDataMapper
import com.example.util.simpletimetracker.domain.interactor.PrefsInteractor
import com.example.util.simpletimetracker.domain.interactor.RecordTypeInteractor
import com.example.util.simpletimetracker.domain.model.RecordType
import com.example.util.simpletimetracker.feature_change_category.mapper.ChangeCategoryMapper
import com.example.util.simpletimetracker.feature_change_category.viewData.ChangeCategoryTypesViewData
import javax.inject.Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import androidx.fragment.app.viewModels
import com.example.util.simpletimetracker.core.base.BaseFragment
import com.example.util.simpletimetracker.core.dialog.ColorSelectionDialogListener
import com.example.util.simpletimetracker.core.dialog.DurationDialogListener
import com.example.util.simpletimetracker.core.extension.addOnBackPressedListener
import com.example.util.simpletimetracker.core.extension.hideKeyboard
import com.example.util.simpletimetracker.core.extension.observeOnce
import com.example.util.simpletimetracker.core.extension.setSharedTransitions
import com.example.util.simpletimetracker.core.extension.showKeyboard
import com.example.util.simpletimetracker.core.extension.toViewData
import com.example.util.simpletimetracker.core.utils.fragmentArgumentDelegate
import com.example.util.simpletimetracker.core.view.UpdateViewChooserState
import com.example.util.simpletimetracker.domain.extension.orFalse
Expand All @@ -32,7 +32,6 @@ import com.example.util.simpletimetracker.feature_base_adapter.recordType.create
import com.example.util.simpletimetracker.feature_change_category.viewData.ChangeCategoryTypesViewData
import com.example.util.simpletimetracker.feature_change_category.viewModel.ChangeCategoryViewModel
import com.example.util.simpletimetracker.feature_change_record_type.goals.GoalsViewDelegate
import com.example.util.simpletimetracker.feature_change_record_type.viewData.ChangeRecordTypeCategoriesViewData
import com.example.util.simpletimetracker.feature_change_record_type.viewData.ChangeRecordTypeChooserState
import com.example.util.simpletimetracker.feature_change_record_type.viewData.ChangeRecordTypeChooserState.State
import com.example.util.simpletimetracker.feature_change_record_type.viewData.ChangeRecordTypeChooserState.State.Closed
Expand Down Expand Up @@ -130,6 +129,7 @@ class ChangeCategoryFragment :
viewModel = viewModel,
layout = layoutChangeCategoryGoals,
)
addOnBackPressedListener(action = viewModel::onBackPressed)
}

override fun initViewModel(): Unit = with(binding) {
Expand Down Expand Up @@ -236,6 +236,7 @@ class ChangeCategoryFragment :
viewModel.statsIconVisibility.value.orFalse() && isClosed
btnChangeCategoryDelete.isVisible =
viewModel.deleteIconVisibility.value.orFalse() && isClosed
dividerChangeCategoryBottom.isVisible = !isClosed

// Chooser fields
fieldChangeCategoryColor.isVisible = isClosed || state.current is Color
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import com.example.util.simpletimetracker.domain.model.Category
import com.example.util.simpletimetracker.domain.model.ChartFilterType
import com.example.util.simpletimetracker.domain.model.RecordTypeGoal
import com.example.util.simpletimetracker.domain.model.WidgetType
import com.example.util.simpletimetracker.feature_base_adapter.ViewHolderType
import com.example.util.simpletimetracker.feature_base_adapter.category.CategoryViewData
import com.example.util.simpletimetracker.feature_base_adapter.recordType.RecordTypeViewData
import com.example.util.simpletimetracker.feature_change_category.R
Expand Down Expand Up @@ -188,6 +187,14 @@ class ChangeCategoryViewModel @Inject constructor(
}
}

fun onBackPressed() {
if (chooserState.value?.current !is ChangeRecordTypeChooserState.State.Closed) {
onNewChooserState(ChangeRecordTypeChooserState.State.Closed)
} else {
router.back()
}
}

private suspend fun saveTypes(categoryId: Long) {
val addedTypes = newTypes.filterNot { it in initialTypes }
val removedTypes = initialTypes.filterNot { it in newTypes }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toTopOf="@id/btnChangeCategorySave"
app:layout_constraintBottom_toTopOf="@id/dividerChangeCategoryButton"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0">

Expand Down Expand Up @@ -312,6 +312,13 @@

</androidx.cardview.widget.CardView>

<View
android:id="@+id/dividerChangeCategoryBottom"
style="@style/EditScreenDivider"
android:layout_width="match_parent"
android:layout_marginTop="@dimen/edit_screen_field_top_margin"
app:layout_constraintTop_toBottomOf="@id/fieldChangeCategoryGoalTime" />

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.core.widget.NestedScrollView>
Expand All @@ -325,7 +332,7 @@
android:layout_marginTop="8dp"
android:overScrollMode="never"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/btnChangeCategorySave"
app:layout_constraintBottom_toTopOf="@id/dividerChangeCategoryButton"
app:layout_constraintTop_toBottomOf="@id/containerChangeCategoryMain"
tools:itemCount="3"
tools:listitem="@layout/item_color_layout"
Expand All @@ -339,7 +346,7 @@
android:layout_marginTop="8dp"
android:overScrollMode="never"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/btnChangeCategorySave"
app:layout_constraintBottom_toTopOf="@id/dividerChangeCategoryButton"
app:layout_constraintTop_toBottomOf="@id/containerChangeCategoryMain"
tools:itemCount="3"
tools:listitem="@layout/item_record_type_layout"
Expand All @@ -352,7 +359,7 @@
android:layout_height="0dp"
android:layout_marginTop="8dp"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/btnChangeCategorySave"
app:layout_constraintBottom_toTopOf="@id/dividerChangeCategoryButton"
app:layout_constraintTop_toBottomOf="@id/containerChangeCategoryMain"
tools:visibility="gone">

Expand All @@ -364,6 +371,12 @@

</androidx.core.widget.NestedScrollView>

<View
android:id="@+id/dividerChangeCategoryButton"
style="@style/EditScreenDivider"
android:layout_width="match_parent"
app:layout_constraintBottom_toTopOf="@id/btnChangeCategorySave" />

<com.google.android.material.button.MaterialButton
android:id="@+id/btnChangeCategorySave"
style="@style/AppButtonActive"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ChangeRecordViewDataMapper @Inject constructor(
dateTimeStarted = timeMapper.getFormattedDateTime(
time = record.timeStarted,
useMilitaryTime = useMilitaryTime,
showSeconds = showSeconds
showSeconds = showSeconds,
),
dateTimeFinished = timeMapper.getFormattedDateTime(
time = record.timeEnded,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@ package com.example.util.simpletimetracker.feature_change_record.view
import android.content.res.ColorStateList
import android.view.View
import androidx.cardview.widget.CardView
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.view.ViewCompat
import androidx.core.view.isInvisible
import androidx.core.view.isVisible
import androidx.core.widget.doAfterTextChanged
import androidx.viewbinding.ViewBinding
import com.example.util.simpletimetracker.core.base.BaseFragment
import com.example.util.simpletimetracker.core.extension.addOnBackPressedListener
import com.example.util.simpletimetracker.core.extension.hideKeyboard
import com.example.util.simpletimetracker.core.extension.observeOnce
import com.example.util.simpletimetracker.core.extension.showKeyboard
import com.example.util.simpletimetracker.core.extension.toViewData
import com.example.util.simpletimetracker.core.utils.setChooserColor
import com.example.util.simpletimetracker.domain.extension.orFalse
import com.example.util.simpletimetracker.domain.model.AppColor
import com.example.util.simpletimetracker.feature_base_adapter.BaseRecyclerAdapter
import com.example.util.simpletimetracker.feature_base_adapter.category.createCategoryAdapterDelegate
import com.example.util.simpletimetracker.feature_base_adapter.category.createCategoryAddAdapterDelegate
Expand All @@ -27,7 +25,6 @@ import com.example.util.simpletimetracker.feature_base_adapter.hintBig.createHin
import com.example.util.simpletimetracker.feature_base_adapter.info.createInfoAdapterDelegate
import com.example.util.simpletimetracker.feature_base_adapter.loader.createLoaderAdapterDelegate
import com.example.util.simpletimetracker.feature_base_adapter.recordType.createRecordTypeAdapterDelegate
import com.example.util.simpletimetracker.feature_change_record.R
import com.example.util.simpletimetracker.feature_change_record.adapter.createChangeRecordCommentAdapterDelegate
import com.example.util.simpletimetracker.feature_change_record.adapter.createChangeRecordCommentFieldAdapterDelegate
import com.example.util.simpletimetracker.feature_change_record.databinding.ChangeRecordCoreLayoutBinding
Expand Down Expand Up @@ -135,7 +132,8 @@ class ChangeRecordCore(
}
}

fun initUx(
fun <T : ViewBinding> initUx(
fragment: BaseFragment<T>,
binding: ChangeRecordCoreLayoutBinding,
) = with(binding) {
etChangeRecordComment.doAfterTextChanged { viewModel.onCommentChange(it.toString()) }
Expand All @@ -158,6 +156,7 @@ class ChangeRecordCore(
btnChangeRecordRepeat.setOnClick(viewModel::onRepeatClick)
btnChangeRecordDuplicate.setOnClick(viewModel::onDuplicateClick)
btnChangeRecordMerge.setOnClick(viewModel::onMergeClick)
fragment.addOnBackPressedListener(action = viewModel::onBackPressed)
}

fun <T : ViewBinding> initViewModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class ChangeRecordFragment :
}

override fun initUx() = with(binding) {
core.initUx(layoutChangeRecordCore)
core.initUx(this@ChangeRecordFragment, layoutChangeRecordCore)
layoutChangeRecordCore.btnChangeRecordStatistics.setOnClick(viewModel::onStatisticsClick)
layoutChangeRecordCore.btnChangeRecordDelete.setOnClick {
viewModel.onDeleteClick()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,14 @@ abstract class ChangeRecordBaseViewModel(
}
}

fun onBackPressed() {
if (chooserState.value?.current !is ChangeRecordChooserState.State.Closed) {
onNewChooserState(ChangeRecordChooserState.State.Closed)
} else {
router.back()
}
}

private suspend fun updateMergeData() {
changeRecordMergeDelegate.updateMergePreviewViewData(
mergeAvailable = mergeAvailable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package com.example.util.simpletimetracker.feature_change_record.viewModel
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.example.util.simpletimetracker.core.extension.set
import com.example.util.simpletimetracker.domain.extension.flip
import com.example.util.simpletimetracker.domain.extension.orFalse
import com.example.util.simpletimetracker.domain.interactor.AddRecordMediator
import com.example.util.simpletimetracker.domain.model.Record
import com.example.util.simpletimetracker.feature_base_adapter.ViewHolderType
Expand Down
Loading

0 comments on commit 0adffee

Please sign in to comment.