Skip to content

Commit

Permalink
Merge pull request #74 from odaridavid/library-into
Browse files Browse the repository at this point in the history
Add about section + 3rd party libraries screen
  • Loading branch information
odaridavid authored Mar 9, 2024
2 parents 5fa08d7 + c53e785 commit 9e16b11
Show file tree
Hide file tree
Showing 11 changed files with 100 additions and 23 deletions.
14 changes: 11 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ plugins {
id("com.google.firebase.crashlytics")
id("io.gitlab.arturbosch.detekt")
jacoco
id("com.google.firebase.firebase-perf")
alias(libs.plugins.firebase.perf.plugin)
alias(libs.plugins.about.lib.plugin)
}

jacoco {
Expand Down Expand Up @@ -77,9 +78,12 @@ fun setupAndroidReporting() {
"**/*Activity*",
"**/di/**",
"**/hilt*/**",
// TODO Remove once UI and instrumented tests are added
"**/entrypoint/**",
"**/designsystem/**",
"**/*Screen*.*"
"**/*Screen*.*",
"**/*NavGraph*.*",
"**/*Destinations*.*"
)

val javaTree = fileTree("${project.buildDir}/intermediates/javac/$sourceName/classes") {
Expand Down Expand Up @@ -167,7 +171,7 @@ android {

dependencies {

implementation (project(":shared"))
implementation(project(":shared"))
// Jetpack Core
implementation(libs.bundles.androidx)
implementation(platform(libs.compose.bom))
Expand Down Expand Up @@ -213,6 +217,10 @@ dependencies {

// In-app update
implementation(libs.bundles.google.play)

// About
implementation(libs.about.lib.core)
implementation(libs.about.lib.compose.ui)
}

kapt {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,17 @@ fun HomeTopBar(cityName: String, onSettingClicked: () -> Unit) {
}

@Composable
fun SettingsTopBar(onBackButtonClicked: () -> Unit) {
fun TopNavigationBar(onBackButtonClicked: () -> Unit, title: String) {
Row(modifier = Modifier.padding(16.dp)) {
IconWithAction(
painter = painterResource(id = R.drawable.ic_arrow_back),
contentDescription = stringResource(R.string.settings_content_description_icon),
modifier = Modifier
.padding(8.dp),
contentDescription = stringResource(R.string.back_button_content_description_icon),
modifier = Modifier.padding(8.dp),
onClicked = { onBackButtonClicked() }
)

MenuHeadline(
text = stringResource(R.string.settings_screen_title),
text = title,
modifier = Modifier.align(Alignment.CenterVertically)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import androidx.compose.ui.unit.dp
@Composable
fun SettingOptionRow(
optionLabel: String,
optionValue: String,
optionValue: String? = null,
@DrawableRes optionIcon: Int,
optionIconContentDescription: String,
modifier: Modifier = Modifier,
Expand All @@ -40,10 +40,13 @@ fun SettingOptionRow(
modifier = Modifier.padding(8.dp)
)
Spacer(modifier = Modifier.weight(1.0f))
Text(
text = optionValue,
style = MaterialTheme.typography.body1,
modifier = Modifier.padding(8.dp)
)

optionValue?.let {
Text(
text = it,
style = MaterialTheme.typography.body1,
modifier = Modifier.padding(8.dp)
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import com.github.odaridavid.weatherapp.ui.about.AboutScreen
import com.github.odaridavid.weatherapp.ui.home.HomeScreen
import com.github.odaridavid.weatherapp.ui.home.HomeScreenIntent
import com.github.odaridavid.weatherapp.ui.home.HomeViewModel
Expand Down Expand Up @@ -46,7 +47,7 @@ fun WeatherAppScreensConfig(

SettingsScreen(
state = state,
onBackButtonClicked = { navController.navigate(Destinations.HOME.route) },
onBackButtonClicked = { navController.navigateUp() },
onLanguageChanged = { selectedLanguage ->
settingsViewModel.processIntent(
SettingsScreenIntent.ChangeLanguage(
Expand All @@ -61,13 +62,22 @@ fun WeatherAppScreensConfig(
settingsViewModel.processIntent(
SettingsScreenIntent.ChangeTimeFormat(selectedFormat)
)
},
onAboutClicked = {
navController.navigate(Destinations.ABOUT.route)
}
)
}
composable(Destinations.ABOUT.route) {
AboutScreen {
navController.navigateUp()
}
}
}
}

enum class Destinations(val route: String) {
HOME("home"),
SETTINGS("settings")
SETTINGS("settings"),
ABOUT("about")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.github.odaridavid.weatherapp.ui.about

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import com.github.odaridavid.weatherapp.R
import com.github.odaridavid.weatherapp.designsystem.TopNavigationBar
import com.mikepenz.aboutlibraries.ui.compose.m3.LibrariesContainer

@Composable
fun AboutScreen(
onBackButtonClicked: () -> Unit,
) {
Column {
TopNavigationBar(
onBackButtonClicked = onBackButtonClicked,
title = stringResource(R.string.about_screen_title),
)

LibrariesContainer(
Modifier.fillMaxSize()
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.github.odaridavid.weatherapp.R
import com.github.odaridavid.weatherapp.designsystem.SettingOptionRow
import com.github.odaridavid.weatherapp.designsystem.SettingOptionRadioButton
import com.github.odaridavid.weatherapp.designsystem.SettingOptionRow
import com.github.odaridavid.weatherapp.designsystem.SettingOptionsDialog
import com.github.odaridavid.weatherapp.designsystem.SettingsTopBar
import com.github.odaridavid.weatherapp.designsystem.TopNavigationBar
import com.github.odaridavid.weatherapp.designsystem.VersionInfoText
import com.github.odaridavid.weatherapp.core.model.TimeFormat

@Composable
fun SettingsScreen(
Expand All @@ -26,9 +25,13 @@ fun SettingsScreen(
onLanguageChanged: (String) -> Unit,
onUnitChanged: (String) -> Unit,
onTimeFormatChanged: (String) -> Unit,
onAboutClicked: () -> Unit,
) {
Column {
SettingsTopBar(onBackButtonClicked)
TopNavigationBar(
onBackButtonClicked = onBackButtonClicked,
title = stringResource(R.string.settings_screen_title),
)

val openLanguageSelectionDialog = remember { mutableStateOf(false) }
SettingOptionRow(
Expand All @@ -54,7 +57,7 @@ fun SettingsScreen(
SettingOptionRow(
optionLabel = stringResource(R.string.settings_time_format),
optionValue = state.selectedTimeFormat,
optionIcon = R.drawable.baseline_access_time_24,
optionIcon = R.drawable.ic_time_24,
optionIconContentDescription = stringResource(R.string.settings_content_description_time_icon)
) {
openTimeFormatSelectionDialog.value = openTimeFormatSelectionDialog.value.not()
Expand Down Expand Up @@ -117,6 +120,14 @@ fun SettingsScreen(
}
}

SettingOptionRow(
optionLabel = stringResource(R.string.settings_about),
optionIcon = R.drawable.ic_info_24,
optionIconContentDescription = stringResource(R.string.settings_content_description_about_icon)
) {
onAboutClicked()
}

Spacer(modifier = Modifier.weight(1.0f))

VersionInfoText(
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_info_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">

<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z"/>

</vector>
File renamed without changes.
7 changes: 6 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@
<string name="home_error_try_again">Try Again</string>
<!-- Settings Screen-->
<string name="settings_screen_title">Settings</string>
<string name="settings_content_description_icon">Setting Icon</string>
<string name="back_button_content_description_icon">Back Button</string>
<string name="settings_language_label">Language</string>
<string name="settings_unit_label">Units</string>
<string name="settings_time_format">Time Format</string>
<string name="settings_about">About</string>
<string name="settings_content_description_lang_icon">Language Icon</string>
<string name="settings_content_description_unit_icon">Units Icon</string>
<string name="settings_content_description_time_icon">Time Icon</string>
<string name="settings_content_description_about_icon">About Icon</string>
<string name="settings_confirm">Confirm</string>

<!-- About Screen-->
<string name="about_screen_title">About</string>

<!-- Permissions-->
<string name="location_rationale_title">Permission Request</string>
<string name="location_rationale_description">Hey there, we need location permission to show you relevant / accurate weather information.</string>
Expand Down
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ plugins {
alias(libs.plugins.dagger.hilt.android) apply false
alias(libs.plugins.org.jetbrains.kotlin.plugin.serialization) apply false
alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.about.lib.plugin) apply false
alias(libs.plugins.firebase.perf.plugin) apply false
// TODO Move some of these to toml file
id("com.github.ben-manes.versions") version "0.41.0"
id("nl.littlerobots.version-catalog-update") version "0.8.4"
id("io.gitlab.arturbosch.detekt") version "1.23.3"
id("org.jlleitschuh.gradle.ktlint") version "12.1.0"
id("com.google.firebase.firebase-perf") version "1.4.2" apply false
}

buildscript {
Expand Down
9 changes: 9 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ turbine = "1.0.0"
leakcanary = "3.0-alpha-1"
#InAppUpdate
inappupdate = "2.1.0"
#About
about-lib = "11.1.0"
firebase-perf = "1.4.2"

[libraries]
activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity-compose" }
Expand Down Expand Up @@ -92,8 +95,12 @@ retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit
truth = { module = "com.google.truth:truth", version.ref = "truth" }
turbine = { module = "app.cash.turbine:turbine", version.ref = "turbine" }
leakcanary = { module = "com.squareup.leakcanary:leakcanary-android", version.ref = "leakcanary" }
#InAppUpdate
inapp-update = { module = "com.google.android.play:app-update", version.ref = "inappupdate" }
inapp-update-ktx = { module = "com.google.android.play:app-update-ktx", version.ref = "inappupdate" }
#About
about-lib-core = { module = "com.mikepenz:aboutlibraries-core", version.ref = "about-lib" }
about-lib-compose-ui = { module = "com.mikepenz:aboutlibraries-compose-m3", version.ref = "about-lib" }

[plugins]
com-android-application = { id = "com.android.application", version.ref = "android-gradle-plugin" }
Expand All @@ -105,6 +112,8 @@ org-jetbrains-kotlin-plugin-serialization = { id = "org.jetbrains.kotlin.plugin.
#Multiplatform
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlinCocoapods = { id = "org.jetbrains.kotlin.native.cocoapods", version.ref = "kotlin" }
about-lib-plugin = { id = "com.mikepenz.aboutlibraries.plugin", version.ref = "about-lib" }
firebase-perf-plugin = { id = "com.google.firebase.firebase-perf", version.ref = "firebase-perf" }

[bundles]
androidx = [
Expand Down

0 comments on commit 9e16b11

Please sign in to comment.