Skip to content

Commit

Permalink
Merge branch 'episodio-13' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoLinks committed Aug 15, 2023
2 parents 30a23d6 + 968cb0c commit fecf5fb
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 27 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/com/compose/instagram/ui/theme/Color.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ val Pink40 = Color(0xFF7D5260)

val StoryCircleColor = Color(0xFFFF6347)
val DividerColor = Color(0xFFC9C9C9)
val DarkDividerColor = Color(0xFF343434)
val Gray = Color(0xFF808080)
14 changes: 4 additions & 10 deletions app/src/main/java/com/compose/instagram/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package com.compose.instagram.ui.theme

import android.app.Activity
import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.core.view.ViewCompat

Expand All @@ -21,15 +17,17 @@ private val DarkColorScheme = darkColorScheme(
secondary = PurpleGrey80,
tertiary = Pink80,
background = Color.Black,
onBackground = Color.White
onBackground = Color.White,
onSurface = DarkDividerColor
)

private val LightColorScheme = lightColorScheme(
primary = Purple40,
secondary = PurpleGrey40,
tertiary = Pink40,
background = Color.White,
onBackground = Color.Black
onBackground = Color.Black,
onSurface = DividerColor
)

@Composable
Expand All @@ -40,10 +38,6 @@ fun InstagramTheme(
content: @Composable () -> Unit
) {
val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
}
darkTheme -> DarkColorScheme
else -> LightColorScheme
}
Expand Down
28 changes: 18 additions & 10 deletions app/src/main/java/com/compose/instagram/ui/view/FeedItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
Expand All @@ -33,7 +34,9 @@ import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi
import com.bumptech.glide.integration.compose.GlideImage
import com.compose.instagram.R
import com.compose.instagram.data.model.Feed
import com.compose.instagram.data.repository.feedList
import com.compose.instagram.ui.theme.Gray
import com.compose.instagram.ui.theme.InstagramTheme
import com.compose.instagram.ui.theme.spacingLarge
import com.compose.instagram.ui.theme.spacingMedium
import com.compose.instagram.ui.theme.spacingSmall
Expand All @@ -54,6 +57,8 @@ fun FeedItem(feed: Feed) {
val commentContentDesc = stringResource(R.string.button_coment_content_description)
val bookmarkContentDesc = stringResource(R.string.button_bookmark_content_description)

val iconsColor = MaterialTheme.colorScheme.onBackground

Column(modifier = Modifier.background(MaterialTheme.colorScheme.background)) {

Row(
Expand Down Expand Up @@ -128,7 +133,8 @@ fun FeedItem(feed: Feed) {
.size(40.dp)
.padding(end = spacingLarge)
.weight(1f)
.wrapContentWidth(align = Alignment.End)
.wrapContentWidth(align = Alignment.End),
colorFilter = ColorFilter.tint(iconsColor)
)
}

Expand Down Expand Up @@ -180,21 +186,23 @@ fun FeedIcon(
contentDescription = contentDescription,
modifier = Modifier
.size(40.dp)
.padding(end = spacingLarge)
.padding(end = spacingLarge),
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onBackground)
)
}

@Preview(showBackground = true)
@Composable
fun FeedItemPreview() {
FeedItem(
feed = Feed(
userNickName = "Joe Doe",
localName = "Brasil",
userAvatar = "",
imageUrl = "",
description = "",
postedAgo = "Há 2 dias"
)
feed = feedList[0]
)
}

@Preview(showBackground = true)
@Composable
fun DarkFeedItemPreview() {
InstagramTheme(darkTheme = true) {
FeedItem(feed = feedList[1])
}
}
14 changes: 10 additions & 4 deletions app/src/main/java/com/compose/instagram/ui/view/HomeScreen.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.compose.instagram.ui.view

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
Expand All @@ -18,7 +16,7 @@ import com.compose.instagram.data.model.Feed
import com.compose.instagram.data.model.Story
import com.compose.instagram.data.repository.feedList
import com.compose.instagram.data.repository.stories
import com.compose.instagram.ui.theme.DividerColor
import com.compose.instagram.ui.theme.InstagramTheme
import com.compose.instagram.ui.theme.spacingMedium

@Composable
Expand All @@ -35,7 +33,7 @@ fun HomeScreen() {
}

item {
Divider(color = DividerColor, thickness = 0.2.dp)
Divider(color = MaterialTheme.colorScheme.onSurface, thickness = 0.2.dp)
}

feedList(feedList = feedList)
Expand All @@ -61,4 +59,12 @@ fun LazyListScope.feedList(feedList: List<Feed>) {
@Composable
fun HomeScreenPreview() {
HomeScreen()
}

@Preview(showBackground = true)
@Composable
fun DarkHomeScreenPreview() {
InstagramTheme(darkTheme = true) {
HomeScreen()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ 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.ColorFilter
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 com.compose.instagram.R
import com.compose.instagram.ui.theme.InstagramTheme
import com.compose.instagram.ui.theme.spacingLarge
import com.compose.instagram.ui.theme.spacingMedium

Expand All @@ -25,6 +27,8 @@ fun InstagramToolBar() {

val instagramLabel = stringResource(id = R.string.app_name)

val iconsColor = MaterialTheme.colorScheme.onBackground

Box(modifier = Modifier.background(MaterialTheme.colorScheme.background)) {
Row(
modifier = Modifier
Expand All @@ -44,15 +48,17 @@ fun InstagramToolBar() {
modifier = Modifier
.size(32.dp)
.padding(end = spacingMedium),
contentDescription = stringResource(R.string.content_description_notification_icon)
contentDescription = stringResource(R.string.content_description_notification_icon),
colorFilter = ColorFilter.tint(iconsColor)
)

Image(
painter = painterResource(id = R.drawable.ic_message),
modifier = Modifier
.size(32.dp)
.padding(start = spacingMedium),
contentDescription = stringResource(R.string.content_description_message_icon)
contentDescription = stringResource(R.string.content_description_message_icon),
colorFilter = ColorFilter.tint(iconsColor)
)

}
Expand All @@ -64,4 +70,12 @@ fun InstagramToolBar() {
@Composable
fun InstagramToolbarPreview() {
InstagramToolBar()
}

@Preview(showBackground = true)
@Composable
fun DarkInstagramToolbarPreview() {
InstagramTheme(darkTheme = true) {
InstagramToolBar()
}
}
12 changes: 11 additions & 1 deletion app/src/main/java/com/compose/instagram/ui/view/StoryItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi
import com.bumptech.glide.integration.compose.GlideImage
import com.compose.instagram.R
import com.compose.instagram.data.model.Story
import com.compose.instagram.data.repository.stories
import com.compose.instagram.ui.theme.InstagramTheme
import com.compose.instagram.ui.theme.StoryCircleColor
import com.compose.instagram.ui.theme.spacingSmall

Expand Down Expand Up @@ -63,5 +65,13 @@ fun StoryItem(story: Story) {
@Preview(showBackground = true)
@Composable
fun StoryItemPreview() {
StoryItem(story = Story(userNickName = "", userAvatar = ""))
StoryItem(story = stories[0])
}

@Preview(showBackground = true)
@Composable
fun DarkStoryItemPreview() {
InstagramTheme(darkTheme = true) {
StoryItem(story = stories[0])
}
}

0 comments on commit fecf5fb

Please sign in to comment.