Skip to content

Commit a4e1e83

Browse files
🔨 Refactor code and update coding style
1 parent 3acb150 commit a4e1e83

13 files changed

Lines changed: 367 additions & 382 deletions

File tree

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
android:theme="@style/Theme.SSLoadingButtonAndroid">
1313
<activity
1414
android:name="com.simform.ssjetpackcomposeprogressbutton.MainActivity"
15-
android:exported="true"
16-
android:label="@string/app_name"
17-
android:theme="@style/Theme.SSLoadingButtonAndroid.NoActionBar">
15+
android:exported="true">
1816
<intent-filter>
1917
<action android:name="android.intent.action.MAIN" />
2018

app/src/main/java/com/simform/ssjetpackcomposeprogressbutton/MainActivity.kt

Lines changed: 174 additions & 162 deletions
Large diffs are not rendered by default.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.simform.ssjetpackcomposeprogressbutton.utils
2+
3+
import androidx.compose.ui.graphics.Color
4+
5+
val LIGHT_PINK = Color(0xFFFF1731)
6+
val LIGHT_BLUE = Color(0xFF23395D)
7+
val DARK_GREEN = Color(0xFF07a34d)
8+
val PRIMARY_DARK = Color(0xFF1c2e4a)

app/src/main/java/com/simform/ssjetpackcomposeprogressbutton/utils/Constant.kt

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.simform.ssjetpackcomposeprogressbutton.utils
2+
3+
import androidx.compose.ui.unit.dp
4+
import androidx.compose.ui.unit.sp
5+
6+
object Dimensions{
7+
val COMMON_WIDTH = 480.dp
8+
val COMMON_HEIGHT = 60.dp
9+
val TOP_BUTTON_HEIGHT = 50.dp
10+
val TOP_BUTTON_RADIUS = 10.dp
11+
val COMMON_BORDER_WIDTH = 3.dp
12+
val SPACING_SMALL = 10.dp
13+
val SPACING_NORMAL = 12.dp
14+
val SPACING_MEDIUM = 24.dp
15+
val SPACING_LARGE = 40.dp
16+
// Constants
17+
const val COMMON_CORNER_RADIUS = 25
18+
// Fonts
19+
val MEDIUM_FONT_SIZE = 20.sp
20+
}

ssjetpackcomposeprogressbutton/src/main/res/drawable/simform_logo.png renamed to app/src/main/res/drawable/simform_logo.png

File renamed without changes.
Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
1-
<resources xmlns:tools="http://schemas.android.com/tools">
1+
<resources>
22
<!-- Base application theme. -->
3-
<style name="Theme.SSLoadingButtonAndroid" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
4-
<!-- Primary brand color. -->
5-
<item name="colorPrimary">@color/colorPrimary</item>
6-
<item name="colorPrimaryVariant">@color/colorPrimaryVariant</item>
7-
<item name="colorOnPrimary">@color/black</item>
8-
<!-- Secondary brand color. -->
9-
<item name="colorSecondary">@color/teal_200</item>
10-
<item name="colorSecondaryVariant">@color/teal_200</item>
11-
<item name="colorOnSecondary">@color/black</item>
12-
<!-- Status bar color. -->
13-
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
14-
<!-- Customize your theme here. -->
15-
</style>
3+
<style name="Theme.SSLoadingButtonAndroid" parent="Theme.MaterialComponents.DayNight.DarkActionBar" />
164
</resources>

app/src/main/res/values/colors.xml

Lines changed: 0 additions & 15 deletions
This file was deleted.

app/src/main/res/values/themes.xml

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,4 @@
1-
<resources xmlns:tools="http://schemas.android.com/tools">
1+
<resources>
22
<!-- Base application theme. -->
3-
<style name="Theme.SSLoadingButtonAndroid" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
4-
<!-- Primary brand color. -->
5-
<item name="colorPrimary">@color/colorPrimary</item>
6-
<item name="colorPrimaryVariant">@color/colorPrimaryVariant</item>
7-
<item name="colorOnPrimary">@color/white</item>
8-
<!-- Secondary brand color. -->
9-
<item name="colorSecondary">@color/teal_200</item>
10-
<item name="colorSecondaryVariant">@color/teal_700</item>
11-
<item name="colorOnSecondary">@color/black</item>
12-
<!-- Status bar color. -->
13-
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
14-
<!-- Customize your theme here. -->
15-
</style>
16-
17-
<style name="Theme.SSLoadingButtonAndroid.NoActionBar">
18-
<item name="windowActionBar">false</item>
19-
<item name="windowNoTitle">true</item>
20-
</style>
21-
22-
<style name="Theme.SSLoadingButtonAndroid.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
23-
24-
<style name="Theme.SSLoadingButtonAndroid.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
3+
<style name="Theme.SSLoadingButtonAndroid" parent="Theme.MaterialComponents.DayNight.DarkActionBar" />
254
</resources>

