Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JetNews] Issue459 - TopAppBar doesn't match design spec #462

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ package com.example.jetnews.ui.article

import android.content.Context
import android.content.Intent
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.material.AlertDialog
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
Expand All @@ -46,6 +49,7 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
Expand Down Expand Up @@ -128,20 +132,37 @@ fun ArticleScreen(
topBar = {
TopAppBar(
title = {
Text(
text = "Published in: ${post.publication?.name}",
style = MaterialTheme.typography.subtitle2,
color = LocalContentColor.current
)
Column(modifier = Modifier.padding(top = 10.dp, bottom = 5.dp)) {
Row(
modifier = Modifier
.fillMaxWidth()
.wrapContentWidth(align = Alignment.CenterHorizontally)
.padding(end = 50.dp)
) {
Image(
painter = painterResource(R.mipmap.ic_android_article),
contentDescription = "",
modifier = Modifier.padding(end = 10.dp)
)
Text(
text = "Published in: \n${post.publication?.name}",
style = MaterialTheme.typography.subtitle2,
color = LocalContentColor.current
)
}
}
},
navigationIcon = {
IconButton(onClick = onBack) {
Icon(
Image(
imageVector = Icons.Filled.ArrowBack,
contentDescription = stringResource(R.string.cd_navigate_up)
contentDescription = stringResource(R.string.cd_navigate_up),
colorFilter = ColorFilter.tint(MaterialTheme.colors.primary)
)
}
}
},
elevation = 0.dp,
backgroundColor = MaterialTheme.colors.onPrimary
)
},
content = { innerPadding ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.example.jetnews.ui.home

import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand All @@ -41,6 +42,8 @@ import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.TextButton
import androidx.compose.material.TopAppBar
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Search
import androidx.compose.material.rememberDrawerState
import androidx.compose.material.rememberScaffoldState
import androidx.compose.runtime.Composable
Expand All @@ -51,6 +54,7 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
Expand Down Expand Up @@ -170,15 +174,38 @@ fun HomeScreen(
topBar = {
val title = stringResource(id = R.string.app_name)
TopAppBar(
title = { Text(text = title) },
title = {
Image(
painter = painterResource(R.drawable.ic_jetnews_wordmark),
contentDescription = title,
colorFilter = ColorFilter.tint(MaterialTheme.colors.onBackground),
modifier = Modifier
.fillMaxSize()
.padding(bottom = 4.dp, top = 10.dp)
)
},
navigationIcon = {
IconButton(onClick = { coroutineScope.launch { scaffoldState.drawerState.open() } }) {
Icon(
Image(
painter = painterResource(R.drawable.ic_jetnews_logo),
contentDescription = stringResource(R.string.cd_open_navigation_drawer)
contentDescription = stringResource(R.string.cd_open_navigation_drawer),
colorFilter = ColorFilter.tint(MaterialTheme.colors.primary)
)
}
}
},
actions = {
IconButton(
onClick = { /* TODO: Open search */ }
) {
Icon(
imageVector = Icons.Filled.Search,
contentDescription = stringResource(R.string.cd_search)
)
}
},
elevation = 0.dp,
backgroundColor = MaterialTheme.colors.onPrimary,
modifier = Modifier.padding(bottom = 10.dp)
)
},
content = { innerPadding ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
Expand All @@ -38,6 +39,8 @@ import androidx.compose.material.Tab
import androidx.compose.material.TabRow
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Search
import androidx.compose.material.rememberDrawerState
import androidx.compose.material.rememberScaffoldState
import androidx.compose.runtime.Composable
Expand All @@ -49,8 +52,10 @@ import androidx.compose.runtime.saveable.rememberSaveable
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.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.jetnews.R
Expand Down Expand Up @@ -182,15 +187,34 @@ fun InterestsScreen(
},
topBar = {
TopAppBar(
title = { Text("Interests") },
title = {
Text(
text = "Interests",
modifier = Modifier.fillMaxWidth(),
textAlign = TextAlign.Center
)
},
navigationIcon = {
IconButton(onClick = { coroutineScope.launch { scaffoldState.drawerState.open() } }) {
Icon(
Image(
painter = painterResource(R.drawable.ic_jetnews_logo),
contentDescription = stringResource(R.string.cd_open_navigation_drawer)
contentDescription = stringResource(R.string.cd_open_navigation_drawer),
colorFilter = ColorFilter.tint(MaterialTheme.colors.primary)
)
}
},
actions = {
IconButton(
onClick = { /* TODO: Open search */ }
) {
Icon(
imageVector = Icons.Filled.Search,
contentDescription = stringResource(R.string.cd_search)
)
}
}
},
elevation = 0.dp,
backgroundColor = MaterialTheme.colors.onPrimary
)
},
content = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ private val LightThemeColors = lightColors(
secondary = Red700,
secondaryVariant = Red900,
onSecondary = Color.White,
error = Red800
error = Red800,
onBackground = Color.Black
)

private val DarkThemeColors = darkColors(
Expand All @@ -39,7 +40,8 @@ private val DarkThemeColors = darkColors(
onPrimary = Color.Black,
secondary = Red300,
onSecondary = Color.Black,
error = Red200
error = Red200,
onBackground = Color.White
)

@Composable
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions JetNews/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@
<string name="cd_bookmark">Bookmark</string>
<string name="unbookmark">unbookmark</string>
<string name="bookmark">bookmark</string>
<string name="cd_search">Search</string>
</resources>