Skip to content

Commit ed5ebea

Browse files
committed
fix: comment out small previews
1 parent 759e8d5 commit ed5ebea

7 files changed

Lines changed: 78 additions & 73 deletions

File tree

app/src/main/java/to/bitkit/ui/screens/widgets/blocks/BlocksPreviewScreen.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ private fun Content(
118118

119119
block?.let {
120120
WidgetSizeCarousel(
121-
wideContent = {
122-
BlockCard(
121+
smallContent = {
122+
BlockCardSmall(
123123
showBlock = blocksPreferences.showBlock,
124124
showTime = blocksPreferences.showTime,
125125
showDate = blocksPreferences.showDate,
@@ -134,13 +134,11 @@ private fun Content(
134134
size = it.size,
135135
fees = it.fees,
136136
source = it.source,
137-
modifier = Modifier
138-
.fillMaxWidth()
139-
.testTag("block_card_wide")
137+
modifier = Modifier.testTag("block_card_small")
140138
)
141139
},
142-
smallContent = {
143-
BlockCardSmall(
140+
wideContent = {
141+
BlockCard(
144142
showBlock = blocksPreferences.showBlock,
145143
showTime = blocksPreferences.showTime,
146144
showDate = blocksPreferences.showDate,
@@ -155,7 +153,9 @@ private fun Content(
155153
size = it.size,
156154
fees = it.fees,
157155
source = it.source,
158-
modifier = Modifier.testTag("block_card_small")
156+
modifier = Modifier
157+
.fillMaxWidth()
158+
.testTag("block_card_wide")
159159
)
160160
},
161161
modifier = Modifier

app/src/main/java/to/bitkit/ui/screens/widgets/calculator/CalculatorPreviewScreen.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ fun CalculatorPreviewContent(
100100
)
101101

102102
WidgetSizeCarousel(
103+
smallContent = {
104+
CalculatorCardSmall(
105+
btcPrimaryDisplayUnit = uiState.displayUnit,
106+
btcValue = uiState.btcValue,
107+
fiatSymbol = uiState.currencySymbol,
108+
fiatValue = uiState.fiatValue,
109+
modifier = Modifier.testTag("calculator_card_small")
110+
)
111+
},
103112
wideContent = {
104113
CalculatorCardEditor(
105114
btcPrimaryDisplayUnit = uiState.displayUnit,
@@ -114,15 +123,6 @@ fun CalculatorPreviewContent(
114123
.testTag("calculator_card_wide")
115124
)
116125
},
117-
smallContent = {
118-
CalculatorCardSmall(
119-
btcPrimaryDisplayUnit = uiState.displayUnit,
120-
btcValue = uiState.btcValue,
121-
fiatSymbol = uiState.currencySymbol,
122-
fiatValue = uiState.fiatValue,
123-
modifier = Modifier.testTag("calculator_card_small")
124-
)
125-
},
126126
modifier = Modifier
127127
.fillMaxWidth()
128128
.testTag("calculator_preview_carousel")

app/src/main/java/to/bitkit/ui/screens/widgets/components/WidgetSizeCarousel.kt

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,23 @@ import to.bitkit.ui.components.Caption13Up
2424
import to.bitkit.ui.components.VerticalSpacer
2525
import to.bitkit.ui.theme.Colors
2626

27-
private enum class PreviewSize {
28-
WIDE,
29-
SMALL,
30-
}
31-
32-
private data class PreviewPage(
33-
val size: PreviewSize,
34-
val content: @Composable () -> Unit,
35-
)
27+
private const val PAGE_SMALL = 0
28+
private const val PAGE_WIDE = 1
29+
private const val PAGE_COUNT = 2
30+
private const val RELEASE_PAGE_COUNT = 1
3631

3732
@Composable
3833
fun WidgetSizeCarousel(
34+
smallContent: @Composable () -> Unit,
3935
wideContent: @Composable () -> Unit,
4036
modifier: Modifier = Modifier,
41-
smallContent: (@Composable () -> Unit)? = null,
4237
) {
43-
val showSmallContent = LocalInspectionMode.current
44-
val pages = if (showSmallContent) {
45-
listOfNotNull(
46-
smallContent?.let { PreviewPage(size = PreviewSize.SMALL, content = it) },
47-
PreviewPage(size = PreviewSize.WIDE, content = wideContent),
48-
)
49-
} else {
50-
listOf(PreviewPage(size = PreviewSize.WIDE, content = wideContent))
51-
}
52-
val pagerState = rememberPagerState(pageCount = { pages.size })
38+
val isPreview = LocalInspectionMode.current
39+
val pagerState = rememberPagerState(
40+
pageCount = {
41+
if (isPreview) PAGE_COUNT else RELEASE_PAGE_COUNT
42+
},
43+
)
5344

5445
Column(
5546
verticalArrangement = Arrangement.Center,
@@ -66,17 +57,31 @@ fun WidgetSizeCarousel(
6657
contentAlignment = Alignment.Center,
6758
modifier = Modifier.fillMaxWidth()
6859
) {
69-
pages[page].content()
60+
when (page) {
61+
PAGE_SMALL -> {
62+
if (isPreview) {
63+
smallContent()
64+
} else {
65+
// temporarily removed until small size widgets variants are implemented
66+
/*
67+
smallContent()
68+
*/
69+
wideContent()
70+
}
71+
}
72+
PAGE_WIDE -> wideContent()
73+
}
7074
}
7175
}
7276

7377
VerticalSpacer(16.dp)
7478

7579
Caption13Up(
7680
text = stringResource(
77-
when (pages[pagerState.currentPage].size) {
78-
PreviewSize.WIDE -> R.string.widgets__widget__size_wide
79-
PreviewSize.SMALL -> R.string.widgets__widget__size_small
81+
if (isPreview && pagerState.currentPage == PAGE_SMALL) {
82+
R.string.widgets__widget__size_small
83+
} else {
84+
R.string.widgets__widget__size_wide
8085
},
8186
),
8287
color = Colors.White64,
@@ -88,14 +93,14 @@ fun WidgetSizeCarousel(
8893

8994
VerticalSpacer(16.dp)
9095

91-
if (pages.size > 1) {
96+
if (isPreview) {
9297
Row(
9398
horizontalArrangement = Arrangement.Center,
9499
modifier = Modifier
95100
.fillMaxWidth()
96101
.testTag("page_indicator")
97102
) {
98-
repeat(pages.size) { index ->
103+
repeat(PAGE_COUNT) { index ->
99104
Box(
100105
modifier = Modifier
101106
.padding(horizontal = 4.dp)

app/src/main/java/to/bitkit/ui/screens/widgets/facts/FactsPreviewScreen.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ fun FactsPreviewContent(
9494
)
9595

9696
WidgetSizeCarousel(
97+
smallContent = {
98+
FactsCardSmall(
99+
headline = fact,
100+
modifier = Modifier.testTag("facts_card_small")
101+
)
102+
},
97103
wideContent = {
98104
FactsCard(
99105
headline = fact,
@@ -102,12 +108,6 @@ fun FactsPreviewContent(
102108
.testTag("facts_card_wide")
103109
)
104110
},
105-
smallContent = {
106-
FactsCardSmall(
107-
headline = fact,
108-
modifier = Modifier.testTag("facts_card_small")
109-
)
110-
},
111111
modifier = Modifier
112112
.fillMaxWidth()
113113
.testTag("facts_preview_carousel")

app/src/main/java/to/bitkit/ui/screens/widgets/headlines/HeadlinesPreviewScreen.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,15 @@ fun HeadlinesPreviewContent(
117117
)
118118

119119
WidgetSizeCarousel(
120+
smallContent = {
121+
HeadlineCardSmall(
122+
showTime = headlinePreferences.showTime,
123+
time = article.timeAgo,
124+
headline = article.title,
125+
link = article.link,
126+
modifier = Modifier.testTag("headline_card_small")
127+
)
128+
},
120129
wideContent = {
121130
HeadlineCard(
122131
showTime = headlinePreferences.showTime,
@@ -130,15 +139,6 @@ fun HeadlinesPreviewContent(
130139
.testTag("headline_card_wide")
131140
)
132141
},
133-
smallContent = {
134-
HeadlineCardSmall(
135-
showTime = headlinePreferences.showTime,
136-
time = article.timeAgo,
137-
headline = article.title,
138-
link = article.link,
139-
modifier = Modifier.testTag("headline_card_small")
140-
)
141-
},
142142
modifier = Modifier
143143
.fillMaxWidth()
144144
.testTag("headlines_preview_carousel")

app/src/main/java/to/bitkit/ui/screens/widgets/price/PricePreviewScreen.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,22 +136,22 @@ fun PricePreviewContent(
136136

137137
if (priceDTO != null) {
138138
WidgetSizeCarousel(
139-
wideContent = {
140-
PriceCard(
139+
smallContent = {
140+
PriceCardSmall(
141141
pricePreferences = pricePreferences,
142142
priceDTO = priceDTO,
143143
modifier = Modifier
144-
.fillMaxWidth()
145-
.testTag("price_card_wide")
144+
.size(WidgetCardDimens.COMPACT_CARD_SIZE)
145+
.testTag("price_card_small")
146146
)
147147
},
148-
smallContent = {
149-
PriceCardSmall(
148+
wideContent = {
149+
PriceCard(
150150
pricePreferences = pricePreferences,
151151
priceDTO = priceDTO,
152152
modifier = Modifier
153-
.size(WidgetCardDimens.COMPACT_CARD_SIZE)
154-
.testTag("price_card_small")
153+
.fillMaxWidth()
154+
.testTag("price_card_wide")
155155
)
156156
},
157157
modifier = Modifier

app/src/main/java/to/bitkit/ui/screens/widgets/weather/WeatherPreviewScreen.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ fun WeatherPreviewContent(
123123

124124
weatherModel?.let { model ->
125125
WidgetSizeCarousel(
126+
smallContent = {
127+
WeatherCardSmall(
128+
weatherModel = model,
129+
preferences = weatherPreferences,
130+
modifier = Modifier.testTag("weather_card_small")
131+
)
132+
},
126133
wideContent = {
127134
WeatherCard(
128135
weatherModel = model,
@@ -132,13 +139,6 @@ fun WeatherPreviewContent(
132139
.testTag("weather_card_wide")
133140
)
134141
},
135-
smallContent = {
136-
WeatherCardSmall(
137-
weatherModel = model,
138-
preferences = weatherPreferences,
139-
modifier = Modifier.testTag("weather_card_small")
140-
)
141-
},
142142
modifier = Modifier
143143
.fillMaxWidth()
144144
.testTag("weather_preview_carousel")

0 commit comments

Comments
 (0)