generated from nimblehq/git-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from nimblehq/feature/4-implement-ui-today-pro…
…fit-card-on-home-screen [#4] Implement UI Today's profit card on Home screen
- Loading branch information
Showing
24 changed files
with
350 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 15 additions & 9 deletions
24
app/src/main/java/co/nimblehq/compose/crypto/ui/screens/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,22 @@ | ||
package co.nimblehq.compose.crypto.ui.screens | ||
|
||
import android.view.LayoutInflater | ||
import androidx.activity.viewModels | ||
import co.nimblehq.compose.crypto.databinding.ActivityMainBinding | ||
import co.nimblehq.compose.crypto.ui.base.BaseActivity | ||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import co.nimblehq.compose.crypto.ui.screens.home.HomeScreen | ||
import co.nimblehq.compose.crypto.ui.theme.ComposeTheme | ||
import dagger.hilt.android.AndroidEntryPoint | ||
|
||
// TODO: Consider update BaseActivity to extends ComponentActivity. | ||
@AndroidEntryPoint | ||
class MainActivity : BaseActivity<ActivityMainBinding>() { | ||
class MainActivity : ComponentActivity() { | ||
|
||
override val bindingInflater: (LayoutInflater) -> ActivityMainBinding | ||
get() = { inflater -> ActivityMainBinding.inflate(inflater) } | ||
|
||
override val viewModel by viewModels<MainViewModel>() | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContent { | ||
ComposeTheme { | ||
HomeScreen() | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
app/src/main/java/co/nimblehq/compose/crypto/ui/screens/compose/theme/Color.kt
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
app/src/main/java/co/nimblehq/compose/crypto/ui/screens/compose/theme/Theme.kt
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
app/src/main/java/co/nimblehq/compose/crypto/ui/screens/compose/theme/Typography.kt
This file was deleted.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
app/src/main/java/co/nimblehq/compose/crypto/ui/screens/home/HomeScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package co.nimblehq.compose.crypto.ui.screens.home | ||
|
||
import androidx.compose.foundation.layout.* | ||
import androidx.compose.material.* | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.constraintlayout.compose.ConstraintLayout | ||
import androidx.constraintlayout.compose.Dimension | ||
import co.nimblehq.compose.crypto.R | ||
import co.nimblehq.compose.crypto.ui.theme.ComposeTheme | ||
import co.nimblehq.compose.crypto.ui.theme.Dimension.Dp16 | ||
import co.nimblehq.compose.crypto.ui.theme.Dimension.Dp40 | ||
import co.nimblehq.compose.crypto.ui.theme.Style | ||
import co.nimblehq.compose.crypto.ui.theme.Style.titleHome | ||
|
||
@Composable | ||
fun HomeScreen() { | ||
Surface { | ||
ConstraintLayout( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.padding(horizontal = Dp16) | ||
) { | ||
val (title, portfolioCard) = createRefs() | ||
|
||
Text( | ||
modifier = Modifier | ||
.padding(start = Dp16, top = Dp16, end = Dp16) | ||
.constrainAs(title) { | ||
top.linkTo(parent.top) | ||
linkTo(start = parent.start, end = parent.end) | ||
width = Dimension.preferredWrapContent | ||
}, | ||
text = stringResource(id = R.string.home_title), | ||
textAlign = TextAlign.Center, | ||
style = Style.semiBold24(), | ||
color = MaterialTheme.colors.titleHome | ||
) | ||
|
||
PortfolioCard( | ||
modifier = Modifier.constrainAs(portfolioCard) { | ||
top.linkTo(title.bottom, margin = Dp40) | ||
} | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
@Preview | ||
fun HomeScreenPreview() { | ||
ComposeTheme { | ||
HomeScreen() | ||
} | ||
} | ||
|
||
@Composable | ||
@Preview | ||
fun HomeScreenPreviewDark() { | ||
ComposeTheme(darkTheme = true) { | ||
HomeScreen() | ||
} | ||
} |
131 changes: 131 additions & 0 deletions
131
app/src/main/java/co/nimblehq/compose/crypto/ui/screens/home/PortfolioCard.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
package co.nimblehq.compose.crypto.ui.screens.home | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material.* | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.KeyboardArrowUp | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.draw.shadow | ||
import androidx.compose.ui.graphics.Brush | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.constraintlayout.compose.ConstraintLayout | ||
import co.nimblehq.compose.crypto.R | ||
import co.nimblehq.compose.crypto.ui.theme.Color | ||
import co.nimblehq.compose.crypto.ui.theme.ComposeTheme | ||
import co.nimblehq.compose.crypto.ui.theme.Dimension.Dp0 | ||
import co.nimblehq.compose.crypto.ui.theme.Dimension.Dp12 | ||
import co.nimblehq.compose.crypto.ui.theme.Dimension.Dp16 | ||
import co.nimblehq.compose.crypto.ui.theme.Dimension.Dp20 | ||
import co.nimblehq.compose.crypto.ui.theme.Dimension.Dp4 | ||
import co.nimblehq.compose.crypto.ui.theme.Dimension.Dp40 | ||
import co.nimblehq.compose.crypto.ui.theme.Dimension.Dp8 | ||
import co.nimblehq.compose.crypto.ui.theme.Style | ||
|
||
@Composable | ||
fun PortfolioCard( | ||
modifier: Modifier | ||
) { | ||
ConstraintLayout( | ||
modifier = modifier | ||
.fillMaxWidth() | ||
.clip(RoundedCornerShape(Dp12)) | ||
.background( | ||
brush = Brush.linearGradient( | ||
colors = listOf(Color.MetallicSeaweed, Color.TiffanyBlue), | ||
) | ||
) | ||
) { | ||
val ( | ||
totalCoinsLabel, | ||
totalCoins, | ||
todayProfitLabel, | ||
todayProfit, | ||
profitPercent | ||
) = createRefs() | ||
|
||
Text( | ||
modifier = Modifier | ||
.padding(top = Dp16, start = Dp16) | ||
.constrainAs(totalCoinsLabel) { | ||
start.linkTo(parent.start) | ||
}, | ||
text = stringResource(R.string.portfolio_card_total_coin_label), | ||
style = Style.lightSilverMedium16() | ||
) | ||
|
||
Text( | ||
modifier = Modifier | ||
.padding(horizontal = Dp16) | ||
.constrainAs(totalCoins) { | ||
top.linkTo(totalCoinsLabel.bottom, margin = Dp8) | ||
}, | ||
// TODO: Remove dummy value when work on Integrate. | ||
text = stringResource(R.string.portfolio_card_total_coin, "7,273,291"), | ||
style = Style.whiteSemiBold24() | ||
) | ||
|
||
Text( | ||
modifier = Modifier | ||
.padding(start = Dp16) | ||
.constrainAs(todayProfitLabel) { | ||
top.linkTo(totalCoins.bottom, margin = Dp40) | ||
}, | ||
text = stringResource(R.string.portfolio_card_today_profit_label), | ||
style = Style.lightSilverMedium16() | ||
) | ||
|
||
Text( | ||
modifier = Modifier | ||
.padding(start = Dp16, bottom = Dp16) | ||
.constrainAs(todayProfit) { | ||
top.linkTo(todayProfitLabel.bottom, margin = Dp8) | ||
}, | ||
// TODO: Remove dummy value when work on Integrate. | ||
text = stringResource(R.string.portfolio_card_today_profit, "193,280"), | ||
style = Style.whiteSemiBold24() | ||
) | ||
|
||
Button( | ||
modifier = Modifier | ||
.padding(start = Dp16, end = Dp16, bottom = Dp16) | ||
.shadow(elevation = Dp0) | ||
.constrainAs(profitPercent) { | ||
linkTo(top = todayProfitLabel.top, bottom = todayProfit.bottom) | ||
end.linkTo(parent.end) | ||
}, | ||
colors = ButtonDefaults.buttonColors( | ||
backgroundColor = Color.Water, | ||
contentColor = Color.GuppieGreen | ||
), | ||
shape = RoundedCornerShape(Dp20), | ||
onClick = { /* TODO */ } | ||
) { | ||
Icon( | ||
imageVector = Icons.Filled.KeyboardArrowUp, | ||
modifier = Modifier.padding(end = Dp4), | ||
contentDescription = null | ||
) | ||
Text( | ||
// TODO: Remove dummy value when work on Integrate. | ||
text = stringResource(R.string.portfolio_card_profit_percent, 2.41), | ||
style = Style.medium16() | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
@Preview | ||
fun PortfolioCardPreview() { | ||
ComposeTheme { | ||
PortfolioCard( | ||
modifier = Modifier | ||
) | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...creens/compose/composables/ContentCard.kt → ...o/ui/screens/to_be_removed/ContentCard.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
app/src/main/java/co/nimblehq/compose/crypto/ui/theme/Color.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package co.nimblehq.compose.crypto.ui.theme | ||
|
||
import androidx.compose.ui.graphics.Color | ||
|
||
@Suppress("MagicNumber") | ||
object Color { | ||
val BlueFreeSpeech = Color(0xFF3F51B5) | ||
val AlmostWhite = Color(0xFFDFE4EA) | ||
val White = Color.White | ||
val MetallicSeaweed = Color(0xFF028090) | ||
val TiffanyBlue = Color(0xFF00BFB2) | ||
val Water = Color(0xFFD6F5F3) | ||
val GuppieGreen = Color(0xFF10DC78) | ||
val DarkJungleGreen = Color(0xFF141B29) | ||
val LightSilver = Color(0xFFD6D7D8) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../crypto/ui/screens/compose/theme/Shape.kt → ...nimblehq/compose/crypto/ui/theme/Shape.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
app/src/main/java/co/nimblehq/compose/crypto/ui/theme/Style.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package co.nimblehq.compose.crypto.ui.theme | ||
|
||
import androidx.compose.material.Colors | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.graphics.Color.Companion.White | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.font.FontWeight | ||
import co.nimblehq.compose.crypto.ui.theme.Color.DarkJungleGreen | ||
import co.nimblehq.compose.crypto.ui.theme.Color.LightSilver | ||
import co.nimblehq.compose.crypto.ui.theme.TextDimension.Sp16 | ||
import co.nimblehq.compose.crypto.ui.theme.TextDimension.Sp24 | ||
|
||
object Style { | ||
|
||
val Colors.titleHome: Color | ||
@Composable | ||
get() = if (isLight) DarkJungleGreen else White | ||
|
||
@Composable | ||
fun medium16() = TextStyle(fontWeight = FontWeight.Medium, fontSize = Sp16) | ||
|
||
@Composable | ||
fun lightSilverMedium16() = medium16().copy(color = LightSilver) | ||
|
||
@Composable | ||
fun semiBold24() = TextStyle(fontWeight = FontWeight.SemiBold, fontSize = Sp24) | ||
|
||
@Composable | ||
fun whiteSemiBold24() = semiBold24().copy(color = White) | ||
} |
Oops, something went wrong.