Skip to content

Commit c9d0bf2

Browse files
Merge pull request #32 from google-developer-training/m3-nav-update
Starter code for part 2
2 parents 569a662 + 0a8ac7a commit c9d0bf2

File tree

9 files changed

+27
-301
lines changed

9 files changed

+27
-301
lines changed

app/src/androidTest/java/com/example/reply/test/ReplyAppStateRestorationTest.kt

Lines changed: 0 additions & 113 deletions
This file was deleted.

app/src/androidTest/java/com/example/reply/test/ReplyAppTest.kt

Lines changed: 0 additions & 79 deletions
This file was deleted.

app/src/androidTest/java/com/example/reply/test/TestAnnotations.kt

Lines changed: 0 additions & 20 deletions
This file was deleted.

app/src/main/java/com/example/reply/MainActivity.kt

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,3 @@ fun ReplyAppCompactPreview() {
5454
)
5555
}
5656
}
57-
58-
@Preview(showBackground = true, widthDp = 700)
59-
@Composable
60-
fun ReplyAppMediumPreview() {
61-
ReplyTheme {
62-
ReplyApp(
63-
windowSize = WindowWidthSizeClass.Medium,
64-
)
65-
}
66-
}
67-
68-
@Preview(showBackground = true, widthDp = 1000)
69-
@Composable
70-
fun ReplyAppExpandedPreview() {
71-
ReplyTheme {
72-
ReplyApp(
73-
windowSize = WindowWidthSizeClass.Expanded,
74-
)
75-
}
76-
}

app/src/main/java/com/example/reply/ui/ReplyApp.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import androidx.compose.ui.Modifier
2222
import androidx.lifecycle.viewmodel.compose.viewModel
2323
import com.example.reply.data.Email
2424
import com.example.reply.data.MailboxType
25-
import com.example.reply.ui.utils.ReplyContentType
2625
import com.example.reply.ui.utils.ReplyNavigationType
2726

