Skip to content

Commit

Permalink
Merge branch 'replace-colorresource-with-theme-colors-droid-377'
Browse files Browse the repository at this point in the history
  • Loading branch information
Pururun committed Oct 2, 2023
2 parents f9706c3 + 523c636 commit 3bf2f57
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
Expand Down Expand Up @@ -51,7 +50,7 @@ fun DnsCell(
}
},
onCellClicked = { onClick.invoke() },
background = colorResource(id = R.color.blue20),
background = MaterialTheme.colorScheme.secondaryContainer,
startPadding = startPadding,
modifier = modifier
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
Expand Down Expand Up @@ -78,8 +76,8 @@ fun ShowDeviceRemovalDialog(onDismiss: () -> Unit, onConfirm: () -> Unit, device
.fillMaxWidth(),
colors =
ButtonDefaults.buttonColors(
containerColor = colorResource(id = R.color.red),
contentColor = Color.White
containerColor = MaterialTheme.colorScheme.error,
contentColor = MaterialTheme.colorScheme.onError
),
onClick = onConfirm,
shape = MaterialTheme.shapes.small
Expand All @@ -100,15 +98,15 @@ fun ShowDeviceRemovalDialog(onDismiss: () -> Unit, onConfirm: () -> Unit, device
.fillMaxWidth(),
colors =
ButtonDefaults.buttonColors(
containerColor = colorResource(id = R.color.blue),
contentColor = Color.White
containerColor = MaterialTheme.colorScheme.primary,
contentColor = MaterialTheme.colorScheme.onPrimary
),
onClick = { onDismiss() },
shape = MaterialTheme.shapes.small
) {
Text(text = stringResource(id = R.string.back), fontSize = 18.sp)
}
},
containerColor = colorResource(id = R.color.darkBlue)
containerColor = MaterialTheme.colorScheme.background
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
Expand Down Expand Up @@ -89,11 +88,11 @@ fun DeviceListScreen(
)
}

val topColor = colorResource(R.color.blue)
val topColor = MaterialTheme.colorScheme.primary
ScaffoldWithTopBar(
topBarColor = topColor,
statusBarColor = topColor,
navigationBarColor = colorResource(id = R.color.darkBlue),
navigationBarColor = MaterialTheme.colorScheme.background,
onSettingsClicked = onSettingsClicked,
onAccountClicked = null,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.graphics.compositeOver
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
Expand All @@ -26,6 +27,7 @@ import net.mullvad.mullvadvpn.R
import net.mullvad.mullvadvpn.compose.button.ActionButton
import net.mullvad.mullvadvpn.compose.component.ScaffoldWithTopBar
import net.mullvad.mullvadvpn.compose.state.DeviceRevokedUiState
import net.mullvad.mullvadvpn.lib.theme.AlphaDisconnectButton
import net.mullvad.mullvadvpn.lib.theme.AppTheme

@Preview
Expand All @@ -41,18 +43,16 @@ fun DeviceRevokedScreen(
onGoToLoginClicked: () -> Unit = {}
) {
val topColor =
colorResource(
if (state == DeviceRevokedUiState.SECURED) {
R.color.green
} else {
R.color.red
}
)
if (state == DeviceRevokedUiState.SECURED) {
MaterialTheme.colorScheme.inversePrimary
} else {
MaterialTheme.colorScheme.error
}

ScaffoldWithTopBar(
topBarColor = topColor,
statusBarColor = topColor,
navigationBarColor = colorResource(id = R.color.darkBlue),
navigationBarColor = MaterialTheme.colorScheme.background,
onSettingsClicked = onSettingsClicked,
onAccountClicked = null
) {
Expand All @@ -61,7 +61,7 @@ fun DeviceRevokedScreen(
Modifier.fillMaxHeight()
.fillMaxWidth()
.padding(it)
.background(colorResource(id = R.color.darkBlue))
.background(color = MaterialTheme.colorScheme.background)
) {
val (icon, body, actionButtons) = createRefs()

Expand Down Expand Up @@ -126,15 +126,15 @@ fun DeviceRevokedScreen(
onClick = onGoToLoginClicked,
colors =
ButtonDefaults.buttonColors(
contentColor = Color.White,
contentColor = MaterialTheme.colorScheme.onPrimary,
containerColor =
colorResource(
if (state == DeviceRevokedUiState.SECURED) {
R.color.red60
} else {
R.color.blue
}
)
if (state == DeviceRevokedUiState.SECURED) {
MaterialTheme.colorScheme.error
.copy(alpha = AlphaDisconnectButton)
.compositeOver(MaterialTheme.colorScheme.background)
} else {
MaterialTheme.colorScheme.primary
}
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,31 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.graphics.compositeOver
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import net.mullvad.mullvadvpn.R
import net.mullvad.mullvadvpn.compose.component.ScaffoldWithTopBar
import net.mullvad.mullvadvpn.lib.theme.AlphaDescription
import net.mullvad.mullvadvpn.lib.theme.AppTheme

@Preview
@Composable
private fun PreviewLoadingScreen() {
LoadingScreen()
AppTheme { LoadingScreen() }
}

@Composable
fun LoadingScreen(onSettingsCogClicked: () -> Unit = {}) {
val backgroundColor = colorResource(id = R.color.blue)
val backgroundColor = MaterialTheme.colorScheme.primary

ScaffoldWithTopBar(
topBarColor = backgroundColor,
Expand Down Expand Up @@ -66,7 +69,10 @@ fun LoadingScreen(onSettingsCogClicked: () -> Unit = {}) {
Text(
text = stringResource(id = R.string.connecting_to_daemon),
fontSize = 13.sp,
color = colorResource(id = R.color.white40),
color =
MaterialTheme.colorScheme.onPrimary
.copy(alpha = AlphaDescription)
.compositeOver(backgroundColor),
modifier = Modifier.padding(top = 12.dp)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.text.ClickableText
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
Expand Down Expand Up @@ -45,11 +45,11 @@ fun PrivacyDisclaimerScreen(
onPrivacyPolicyLinkClicked: () -> Unit,
onAcceptClicked: () -> Unit,
) {
val topColor = colorResource(R.color.blue)
val topColor = MaterialTheme.colorScheme.primary
ScaffoldWithTopBar(
topBarColor = topColor,
statusBarColor = topColor,
navigationBarColor = colorResource(id = R.color.darkBlue),
navigationBarColor = MaterialTheme.colorScheme.background,
onAccountClicked = null,
onSettingsClicked = null
) {
Expand All @@ -58,7 +58,7 @@ fun PrivacyDisclaimerScreen(
Modifier.fillMaxHeight()
.fillMaxWidth()
.padding(it)
.background(colorResource(id = R.color.darkBlue))
.background(color = MaterialTheme.colorScheme.background)
) {
val (body, actionButtons) = createRefs()
val sideMargin = dimensionResource(id = R.dimen.side_margin)
Expand Down Expand Up @@ -124,8 +124,8 @@ fun PrivacyDisclaimerScreen(
onClick = onAcceptClicked::invoke,
colors =
ButtonDefaults.buttonColors(
contentColor = Color.White,
containerColor = colorResource(R.color.blue)
contentColor = MaterialTheme.colorScheme.onPrimary,
containerColor = MaterialTheme.colorScheme.primary
)
)
}
Expand Down

0 comments on commit 3bf2f57

Please sign in to comment.