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

Small Screen Preview Fix #166

Merged
merged 4 commits into from
Oct 16, 2024
Merged
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 @@ -2,22 +2,31 @@ package com.emergetools.hackernews.features.settings

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Lock
import androidx.compose.material.icons.rounded.Warning
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.NavigationBarItemDefaults
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Devices
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.emergetools.hackernews.R
import com.emergetools.hackernews.features.settings.components.BuiltByCard
Expand All @@ -41,17 +50,21 @@ fun SettingsScreen(
Column(
modifier = Modifier
.fillMaxSize()
.background(color = MaterialTheme.colorScheme.background)
.padding(8.dp),
.background(color = MaterialTheme.colorScheme.background),
verticalArrangement = Arrangement.spacedBy(16.dp),
) {
Text(
text = "Settings",
modifier = Modifier.fillMaxWidth(),
modifier = Modifier
.fillMaxWidth()
.padding(8.dp),
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.onBackground
)
Column(
modifier = Modifier
.verticalScroll(state = rememberScrollState())
.padding(horizontal = 8.dp),
verticalArrangement = Arrangement.spacedBy(4.dp)
) {
SettingsSectionLabel("Profile")
Expand Down Expand Up @@ -171,3 +184,74 @@ private fun SettingsScreenPreview() {
)
}
}

@Preview(
device = Devices.PIXEL_2,
showSystemUi = true
)
@Composable
private fun SettingsSmallScreenPreview() {
HackerNewsTheme {
Scaffold(
bottomBar = {
SettingsPreviewNavBar()
}
) { innerPadding ->
Box(modifier = Modifier.padding(innerPadding)) {
SettingsScreen(
state = SettingsState(false),
actions = {},
navigation = {}
)
}
}
}
}

@Composable
private fun SettingsPreviewNavBar() {
NavigationBar {
NavigationBarItem(
selected = false,
colors = NavigationBarItemDefaults.colors(
selectedIconColor = MaterialTheme.colorScheme.primary,
indicatorColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.2f)
),
onClick = { },
icon = {
Icon(
painter = painterResource(R.drawable.ic_feed),
contentDescription = "feed"
)
},
)
NavigationBarItem(
selected = false,
colors = NavigationBarItemDefaults.colors(
selectedIconColor = MaterialTheme.colorScheme.primary,
indicatorColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.2f)
),
onClick = { },
icon = {
Icon(
painter = painterResource(R.drawable.ic_bookmarks),
contentDescription = "bookmarks"
)
},
)
NavigationBarItem(
selected = true,
colors = NavigationBarItemDefaults.colors(
selectedIconColor = MaterialTheme.colorScheme.primary,
indicatorColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.2f)
),
onClick = { },
icon = {
Icon(
painter = painterResource(R.drawable.ic_settings),
contentDescription = "settings"
)
},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ annotation class AppStoreSnapshot

@Preview(device = Devices.PIXEL_FOLD)
@Preview(device = Devices.PIXEL_TABLET)
@Preview(device = Devices.PIXEL_2)
annotation class DevicePreview

@DevicePreview
Expand Down
Loading