Skip to content

Commit e0ca42b

Browse files
committed
Follow-up: YiR entry dialog code optimization
1 parent c38a78a commit e0ca42b

File tree

5 files changed

+27
-26
lines changed

5 files changed

+27
-26
lines changed

app/src/main/java/org/wikipedia/main/MainFragment.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ import org.wikipedia.util.TabUtil
8686
import org.wikipedia.views.NotificationButtonView
8787
import org.wikipedia.views.TabCountsView
8888
import org.wikipedia.watchlist.WatchlistActivity
89-
import org.wikipedia.yearinreview.YearInReviewDialog
89+
import org.wikipedia.yearinreview.YearInReviewEntryDialog
9090
import java.io.File
9191
import java.util.concurrent.TimeUnit
9292

@@ -473,7 +473,7 @@ class MainFragment : Fragment(), BackPressedHandler, MenuProvider, FeedFragment.
473473
}
474474

475475
override fun yearInReviewClick() {
476-
ExclusiveBottomSheetPresenter.show(childFragmentManager, YearInReviewDialog.newInstance())
476+
ExclusiveBottomSheetPresenter.show(childFragmentManager, YearInReviewEntryDialog.newInstance())
477477
}
478478

479479
fun setBottomNavVisible(visible: Boolean) {

app/src/main/java/org/wikipedia/yearinreview/YearInReviewDialog.kt renamed to app/src/main/java/org/wikipedia/yearinreview/YearInReviewEntryDialog.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialog
1010
import org.wikipedia.compose.theme.BaseTheme
1111
import org.wikipedia.page.ExtendedBottomSheetDialogFragment
1212

13-
class YearInReviewDialog : ExtendedBottomSheetDialogFragment() {
13+
class YearInReviewEntryDialog : ExtendedBottomSheetDialogFragment() {
1414

1515
override fun onCreateView(
1616
inflater: LayoutInflater,
@@ -23,15 +23,15 @@ class YearInReviewDialog : ExtendedBottomSheetDialogFragment() {
2323
return ComposeView(requireContext()).apply {
2424
setContent {
2525
BaseTheme {
26-
YearInReviewBottomSheet()
26+
YearInReviewEntryDialogScreen()
2727
}
2828
}
2929
}
3030
}
3131

3232
companion object {
33-
fun newInstance(): YearInReviewDialog {
34-
return YearInReviewDialog()
33+
fun newInstance(): YearInReviewEntryDialog {
34+
return YearInReviewEntryDialog()
3535
}
3636
}
3737
}

app/src/main/java/org/wikipedia/yearinreview/BottomSheetScaffold.kt renamed to app/src/main/java/org/wikipedia/yearinreview/YearInReviewEntryDialogScreen.kt

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package org.wikipedia.yearinreview
33
import android.widget.ImageView
44
import androidx.compose.foundation.layout.Arrangement
55
import androidx.compose.foundation.layout.Column
6-
import androidx.compose.foundation.layout.aspectRatio
76
import androidx.compose.foundation.layout.fillMaxWidth
7+
import androidx.compose.foundation.layout.heightIn
88
import androidx.compose.foundation.layout.padding
99
import androidx.compose.foundation.layout.wrapContentHeight
1010
import androidx.compose.foundation.rememberScrollState
@@ -19,7 +19,9 @@ import androidx.compose.runtime.Composable
1919
import androidx.compose.ui.Alignment
2020
import androidx.compose.ui.Modifier
2121
import androidx.compose.ui.draw.clip
22+
import androidx.compose.ui.input.nestedscroll.nestedScroll
2223
import androidx.compose.ui.platform.LocalContext
24+
import androidx.compose.ui.platform.rememberNestedScrollInteropConnection
2325
import androidx.compose.ui.res.stringResource
2426
import androidx.compose.ui.text.style.TextAlign
2527
import androidx.compose.ui.tooling.preview.Preview
@@ -31,34 +33,34 @@ import org.wikipedia.compose.theme.WikipediaTheme
3133

3234
@OptIn(ExperimentalMaterial3Api::class)
3335
@Composable
34-
fun YearInReviewBottomSheet() {
36+
fun YearInReviewEntryDialogScreen() {
3537
val context = LocalContext.current
36-
val scrollState = rememberScrollState()
3738
Column(
3839
modifier = Modifier
3940
.fillMaxWidth()
4041
.wrapContentHeight()
4142
.clip(RoundedCornerShape(topStart = 20.dp, topEnd = 20.dp))
42-
.padding(20.dp)
43-
.verticalScroll(scrollState),
43+
.padding(vertical = 16.dp)
44+
.nestedScroll(rememberNestedScrollInteropConnection())
45+
.verticalScroll(rememberScrollState()),
4446
horizontalAlignment = Alignment.CenterHorizontally,
4547
verticalArrangement = Arrangement.spacedBy(10.dp)
4648
) {
4749
Text(
4850
modifier = Modifier.padding(
49-
horizontal = 30.dp
51+
horizontal = 32.dp
5052
),
51-
text = stringResource(R.string.year_in_review_explore_screen_title),
53+
text = stringResource(R.string.year_in_review_entry_dialog_title),
5254
color = WikipediaTheme.colors.primaryColor,
5355
style = MaterialTheme.typography.headlineSmall,
5456
textAlign = TextAlign.Center
5557

5658
)
5759
Text(
5860
modifier = Modifier.padding(
59-
horizontal = 45.dp
61+
horizontal = 16.dp
6062
),
61-
text = stringResource(R.string.year_in_review_explore_screen_bodytext),
63+
text = stringResource(R.string.year_in_review_entry_dialog_bodytext),
6264
color = WikipediaTheme.colors.primaryColor,
6365
style = MaterialTheme.typography.bodyMedium,
6466
textAlign = TextAlign.Center
@@ -69,13 +71,12 @@ fun YearInReviewBottomSheet() {
6971
Glide.with(this)
7072
.asGif()
7173
.load(R.drawable.wyir_puzzle_4_v2)
72-
.centerCrop()
7374
.into(this)
7475
}
7576
},
7677
modifier = Modifier
7778
.fillMaxWidth()
78-
.aspectRatio(3f / 2f)
79+
.heightIn(max = 240.dp)
7980
.clip(RoundedCornerShape(16.dp))
8081
)
8182
Button(
@@ -91,16 +92,16 @@ fun YearInReviewBottomSheet() {
9192
)
9293
) {
9394
Text(
94-
text = stringResource(R.string.year_in_review_explore_screen_continue),
95+
text = stringResource(R.string.year_in_review_entry_dialog_continue),
9596
color = WikipediaTheme.colors.paperColor,
9697
style = MaterialTheme.typography.labelLarge
9798
)
9899
}
99100
}
100101
}
101102

102-
@Preview
103+
@Preview(showBackground = true)
103104
@Composable
104105
fun PreviewBottomSheet() {
105-
YearInReviewBottomSheet()
106+
YearInReviewEntryDialogScreen()
106107
}

app/src/main/res/values-qq/strings.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,7 +1793,7 @@
17931793
<string name="year_in_review_read_count_bodytext">Body text for the year in review readcount page. \"%d\" represents the total number of articles in the HistoryEntry table for the current year</string>
17941794
<string name="year_in_review_edit_count_headline">Headline text for the year in review editcount page. \"%d\" represents the total number of userContribs for the current year</string>
17951795
<string name="year_in_review_edit_count_bodytext">Body text for the year in review editcount page. \"%d\" represents the total number of userContribs for the current year</string>
1796-
<string name="year_in_review_explore_screen_title">Headline for the year in review Explore Screen</string>
1797-
<string name="year_in_review_explore_screen_bodytext">Body text for the year in review Explore Screen</string>
1798-
<string name="year_in_review_explore_screen_continue">Button text for the year in review Explore Screen</string>
1796+
<string name="year_in_review_entry_dialog_title">Headline for the year in review Explore Screen</string>
1797+
<string name="year_in_review_entry_dialog_bodytext">Body text for the year in review Explore Screen</string>
1798+
<string name="year_in_review_entry_dialog_continue">Button text for the year in review Explore Screen</string>
17991799
</resources>

app/src/main/res/values/strings.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,7 +1876,7 @@
18761876
<string name="year_in_review_read_count_bodytext">This year, you read %d articles, including Climate change, Dogs, and Cats. Wikipedia had more than 63 million articles available across over 300 languages. You joined millions in expanding knowledge and exploring diverse topics.</string>
18771877
<string name="year_in_review_edit_count_headline">You edited Wikipedia %d times</string>
18781878
<string name="year_in_review_edit_count_bodytext">You edited Wikipedia %d times. Thank you for being one of the volunteer editors making a difference on Wikimedia projects around the world.</string>
1879-
<string name="year_in_review_explore_screen_title">Explore your Wikipedia in Review</string>
1880-
<string name="year_in_review_explore_screen_bodytext">See insights about what articles we read and edited, and share highlights from our year on Wikipedia.</string>
1881-
<string name="year_in_review_explore_screen_continue">Continue</string>
1879+
<string name="year_in_review_entry_dialog_title">Explore your Wikipedia in Review</string>
1880+
<string name="year_in_review_entry_dialog_bodytext">See insights about what articles we read and edited, and share highlights from our year on Wikipedia.</string>
1881+
<string name="year_in_review_entry_dialog_continue">Continue</string>
18821882
</resources>

0 commit comments

Comments
 (0)