Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Android CI

on:
push:
branches: [ "master" ]
branches: [ "main" ]
pull_request:
branches: [ "master" ]
branches: [ "main" ]

jobs:
build:
Expand Down
5 changes: 4 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
alias(libs.plugins.androidApp)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.ksp)
alias(libs.plugins.hilt)
alias(libs.plugins.kotlin.parcelize)
Expand Down Expand Up @@ -59,7 +60,8 @@ dependencies {
implementation project(path: ':data:geocoding')
implementation project(path: ':data:weather')
implementation project(path: ':data:location')
implementation project(path: ':presentation')
implementation project(path: ':ui:common')
implementation project(path: ':feature:cityforecast')

// di
implementation libs.hilt.android
Expand All @@ -68,6 +70,16 @@ dependencies {
// logging
implementation libs.timber

// compose
implementation platform(libs.compose.bom)
implementation libs.compose
implementation libs.compose.material3
implementation libs.compose.icons.extended

// navigation
implementation libs.navigation
implementation libs.navigation.compose

// testing
testImplementation libs.junit
androidTestImplementation libs.androidx.test.ext.junit
Expand Down
13 changes: 12 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.RickMortyChars"
android:usesCleartextTraffic="true" />
android:usesCleartextTraffic="true" >

<activity
android:name="io.chthonic.weather.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.chthonic.weather.presentation
package io.chthonic.weather

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.fillMaxSize
Expand All @@ -18,8 +18,15 @@ import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import io.chthonic.weather.presentation.theme.AppColors
import io.chthonic.weather.ui.common.AppBarStyle
import io.chthonic.weather.ui.common.rememberAppContainerState
import io.chthonic.weather.ui.common.theme.AppColors

/**
* Root composable that assembles the app shell — scaffold, app bar, snackbar host,and navigation host.
* Note, [io.chthonic.weather.ui.common.AppContainerState], that lives in module :ui:common, allows modules to update AppContainer's UI
* elements such as the app bar title, navigation icon, and actions — without depending on :app.
*/
@Composable
@OptIn(ExperimentalMaterial3Api::class)
fun AppContainer() {
Expand Down
40 changes: 40 additions & 0 deletions app/src/main/java/io/chthonic/weather/AppContainerNav.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package io.chthonic.weather

import androidx.compose.animation.ExperimentalSharedTransitionApi
import androidx.compose.animation.SharedTransitionLayout
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.compose.NavHost
import io.chthonic.weather.feature.cityforecast.CityForecastDestination
import io.chthonic.weather.feature.cityforecast.cityForecastNavGraph
import io.chthonic.weather.ui.common.AppContainerState

/**
* Wires the nav graph and connects each destination to its screen composable.
*
* Note, In this implementation features have zero knowledge of each other
* and only expose callback to the NavHost describing the intent.
* e.g., navigate from the City Air Quality feature's screen to the City Forecast feature's screen:
* `cityAirQualityNavGraph(
* appContainerState = appContainerState,
* onNavigateToCityForecast = { lat, lon, name ->
* appContainerState.navController.navigate(
* CityForecastDestination.CityDetail.buildUniqueRoute(lat, lon, name)
* )
* }
* )`
*/
@OptIn(ExperimentalSharedTransitionApi::class)
@Composable
fun AppContainerNavHost(
appContainerState: AppContainerState,
modifier: Modifier,
) = SharedTransitionLayout(modifier = modifier) {
NavHost(
navController = appContainerState.navController,
startDestination = CityForecastDestination.CityList.route,
modifier = Modifier,
) {
cityForecastNavGraph(appContainerState)
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package io.chthonic.weather.presentation
package io.chthonic.weather

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.isSystemInDarkTheme
import dagger.hilt.android.AndroidEntryPoint
import io.chthonic.weather.presentation.theme.AppTheme
import io.chthonic.weather.ui.common.theme.AppTheme

@AndroidEntryPoint
class MainActivity : ComponentActivity() {
Expand Down

This file was deleted.

This file was deleted.

File renamed without changes.
19 changes: 7 additions & 12 deletions presentation/build.gradle → feature/cityforecast/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

android {
namespace 'io.chthonic.weather.presentation'
namespace 'io.chthonic.weather.feature.cityforecast'
compileSdk versions.targetSdk

defaultConfig {
Expand All @@ -16,17 +16,11 @@ android {
consumerProguardFiles "consumer-rules.pro"
}

viewBinding {
enabled = true
}
buildFeatures {
compose true
}
lint {
targetSdk 36
}
testOptions {
targetSdk 36
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}

Expand All @@ -37,6 +31,7 @@ kotlin {
dependencies {
implementation libs.androidx.core
implementation project(path: ':common')
implementation project(path: ':ui:common')
implementation project(path: ':domain:presentationapi')

// di
Expand Down
4 changes: 4 additions & 0 deletions feature/cityforecast/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.chthonic.weather.presentation.nav
package io.chthonic.weather.feature.cityforecast

import android.net.Uri
import android.os.Bundle
Expand All @@ -10,19 +10,29 @@ private const val LOC_LAT_ARG: String = "lat"
private const val LOC_LON_ARG: String = "lon"
private const val LOC_NAME_ARG: String = "name"

sealed class Destination(val route: String, val arguments: List<NamedNavArgument> = emptyList()) {

data object LocationList : Destination(route = "locations")

data object LocationDetail :
Destination(
/**
* Navigation destinations supported by the City Forecast feature:
* [CityList] - Displays the current weather of user's location and a list of cities resulting from a search query.
* [CityDetail] - Displays a week's weather for a city/location.
*
* Can navigate destination using [io.chthonic.weather.ui.common.AppContainerState.navController], e.g.:
* `appContainerState.navController.navigate(CityForecastDestination.CityDetail.route)`
*/
sealed class CityForecastDestination(
val route: String,
val arguments: List<NamedNavArgument> = emptyList()
) {

data object CityList : CityForecastDestination(route = "locations")

data object CityDetail :
CityForecastDestination(
route = "location/{$LOC_NAME_ARG}/{$LOC_LAT_ARG}/{$LOC_LON_ARG}",
arguments = listOf(
navArgument(LOC_NAME_ARG) { type = NavType.StringType },
navArgument(LOC_LAT_ARG) { type = NavType.StringType },
navArgument(LOC_LON_ARG) { type = NavType.StringType },

)
)
) {

fun buildUniqueRoute(name: String, lat: Double, lon: Double): String =
Expand Down
Loading
Loading