Skip to content

Commit

Permalink
style: SIMT-77 ci
Browse files Browse the repository at this point in the history
  • Loading branch information
kimjjunho committed Dec 22, 2022
1 parent 9e0f9ad commit d9eb673
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 261 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ fun SimTongCalendarDialog(
modifier: Modifier = Modifier,
visible: Boolean,
onDismissRequest: () -> Unit,
startDay: String,
endDay: String,
startDayDate: String,
endDayDate: String,
isChangeStartDay: Boolean,
onItemClicked: (String) -> Unit,
properties: DialogProperties = DialogProperties(),
Expand All @@ -106,8 +106,8 @@ fun SimTongCalendarDialog(
var year by remember { mutableStateOf(calendar.get(Calendar.YEAR)) }
var month by remember { mutableStateOf((calendar.get(Calendar.MONTH) + 1)) }

val startDay = try { dateToInt(startDay) } catch (e: Exception) { 0 }
val endDay = try { dateToInt(endDay) } catch (e: Exception) { 0 }
val startDay = try { dateToInt(startDayDate) } catch (e: Exception) { 0 }
val endDay = try { dateToInt(endDayDate) } catch (e: Exception) { 0 }

if (visible) {
Dialog(
Expand Down Expand Up @@ -144,13 +144,13 @@ fun SimTongCalendarDialog(
IconButton(
onClick = {
checkMonth --
val calendar = GregorianCalendar(
val calendarAddCheckMonth = GregorianCalendar(
today.get(Calendar.YEAR),
today.get(Calendar.MONTH) + checkMonth,
today.get(Calendar.DATE)
)
year = calendar.get(Calendar.YEAR)
month = (calendar.get(Calendar.MONTH) + 1)
year = calendarAddCheckMonth.get(Calendar.YEAR)
month = (calendarAddCheckMonth.get(Calendar.MONTH) + 1)
},
modifier = Modifier.size(SimTongCalendarDateButtonSize),
) {
Expand All @@ -165,13 +165,13 @@ fun SimTongCalendarDialog(
IconButton(
onClick = {
checkMonth ++
val calendar = GregorianCalendar(
val calendarAddCheckMonth = GregorianCalendar(
today.get(Calendar.YEAR),
today.get(Calendar.MONTH) + checkMonth,
today.get(Calendar.DATE)
)
year = calendar.get(Calendar.YEAR)
month = (calendar.get(Calendar.MONTH) + 1)
year = calendarAddCheckMonth.get(Calendar.YEAR)
month = (calendarAddCheckMonth.get(Calendar.MONTH) + 1)
},
modifier = Modifier.size(SimTongCalendarDateButtonSize)
) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file: Suppress("WildcardImport", "MagicNumber")

package com.comit.common.dialog.timerdialog

import androidx.compose.animation.core.Animatable
Expand All @@ -11,12 +13,21 @@ import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.gestures.draggable
import androidx.compose.foundation.gestures.rememberDraggableState
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material.LocalTextStyle
import androidx.compose.material.MaterialTheme
import androidx.compose.material.ProvideTextStyle
import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
Expand Down Expand Up @@ -64,8 +75,7 @@ fun <T> ListItemPicker(
.apply {
val index = list.indexOf(value)
val offsetRange = remember(value, list) {
-((list.count() - 1) - index) * halfNumbersColumnHeightPx to
index * halfNumbersColumnHeightPx
-((list.count() - 1) - index) * halfNumbersColumnHeightPx to index * halfNumbersColumnHeightPx
}
updateBounds(offsetRange.first, offsetRange.second)
}
Expand Down Expand Up @@ -93,9 +103,15 @@ fun <T> ListItemPicker(
adjustTarget = { target ->
val coercedTarget = target % halfNumbersColumnHeightPx
val coercedAnchors =
listOf(-halfNumbersColumnHeightPx, 0f, halfNumbersColumnHeightPx)
val coercedPoint = coercedAnchors.minByOrNull { abs(it - coercedTarget) }!!
val base = halfNumbersColumnHeightPx * (target / halfNumbersColumnHeightPx).toInt()
listOf(
-halfNumbersColumnHeightPx,
0f,
halfNumbersColumnHeightPx
)
val coercedPoint =
coercedAnchors.minByOrNull { abs(it - coercedTarget) }!!
val base =
halfNumbersColumnHeightPx * (target / halfNumbersColumnHeightPx).toInt()
coercedPoint + base
}
).endState.value
Expand Down Expand Up @@ -128,24 +144,29 @@ fun <T> ListItemPicker(
text = label(list.elementAt(indexOfElement - 1)),
modifier = baseLabelModifier
.offset(y = -halfNumbersColumnHeight)
.alpha(maxOf(minimumAlpha, coercedAnimatedOffset / halfNumbersColumnHeightPx))
.alpha(
maxOf(
minimumAlpha,
coercedAnimatedOffset / halfNumbersColumnHeightPx
)
)
)
Label(
text = label(list.elementAt(indexOfElement)),
modifier = baseLabelModifier
.alpha(
(maxOf(
minimumAlpha,
1 - abs(coercedAnimatedOffset) / halfNumbersColumnHeightPx
))
)
.alpha((maxOf(minimumAlpha, 1 - abs(coercedAnimatedOffset) / halfNumbersColumnHeightPx)))
)
if (indexOfElement < list.count() - 1)
Label(
text = label(list.elementAt(indexOfElement + 1)),
modifier = baseLabelModifier
.offset(y = halfNumbersColumnHeight)
.alpha(maxOf(minimumAlpha, -coercedAnimatedOffset / halfNumbersColumnHeightPx))
.alpha(
maxOf(
minimumAlpha,
-coercedAnimatedOffset / halfNumbersColumnHeightPx
)
)
)
}
}
Expand All @@ -171,10 +192,8 @@ fun <T> ListItemPicker(
.toDp()

// Set the size of the layout as big as it can
layout(dividersWidth.toPx().toInt(), placeables
.sumOf {
it.height
}
layout(
dividersWidth.toPx().toInt(), placeables.sumOf { it.height }
) {
// Track the y co-ord we have placed children up to
var yPosition = 0
Expand Down Expand Up @@ -226,4 +245,4 @@ private suspend fun Animatable<Float, AnimationVector1D>.fling(
block = block,
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ fun NumberPicker(
list = range.toList(),
textStyle = textStyle
)
}
}
Loading

0 comments on commit d9eb673

Please sign in to comment.