Skip to content

Commit

Permalink
Merge pull request #6 from lucas-marciano/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
lucas-marciano authored May 31, 2022
2 parents 4b4ba72 + 31727d5 commit e22a529
Show file tree
Hide file tree
Showing 55 changed files with 1,821 additions and 293 deletions.
16 changes: 15 additions & 1 deletion .idea/misc.xml

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

11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Compose project

## Introdução
- Projeto serve como caso de estudo, montando a interface do seu negócio do app do iti

## Proximas features
- Testes unitários
- Camada de dados
- Testes de interface
- Preview em todo os elementos
- Construção de um theme sem usar as cores do material design
19 changes: 12 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ dependencies {
implementation "androidx.compose.material:material-icons-extended:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation "androidx.constraintlayout:constraintlayout-compose:$constraint_compose_version"
implementation "androidx.compose.ui:ui-util:$compose_version"

implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version"
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"
Expand All @@ -70,21 +71,25 @@ dependencies {

implementation 'androidx.activity:activity-compose:1.4.0'

implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
implementation "com.squareup.okhttp3:okhttp:4.9.0"
implementation "com.squareup.okhttp3:okhttp:4.9.0"
implementation "com.squareup.okhttp3:logging-interceptor:4.9.0"
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp_version"

implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

implementation "com.google.accompanist:accompanist-systemuicontroller:0.20.3"
implementation "com.google.accompanist:accompanist-pager:0.12.0"
implementation "com.google.accompanist:accompanist-navigation-animation:0.24.9-beta"

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
testImplementation("com.squareup.okhttp3:mockwebserver:4.9.0")
testImplementation("com.squareup.okhttp3:mockwebserver:$okhttp_version")

implementation "com.google.accompanist:accompanist-insets:0.17.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import com.lucasmarciano.composeproject.routes.Navigation
import com.lucasmarciano.composeproject.ui.theme.ComposeProjectTheme

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Navigation()
ComposeProjectTheme {
Navigation()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.lucasmarciano.composeproject.data.models.CallToActionVO
import com.lucasmarciano.composeproject.utils.extensions.emptyString

data class ItemCardHomeVO(
val id: Int,
val text: String,
val icon: String = emptyString(),
val callToAction: CallToActionVO,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.lucasmarciano.composeproject.data.models

import androidx.annotation.DrawableRes
import com.lucasmarciano.composeproject.R
import com.lucasmarciano.composeproject.utils.extensions.emptyString

internal data class ErrorVO(
val image: ErrorImage = ErrorImage.CONNECTION_ERROR,
val title: String,
val description: String,
val closeAction: String = emptyString(),
val callToActionVO: CallToActionVO = CallToActionVO()
)

enum class ErrorImage(@DrawableRes val imageId: Int) {
CONNECTION_ERROR(R.drawable.img_error_cone),
EMPTY_ERROR(R.drawable.img_error_list);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.lucasmarciano.composeproject.data.models

import androidx.compose.ui.graphics.Color
import com.lucasmarciano.composeproject.ui.theme.ColorBlueCard
import com.lucasmarciano.composeproject.ui.theme.ColorBlueChipInfo
import com.lucasmarciano.composeproject.ui.theme.ColorRedChipInfo

internal data class ItemTimeLineVO(
val position: Int,
val id: String,
val icon: String,
val title: String,
val value: String,
val description: String,
val tag: String,
val tagType: ChipType = ChipType.INFO,
val callToActionVO: CallToActionVO
)

internal enum class ChipType(val mainColor: Color, val secondaryColor: Color) {
ERROR(Color.Red, ColorRedChipInfo),
INFO(ColorBlueCard, ColorBlueChipInfo)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.lucasmarciano.composeproject.data.models

import com.lucasmarciano.composeproject.utils.extensions.emptyString

data class SalesInformationVO(
val title: String = emptyString(),
val subtitle: String = emptyString(),
val value: String = emptyString(),
val icon: String = emptyString(),
)
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
@file:OptIn(ExperimentalAnimationApi::class)
@file:Suppress("OPT_IN_IS_NOT_ENABLED")

package com.lucasmarciano.composeproject.features.home

import android.content.res.Configuration
import android.widget.Toast
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import com.google.accompanist.navigation.animation.rememberAnimatedNavController
import com.lucasmarciano.composeproject.features.home.components.ShimmerHomeController
import com.lucasmarciano.composeproject.ui.Components
import com.lucasmarciano.composeproject.ui.InterfaceFactory
import com.lucasmarciano.composeproject.ui.components.MainContainer
import com.lucasmarciano.composeproject.ui.mockspreview.mockHomeResult
import com.lucasmarciano.composeproject.ui.values.InterfaceItemComponent
import com.lucasmarciano.composeproject.ui.values.ToolbarComponent

@Composable
fun HomeScreen(navController: NavController) {
fun HomeScreen(navController: NavController = rememberAnimatedNavController()) {
val viewModel = viewModel<HomeViewModel>()
val state by viewModel.uiState.collectAsState()

Expand All @@ -45,17 +49,14 @@ fun HomeScreen(navController: NavController) {
private fun HomeContent(
isLoading: Boolean = true,
listItems: List<InterfaceItemComponent> = emptyList(),
navController: NavController = rememberNavController()
navController: NavController = rememberAnimatedNavController()
) {
var toolbar: ToolbarComponent? = null
if (listItems.isNotEmpty()) {
val toolbarData = listItems.find { it.typeComponent == Components.TOOLBAR }
toolbar = (toolbarData as ToolbarComponent)
}
ShimmerHomeController(isLoading) {
MainContainer(toolbarData = toolbar, navController) {
InterfaceFactory(listItems, navController)
}
val mListItems by remember { mutableStateOf(listItems) }
val mIsLoading by remember { mutableStateOf(isLoading) }
val state = rememberLazyListState()

ShimmerHomeController(mIsLoading) {
MainContainer(navController, mListItems, state)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
@file:OptIn(ExperimentalAnimationApi::class)
@file:Suppress("OPT_IN_IS_NOT_ENABLED")

package com.lucasmarciano.composeproject.features.home.components

import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import androidx.navigation.NavController
import com.google.accompanist.navigation.animation.rememberAnimatedNavController
import com.lucasmarciano.composeproject.data.home.models.ItemCardHomeVO
import com.lucasmarciano.composeproject.ui.components.BlueCard
import com.lucasmarciano.composeproject.ui.mockspreview.mockItemCard
import com.lucasmarciano.composeproject.ui.theme.ComposeProjectTheme
import com.lucasmarciano.composeproject.ui.utils.spacing

import com.lucasmarciano.composeproject.utils.extensions.navTo

@Composable
fun BlueCardsList(cards: List<ItemCardHomeVO>) {
LazyRow(horizontalArrangement = Arrangement.spacedBy(MaterialTheme.spacing.small)) {
items(cards) { card ->
BlueCard(item = card)
fun BlueCardsList(
cards: List<ItemCardHomeVO>,
navController: NavController = rememberAnimatedNavController(),
) {
LazyRow(
state = rememberLazyListState(),
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.spacing.small)
) {
items(cards, key = { it.id }) { card ->
BlueCard(item = card) { navController.navTo(card.callToAction.action) }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,41 @@
@file:OptIn(ExperimentalAnimationApi::class)
@file:Suppress("OPT_IN_IS_NOT_ENABLED")

package com.lucasmarciano.composeproject.features.home.components

import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import androidx.navigation.NavController
import com.google.accompanist.navigation.animation.rememberAnimatedNavController
import com.lucasmarciano.composeproject.data.home.models.ItemCardHomeVO
import com.lucasmarciano.composeproject.ui.components.CardWithIcon
import com.lucasmarciano.composeproject.ui.mockspreview.mockListSimpleItemCardWithIcon
import com.lucasmarciano.composeproject.ui.theme.ComposeProjectTheme
import com.lucasmarciano.composeproject.ui.utils.spacing
import com.lucasmarciano.composeproject.utils.extensions.navTo

@Composable
fun CardsList(cards: List<ItemCardHomeVO>) {
fun CardsList(
cards: List<ItemCardHomeVO>,
navController: NavController = rememberAnimatedNavController(),
) {
LazyRow(
state = rememberLazyListState(),
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.spacing.small),
contentPadding = PaddingValues(
end = MaterialTheme.spacing.small,
bottom = MaterialTheme.spacing.small
)
) {
items(cards) { card ->
CardWithIcon(item = card)
items(cards, key = { it.id }) { card ->
CardWithIcon(item = card) { navController.navTo(card.callToAction.action) }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.tooling.preview.Preview
import com.lucasmarciano.composeproject.utils.ComposableAlias
import com.lucasmarciano.composeproject.ui.components.shimmer.BannerShimmer
import com.lucasmarciano.composeproject.ui.components.shimmer.BlueCardShimmer
import com.lucasmarciano.composeproject.ui.components.shimmer.CardWithIconShimmer
Expand All @@ -23,7 +24,7 @@ import com.lucasmarciano.composeproject.ui.components.shimmer.TitleShimmer
import com.lucasmarciano.composeproject.ui.utils.spacing

@Composable
fun ShimmerHomeController(isLoading: Boolean = true, content: @Composable () -> Unit) {
fun ShimmerHomeController(isLoading: Boolean = true, content: ComposableAlias) {
ShimmerView(isLoading, content) { HomeShimmerScreen(brush = it) }
}

Expand Down
Loading

0 comments on commit e22a529

Please sign in to comment.