Skip to content

Commit

Permalink
Update About screen with components from Ark-android (#108)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
hieuwu authored Sep 14, 2024
1 parent e885fee commit 8ac27ad
Show file tree
Hide file tree
Showing 16 changed files with 36 additions and 400 deletions.
35 changes: 18 additions & 17 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,30 +94,31 @@ 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'

implementation "androidx.work:work-runtime-ktx:2.8.1"
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")
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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),
)
}
}
Loading

0 comments on commit 8ac27ad

Please sign in to comment.