2827
@Composable
@@ -31,31 +30,25 @@ fun ReplyApp(
3130
modifier: Modifier = Modifier,
3231
) {
3332
val navigationType: ReplyNavigationType
34-
val contentType: ReplyContentType
3533
val viewModel: ReplyViewModel = viewModel()
3634
val replyUiState = viewModel.uiState.collectAsState().value
3735

3836
when (windowSize) {
3937
WindowWidthSizeClass.Compact -> {
4038
navigationType = ReplyNavigationType.BOTTOM_NAVIGATION
41-
contentType = ReplyContentType.LIST_ONLY
4239
}
4340
WindowWidthSizeClass.Medium -> {
4441
navigationType = ReplyNavigationType.NAVIGATION_RAIL
45-
contentType = ReplyContentType.LIST_ONLY
4642
}
4743
WindowWidthSizeClass.Expanded -> {
4844
navigationType = ReplyNavigationType.PERMANENT_NAVIGATION_DRAWER
49-
contentType = ReplyContentType.LIST_AND_DETAIL
5045
}
5146
else -> {
5247
navigationType = ReplyNavigationType.BOTTOM_NAVIGATION
53-
contentType = ReplyContentType.LIST_ONLY
5448
}
5549
}
5650
ReplyHomeScreen(
5751
navigationType = navigationType,
58-
contentType = contentType,
5952
replyUiState = replyUiState,
6053
onTabPressed = { mailboxType: MailboxType ->
6154
viewModel.updateCurrentMailbox(mailboxType = mailboxType)

app/src/main/java/com/example/reply/ui/ReplyDetailsScreen.kt

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ import androidx.compose.foundation.layout.Arrangement
2222
import androidx.compose.foundation.layout.Box
2323
import androidx.compose.foundation.layout.Column
2424
import androidx.compose.foundation.layout.Row
25-
import androidx.compose.foundation.layout.Spacer
2625
import androidx.compose.foundation.layout.fillMaxSize
2726
import androidx.compose.foundation.layout.fillMaxWidth
28-
import androidx.compose.foundation.layout.height
2927
import androidx.compose.foundation.layout.padding
3028
import androidx.compose.foundation.layout.size
3129
import androidx.compose.foundation.lazy.LazyColumn
@@ -56,7 +54,6 @@ fun ReplyDetailsScreen(
5654
replyUiState: ReplyUiState,
5755
modifier: Modifier = Modifier,
5856
onBackPressed: () -> Unit = {},
59-
isFullScreen: Boolean = false
6057
) {
6158
BackHandler {
6259
onBackPressed()
@@ -70,23 +67,16 @@ fun ReplyDetailsScreen(
7067
.padding(top = dimensionResource(R.dimen.detail_card_list_padding_top))
7168
) {
7269
item {
73-
if (isFullScreen) {
74-
ReplyDetailsScreenTopBar(
75-
onBackPressed,
76-
replyUiState,
77-
Modifier
78-
.fillMaxWidth()
79-
.padding(bottom = dimensionResource(R.dimen.detail_topbar_padding_bottom))
80-
)
81-
}
70+
ReplyDetailsScreenTopBar(
71+
onBackPressed,
72+
replyUiState,
73+
Modifier
74+
.fillMaxWidth()
75+
.padding(bottom = dimensionResource(R.dimen.detail_topbar_padding_bottom))
76+
)
8277
ReplyEmailDetailsCard(
8378
email = replyUiState.currentSelectedEmail,
84-
mailboxType = replyUiState.currentMailbox,
85-
isFullScreen = isFullScreen,
86-
modifier = if (isFullScreen)
87-
Modifier.padding(horizontal = dimensionResource(R.dimen.detail_card_outer_padding_horizontal))
88-
else
89-
Modifier.padding(end = dimensionResource(R.dimen.detail_card_outer_padding_horizontal))
79+
mailboxType = replyUiState.currentMailbox
9080
)
9181
}
9282
}
@@ -134,7 +124,6 @@ private fun ReplyEmailDetailsCard(
134124
email: Email,
135125
mailboxType: MailboxType,
136126
modifier: Modifier = Modifier,
137-
isFullScreen: Boolean = false
138127
) {
139128
val context = LocalContext.current
140129
val displayToast = { text: String ->
@@ -153,19 +142,15 @@ private fun ReplyEmailDetailsCard(
153142
email,
154143
Modifier.fillMaxWidth()
155144
)
156-
if (!isFullScreen) {
157-
Text(
158-
text = stringResource(email.subject),
159-
style = MaterialTheme.typography.bodyMedium,
160-
color = MaterialTheme.colorScheme.outline,
161-
modifier = Modifier.padding(
162-
top = dimensionResource(R.dimen.detail_content_padding_top),
163-
bottom = dimensionResource(R.dimen.detail_expanded_subject_body_spacing)
164-
),
165-
)
166-
} else {
167-
Spacer(modifier = Modifier.height(dimensionResource(R.dimen.detail_content_padding_top)))
168-
}
145+
Text(
146+
text = stringResource(email.subject),
147+
style = MaterialTheme.typography.bodyMedium,
148+
color = MaterialTheme.colorScheme.outline,
149+
modifier = Modifier.padding(
150+
top = dimensionResource(R.dimen.detail_content_padding_top),
151+
bottom = dimensionResource(R.dimen.detail_expanded_subject_body_spacing)
152+
),
153+
)
169154
Text(
170155
text = stringResource(email.body),
171156
style = MaterialTheme.typography.bodyLarge,

app/src/main/java/com/example/reply/ui/ReplyHomeContent.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ fun ReplyListAndDetailContent(
113113
ReplyDetailsScreen(
114114
replyUiState = replyUiState,
115115
modifier = Modifier.weight(1f),
116-
onBackPressed = { activity.finish() }
116+
onBackPressed = {}
117117
)
118118
}
119119
}

0 commit comments

Comments
 (0)