Skip to content

Commit

Permalink
Add #opensource to OnboardingSplashLogin.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
Iliyan Germanov committed Nov 5, 2021
1 parent 5b69d04 commit ba78b3f
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 27 deletions.
3 changes: 3 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions app/src/main/java/com/ivy/wallet/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ object Constants {
const val URL_PRIVACY_POLICY =
"https://github.com/ILIYANGERMANOV/privacy-policies/blob/master/ivy-wallet-privacy-policy.md"

const val URL_IVY_WALLET_REPO = "https://github.com/ILIYANGERMANOV/ivy-wallet"

const val URL_IVY_WALLET_GOOGLE_PLAY =
"https://play.google.com/store/apps/details?id=com.ivy.wallet"

Expand Down
7 changes: 6 additions & 1 deletion app/src/main/java/com/ivy/wallet/base/ComposeExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import androidx.compose.ui.graphics.drawscope.drawIntoCanvas
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.platform.UriHandler
import androidx.compose.ui.text.TextRange
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.unit.Density
Expand Down Expand Up @@ -193,4 +194,8 @@ fun Dp.toDensityPx() = densityScope { toPx() }
fun Int.toDensityDp() = densityScope { toDp() }

@Composable
fun Float.toDensityDp() = densityScope { toDp() }
fun Float.toDensityDp() = densityScope { toDp() }

fun openUrl(uriHandler: UriHandler, url: String) {
uriHandler.openUri(url)
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import com.ivy.wallet.Constants
import com.ivy.wallet.R
import com.ivy.wallet.base.*
import com.ivy.wallet.ui.IvyAppPreview
import com.ivy.wallet.ui.IvyContext
import com.ivy.wallet.ui.LocalIvyContext
import com.ivy.wallet.ui.onboarding.OnboardingState
import com.ivy.wallet.ui.theme.*
Expand Down Expand Up @@ -159,19 +160,10 @@ fun BoxWithConstraintsScope.OnboardingSplashLogin(
Spacer(Modifier.height(marginTextTop))

Text(
modifier = Modifier.layout { measurable, constraints ->
val placeable = measurable.measure(constraints)

layout(placeable.width, placeable.height) {
val xSplash = ivyContext.screenWidth / 2f - placeable.width / 2
val xLogin = 32.dp.toPx()

placeable.placeRelative(
x = lerp(xSplash, xLogin, percentTransition).roundToInt(),
y = 0
)
}
},
modifier = Modifier.animateXCenterToLeft(
ivyContext = ivyContext,
percentTransition = percentTransition
),
text = "Ivy Wallet",
style = Typo.h2.style(
color = IvyTheme.colors.pureInverse,
Expand All @@ -183,26 +175,39 @@ fun BoxWithConstraintsScope.OnboardingSplashLogin(
Spacer(modifier = Modifier.height(16.dp))

Text(
modifier = Modifier.layout { measurable, constraints ->
val placeable = measurable.measure(constraints)

layout(placeable.width, placeable.height) {
val xSplash = ivyContext.screenWidth / 2f - placeable.width / 2
val xLogin = 32.dp.toPx()

placeable.placeRelative(
x = lerp(xSplash, xLogin, percentTransition).roundToInt(),
y = 0
)
}
},
modifier = Modifier.animateXCenterToLeft(
ivyContext = ivyContext,
percentTransition = percentTransition
),
text = "Your personal money manager",
style = Typo.body2.style(
color = IvyTheme.colors.pureInverse,
fontWeight = FontWeight.SemiBold
)
)

val uriHandler = LocalUriHandler.current
Text(
modifier = Modifier
.animateXCenterToLeft(
ivyContext = ivyContext,
percentTransition = percentTransition
)
.clickable {
openUrl(
uriHandler = uriHandler,
url = Constants.URL_IVY_WALLET_REPO
)
}
.padding(vertical = 8.dp)
.padding(end = 8.dp),
text = "#opensource",
style = Typo.caption.style(
color = Green,
fontWeight = FontWeight.Bold
)
)

LoginSection(
percentTransition = percentTransition,

Expand All @@ -213,6 +218,25 @@ fun BoxWithConstraintsScope.OnboardingSplashLogin(
}
}

private fun Modifier.animateXCenterToLeft(
ivyContext: IvyContext,
percentTransition: Float
): Modifier {
return this.layout { measurable, constraints ->
val placeable = measurable.measure(constraints)

layout(placeable.width, placeable.height) {
val xSplash = ivyContext.screenWidth / 2f - placeable.width / 2
val xLogin = 32.dp.toPx()

placeable.placeRelative(
x = lerp(xSplash, xLogin, percentTransition).roundToInt(),
y = 0
)
}
}
}

@Composable
private fun LoginSection(
percentTransition: Float,
Expand Down

0 comments on commit ba78b3f

Please sign in to comment.