Skip to content

Commit

Permalink
FE-1499 Refactor RetryCardView as composable (#468)
Browse files Browse the repository at this point in the history
* Refactor RetryCardView as composable

* Feature/fe 1495 refactor headerview as a composable (#469)

* Refactor HeaderView as composable

* Enable previews in new composables

* Fix detekt

* Refactor InfoBannerCard as composable (#470)

* Refactor InfoBannerCard as composable

* Refactor RewardIssueCardView to composable. Fix ripple effect on buttons. (#472)
  • Loading branch information
PavlosTze committed Feb 3, 2025
1 parent c290faf commit dcef4f4
Show file tree
Hide file tree
Showing 29 changed files with 550 additions and 648 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ tasks.register("jacocoCoverageTestReport", type = JacocoReport::class) {
"**/ui/**/*CardView*.*",
"**/ui/common/Animation*.*",
"**/ui/common/Views*.*",
"**/ui/components/compose/**",
"**/ui/components/Base*.*",
"**/ui/components/*View.*",
"**/ui/components/ChartsView*.*",
Expand Down Expand Up @@ -422,8 +423,8 @@ dependencies {
implementation(libs.androidx.collection.ktx)
implementation(libs.androidx.compose.foundation)
implementation(libs.androidx.compose.material3)
debugImplementation(libs.androidx.compose.preview)
debugImplementation(libs.androidx.compose.ui.tooling)
implementation(libs.androidx.compose.preview)
implementation(libs.androidx.compose.ui.tooling)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.coordinatorlayout)
implementation(libs.androidx.core.ktx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.app.Activity
import android.os.Bundle
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Arrangement.spacedBy
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand All @@ -14,7 +13,9 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import com.weatherxm.R
import com.weatherxm.analytics.AnalyticsService
import com.weatherxm.databinding.ActivityClaimSelectStationBinding
Expand Down Expand Up @@ -45,46 +46,7 @@ class SelectStationTypeActivity : BaseActivity() {
}

binding.deviceTypes.setContent {
Column(
verticalArrangement = spacedBy(dimensionResource(R.dimen.margin_normal))
) {
Row(
horizontalArrangement = spacedBy(dimensionResource(R.dimen.margin_normal))
) {
Column(Modifier.weight(1F)) {
CardViewClickable(
onClickListener = { startClaimingFlow(DeviceType.M5_WIFI) }
) {
TypeContent(getString(R.string.m5_wifi), R.drawable.device_type_m5)
}
}
Column(Modifier.weight(1F)) {
CardViewClickable(
onClickListener = { startClaimingFlow(DeviceType.D1_WIFI) }
) {
TypeContent(getString(R.string.d1_wifi), R.drawable.device_type_d1)
}
}
}
Row(
horizontalArrangement = spacedBy(dimensionResource(R.dimen.margin_normal))
) {
Column(Modifier.weight(1F)) {
CardViewClickable(
onClickListener = { startClaimingFlow(DeviceType.HELIUM) },
) {
TypeContent(getString(R.string.helium), R.drawable.device_type_helium)
}
}
Column(Modifier.weight(1F)) {
CardViewClickable(
onClickListener = { startClaimingFlow(DeviceType.PULSE_4G) },
) {
TypeContent(getString(R.string.pulse_4g), R.drawable.device_type_pulse)
}
}
}
}
DeviceTypes()
}
}

Expand All @@ -99,13 +61,59 @@ class SelectStationTypeActivity : BaseActivity() {
navigator.showClaimFlow(claimingLauncher, this, deviceType)
}

@Suppress("FunctionNaming")
@Preview
@Composable
fun DeviceTypes() {
Column(
verticalArrangement = spacedBy(dimensionResource(R.dimen.margin_normal))
) {
Row(
horizontalArrangement = spacedBy(dimensionResource(R.dimen.margin_normal))
) {
Column(Modifier.weight(1F)) {
CardViewClickable(
onClickListener = { startClaimingFlow(DeviceType.M5_WIFI) }
) {
TypeContent(stringResource(R.string.m5_wifi), R.drawable.device_type_m5)
}
}
Column(Modifier.weight(1F)) {
CardViewClickable(
onClickListener = { startClaimingFlow(DeviceType.D1_WIFI) }
) {
TypeContent(stringResource(R.string.d1_wifi), R.drawable.device_type_d1)
}
}
}
Row(
horizontalArrangement = spacedBy(dimensionResource(R.dimen.margin_normal))
) {
Column(Modifier.weight(1F)) {
CardViewClickable(
onClickListener = { startClaimingFlow(DeviceType.HELIUM) },
) {
TypeContent(stringResource(R.string.helium), R.drawable.device_type_helium)
}
}
Column(Modifier.weight(1F)) {
CardViewClickable(
onClickListener = { startClaimingFlow(DeviceType.PULSE_4G) },
) {
TypeContent(stringResource(R.string.pulse_4g), R.drawable.device_type_pulse)
}
}
}
}
}

@Suppress("FunctionNaming")
@Composable
fun TypeContent(name: String, imageResId: Int) {
Column(
modifier = Modifier.padding(dimensionResource(R.dimen.padding_normal)),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(dimensionResource(R.dimen.margin_small))
verticalArrangement = spacedBy(dimensionResource(R.dimen.margin_small))
) {
Image(painter = painterResource(imageResId), contentDescription = null)
MediumText(text = name, fontWeight = FontWeight.Bold, colorRes = R.color.darkestBlue)
Expand Down
68 changes: 0 additions & 68 deletions app/src/main/java/com/weatherxm/ui/components/HeaderView.kt

This file was deleted.

This file was deleted.

33 changes: 0 additions & 33 deletions app/src/main/java/com/weatherxm/ui/components/RetryCardView.kt

This file was deleted.

This file was deleted.

Loading

0 comments on commit dcef4f4

Please sign in to comment.