feat: Add DonationsTile

This commit is contained in:
Myzel394 2023-10-25 18:59:23 +02:00
parent fe9d2ef1e6
commit b6d0501c85
No known key found for this signature in database
GPG Key ID: 79CC92F37B3E1A2B
4 changed files with 246 additions and 100 deletions

View File

@ -6,3 +6,41 @@ import androidx.compose.ui.unit.dp
val BIG_PRIMARY_BUTTON_SIZE = 64.dp
val MAX_AMPLITUDE = 20000
val SUPPORTS_DARK_MODE_NATIVELY = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
const val PUBLIC_KEY = """-----BEGIN PGP PUBLIC KEY BLOCK-----
mDMEZTfvnhYJKwYBBAHaRw8BAQdAi2AiLsTaBoLhnQtY5vi3xBU/H428wbNfBSe+
2dhz3r60Jk15emVsMzk0IDxnaXRodWIuN2Eyb3BAc2ltcGxlbG9naW4uY28+iJkE
ExYKAEEWIQR9BS8nNHwqrNgV0B3NE0dCwel5WQUCZTfvngIbAwUJEswDAAULCQgH
AgIiAgYVCgkICwIEFgIDAQIeBwIXgAAKCRDNE0dCwel5WcS8AQCf9g6eEaut1suW
l6jCLIg3b1nWLckmLJaonM6PruUtigEAmVnFOxMpOZEIcILT8CD2Riy+IVN9gTNH
qOHnaFsu8AK4OARlN++eEgorBgEEAZdVAQUBAQdAe4ffDtRundKH9kam746i2TBu
P9sfb3QVi5QqfK+bek8DAQgHiH4EGBYKACYWIQR9BS8nNHwqrNgV0B3NE0dCwel5
WQUCZTfvngIbDAUJEswDAAAKCRDNE0dCwel5WWwSAQDj4ZAl6bSqwbcptEMYQaPM
MMhMafm446MjkhQioeXw+wEAzA8mS6RBx7IZvu1dirmFHXOEYJclwjyQhNs4uEjq
/Ak=
=ICHe
-----END PGP PUBLIC KEY BLOCK-----"""
const val PUBLIC_KEY_FINGERPRINT = "7D05 2F27 347C 2AAC D815 D01D CD13 4742 C1E9 7959"
val CRYPTO_DONATIONS = mapOf(
"Bitcoin" to "bc1qw054829yj8e2u8glxnfcg3w22dkek577mjt5x6",
"Bitcoin Cash" to "qr9s64vfqedvurfef9ykf7szchmt0xyvnga452fc8l",
"Ethereum" to "0xbb5E631c03C65334d1d9EfBCD926DC1265CC20D7",
"Tether USD" to "0xbb5E631c03C65334d1d9EfBCD926DC1265CC20D7",
"Monero" to "83dm5wyuckG4aPbuMREHCEgLNwVn5i7963SKBhECaA7Ueb7DKBTy639R3QfMtb3DsFHMp8u6WGiCFgbdRDBBcz5sLduUtm8",
"Zcash" to "t1ZfvNpzfdaW6csT9Kc7iJA7LUU3hmNj2sx",
"Litecoin" to "LZayhTosZ9ToRvcbeR1gEDgb76Z7ZA2drN",
"Dash" to "XcTkni8CVAXBcuc5VwvHmsYftVK4CPLetU",
"Avalanche" to "0xbb5E631c03C65334d1d9EfBCD926DC1265CC20D7",
"XRP" to "rNpfDm8UwDTumCebchBadjVW2FEPteFgNg",
"Solana" to "2h6CB3hz5Vb2nYS1RQiXZ4aWTzc5frBPR7Sp1b4muFqb",
"ADA" to "addr1q8vy2vcp6lacaw8lkc29gufuzajaytc5qc0c2mxlmw5lndxcg5esr4lm36u0lds523cnc9m96gh3gpsls4kdlkaflx6qf6qpvc",
"Dogecoin" to "DUA4j7mVoc7Rvezu8YgeRKwxNuMzKeDoxD",
"Tron" to "THWVLGhne5wDsGjd1CNenHDKQGzvGzrzLb",
"Polkadot" to "1642iaR6AoKyM6qnnMHkfCRfRqRKJ2wC6Cm3UEWEFEz6EtZR",
"Cosmos" to "cosmos1vt5z6rfj5sgnkdlddkuu8srw3xupyqxscva9hz",
"Algorand" to "QBOQ6VSLMD77QEF33P5J3HKGOM5RZLNO6P5P3FTWCMQM3ORF6QY2W34KUI",
"Tezos" to "tz1QUWNYuFqDibGCrwmkdaHSpTx3d6ZdxLMi",
"Litecoin" to "LZayhTosZ9ToRvcbeR1gEDgb76Z7ZA2drN",
"Filecoin" to "f1j6pm3chzhgadpf6iwmtux33jb5gccj5arkg4dsq",
)

