-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement DoB and Full Name in wallet activation
- Loading branch information
1 parent
8b62916
commit f331ecc
Showing
14 changed files
with
317 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
app/src/main/kotlin/net/primal/android/core/compose/DatePickerModalBottomSheet.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package net.primal.android.core.compose | ||
|
||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.DatePicker | ||
import androidx.compose.material3.DatePickerColors | ||
import androidx.compose.material3.DatePickerDefaults | ||
import androidx.compose.material3.DatePickerFormatter | ||
import androidx.compose.material3.DatePickerState | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.ModalBottomSheet | ||
import androidx.compose.material3.rememberModalBottomSheetState | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import net.primal.android.theme.AppTheme | ||
|
||
@ExperimentalMaterial3Api | ||
@Composable | ||
fun DatePickerModalBottomSheet( | ||
state: DatePickerState, | ||
dateFormatter: DatePickerFormatter = remember { DatePickerFormatter() }, | ||
dateValidator: (Long) -> Boolean = { true }, | ||
showModeToggle: Boolean = true, | ||
colors: DatePickerColors = DatePickerDefaults.colors( | ||
selectedDayContainerColor = AppTheme.colorScheme.primary, | ||
), | ||
onDismissRequest: () -> Unit, | ||
) { | ||
ModalBottomSheet( | ||
sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true), | ||
containerColor = AppTheme.colorScheme.surface, | ||
tonalElevation = 0.dp, | ||
onDismissRequest = onDismissRequest, | ||
) { | ||
DatePicker( | ||
state = state, | ||
modifier = Modifier.padding(bottom = 16.dp), | ||
dateFormatter = dateFormatter, | ||
dateValidator = dateValidator, | ||
showModeToggle = showModeToggle, | ||
colors = colors, | ||
) | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
app/src/main/kotlin/net/primal/android/core/compose/ToS.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package net.primal.android.core.compose | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalUriHandler | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.SpanStyle | ||
import androidx.compose.ui.text.buildAnnotatedString | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.text.withStyle | ||
import net.primal.android.R | ||
import net.primal.android.core.ext.openUriSafely | ||
import net.primal.android.theme.AppTheme | ||
|
||
private const val TOS_ANNOTATION_TAG = "TosAnnotationTag" | ||
private const val PRIVACY_ANNOTATION_TAG = "PrivacyAnnotationTag" | ||
|
||
private const val PRIMAL_TOS_URL = "https://www.primal.net/terms" | ||
private const val PRIMAL_PRIVACY_POLICY_URL = "https://www.primal.net/privacy" | ||
|
||
@Composable | ||
fun ToSAndPrivacyPolicyText(modifier: Modifier = Modifier, tosPrefix: String) { | ||
val linkSpanStyle = SpanStyle(color = AppTheme.colorScheme.primary) | ||
val annotatedString = buildAnnotatedString { | ||
append(tosPrefix) | ||
append("\n") | ||
|
||
pushStringAnnotation(TOS_ANNOTATION_TAG, "tos") | ||
withStyle(style = linkSpanStyle) { | ||
append(stringResource(id = R.string.legal_tos_hint_highlighted_word)) | ||
} | ||
pop() | ||
|
||
append(" and ") | ||
pushStringAnnotation(PRIVACY_ANNOTATION_TAG, "privacy") | ||
withStyle(style = linkSpanStyle) { | ||
append(stringResource(id = R.string.legal_privacy_policy_hint_highlighted_word)) | ||
} | ||
append(".") | ||
pop() | ||
} | ||
|
||
val localUriHandler = LocalUriHandler.current | ||
PrimalClickableText( | ||
modifier = modifier, | ||
text = annotatedString, | ||
style = AppTheme.typography.bodySmall.copy( | ||
color = AppTheme.extraColorScheme.onSurfaceVariantAlt3, | ||
textAlign = TextAlign.Center, | ||
), | ||
onClick = { position, offset -> | ||
annotatedString.getStringAnnotations( | ||
start = position, | ||
end = position, | ||
).firstOrNull()?.let { annotation -> | ||
when (annotation.tag) { | ||
TOS_ANNOTATION_TAG -> localUriHandler.openUriSafely(PRIMAL_TOS_URL) | ||
PRIVACY_ANNOTATION_TAG -> localUriHandler.openUriSafely(PRIMAL_PRIVACY_POLICY_URL) | ||
} | ||
} | ||
}, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.