Skip to content

Commit 3bc661b

Browse files
committed
(All) Cleanup
- Fixes imports - Adds missing kdocs
1 parent f28d981 commit 3bc661b

File tree

20 files changed

+92
-109
lines changed

20 files changed

+92
-109
lines changed

calendar/src/main/java/com/maxkeppeler/sheets/calendar/CalendarView.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,6 @@ fun CalendarView(
9393
yearListState = yearListState,
9494
mode = calendarState.mode,
9595
cells = calendarState.cells,
96-
nextDisabled = calendarState.isNextDisabled,
97-
prevDisabled = calendarState.isPrevDisabled,
98-
onNext = calendarState::onNext,
99-
onPrev = calendarState::onPrevious,
10096
onCalendarView = {
10197
setupCalendarSelectionView(
10298
config = config,

calendar/src/main/java/com/maxkeppeler/sheets/calendar/views/CalendarBaseSelectionComponent.kt

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,20 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
@file:OptIn(ExperimentalSnapperApi::class, ExperimentalMaterialApi::class)
16+
@file:OptIn(ExperimentalSnapperApi::class)
1717

1818
package com.maxkeppeler.sheets.calendar.views
1919

20-
import androidx.compose.foundation.gestures.Orientation
2120
import androidx.compose.foundation.layout.*
2221
import androidx.compose.foundation.lazy.LazyListScope
2322
import androidx.compose.foundation.lazy.LazyListState
2423
import androidx.compose.foundation.lazy.LazyRow
2524
import androidx.compose.foundation.lazy.grid.GridCells
2625
import androidx.compose.foundation.lazy.grid.LazyGridScope
2726
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
28-
import androidx.compose.material.ExperimentalMaterialApi
29-
import androidx.compose.material.FractionalThreshold
30-
import androidx.compose.material.rememberSwipeableState
31-
import androidx.compose.material.swipeable
3227
import androidx.compose.material3.MaterialTheme
3328
import androidx.compose.material3.Text
3429
import androidx.compose.runtime.Composable
35-
import androidx.compose.runtime.LaunchedEffect
3630
import androidx.compose.ui.Alignment
3731
import androidx.compose.ui.Modifier
3832
import androidx.compose.ui.draw.drawWithContent
@@ -44,7 +38,6 @@ import androidx.compose.ui.res.dimensionResource
4438
import androidx.compose.ui.res.stringResource
4539
import com.maxkeppeler.sheets.calendar.R
4640
import com.maxkeppeler.sheets.calendar.models.CalendarDisplayMode
47-
import com.maxkeppeler.sheets.calendar.models.CalendarSwipeAction
4841
import dev.chrisbanes.snapper.ExperimentalSnapperApi
4942
import dev.chrisbanes.snapper.SnapOffsets
5043
import dev.chrisbanes.snapper.rememberSnapperFlingBehavior
@@ -56,10 +49,6 @@ import com.maxkeppeler.sheets.core.R as RC
5649
* @param yearListState The state of the year list selection view.
5750
* @param cells The amount of cells / columns that are used for the calendar grid view.
5851
* @param mode The display mode of the dialog.
59-
* @param nextDisabled Whenever the navigation to the next period is disabled.
60-
* @param prevDisabled Whenever the navigation to the previous period is disabled.
61-
* @param onPrev The listener that is invoked when the navigation to the previous period is invoked.
62-
* @param onNext The listener that is invoked when the navigation to the next period is invoked.
6352
* @param onCalendarView The content that will be displayed if the [CalendarDisplayMode] is in [CalendarDisplayMode.CALENDAR].
6453
* @param onMonthView The content that will be displayed if the [CalendarDisplayMode] is in [CalendarDisplayMode.MONTH].
6554
* @param onYearView The content that will be displayed if the [CalendarDisplayMode] is in [CalendarDisplayMode.YEAR].
@@ -70,48 +59,15 @@ internal fun CalendarBaseSelectionComponent(
7059
yearListState: LazyListState,
7160
cells: Int,
7261
mode: CalendarDisplayMode,
73-
nextDisabled: Boolean,
74-
prevDisabled: Boolean,
75-
onPrev: () -> Unit,
76-
onNext: () -> Unit,
7762
onCalendarView: LazyGridScope.() -> Unit,
7863
onMonthView: LazyGridScope.() -> Unit,
7964
onYearView: LazyListScope.() -> Unit
8065
) {
8166

82-
val swipeableState = rememberSwipeableState(CalendarSwipeAction.NONE)
83-
val anchors = mapOf(
84-
0f to CalendarSwipeAction.NEXT,
85-
150f to CalendarSwipeAction.NONE,
86-
300f to CalendarSwipeAction.PREV
87-
)
88-
89-
when (swipeableState.currentValue) {
90-
CalendarSwipeAction.NEXT -> {
91-
LaunchedEffect(swipeableState.currentValue) {
92-
if (!nextDisabled) onNext()
93-
swipeableState.snapTo(CalendarSwipeAction.NONE)
94-
}
95-
}
96-
CalendarSwipeAction.PREV -> {
97-
LaunchedEffect(swipeableState.currentValue) {
98-
if (!prevDisabled) onPrev()
99-
swipeableState.snapTo(CalendarSwipeAction.NONE)
100-
}
101-
}
102-
CalendarSwipeAction.NONE -> Unit
103-
}
104-
10567
val baseModifier = modifier
10668
.fillMaxWidth()
10769
.padding(top = dimensionResource(RC.dimen.scd_normal_100))
10870

109-
val gridDateModifier = baseModifier.swipeable(
110-
state = swipeableState,
111-
anchors = anchors,
112-
thresholds = { _, _ -> FractionalThreshold(0.5f) },
113-
orientation = Orientation.Horizontal
114-
)
11571
val gridYearModifier = baseModifier
11672
.graphicsLayer { alpha = 0.99F }
11773
.drawWithContent {
@@ -137,7 +93,7 @@ internal fun CalendarBaseSelectionComponent(
13793
CalendarDisplayMode.CALENDAR -> {
13894
LazyVerticalGrid(
13995
columns = GridCells.Fixed(cells),
140-
modifier = gridDateModifier,
96+
modifier = baseModifier,
14197
userScrollEnabled = false,
14298
) {
14399
onCalendarView()

color/src/main/java/com/maxkeppeler/sheets/color/models/MultipleColors.kt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,76 @@ import androidx.annotation.ColorInt
2323
import androidx.annotation.ColorRes
2424
import androidx.core.content.ContextCompat
2525

26+
/**
27+
* Holds various colors of a specific type.
28+
* @param colorsInt colors as packed color int, AARRGGBB.
29+
* @param colorsRes colors as resource references, R.color.the_color.
30+
* @param colorsHex color as String value, #RRGGBB or #AARRGGBB.
31+
*/
2632
sealed class MultipleColors(
2733
@ColorInt private var colorsInt: Array<Int>? = null,
2834
@ColorRes private var colorsRes: Array<Int>? = null,
2935
private var colorsHex: Array<String>? = null,
3036
) {
3137

38+
/**
39+
* Define a variety of color integers.
40+
*/
3241
class ColorsRes : MultipleColors {
42+
43+
/**
44+
* Define dynamic amount of colors.
45+
* @param colors The color integers
46+
*/
3347
constructor(@ColorRes vararg colors: Int) : super(colorsRes = colors.toTypedArray())
48+
49+
/**
50+
* Define a list of colors.
51+
* @param colors The color integers
52+
*/
3453
constructor(@ColorRes colors: List<Int>) : super(colorsRes = colors.toTypedArray())
3554
}
3655

56+
/**
57+
* Define a variety of color resource references.
58+
*/
3759
class ColorsInt : MultipleColors {
60+
61+
/**
62+
* Define dynamic amount of colors.
63+
* @param colors The color resource references
64+
*/
3865
constructor(@ColorInt vararg colors: Int) : super(colorsInt = colors.toTypedArray())
66+
67+
/**
68+
* Define an array of colors.
69+
* @param colors The color resource references
70+
*/
3971
constructor(@ColorInt colors: List<Int>) : super(colorsInt = colors.toTypedArray())
4072
}
4173

74+
/**
75+
* Define a variety of color String values.
76+
*/
4277
class ColorsHex : MultipleColors {
78+
79+
/**
80+
* Define dynamic amount of colors.
81+
* @param colors The color string values.
82+
*/
4383
constructor(vararg colors: String) : super(colorsHex = colors.toList().toTypedArray())
84+
85+
/**
86+
* Define an array of colors.
87+
* @param colors The color string values.
88+
*/
4489
constructor(colors: List<String>) : super(colorsHex = colors.toTypedArray())
4590
}
4691

92+
/**
93+
* Resolve the defined colors as color integers.
94+
* @param context the Context to resolve the colors.
95+
*/
4796
fun getColorsAsInt(context: Context): List<Int> {
4897
return colorsInt?.toList()
4998
?: colorsRes?.map { ContextCompat.getColor(context, it) }

core/src/main/java/com/maxkeppeker/sheets/core/CoreDialog.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,10 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
@file:OptIn(
17-
ExperimentalMaterialApi::class, ExperimentalMaterial3Api::class,
18-
ExperimentalMaterialApi::class, ExperimentalMaterialApi::class
19-
)
16+
@file:OptIn(ExperimentalMaterial3Api::class)
2017

2118
package com.maxkeppeker.sheets.core
2219

23-
import androidx.compose.material.ExperimentalMaterialApi
2420
import androidx.compose.material3.ExperimentalMaterial3Api
2521
import androidx.compose.runtime.Composable
2622
import androidx.compose.ui.window.DialogProperties
@@ -36,7 +32,6 @@ import com.maxkeppeker.sheets.core.views.base.DialogBase
3632
* @param header The header to be displayed at the top of the dialog.
3733
* @param body The body content to be displayed inside the dialog.
3834
* @param onPositiveValid Listener that is invoked to check if the dialog input is valid.
39-
* @param onClose Listener that is invoked to indicate that the use-case is done and the view should be closed.
4035
* @param onPositiveValid If the positive button is valid and therefore enabled.
4136
*/
4237
@ExperimentalMaterial3Api

core/src/main/java/com/maxkeppeker/sheets/core/models/base/BaseBehaviors.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,20 @@ import kotlinx.coroutines.delay
2121
import kotlinx.coroutines.launch
2222

2323
/**
24-
* Base configs for dialog-specific configs.
24+
* Base behaviors for the use-case views.
2525
*/
26-
2726
object BaseBehaviors {
2827

28+
/**
29+
* A behavior construct for views to handle the automatic selection process when the button view is disabled.
30+
*
31+
* @param coroutine The coroutine scope that is used to execute the behavior on.
32+
* @param selection The base selection that is used to identify if the behavior should be enabled or not.
33+
* @param condition A custom additional condition when the button view is not enabled.
34+
* @param onDisableInput Listener that is invoked when the input is disabled as it should be blocked based on the behavior.
35+
* @param onSelection Listener that is invoked the automatic selection is executed.
36+
* @param onFinished Listener that is invoked when the behavior has ended.
37+
*/
2938
fun autoFinish(
3039
coroutine: CoroutineScope,
3140
selection: BaseSelection,

core/src/main/java/com/maxkeppeker/sheets/core/models/base/SheetState.kt

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package com.maxkeppeker.sheets.core.models.base
1717

18-
import android.util.Log
1918
import androidx.compose.runtime.Composable
2019
import androidx.compose.runtime.getValue
2120
import androidx.compose.runtime.mutableStateOf
@@ -43,23 +42,29 @@ class SheetState(
4342
var embedded by mutableStateOf(embedded)
4443
var reset by mutableStateOf(false)
4544

45+
/**
46+
* Display the dialog / view.
47+
*/
4648
fun show() {
4749
visible = true
4850
}
4951

52+
/**
53+
* Hide the dialog / view.
54+
*/
5055
fun hide() {
5156
visible = false
5257
reset = true
5358
onDismissRequest?.invoke(this)
5459
onCloseRequest?.invoke(this)
5560
}
5661

57-
private fun invokeReset() {
58-
reset = true
62+
internal fun clearReset() {
63+
reset = false
5964
}
6065

61-
fun clearReset() {
62-
reset = false
66+
private fun invokeReset() {
67+
reset = true
6368
}
6469

6570
// Closed
@@ -70,9 +75,10 @@ class SheetState(
7075
onCloseRequest?.invoke(this)
7176
}
7277

73-
// Use case finished
78+
/**
79+
* Finish the use-case view.
80+
*/
7481
fun finish() {
75-
Log.d("SheetState", "finish")
7682
/*
7783
We don't want to remove the view itself,
7884
but inform through the state that the use-case is done.
@@ -87,7 +93,6 @@ class SheetState(
8793
}
8894

8995
internal fun markAsEmbedded() {
90-
Log.d("SheetState", "markAsEmbedded")
9196
embedded = false
9297
}
9398

core/src/main/java/com/maxkeppeker/sheets/core/utils/BaseUtils.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515
*/
1616
package com.maxkeppeker.sheets.core.utils
1717

18-
import androidx.compose.runtime.Stable
19-
import androidx.compose.ui.Modifier
20-
import androidx.compose.ui.semantics.semantics
21-
import androidx.compose.ui.semantics.testTag
22-
2318
/**
2419
* Joins multiple test tags together into a sequence.
2520
* @param testTags The test tags you apply to the element.

core/src/main/java/com/maxkeppeker/sheets/core/utils/TestTags.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
*/
1616
package com.maxkeppeker.sheets.core.utils
1717

18+
/**
19+
* Test tags that used for the compose UI tests.
20+
*/
1821
object TestTags {
1922

2023
/*

core/src/main/java/com/maxkeppeker/sheets/core/views/BaseTypeState.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,16 @@ import androidx.compose.runtime.mutableStateOf
2020
import androidx.compose.runtime.setValue
2121
import java.io.Serializable
2222

23+
/**
24+
* The base class for the use-case view states.
25+
*/
2326
abstract class BaseTypeState : Serializable {
2427

2528
open var inputDisabled by mutableStateOf(false)
2629

30+
/**
31+
* Disables the input for the use-case view state.
32+
*/
2733
fun disableInput() {
2834
inputDisabled = true
2935
}

info/src/main/java/com/maxkeppeler/sheets/info/InfoDialog.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,10 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
@file:OptIn(
17-
ExperimentalMaterialApi::class, ExperimentalMaterial3Api::class,
18-
ExperimentalMaterialApi::class
19-
)
16+
@file:OptIn(ExperimentalMaterial3Api::class)
2017

2118
package com.maxkeppeler.sheets.info
2219

23-
import androidx.compose.material.ExperimentalMaterialApi
2420
import androidx.compose.material3.ExperimentalMaterial3Api
2521
import androidx.compose.runtime.Composable
2622
import androidx.compose.ui.window.DialogProperties

0 commit comments

Comments
 (0)