Skip to content

Commit 2068afa

Browse files
committed
BAse Non Originating screen
1 parent 89bf98c commit 2068afa

File tree

4 files changed

+144
-18
lines changed

4 files changed

+144
-18
lines changed

app/src/main/java/org/thoughtcrime/securesms/preferences/prosettings/BaseProSettingsScreens.kt

Lines changed: 140 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package org.thoughtcrime.securesms.preferences.prosettings
22

3+
import androidx.annotation.DrawableRes
4+
import androidx.compose.foundation.background
5+
import androidx.compose.foundation.layout.Arrangement
36
import androidx.compose.foundation.layout.Box
47
import androidx.compose.foundation.layout.Column
8+
import androidx.compose.foundation.layout.Row
59
import androidx.compose.foundation.layout.Spacer
610
import androidx.compose.foundation.layout.WindowInsets
711
import androidx.compose.foundation.layout.WindowInsetsSides
@@ -11,17 +15,22 @@ import androidx.compose.foundation.layout.fillMaxWidth
1115
import androidx.compose.foundation.layout.height
1216
import androidx.compose.foundation.layout.only
1317
import androidx.compose.foundation.layout.padding
18+
import androidx.compose.foundation.layout.size
1419
import androidx.compose.foundation.layout.systemBars
1520
import androidx.compose.foundation.layout.widthIn
1621
import androidx.compose.foundation.rememberScrollState
1722
import androidx.compose.foundation.verticalScroll
1823
import androidx.compose.material3.ExperimentalMaterial3Api
24+
import androidx.compose.material3.Icon
25+
import androidx.compose.material3.MaterialTheme
1926
import androidx.compose.material3.Scaffold
2027
import androidx.compose.material3.Text
2128
import androidx.compose.runtime.Composable
29+
import androidx.compose.ui.Alignment.Companion.Center
2230
import androidx.compose.ui.Alignment.Companion.CenterHorizontally
2331
import androidx.compose.ui.Modifier
2432
import androidx.compose.ui.graphics.Color
33+
import androidx.compose.ui.res.painterResource
2534
import androidx.compose.ui.text.style.TextAlign
2635
import androidx.compose.ui.tooling.preview.Preview
2736
import androidx.compose.ui.tooling.preview.PreviewParameter
@@ -31,12 +40,16 @@ import org.thoughtcrime.securesms.ui.SessionProSettingsHeader
3140
import org.thoughtcrime.securesms.ui.components.AccentFillButtonRect
3241
import org.thoughtcrime.securesms.ui.components.BackAppBar
3342
import org.thoughtcrime.securesms.ui.components.DangerFillButtonRect
43+
import org.thoughtcrime.securesms.ui.components.annotatedStringResource
3444
import org.thoughtcrime.securesms.ui.theme.LocalColors
3545
import org.thoughtcrime.securesms.ui.theme.LocalDimensions
3646
import org.thoughtcrime.securesms.ui.theme.LocalType
3747
import org.thoughtcrime.securesms.ui.theme.PreviewTheme
3848
import org.thoughtcrime.securesms.ui.theme.SessionColorsParameterProvider
3949
import org.thoughtcrime.securesms.ui.theme.ThemeColors
50+
import org.thoughtcrime.securesms.ui.theme.bold
51+
import network.loki.messenger.R
52+
import org.thoughtcrime.securesms.ui.DialogBg
4053

