Skip to content

Commit

Permalink
Added dimens support to aero theme.
Browse files Browse the repository at this point in the history
  • Loading branch information
nassdk committed Jan 16, 2022
1 parent f8dc973 commit 4bc6dad
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 63 deletions.
31 changes: 13 additions & 18 deletions core/ui/src/main/java/com/nassdk/ui/theme/Dimens.kt
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
package com.nassdk.ui.theme

import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

val dimen_4 = 4.dp
val dimen_8 = 8.dp
val dimen_12 = 12.dp
val dimen_16 = 16.dp
val dimen_20 = 20.dp
val dimen_24 = 24.dp
val dimen_28 = 28.dp
val dimen_32 = 32.dp

val text_4 = 4.sp
val text_8 = 8.sp
val text_12 = 12.sp
val text_14 = 14.sp
val text_16 = 16.sp
val text_20 = 20.sp
val text_24 = 24.sp
val text_28 = 28.sp
val text_32 = 32.sp
data class AeroDimens(
val dp4: Dp = 4.dp,
val dp8: Dp = 8.dp,
val dp12: Dp = 12.dp,
val dp16: Dp = 16.dp,
val sp4: TextUnit = 4.sp,
val sp8: TextUnit = 8.sp,
val sp12: TextUnit = 12.sp,
val sp20: TextUnit = 20.sp,
val sp24: TextUnit = 24.sp,
)
12 changes: 10 additions & 2 deletions core/ui/src/main/java/com/nassdk/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ data class AeroColors(
val secondaryBackground: Color,
val tintPrimary: Color,
val tintSecondary: Color,
val dividerColor: Color
val dividerColor: Color,
)

