From 8ac27ad03ba15195d0fcfe016a319e625e82b4c6 Mon Sep 17 00:00:00 2001 From: Hieu Vu Date: Sat, 14 Sep 2024 10:17:40 +0700 Subject: [PATCH] Update About screen with components from Ark-android (#108) * Replace About screen with one from Ark-android * Upgrade libraries * Fix linting * Remove unused resources * Revert changes related to launcher * Upgrade about module and use modifier --- app/build.gradle | 35 +- .../rate/presentation/settings/AboutScreen.kt | 307 +----------------- .../main/res/drawable/currency_exchange.xml | 5 - .../main/res/drawable/ic_delete_outline.xml | 5 - app/src/main/res/drawable/ic_duplicate.xml | 13 - app/src/main/res/drawable/ic_list.xml | 5 - app/src/main/res/drawable/ic_list_alt.xml | 5 - .../main/res/drawable/ic_question_mark.xml | 5 - app/src/main/res/drawable/ic_refresh.xml | 13 - app/src/main/res/drawable/ic_settings.xml | 5 - app/src/main/res/drawable/ic_sort.xml | 13 - .../res/mipmap-anydpi-v26/ic_launcher.xml | 2 +- .../ic_launcher_debug_round.xml | 2 +- app/src/main/res/values/colors.xml | 8 +- app/src/main/res/values/strings.xml | 5 - settings.gradle | 8 + 16 files changed, 36 insertions(+), 400 deletions(-) delete mode 100644 app/src/main/res/drawable/currency_exchange.xml delete mode 100644 app/src/main/res/drawable/ic_delete_outline.xml delete mode 100644 app/src/main/res/drawable/ic_duplicate.xml delete mode 100644 app/src/main/res/drawable/ic_list.xml delete mode 100644 app/src/main/res/drawable/ic_list_alt.xml delete mode 100644 app/src/main/res/drawable/ic_question_mark.xml delete mode 100644 app/src/main/res/drawable/ic_refresh.xml delete mode 100644 app/src/main/res/drawable/ic_settings.xml delete mode 100644 app/src/main/res/drawable/ic_sort.xml diff --git a/app/build.gradle b/app/build.gradle index 0fde4de87..deb9afdca 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -94,22 +94,23 @@ dependencies { implementation project(':fiaticons') implementation project(':cryptoicons') - implementation "androidx.compose.ui:ui:1.5.4" - implementation "androidx.navigation:navigation-compose:2.7.5" - implementation "androidx.compose.material3:material3:1.2.0" - implementation "androidx.compose.ui:ui-tooling-preview:1.5.4" - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' - implementation 'androidx.activity:activity-compose:1.8.1' + implementation "dev.arkbuilders.components:about:0.1.1" + implementation "androidx.compose.ui:ui:1.6.8" + implementation "androidx.navigation:navigation-compose:2.7.7" + implementation "androidx.compose.material3:material3:1.2.1" + implementation "androidx.compose.ui:ui-tooling-preview:1.6.8" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.4' + implementation 'androidx.activity:activity-compose:1.9.1' implementation "androidx.constraintlayout:constraintlayout-compose:1.0.1" implementation "com.google.dagger:dagger:2.50" ksp "com.google.dagger:dagger-compiler:2.50" - implementation "androidx.room:room-runtime:2.6.0" + implementation "androidx.room:room-runtime:2.6.1" implementation "androidx.room:room-ktx:2.6.1" - ksp "androidx.room:room-compiler:2.6.0" + ksp "androidx.room:room-compiler:2.6.1" - implementation "androidx.datastore:datastore-preferences:1.0.0" + implementation "androidx.datastore:datastore-preferences:1.1.1" implementation 'com.jakewharton.timber:timber:5.0.1' @@ -117,7 +118,7 @@ dependencies { implementation 'io.github.oleksandrbalan:tagcloud:1.1.0' implementation("org.orbit-mvi:orbit-compose:4.6.1") - implementation("org.orbit-mvi:orbit-viewmodel:4.6.1") + implementation("org.orbit-mvi:orbit-viewmodel:6.1.0") implementation("io.arrow-kt:arrow-core:1.2.1") implementation("io.arrow-kt:arrow-fx-coroutines:1.2.1") @@ -127,20 +128,20 @@ dependencies { implementation("io.github.raamcosta.compose-destinations:animations-core:1.9.62") ksp 'io.github.raamcosta.compose-destinations:ksp:1.9.62' - implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.retrofit2:retrofit:2.11.0' implementation 'com.squareup.retrofit2:converter-gson:2.9.0' implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0' - implementation(platform("com.google.firebase:firebase-bom:33.1.0")) + implementation(platform("com.google.firebase:firebase-bom:33.1.2")) implementation("com.google.firebase:firebase-analytics-ktx") implementation("com.google.firebase:firebase-crashlytics-ktx") testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.5.4" - debugImplementation "androidx.compose.ui:ui-tooling:1.5.4" - debugImplementation "androidx.compose.ui:ui-test-manifest:1.5.4" + androidTestImplementation 'androidx.test.ext:junit:1.2.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' + androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.6.8" + debugImplementation "androidx.compose.ui:ui-tooling:1.6.8" + debugImplementation "androidx.compose.ui:ui-test-manifest:1.6.8" } ktlint { diff --git a/app/src/main/java/dev/arkbuilders/rate/presentation/settings/AboutScreen.kt b/app/src/main/java/dev/arkbuilders/rate/presentation/settings/AboutScreen.kt index 806cb89f0..1b46a4a10 100644 --- a/app/src/main/java/dev/arkbuilders/rate/presentation/settings/AboutScreen.kt +++ b/app/src/main/java/dev/arkbuilders/rate/presentation/settings/AboutScreen.kt @@ -1,45 +1,16 @@ package dev.arkbuilders.rate.presentation.settings -import androidx.compose.foundation.BorderStroke -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.PaddingValues -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.foundation.shape.RoundedCornerShape -import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.Icon -import androidx.compose.material3.OutlinedButton import androidx.compose.material3.Scaffold -import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -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.graphics.Color -import androidx.compose.ui.graphics.painter.Painter -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator +import dev.arkbuilders.components.about.presentation.ArkAbout import dev.arkbuilders.rate.BuildConfig import dev.arkbuilders.rate.R -import dev.arkbuilders.rate.presentation.theme.ArkColor -import dev.arkbuilders.rate.presentation.ui.AppHorDiv import dev.arkbuilders.rate.presentation.ui.AppTopBarBack -import dev.arkbuilders.rate.presentation.utils.openLink @Destination @Composable @@ -49,276 +20,12 @@ fun AboutScreen(navigator: DestinationsNavigator) { AppTopBarBack(title = stringResource(R.string.about), navigator) }, ) { - Box(modifier = Modifier.padding(it)) { - Content(navigator) - } - } -} - -@Composable -private fun Content(navigator: DestinationsNavigator) { - val ctx = LocalContext.current - - var btcDialogVisible by remember { mutableStateOf(false) } - var ethDialogVisible by remember { mutableStateOf(false) } - - QRCryptoDialog( - visible = btcDialogVisible, - title = stringResource(R.string.about_donate_btc), - wallet = stringResource(R.string.about_btc_wallet), - fileName = "ArkQrBtc.jpg", - qrBitmap = R.drawable.qr_btc, - ) { - btcDialogVisible = false - } - - QRCryptoDialog( - visible = ethDialogVisible, - title = stringResource(R.string.about_donate_eth), - wallet = stringResource(R.string.about_eth_wallet), - fileName = "ArkQrEth.jpg", - qrBitmap = R.drawable.qr_eth, - ) { - ethDialogVisible = false - } - - Column( - modifier = - Modifier - .verticalScroll(rememberScrollState()), - ) { - Column( - modifier = Modifier.padding(horizontal = 16.dp), - horizontalAlignment = Alignment.CenterHorizontally, - ) { - Icon( - modifier = Modifier.padding(top = 32.dp), - painter = painterResource(id = R.drawable.ic_about_logo), - contentDescription = "", - tint = Color.Unspecified, - ) - Text( - modifier = Modifier.padding(top = 20.dp), - text = stringResource(R.string.app_name), - fontSize = 20.sp, - fontWeight = FontWeight.SemiBold, - color = ArkColor.TextPrimary, - ) - Text( - modifier = Modifier.padding(top = 12.dp), - text = "Version ${BuildConfig.VERSION_NAME}", - color = ArkColor.TextTertiary, - ) - Text( - modifier = Modifier.padding(top = 12.dp), - text = "ARK Builders · Copyright ©2024", - color = ArkColor.TextTertiary, - ) - Row( - modifier = Modifier.padding(top = 12.dp), - verticalAlignment = Alignment.CenterVertically, - ) { - SocialLink( - painterResource(R.drawable.ic_about_site), - text = "Website", - ) { - ctx.openLink(ctx.getString(R.string.ark_website_url)) - } - SocialLink( - painterResource(R.drawable.ic_about_telegram), - text = "Telegram", - ) { - ctx.openLink(ctx.getString(R.string.ark_tg_url)) - } - SocialLink( - painterResource(R.drawable.ic_about_discord), - text = "Discord", - ) { - ctx.openLink(ctx.getString(R.string.ark_discord_url)) - } - } - OutlinedButton( - modifier = - Modifier - .padding(top = 32.dp) - .fillMaxWidth(), - onClick = { ctx.openLink(ctx.getString(R.string.privacy_policy_url)) }, - border = - BorderStroke( - width = 1.dp, - color = ArkColor.BorderSecondary, - ), - shape = RoundedCornerShape(8.dp), - ) { - Text( - text = stringResource(R.string.privacy_policy), - fontWeight = FontWeight.SemiBold, - color = ArkColor.FGSecondary, - ) - Icon( - modifier = Modifier.padding(start = 6.dp), - painter = painterResource(R.drawable.ic_external), - contentDescription = "", - tint = ArkColor.FGSecondary, - ) - } - AppHorDiv(modifier = Modifier.padding(top = 20.dp)) - Column { - Text( - modifier = Modifier.padding(top = 20.dp), - text = stringResource(R.string.about_support_us), - fontSize = 16.sp, - fontWeight = FontWeight.SemiBold, - color = ArkColor.TextPrimary, - ) - Text( - modifier = Modifier.padding(top = 4.dp), - text = - stringResource( - R.string.about_we_greatly_appreciate_every_bit_of_support, - ), - color = ArkColor.TextTertiary, - ) - Row(modifier = Modifier.padding(top = 12.dp)) { - DonateBtn( - modifier = Modifier, - icon = painterResource(dev.arkbuilders.rate.cryptoicons.R.drawable.btc), - text = stringResource(R.string.about_donate_using_btc), - ) { - btcDialogVisible = true - } - DonateBtn( - modifier = Modifier.padding(start = 12.dp), - icon = painterResource(dev.arkbuilders.rate.cryptoicons.R.drawable.eth), - text = stringResource(R.string.about_donate_using_eth), - ) { - ethDialogVisible = true - } - } - Row(modifier = Modifier.padding(top = 12.dp)) { - DonateBtn( - modifier = Modifier, - icon = painterResource(R.drawable.ic_about_patreon), - text = stringResource(R.string.about_donate_on_patreon), - ) { - ctx.openLink(ctx.getString(R.string.about_ark_patreon_url)) - } - DonateBtn( - modifier = Modifier.padding(start = 12.dp), - icon = painterResource(R.drawable.ic_about_coffee), - text = stringResource(R.string.about_buy_as_a_coffee), - ) { - ctx.openLink(ctx.getString(R.string.about_ark_buy_coffee_url)) - } - } - AppHorDiv(modifier = Modifier.padding(top = 20.dp)) - Row(modifier = Modifier.padding(top = 12.dp, bottom = 50.dp)) { - OutlinedButton( - modifier = Modifier, - onClick = { ctx.openLink(ctx.getString(R.string.ark_contribute_url)) }, - border = - BorderStroke( - width = 1.dp, - color = ArkColor.BorderSecondary, - ), - shape = RoundedCornerShape(8.dp), - contentPadding = PaddingValues(0.dp), - ) { - Text( - modifier = Modifier.padding(8.dp), - text = stringResource(R.string.about_discover_issues_to_work_on), - color = ArkColor.TextSecondary, - fontSize = 12.sp, - fontWeight = FontWeight.Medium, - ) - } - OutlinedButton( - modifier = Modifier.padding(start = 12.dp), - onClick = { }, - border = - BorderStroke( - width = 1.dp, - color = ArkColor.BorderSecondary, - ), - shape = RoundedCornerShape(8.dp), - contentPadding = PaddingValues(0.dp), - enabled = false, - ) { - Text( - modifier = Modifier.padding(8.dp), - text = stringResource(R.string.about_see_open_bounties), - color = ArkColor.TextPlaceHolder, - fontSize = 12.sp, - fontWeight = FontWeight.Medium, - ) - } - } - } - } - } -} - -@Composable -private fun SocialLink( - painter: Painter, - text: String, - onClick: () -> Unit, -) { - Row( - modifier = - Modifier - .clip(RoundedCornerShape(4.dp)) - .clickable { onClick() } - .padding(horizontal = 4.dp), - verticalAlignment = Alignment.CenterVertically, - ) { - Icon( - modifier = Modifier.size(20.dp), - painter = painter, - contentDescription = text, - tint = Color.Unspecified, - ) - Text( - modifier = Modifier.padding(start = 4.dp), - text = text, - color = ArkColor.TextTertiary, - ) - } -} - -@Composable -private fun DonateBtn( - modifier: Modifier, - icon: Painter, - text: String, - onClick: () -> Unit, -) { - OutlinedButton( - modifier = modifier, - onClick = onClick, - border = - BorderStroke( - width = 1.dp, - color = ArkColor.BorderSecondary, - ), - shape = RoundedCornerShape(8.dp), - contentPadding = PaddingValues(0.dp), - ) { - Icon( - modifier = - Modifier - .padding(start = 8.dp, top = 8.dp, bottom = 8.dp) - .size(20.dp), - painter = icon, - contentDescription = "", - tint = Color.Unspecified, - ) - Text( - modifier = Modifier.padding(start = 8.dp, end = 8.dp), - text = text, - fontSize = 12.sp, - fontWeight = FontWeight.Medium, - color = ArkColor.FGSecondary, + ArkAbout( + modifier = Modifier.padding(it), + appName = stringResource(id = R.string.app_name), + appLogoResId = R.drawable.ic_about_logo, + versionName = BuildConfig.VERSION_NAME, + privacyPolicyUrl = stringResource(R.string.privacy_policy_url), ) } } diff --git a/app/src/main/res/drawable/currency_exchange.xml b/app/src/main/res/drawable/currency_exchange.xml deleted file mode 100644 index d2a8e61db..000000000 --- a/app/src/main/res/drawable/currency_exchange.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_delete_outline.xml b/app/src/main/res/drawable/ic_delete_outline.xml deleted file mode 100644 index ef3664912..000000000 --- a/app/src/main/res/drawable/ic_delete_outline.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_duplicate.xml b/app/src/main/res/drawable/ic_duplicate.xml deleted file mode 100644 index 69b1d1ecc..000000000 --- a/app/src/main/res/drawable/ic_duplicate.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_list.xml b/app/src/main/res/drawable/ic_list.xml deleted file mode 100644 index 7483a9873..000000000 --- a/app/src/main/res/drawable/ic_list.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_list_alt.xml b/app/src/main/res/drawable/ic_list_alt.xml deleted file mode 100644 index 57fd02706..000000000 --- a/app/src/main/res/drawable/ic_list_alt.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_question_mark.xml b/app/src/main/res/drawable/ic_question_mark.xml deleted file mode 100644 index 1d4bf0826..000000000 --- a/app/src/main/res/drawable/ic_question_mark.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_refresh.xml b/app/src/main/res/drawable/ic_refresh.xml deleted file mode 100644 index 001d27cd6..000000000 --- a/app/src/main/res/drawable/ic_refresh.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_settings.xml b/app/src/main/res/drawable/ic_settings.xml deleted file mode 100644 index 298a5a1ff..000000000 --- a/app/src/main/res/drawable/ic_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_sort.xml b/app/src/main/res/drawable/ic_sort.xml deleted file mode 100644 index 338724a94..000000000 --- a/app/src/main/res/drawable/ic_sort.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml index 7353dbd1f..5ed0a2df7 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -2,4 +2,4 @@ - \ No newline at end of file + diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_debug_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_debug_round.xml index 0f0160f91..565aec5f9 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_debug_round.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_debug_round.xml @@ -2,4 +2,4 @@ - \ No newline at end of file + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index f8c6127d3..b8acf28a8 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -1,10 +1,4 @@ - #FFBB86FC - #FF6200EE - #FF3700B3 - #FF03DAC5 - #FF018786 - #FF000000 #FFFFFFFF - \ No newline at end of file + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c582f2308..1a36d6cc1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -5,10 +5,6 @@ The total market value of a cryptocurrency\'s circulating supply.\n\nIt is analogous to the free-float capitalization in the stock market.\n\nCap = Current Price x Circulating Supply. Currency in circulation refers to the amount of cash–in the form of paper notes or coins–within a country that is physically used to conduct transactions between consumers and businesses. - Sorry, the application crashed. Please send a report to the developers. - Crash - You can add a comment here: - Portfolios Alerts Quick @@ -67,7 +63,6 @@ Crash reports All currencies - OK Oops! Something went wrong diff --git a/settings.gradle b/settings.gradle index b591e240b..7921fd28b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -14,6 +14,14 @@ dependencyResolutionManagement { mavenCentral() maven { url "https://jitpack.io" } jcenter() + maven { + name = "GitHubPackages" + url = "https://maven.pkg.github.com/ARK-Builders/arklib-android" + credentials { + username = "token" + password = "\u0037\u0066\u0066\u0036\u0030\u0039\u0033\u0066\u0032\u0037\u0033\u0036\u0033\u0037\u0064\u0036\u0037\u0066\u0038\u0030\u0034\u0039\u0062\u0030\u0039\u0038\u0039\u0038\u0066\u0034\u0066\u0034\u0031\u0064\u0062\u0033\u0064\u0033\u0038\u0065" + } + } } } rootProject.name = "arkrate"