View File

@ -0,0 +1,127 @@
package app.myzel394.alibi.ui.components.AboutScreen.atoms
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ContentCopy
import androidx.compose.material.icons.filled.CurrencyBitcoin
import androidx.compose.material.icons.filled.CurrencyFranc
import androidx.compose.material.icons.filled.CurrencyLira
import androidx.compose.material.icons.filled.CurrencyPound
import androidx.compose.material.icons.filled.CurrencyRuble
import androidx.compose.material.icons.filled.CurrencyRupee
import androidx.compose.material.icons.filled.CurrencyYen
import androidx.compose.material.icons.filled.CurrencyYuan
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import app.myzel394.alibi.R
import app.myzel394.alibi.ui.CRYPTO_DONATIONS
import app.myzel394.alibi.ui.PUBLIC_KEY
@Composable
fun DonationsTile() {
var donationsOpened by rememberSaveable {
mutableStateOf(false)
}
val label = stringResource(R.string.ui_about_contribute_donatation)
Row(
modifier = Modifier
.fillMaxWidth()
.clip(MaterialTheme.shapes.medium)
.semantics {
contentDescription = label
}
.clickable {
donationsOpened = !donationsOpened
}
.background(
MaterialTheme.colorScheme.surfaceVariant
)
.padding(16.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Icon(
listOf(
Icons.Default.CurrencyBitcoin,
Icons.Default.CurrencyFranc,
Icons.Default.CurrencyLira,
Icons.Default.CurrencyPound,
Icons.Default.CurrencyRuble,
Icons.Default.CurrencyRupee,
Icons.Default.CurrencyYen,
Icons.Default.CurrencyYuan,
).asSequence().shuffled().first(),
contentDescription = null,
modifier = Modifier.size(ButtonDefaults.IconSize.times(1.2f))
)
Text(
stringResource(R.string.ui_about_contribute_donatation),
fontWeight = FontWeight.Bold,
)
}
// TODO: Add LazyColumn, make expandable
Column {
val clipboardManager =
LocalContext.current.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
for (crypto in CRYPTO_DONATIONS) {
Row(
modifier = Modifier
.fillMaxWidth()
.clip(MaterialTheme.shapes.medium)
.clickable {
val clip = ClipData.newPlainText("text", crypto.value)
clipboardManager.setPrimaryClip(clip)
}
.padding(8.dp)
.horizontalScroll(rememberScrollState()),
horizontalArrangement = Arrangement.spacedBy(8.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Icon(
Icons.Default.ContentCopy,
contentDescription = null,
)
Text(
crypto.key,
style = MaterialTheme.typography.bodyMedium,
fontWeight = FontWeight.Bold,
)
Text(
crypto.value,
fontSize = MaterialTheme.typography.bodyMedium.fontSize.times(0.5),
)
}
}
}
}

View File

@ -0,0 +1,77 @@
package app.myzel394.alibi.ui.components.AboutScreen.atoms
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Key
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import app.myzel394.alibi.R
import app.myzel394.alibi.ui.PUBLIC_KEY_FINGERPRINT
import app.myzel394.alibi.ui.PUBLIC_KEY
@Composable
fun GPGKeyOverview() {
Column(
modifier = Modifier
.fillMaxWidth()
.clip(MaterialTheme.shapes.medium)
.background(
MaterialTheme.colorScheme.primaryContainer
)
.padding(16.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(16.dp),
) {
Icon(
Icons.Default.Key,
contentDescription = null,
modifier = Modifier.size(48.dp)
)
Text(
stringResource(R.string.ui_about_gpg_key_hint),
style = MaterialTheme.typography.bodyMedium,
)
val clipboardManager =
LocalContext.current.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
Text(
PUBLIC_KEY_FINGERPRINT,
modifier = Modifier
.clip(MaterialTheme.shapes.small)
.background(
MaterialTheme.colorScheme.surfaceVariant
)
.padding(8.dp),
)
Button(
onClick = {
val clip = ClipData.newPlainText("text", PUBLIC_KEY)
clipboardManager.setPrimaryClip(clip)
},
colors = ButtonDefaults.textButtonColors(),
modifier = Modifier
.fillMaxWidth()
) {
Text(stringResource(R.string.ui_about_gpg_key_copy))
}
}
}

View File

@ -62,25 +62,12 @@ import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import app.myzel394.alibi.R
import app.myzel394.alibi.BuildConfig
import app.myzel394.alibi.ui.components.AboutScreen.atoms.DonationsTile
import app.myzel394.alibi.ui.components.AboutScreen.atoms.GPGKeyOverview
import kotlin.random.Random
const val GITHUB_URL = "https://github.com/Myzel394/Alibi"
const val CROWDIN_URL = "https://crowdin.com/project/alibi"
const val PUBLIC_KEY = """-----BEGIN PGP PUBLIC KEY BLOCK-----
mDMEZTfvnhYJKwYBBAHaRw8BAQdAi2AiLsTaBoLhnQtY5vi3xBU/H428wbNfBSe+
2dhz3r60Jk15emVsMzk0IDxnaXRodWIuN2Eyb3BAc2ltcGxlbG9naW4uY28+iJkE
ExYKAEEWIQR9BS8nNHwqrNgV0B3NE0dCwel5WQUCZTfvngIbAwUJEswDAAULCQgH
AgIiAgYVCgkICwIEFgIDAQIeBwIXgAAKCRDNE0dCwel5WcS8AQCf9g6eEaut1suW
l6jCLIg3b1nWLckmLJaonM6PruUtigEAmVnFOxMpOZEIcILT8CD2Riy+IVN9gTNH
qOHnaFsu8AK4OARlN++eEgorBgEEAZdVAQUBAQdAe4ffDtRundKH9kam746i2TBu
P9sfb3QVi5QqfK+bek8DAQgHiH4EGBYKACYWIQR9BS8nNHwqrNgV0B3NE0dCwel5
WQUCZTfvngIbDAUJEswDAAAKCRDNE0dCwel5WWwSAQDj4ZAl6bSqwbcptEMYQaPM
MMhMafm446MjkhQioeXw+wEAzA8mS6RBx7IZvu1dirmFHXOEYJclwjyQhNs4uEjq
/Ak=
=ICHe
-----END PGP PUBLIC KEY BLOCK-----"""
const val PUBLIC_KEY_FINGERPRINT = "7D05 2F27 347C 2AAC D815 D01D CD13 4742 C1E9 7959"
@OptIn(ExperimentalMaterial3Api::class)
@Composable
@ -232,92 +219,9 @@ fun AboutScreen(
)
}
var donationsOpened by rememberSaveable {
mutableStateOf(false)
}
val donationLabel = stringResource(R.string.ui_about_contribute_donatation)
Row(
modifier = Modifier
.fillMaxWidth()
.clip(MaterialTheme.shapes.medium)
.semantics {
contentDescription = donationLabel
}
.clickable {
donationsOpened = !donationsOpened
}
.background(
MaterialTheme.colorScheme.surfaceVariant
)
.padding(16.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Icon(
listOf(
Icons.Default.CurrencyBitcoin,
Icons.Default.CurrencyFranc,
Icons.Default.CurrencyLira,
Icons.Default.CurrencyPound,
Icons.Default.CurrencyRuble,
Icons.Default.CurrencyRupee,
Icons.Default.CurrencyYen,
Icons.Default.CurrencyYuan,
).asSequence().shuffled().first(),
contentDescription = null,
modifier = Modifier.size(ButtonDefaults.IconSize.times(1.2f))
)
Text(
stringResource(R.string.ui_about_contribute_donatation),
fontWeight = FontWeight.Bold,
)
}
DonationsTile()
Column(
modifier = Modifier
.fillMaxWidth()
.clip(MaterialTheme.shapes.medium)
.background(
MaterialTheme.colorScheme.primaryContainer
)
.padding(16.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(16.dp),
) {
Icon(
Icons.Default.Key,
contentDescription = null,
modifier = Modifier.size(48.dp)
)
Text(
stringResource(R.string.ui_about_gpg_key_hint),
style = MaterialTheme.typography.bodyMedium,
)
val clipboardManager =
LocalContext.current.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
Text(
PUBLIC_KEY_FINGERPRINT,
modifier = Modifier
.clip(MaterialTheme.shapes.small)
.background(
MaterialTheme.colorScheme.surfaceVariant
)
.padding(8.dp),
)
Button(
onClick = {
val clip = ClipData.newPlainText("text", PUBLIC_KEY)
clipboardManager.setPrimaryClip(clip)
},
colors = ButtonDefaults.textButtonColors(),
modifier = Modifier
.fillMaxWidth()
) {
Text(stringResource(R.string.ui_about_gpg_key_copy))
}
}
GPGKeyOverview()
}
}
}