4154
/**
4255
* Base structure used in most Pro Settings screen
@@ -114,7 +127,14 @@ fun BaseCellButtonProSettingsScreen(
114127

115128
Spacer(Modifier.height(LocalDimensions.current.smallSpacing))
116129

117-
Cell(content = content)
130+
Cell {
131+
Column(
132+
modifier = Modifier.fillMaxWidth()
133+
.padding(LocalDimensions.current.smallSpacing)
134+
) {
135+
content()
136+
}
137+
}
118138

119139
Spacer(Modifier.height(LocalDimensions.current.smallSpacing))
120140

@@ -170,20 +190,116 @@ fun BaseNonOriginatingProSettingsScreen(
170190
buttonText: String,
171191
dangerButton: Boolean,
172192
onButtonClick: () -> Unit,
173-
title: String? = null,
174-
content: @Composable () -> Unit
193+
headerTitle: String?,
194+
contentTitle: String?,
195+
contentDescription: CharSequence?,
196+
linkCellsInfo: String?,
197+
linkCells: List<NonOriginatingLinkCellData> = emptyList(),
175198
) {
176199
BaseCellButtonProSettingsScreen(
177200
disabled = disabled,
178201
onBack = onBack,
179202
buttonText = buttonText,
180203
dangerButton = dangerButton,
181204
onButtonClick = onButtonClick,
182-
title = title,
183-
content = content
184-
)
205+
title = headerTitle,
206+
){
207+
if (contentTitle != null) {
208+
Text(
209+
text = contentTitle,
210+
style = LocalType.current.h7,
211+
color = LocalColors.current.text,
212+
)
213+
}
214+
215+
if (contentDescription != null) {
216+
Spacer(Modifier.height(LocalDimensions.current.xxxsSpacing))
217+
Text(
218+
text = annotatedStringResource(contentDescription),
219+
style = LocalType.current.base,
220+
color = LocalColors.current.text,
221+
)
222+
}
223+
224+
if (linkCellsInfo != null) {
225+
Spacer(Modifier.height(LocalDimensions.current.smallSpacing))
226+
Text(
227+
text = linkCellsInfo,
228+
style = LocalType.current.base,
229+
color = LocalColors.current.textSecondary,
230+
)
231+
}
232+
233+
Spacer(Modifier.height(LocalDimensions.current.xsSpacing))
234+
235+
linkCells.forEachIndexed { index, data ->
236+
if (index > 0) {
237+
Spacer(Modifier.height(LocalDimensions.current.xsSpacing))
238+
}
239+
NonOriginatingLinkCell(data)
240+
}
241+
}
242+
}
243+
244+
@Composable
245+
fun NonOriginatingLinkCell(
246+
data: NonOriginatingLinkCellData
247+
) {
248+
DialogBg(
249+
bgColor = LocalColors.current.backgroundTertiary
250+
) {
251+
Row(
252+
modifier = Modifier.fillMaxWidth()
253+
.padding(LocalDimensions.current.smallSpacing),
254+
horizontalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallSpacing)
255+
) {
256+
// icon
257+
Box(modifier = Modifier
258+
.background(
259+
color = LocalColors.current.accent.copy(alpha = 0.2f),
260+
shape = MaterialTheme.shapes.small
261+
)
262+
.padding(10.dp)
263+
){
264+
Icon(
265+
modifier = Modifier.align(Center)
266+
.size(LocalDimensions.current.iconMedium),
267+
painter = painterResource(id = data.iconRes),
268+
tint = LocalColors.current.accent,
269+
contentDescription = null
270+
)
271+
}
272+
273+
// text content
274+
Column(
275+
modifier = Modifier.weight(1f)
276+
) {
277+
Text(
278+
text = annotatedStringResource(data.title),
279+
style = LocalType.current.base.bold(),
280+
color = LocalColors.current.text,
281+
)
282+
283+
Spacer(Modifier.height(LocalDimensions.current.xxxsSpacing))
284+
285+
Text(
286+
text = annotatedStringResource(data.info),
287+
style = LocalType.current.base,
288+
color = LocalColors.current.text,
289+
)
290+
}
291+
}
292+
}
185293
}
186294

295+
296+
data class NonOriginatingLinkCellData(
297+
val title: CharSequence,
298+
val info: CharSequence,
299+
@DrawableRes val iconRes: Int,
300+
val onClick: (() -> Unit)? = null
301+
)
302+
187303
@Preview
188304
@Composable
189305
private fun PreviewBaseNonOrig(
@@ -193,17 +309,26 @@ private fun PreviewBaseNonOrig(
193309
BaseNonOriginatingProSettingsScreen(
194310
disabled = false,
195311
onBack = {},
196-
title = "This is a title",
312+
headerTitle = "This is a title",
197313
buttonText = "This is a button",
198-
dangerButton = true,
314+
dangerButton = false,
199315
onButtonClick = {},
200-
content = {
201-
Box(
202-
modifier = Modifier.padding(LocalDimensions.current.smallSpacing)
203-
) {
204-
Text("This is a cell button content screen~")
205-
}
206-
}
316+
contentTitle = "This is a content title",
317+
contentDescription = "This is a content description",
318+
linkCellsInfo = "This is a link cells info",
319+
linkCells = listOf(
320+
NonOriginatingLinkCellData(
321+
title = "This is a title",
322+
info = "This is some info",
323+
iconRes = R.drawable.ic_globe
324+
),
325+
NonOriginatingLinkCellData(
326+
title = "This is another title",
327+
info = "This is some different info",
328+
iconRes = R.drawable.ic_phone
329+
)
330+
)
331+
207332
)
208333
}
209334
}

app/src/main/java/org/thoughtcrime/securesms/preferences/prosettings/PlanConfirmationScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ fun PlanConfirmation(
149149
color = LocalColors.current.text,
150150
)
151151

152-
Spacer(Modifier.height(LocalDimensions.current.smallSpacing))
152+
Spacer(Modifier.height(LocalDimensions.current.spacing))
153153

154154
//todo PRO the button text can change if the user was renewing vs expiring and/or/auto-renew
155155
AccentFillButtonRect(

app/src/main/java/org/thoughtcrime/securesms/preferences/prosettings/ProSettingsNavHost.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fun ProSettingsNavHost(
6464
}
6565
}
6666

67-
NavHost(navController = navController, startDestination = PlanConfirmation) {
67+
NavHost(navController = navController, startDestination = Home) {
6868
// Home
6969
horizontalSlideComposable<Home> {
7070
ProSettingsHomeScreen(

app/src/main/java/org/thoughtcrime/securesms/ui/AlertDialog.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,13 @@ fun DialogButton(
292292
@Composable
293293
fun DialogBg(
294294
modifier: Modifier = Modifier,
295+
bgColor: Color = LocalColors.current.backgroundSecondary,
295296
content: @Composable BoxScope.() -> Unit
296297
){
297298
Box(
298299
modifier = modifier
299300
.background(
300-
color = LocalColors.current.backgroundSecondary,
301+
color = bgColor,
301302
shape = MaterialTheme.shapes.small
302303
)
303304
.border(

0 commit comments

Comments
 (0)