ssjetpackcomposeprogressbutton/src/main/java/com/simform/ssjetpackcomposeprogressbuttonlibrary/ClockLoadingBar.kt

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@ import androidx.compose.ui.graphics.StrokeCap
99
import androidx.compose.ui.graphics.drawscope.withTransform
1010
import androidx.compose.ui.unit.Dp
1111
import androidx.compose.ui.unit.dp
12+
import com.simform.ssjetpackcomposeprogressbuttonlibrary.utils.Dimens.SPACING_MEDIUM
13+
import com.simform.ssjetpackcomposeprogressbuttonlibrary.utils.Dimens.SPACING_SMALL
1214
import com.simform.ssjetpackcomposeprogressbuttonlibrary.utils.HOUR_DURATION
1315
import com.simform.ssjetpackcomposeprogressbuttonlibrary.utils.MINUTE_DURATION
14-
import com.simform.ssjetpackcomposeprogressbuttonlibrary.utils.oneFloat
15-
import com.simform.ssjetpackcomposeprogressbuttonlibrary.utils.six
16-
import com.simform.ssjetpackcomposeprogressbuttonlibrary.utils.ten
17-
import com.simform.ssjetpackcomposeprogressbuttonlibrary.utils.threeSixtyFloat
18-
import com.simform.ssjetpackcomposeprogressbuttonlibrary.utils.twelve
19-
import com.simform.ssjetpackcomposeprogressbuttonlibrary.utils.two
20-
import com.simform.ssjetpackcomposeprogressbuttonlibrary.utils.zeroFloat
16+
import com.simform.ssjetpackcomposeprogressbuttonlibrary.utils.ANIMATION_TARGET_ONE
17+
import com.simform.ssjetpackcomposeprogressbuttonlibrary.utils.ROTATE_THREE_SIXTY_DEGREE
18+
import com.simform.ssjetpackcomposeprogressbuttonlibrary.utils.ANIMATION_INITIAL_ZERO
19+
import com.simform.ssjetpackcomposeprogressbuttonlibrary.utils.Dimens.BORDER_LARGE
2120

2221
@Composable
2322
fun ClockLoadingBar(
@@ -27,45 +26,45 @@ fun ClockLoadingBar(
2726
minHeightWidth: Dp
2827
) {
2928
val progressRotation = ssRepeatedFloatAnimation(
30-
initialValue = zeroFloat,
31-
targetValue = oneFloat,
29+
initialValue = ANIMATION_INITIAL_ZERO,
30+
targetValue = ANIMATION_TARGET_ONE,
3231
durationMillis = MINUTE_DURATION
3332
)
3433
val progressHourRotation = ssRepeatedFloatAnimation(
35-
initialValue = zeroFloat,
36-
targetValue = oneFloat,
34+
initialValue = ANIMATION_INITIAL_ZERO,
35+
targetValue = ANIMATION_TARGET_ONE,
3736
durationMillis = HOUR_DURATION
3837
)
3938
Canvas(modifier = modifier) {
40-
val middle = Offset(size.minDimension / two, size.minDimension / two)
39+
val middle = Offset(size.minDimension / 2, size.minDimension / 2)
4140
withTransform(
4241
{
43-
rotate(threeSixtyFloat * progressRotation, middle)
42+
rotate(ROTATE_THREE_SIXTY_DEGREE * progressRotation, middle)
4443
}, {
4544
drawLine(
46-
strokeWidth = six.dp.toPx(),
45+
strokeWidth = BORDER_LARGE.toPx(),
4746
cap = StrokeCap.Round,
4847
color = minuteColor,
4948
start = middle,
5049
end = Offset(
51-
size.minDimension / two,
52-
(minHeightWidth / two - ten.dp).toPx()
50+
size.minDimension / 2,
51+
(minHeightWidth / 2 - SPACING_SMALL).toPx()
5352
)
5453
)
5554
}
5655
)
5756
withTransform(
5857
{
59-
rotate(threeSixtyFloat * progressHourRotation, middle)
58+
rotate(ROTATE_THREE_SIXTY_DEGREE * progressHourRotation, middle)
6059
}, {
6160
drawLine(
62-
strokeWidth = six.dp.toPx(),
61+
strokeWidth = BORDER_LARGE.toPx(),
6362
cap = StrokeCap.Round,
6463
color = hourColor,
6564
start = middle,
6665
end = Offset(
67-
size.minDimension / two,
68-
(minHeightWidth / two - twelve.dp).toPx()
66+
size.minDimension / 2,
67+
(minHeightWidth / 2 - SPACING_MEDIUM).toPx()
6968
)
7069
)
7170
}

0 commit comments

Comments
 (0)