Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add contributors list #69

Merged
merged 2 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add .padding(top = 16.dp, bottom = 8.dp) here?
The top padding will make it consistent with the other headers and the bottom padding will better separate the sentence from the following list.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

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>
Loading