object AeroTheme {
Expand All @@ -26,12 +26,20 @@ object AeroTheme {
val typegraphy: AeroTypography
@Composable
get() = LocalAeroTypography.current

val dimens: AeroDimens
@Composable
get() = LocalAeroDimens.current
}

val LocalAeroColors = staticCompositionLocalOf<AeroColors> {
error("No colors provided")
}

val LocalAeroTypography = staticCompositionLocalOf<AeroTypography> {
error("No colors provided")
error("No typography provided")
}

val LocalAeroDimens = staticCompositionLocalOf<AeroDimens> {
error("No dimens provided")
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ fun FlightAeroTheme(
CompositionLocalProvider(
LocalAeroColors provides colors,
LocalAeroTypography provides typography,
LocalAeroDimens provides AeroDimens(),
content = content
)
}
10 changes: 5 additions & 5 deletions core/ui/src/main/java/com/nassdk/ui/theme/Typography.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ data class AeroTypography(

val typography = AeroTypography(
headerBoldRubik = TextStyle(
fontSize = text_24,
fontSize = 24.sp,
fontFamily = familyRubik,
fontWeight = FontWeight.Bold
),
Expand All @@ -51,22 +51,22 @@ val typography = AeroTypography(
fontWeight = FontWeight.Medium
),
headerMedRoboto = TextStyle(
fontSize = text_20,
fontSize = 20.sp,
fontFamily = familyRoboto,
fontWeight = FontWeight.Medium
),
bodyMedRoboto = TextStyle(
fontSize = text_14,
fontSize = 14.sp,
fontFamily = familyRoboto,
fontWeight = FontWeight.Medium
),
subMedRoboto = TextStyle(
fontSize = text_12,
fontSize = 12.sp,
fontFamily = familyRoboto,
fontWeight = FontWeight.Medium
),
buttonMedRoboto = TextStyle(
fontSize = text_14,
fontSize = 14.sp,
fontFamily = familyRoboto,
fontWeight = FontWeight.Medium
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.nassdk.flights.R
import com.nassdk.ui.theme.AeroTheme
import com.nassdk.ui.theme.dimen_12
import com.nassdk.ui.theme.dimen_16

@Composable
internal fun AppBar() {
Expand All @@ -25,7 +23,8 @@ internal fun AppBar() {
.fillMaxWidth()
.height(height = 56.dp),
backgroundColor = AeroTheme.colors.secondaryBackground,
contentPadding = PaddingValues(horizontal = dimen_16, vertical = dimen_12),
contentPadding = PaddingValues(horizontal = AeroTheme.dimens.dp16,
vertical = AeroTheme.dimens.dp12),
content = {
Text(
text = stringResource(id = R.string.flights_header_title),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import com.nassdk.flights.R
import com.nassdk.flights.presentation.ui.FlightsListModel
import com.nassdk.ui.helpers.DashedLine
import com.nassdk.ui.theme.AeroTheme
import com.nassdk.ui.theme.dimen_16
import com.nassdk.ui.theme.dimen_8

@OptIn(ExperimentalMaterialApi::class)
@Composable
Expand All @@ -34,15 +32,15 @@ internal fun FlightItem(entity: FlightsListModel.Flight) {
onClick = { /*TODO*/ },
enabled = false,
shape = RoundedCornerShape(size = 20.dp),
elevation = 4.dp,
elevation = AeroTheme.dimens.dp4,
backgroundColor = AeroTheme.colors.secondaryBackground,
modifier = Modifier.fillMaxWidth(),
content = {

Column(
modifier = Modifier
.fillMaxSize()
.padding(vertical = dimen_16),
.padding(vertical = AeroTheme.dimens.dp16),

content = {

Expand All @@ -52,7 +50,7 @@ internal fun FlightItem(entity: FlightsListModel.Flight) {

Divider(
modifier = Modifier
.padding(top = 16.dp)
.padding(top = AeroTheme.dimens.dp16)
.fillMaxWidth()
.background(color = AeroTheme.colors.dividerColor)
)
Expand All @@ -70,7 +68,7 @@ private fun TrajectoryView() {
ConstraintLayout(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = dimen_16),
.padding(horizontal = AeroTheme.dimens.dp16),

content = {

Expand Down Expand Up @@ -157,9 +155,9 @@ private fun FlightInfo(entity: FlightsListModel.Flight) {

ConstraintLayout(
modifier = Modifier
.padding(top = dimen_16)
.padding(top = AeroTheme.dimens.dp16)
.fillMaxWidth()
.padding(horizontal = dimen_16),
.padding(horizontal = AeroTheme.dimens.dp16),
content = {
val (departureCity, departureTime, arrivalCity, arrivalTime, statusTitle) = createRefs()

Expand All @@ -181,7 +179,7 @@ private fun FlightInfo(entity: FlightsListModel.Flight) {
style = AeroTheme.typegraphy.subMedRoboto,
color = AeroTheme.colors.secondaryText,
modifier = Modifier
.padding(top = dimen_8)
.padding(top = AeroTheme.dimens.dp8)
.constrainAs(
ref = departureTime,
constrainBlock = {
Expand Down Expand Up @@ -209,7 +207,7 @@ private fun FlightInfo(entity: FlightsListModel.Flight) {
style = AeroTheme.typegraphy.subMedRoboto,
color = AeroTheme.colors.secondaryText,
modifier = Modifier
.padding(top = dimen_8)
.padding(top = AeroTheme.dimens.dp8)
.constrainAs(
ref = arrivalTime,
constrainBlock = {
Expand All @@ -224,7 +222,7 @@ private fun FlightInfo(entity: FlightsListModel.Flight) {
style = AeroTheme.typegraphy.bodyMedRoboto,
color = entity.status.tint,
modifier = Modifier
.padding(top = dimen_16)
.padding(top = AeroTheme.dimens.dp16)
.constrainAs(
ref = statusTitle,
constrainBlock = {
Expand All @@ -243,8 +241,8 @@ private fun NavigateItem(number: String) {
ConstraintLayout(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = dimen_16)
.padding(top = dimen_16),
.padding(horizontal = AeroTheme.dimens.dp16)
.padding(top = AeroTheme.dimens.dp16),
content = {
val (numberTitle, goThrough, chevron) = createRefs()

Expand Down
38 changes: 22 additions & 16 deletions feature/profile/src/main/java/com/nassdk/profile/ProfileScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import com.nassdk.common.extensions.navigate
import com.nassdk.navigation.Screens
import com.nassdk.profile.views.AppBar
import com.nassdk.ui.theme.AeroTheme
import com.nassdk.ui.theme.dimen_12
import com.nassdk.ui.theme.dimen_16

@Composable
fun ProfileScreen(navController: NavHostController) {
Expand Down Expand Up @@ -94,7 +92,11 @@ fun ProfileScreen(navController: NavHostController) {
text = "Никола Тесла",
style = AeroTheme.typegraphy.headerMedRoboto,
modifier = Modifier
.padding(start = dimen_16, end = dimen_16, top = dimen_12)
.padding(
start = AeroTheme.dimens.dp16,
end = AeroTheme.dimens.dp16,
top = AeroTheme.dimens.dp12
)
.constrainAs(
ref = name,
constrainBlock = {
Expand All @@ -107,7 +109,9 @@ fun ProfileScreen(navController: NavHostController) {

Column(
modifier = Modifier
.padding(start = dimen_16, end = dimen_16, top = 40.dp)
.padding(start = AeroTheme.dimens.dp16,
end = AeroTheme.dimens.dp16,
top = 40.dp)
.constrainAs(
ref = personalActions,
constrainBlock = {
Expand All @@ -119,10 +123,10 @@ fun ProfileScreen(navController: NavHostController) {
content = {
Button(
onClick = { /*TODO*/ },
contentPadding = PaddingValues(all = dimen_16),
contentPadding = PaddingValues(all = AeroTheme.dimens.dp16),
shape = RoundedCornerShape(
topEnd = 16.dp,
topStart = 16.dp
topEnd = AeroTheme.dimens.dp16,
topStart = AeroTheme.dimens.dp16
),
colors = ButtonDefaults.buttonColors(
backgroundColor = AeroTheme.colors.secondaryBackground
Expand All @@ -139,7 +143,7 @@ fun ProfileScreen(navController: NavHostController) {
style = AeroTheme.typegraphy.buttonMedRoboto,
color = AeroTheme.colors.secondaryButton,
modifier = Modifier
.padding(start = dimen_12)
.padding(start = AeroTheme.dimens.dp12)
.weight(weight = 1f)
)

Expand All @@ -154,10 +158,10 @@ fun ProfileScreen(navController: NavHostController) {

Button(
onClick = { /*TODO*/ },
contentPadding = PaddingValues(all = dimen_16),
contentPadding = PaddingValues(all = AeroTheme.dimens.dp16),
shape = RoundedCornerShape(
bottomEnd = 16.dp,
bottomStart = 16.dp
bottomEnd = AeroTheme.dimens.dp16,
bottomStart = AeroTheme.dimens.dp16
),
colors = ButtonDefaults.buttonColors(
backgroundColor = AeroTheme.colors.secondaryBackground
Expand All @@ -174,7 +178,7 @@ fun ProfileScreen(navController: NavHostController) {
style = AeroTheme.typegraphy.buttonMedRoboto,
color = AeroTheme.colors.secondaryButton,
modifier = Modifier
.padding(start = dimen_12)
.padding(start = AeroTheme.dimens.dp12)
.weight(weight = 1f)
)

Expand All @@ -192,7 +196,9 @@ fun ProfileScreen(navController: NavHostController) {
navController.navigate(target = Screens.Settings)
},
modifier = Modifier
.padding(top = dimen_12, start = dimen_16, end = dimen_16)
.padding(top = AeroTheme.dimens.dp12,
start = AeroTheme.dimens.dp16,
end = AeroTheme.dimens.dp16)
.constrainAs(
ref = settings,
constrainBlock = {
Expand All @@ -201,8 +207,8 @@ fun ProfileScreen(navController: NavHostController) {
end.linkTo(anchor = parent.end)
}
),
contentPadding = PaddingValues(all = dimen_16),
shape = RoundedCornerShape(size = 16.dp),
contentPadding = PaddingValues(all = AeroTheme.dimens.dp16),
shape = RoundedCornerShape(size = AeroTheme.dimens.dp16),
colors = ButtonDefaults.buttonColors(
backgroundColor = AeroTheme.colors.secondaryBackground
),
Expand All @@ -218,7 +224,7 @@ fun ProfileScreen(navController: NavHostController) {
style = AeroTheme.typegraphy.buttonMedRoboto,
color = AeroTheme.colors.secondaryButton,
modifier = Modifier
.padding(start = dimen_12)
.padding(start = AeroTheme.dimens.dp16)
.weight(weight = 1f)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import com.nassdk.profile.R
import com.nassdk.ui.theme.AeroTheme
import com.nassdk.ui.theme.dimen_12
import com.nassdk.ui.theme.dimen_16

@Composable
internal fun AppBar(modifier: Modifier) {

TopAppBar(
modifier = modifier,
backgroundColor = AeroTheme.colors.secondaryBackground,
contentPadding = PaddingValues(horizontal = dimen_16, vertical = dimen_12),
contentPadding = PaddingValues(horizontal = AeroTheme.dimens.dp16,
vertical = AeroTheme.dimens.dp12),
content = {
Text(
text = stringResource(id = R.string.profile_header_title),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import androidx.compose.ui.res.stringResource
import androidx.navigation.NavHostController
import com.nassdk.settings.domain.entity.SettingsBundle
import com.nassdk.ui.theme.AeroTheme
import com.nassdk.ui.theme.dimen_16

@Composable
fun SettingsScreen(
Expand Down Expand Up @@ -54,7 +53,7 @@ fun SettingsScreen(
style = AeroTheme.typegraphy.headerMedRoboto,
color = AeroTheme.colors.headerColor,
modifier = Modifier
.padding(start = dimen_16)
.padding(start = AeroTheme.dimens.dp16)
.align(alignment = Alignment.CenterVertically)
)
}
Expand All @@ -63,7 +62,7 @@ fun SettingsScreen(
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.padding(horizontal = dimen_16)
.padding(horizontal = AeroTheme.dimens.dp16)
.fillMaxWidth(),

content = {
Expand Down

0 comments on commit 4bc6dad

Please sign in to comment.