Skip to content

Commit

Permalink
Merge pull request #82 from ferPrieto/chore/Update-Colors-Access
Browse files Browse the repository at this point in the history
Updated SpaceXColors, theme structure and typography
  • Loading branch information
ferPrieto authored Nov 19, 2022
2 parents a6c019a + d5538a0 commit ba47a54
Show file tree
Hide file tree
Showing 9 changed files with 567 additions and 593 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import androidx.compose.material.ExperimentalMaterialApi
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.InternalCoroutinesApi
import prieto.fernando.spacex.presentation.screens.MainScreen
import prieto.fernando.spacex.theme.SpaceXTheme
import prieto.fernando.spacex.theme.SpaceX

@AndroidEntryPoint
class EntryPointActivity : ComponentActivity() {
Expand All @@ -16,7 +16,7 @@ class EntryPointActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
SpaceXTheme {
SpaceX.SpaceXTheme {
MainScreen()
}
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package prieto.fernando.spacex.presentation.screens.dashboard

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material.MaterialTheme
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
Expand All @@ -17,14 +19,12 @@ import com.airbnb.lottie.compose.LottieCompositionSpec
import com.airbnb.lottie.compose.animateLottieCompositionAsState
import com.airbnb.lottie.compose.rememberLottieComposition
import prieto.fernando.spacex.R
import prieto.fernando.spacex.presentation.screens.common.ErrorAnimation
import prieto.fernando.spacex.theme.Dark
import prieto.fernando.spacex.theme.Light
import prieto.fernando.spacex.theme.SpaceXTypography
import prieto.fernando.spacex.presentation.screens.error.ErrorAnimation
import prieto.fernando.spacex.theme.SpaceX

@Composable
fun DashboardScreen(
state: DashboardContract.State
state: DashboardContract.State
) {
val loadingComposition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.loading_animation))
val loadingProgress by animateLottieCompositionAsState(loadingComposition)
Expand All @@ -36,46 +36,41 @@ fun DashboardScreen(
val bodyProgress by animateLottieCompositionAsState(bodyComposition)

Column(
modifier = Modifier
.fillMaxHeight()
.background(
if (MaterialTheme.colors.isLight) Light.Background
else Dark.Background
)
modifier = Modifier
.fillMaxHeight()
.background(SpaceX.LocalColors.current.background)
) {
Text(
text = stringResource(id = R.string.company_title),
modifier = Modifier.padding(16.dp),
style = SpaceXTypography.h1,
color = if (MaterialTheme.colors.isLight) Light.TextColorPrimary
else Dark.TextColorPrimary
text = stringResource(id = R.string.company_title),
modifier = Modifier.padding(16.dp),
style = SpaceX.LocalTypography.current.h1,
color = SpaceX.LocalColors.current.textColorPrimary
)
when {
state.isLoading -> {
LottieAnimation(
composition = loadingComposition,
progress = loadingProgress,
modifier = Modifier.semantics { contentDescription = "Loading Animation" }
composition = loadingComposition,
progress = loadingProgress,
modifier = Modifier.semantics { contentDescription = "Loading Animation" }
)
}
state.isError -> {
ErrorAnimation(errorComposition, errorProgress)
}
else -> {
Text(
text = fillCompanyInfo(state.companyInfoUiModel),
modifier = Modifier.padding(16.dp),
style = SpaceXTypography.h4,
color = if (MaterialTheme.colors.isLight) Light.TextColorSecondary
else Dark.TextColorSecondary
text = fillCompanyInfo(state.companyInfoUiModel),
modifier = Modifier.padding(16.dp),
style = SpaceX.LocalTypography.current.h4,
color = SpaceX.LocalColors.current.textColorSecondary
)
LottieAnimation(
composition = bodyComposition,
progress = bodyProgress,
modifier = Modifier
.size(260.dp)
.align(Alignment.CenterHorizontally)
.semantics { contentDescription = "Planet Animation" }
composition = bodyComposition,
progress = bodyProgress,
modifier = Modifier
.size(260.dp)
.align(Alignment.CenterHorizontally)
.semantics { contentDescription = "Planet Animation" }
)
}
}
Expand All @@ -84,12 +79,12 @@ fun DashboardScreen(

@Composable
private fun fillCompanyInfo(companyInfoUiModel: CompanyInfoUiModel): String =
String.format(
stringResource(id = R.string.company_data),
companyInfoUiModel.name,
companyInfoUiModel.founder,
companyInfoUiModel.foundedYear,
companyInfoUiModel.employees,
companyInfoUiModel.launchSites,
companyInfoUiModel.valuation
)
String.format(
stringResource(id = R.string.company_data),
companyInfoUiModel.name,
companyInfoUiModel.founder,
companyInfoUiModel.foundedYear,
companyInfoUiModel.employees,
companyInfoUiModel.launchSites,
companyInfoUiModel.valuation
)
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package prieto.fernando.spacex.presentation.screens.common
package prieto.fernando.spacex.presentation.screens.error

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
Expand All @@ -14,9 +13,7 @@ import androidx.compose.ui.unit.dp
import com.airbnb.lottie.LottieComposition
import com.airbnb.lottie.compose.LottieAnimation
import prieto.fernando.spacex.R
import prieto.fernando.spacex.theme.Dark
import prieto.fernando.spacex.theme.Light
import prieto.fernando.spacex.theme.SpaceXTypography
import prieto.fernando.spacex.theme.SpaceX

@Composable
fun ErrorAnimation(
Expand All @@ -27,12 +24,11 @@ fun ErrorAnimation(
Box {
Text(
text = stringResource(id = R.string.launches_error_occurred),
style = SpaceXTypography.h3,
style = SpaceX.LocalTypography.current.h3,
modifier = modifier
.padding(top = 40.dp)
.align(Alignment.TopCenter),
color = if (MaterialTheme.colors.isLight) Light.Accent
else Dark.Accent
color = SpaceX.LocalColors.current.accent
)
LottieAnimation(
composition = errorComposition,
Expand Down
Loading

0 comments on commit ba47a54

Please sign in to comment.