Skip to content

Commit

Permalink
Add contributors list
Browse files Browse the repository at this point in the history
  • Loading branch information
DeKaN committed Oct 3, 2023
1 parent 798df34 commit d4ef372
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.lorenzovainigli.foodexpirationdates.model

class Contributor(
val name: String,
val username: String
)

val contributors = listOf(
Contributor("Lorenzo Vainigli", "lorenzovngl"),
Contributor("Abdul Muizz", "abdulmuizz0903"),
Contributor("Steve", "uDEV2019"),
Contributor("Devpreyo Roy", "devedroy"),
Contributor("Quadropo", "Quadropo"),
Contributor("Bhavesh Kumawat", "bhavesh100"),
Contributor("Richard", "Rick-AB"),
)
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
Expand All @@ -42,6 +43,7 @@ import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import com.lorenzovainigli.foodexpirationdates.BuildConfig
import com.lorenzovainigli.foodexpirationdates.R
import com.lorenzovainigli.foodexpirationdates.model.contributors
import com.lorenzovainigli.foodexpirationdates.model.repository.PreferencesRepository
import com.lorenzovainigli.foodexpirationdates.ui.theme.FoodExpirationDatesTheme
import com.lorenzovainigli.foodexpirationdates.view.composable.MyTopAppBar
Expand All @@ -68,6 +70,8 @@ fun InfoActivityLayout(
PreferencesRepository.Companion.ThemeMode.DARK.ordinal -> true
else -> isSystemInDarkTheme()
}
val features = stringArrayResource(id = R.array.features)
.joinToString(separator = "\n") { it.asListItem() }
FoodExpirationDatesTheme(
darkTheme = isInDarkTheme,
dynamicColor = dynamicColorsState
Expand Down Expand Up @@ -147,13 +151,9 @@ fun InfoActivityLayout(
style = MaterialTheme.typography.headlineMedium,
textAlign = TextAlign.Center
)
val sb = StringBuilder()
stringArrayResource(id = R.array.features).map {
sb.append("").append(it).append("\n")
}
Text(
modifier = Modifier.fillMaxWidth(),
text = sb.toString()
text = features
)
/*TextIconButton(
modifier = Modifier.align(CenterHorizontally),
Expand All @@ -164,6 +164,7 @@ fun InfoActivityLayout(
contentDescription = "Star",
text = stringResource(id = R.string.report_a_bug)
)*/
ContributorsList()
Text(
modifier = Modifier.padding(top = 16.dp),
text = stringResource(id = R.string.support_this_project),
Expand Down Expand Up @@ -229,10 +230,47 @@ fun InfoActivityLayout(
}
}

@Composable
fun ContributorsList(
modifier: Modifier = Modifier
) {
val contributorsText = remember {
contributors.joinToString(separator = "\n") {
"${it.name} (@${it.username})".asListItem()
}
}
Column(modifier = modifier.fillMaxWidth()) {
Text(
modifier = Modifier.padding(top = 16.dp),
text = stringResource(id = R.string.contributors_list_title),
style = MaterialTheme.typography.headlineMedium,
textAlign = TextAlign.Center
)
Text(
modifier = Modifier.fillMaxWidth(),
text = stringResource(id = R.string.contributors_list_subtitle)
)
Text(
modifier = Modifier.fillMaxWidth(),
text = contributorsText
)
}
}

private fun String.asListItem() = "$this"

@DefaultPreviews
@DevicePreviews
@LanguagePreviews
@Composable
fun InfoActivityLayoutPreview() {
InfoActivityLayout()
}
}

@DefaultPreviews
@DevicePreviews
@LanguagePreviews
@Composable
fun ContributorsListPreview() {
ContributorsList()
}
4 changes: 3 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<string name="app_description">%1$s is an open source project developed by Lorenzo Vainigli and other contributors.\nThe code of this application is published under the MIT license and available on GitHub.</string>
<string name="about_this_app">About this app</string>
<string name="privacy_policy">Privacy policy</string>
<string name="contributors_list_title">Contributors</string>
<string name="contributors_list_subtitle">Thanks to these awesome people for contributing to the development of this app.</string>
<string name="back">Back</string>
<string name="no_items_found">No items found</string>
<string name="please_insert_one">Please insert one</string>
Expand Down Expand Up @@ -67,4 +69,4 @@
<item>Mushrooms</item>
<item>Tomatoes</item>
</string-array>
</resources>
</resources>

0 comments on commit d4ef372

Please sign in to comment.