Skip to content

Commit

Permalink
Added flow screen, bottom navigation, flight & profile tabs, atm stubs.
Browse files Browse the repository at this point in the history
  • Loading branch information
nassdk committed Jan 5, 2022
1 parent fbf653c commit 4f7d270
Show file tree
Hide file tree
Showing 50 changed files with 691 additions and 37 deletions.
3 changes: 3 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ dependencies {
implementation(dependencyNotation = core.common)

implementation(dependencyNotation = feature.splash)
implementation(dependencyNotation = feature.flow)
implementation(dependencyNotation = feature.flights)
implementation(dependencyNotation = feature.profile)
}

libs.run {
Expand Down
17 changes: 1 addition & 16 deletions app/src/main/java/com/nassdk/aero/AppActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import androidx.activity.compose.setContent
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material.Surface
import androidx.compose.runtime.SideEffect
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import com.nassdk.ui.theme.AeroTheme
import com.nassdk.ui.theme.FlightAeroTheme
import com.nassdk.ui.theme.White_F1F1F1
import javax.inject.Inject

class AppActivity : ComponentActivity() {
Expand All @@ -24,21 +21,9 @@ class AppActivity : ComponentActivity() {

setContent {

val isDarkMode = isSystemInDarkTheme()

FlightAeroTheme(
darkTheme = isDarkMode,
darkTheme = isSystemInDarkTheme(),
content = {
val systemUiController = rememberSystemUiController()

SideEffect(
effect = {
systemUiController.setSystemBarsColor(
color = if (isDarkMode) White_F1F1F1 else White_F1F1F1
)
}
)

Surface(
color = AeroTheme.colors.primaryBackground,
content = {
Expand Down
37 changes: 35 additions & 2 deletions app/src/main/java/com/nassdk/aero/AppGraph.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import com.google.accompanist.navigation.animation.rememberAnimatedNavController
import com.nassdk.aero.mediators.MediatorManager
import com.nassdk.common.extensions.aeroComposable
import com.nassdk.common.extensions.composeViewModel
import com.nassdk.flights.presentation.FlightsScreen
import com.nassdk.flow.presentation.FlowScreen
import com.nassdk.navigation.Screens
import com.nassdk.navigation.TransitionType
import com.nassdk.profile.ProfileScreen
import com.nassdk.splash.presentation.SplashScreen

@ExperimentalAnimationApi
Expand All @@ -22,14 +26,43 @@ fun MainGraph() {
builder = {

aeroComposable(
route = Screens.Splash,
target = Screens.Splash,
content = {

val viewModel = composeViewModel {
MediatorManager.splashMediator.getApi().provideViewModel()
}

SplashScreen(viewModel = viewModel)
SplashScreen(viewModel = viewModel, navController = navController)
}
)

aeroComposable(
target = Screens.Flow,
transitionType = TransitionType.NONE,
content = {
FlowScreen(
flowGraphBuilder = {
aeroComposable(
target = Screens.Flights,
transitionType = TransitionType.NONE,
content = {

val viewModel = composeViewModel {
MediatorManager.flightsMediator.getApi().provideViewModel()
}

FlightsScreen(viewModel = viewModel)
}
)

aeroComposable(
target = Screens.Profile,
transitionType = TransitionType.NONE,
content = { ProfileScreen() }
)
}
)
}
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.nassdk.aero.mediators

import com.nassdk.flights.FlightsApi
import com.nassdk.flights.FlightsFeature

class FlightsMediator {

fun getApi(): FlightsApi = FlightsFeature.getApi()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ package com.nassdk.aero.mediators

object MediatorManager {
val splashMediator: SplashMediator by lazy { SplashMediator() }
val flightsMediator: FlightsMediator by lazy { FlightsMediator() }
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
package com.nassdk.common.extensions

fun <T> T?.ifNull(alternative: T): T = this ?: alternative
fun <T> T?.ifNull(alternative: T): T = this ?: alternative
fun <T> T?.ifNull(make: () -> T) {
make()
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ private const val ANIMATION_OFFSET = 1000

@ExperimentalAnimationApi
fun NavGraphBuilder.aeroComposable(
route: NavTarget,
target: NavTarget,
arguments: List<NamedNavArgument> = emptyList(),
deepLinks: List<NavDeepLink> = emptyList(),
transitionType: TransitionType = TransitionType.HORIZONTAL,
content: @Composable AnimatedVisibilityScope.(NavBackStackEntry) -> Unit,
) {
composable(
route = route.route,
route = target.route,
arguments = arguments,
deepLinks = deepLinks,
enterTransition = { getEnterTransition(type = transitionType) },
Expand Down
12 changes: 12 additions & 0 deletions core/navigation/src/main/java/com/nassdk/navigation/Screens.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,16 @@ sealed class Screens {
object Splash : NavTarget {
override val route: String = "splash"
}

object Flow : NavTarget {
override val route: String = "flow"
}

object Flights : NavTarget {
override val route: String = "flights"
}

object Profile : NavTarget {
override val route: String = "profile"
}
}
6 changes: 4 additions & 2 deletions core/ui/src/main/java/com/nassdk/ui/theme/Palette.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ internal val DarkPalette = AeroColors(
primaryBackground = White_F1F1F1,
primaryText = Black,
secondaryText = Gray_979797,
spinnerColor = Orange_FF9A8D
spinnerColor = Orange_FF9A8D,
secondaryBackground = White
)

internal val LightPalette = AeroColors(
primaryBackground = White_F1F1F1,
primaryText = Black,
secondaryText = Gray_979797,
spinnerColor = Orange_FF9A8D
spinnerColor = Orange_FF9A8D,
secondaryBackground = White
)
3 changes: 2 additions & 1 deletion core/ui/src/main/java/com/nassdk/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ data class AeroColors(
val primaryBackground: Color,
val primaryText: Color,
val secondaryText: Color,
val spinnerColor: Color
val spinnerColor: Color,
val secondaryBackground: Color,
)

object AeroTheme {
Expand Down
1 change: 1 addition & 0 deletions feature/flights/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
39 changes: 39 additions & 0 deletions feature/flights/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
plugins {
id("com.android.library")
kotlin(module = "android")
kotlin(module = "kapt")
}

android {
compileSdk = 31

defaultConfig {
minSdk = 23
targetSdk = 31

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

buildFeatures {
compose = true
}

composeOptions {
kotlinCompilerExtensionVersion = "1.0.5"
}

kotlinOptions {
jvmTarget = "1.8"
}
}

dependencies {
implementation(dependencyNotation = projects.core.common)
kapt(dependencyNotation = libs.daggerCompiler)
}
Empty file.
21 changes: 21 additions & 0 deletions feature/flights/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.kts.
#
# For more details, see
# https://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
2 changes: 2 additions & 0 deletions feature/flights/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.nassdk.flights" />
10 changes: 10 additions & 0 deletions feature/flights/src/main/java/com/nassdk/flights/FlightsApi.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.nassdk.flights

import com.nassdk.common.base.BaseViewModel
import com.nassdk.flights.presentation.mvi.FlightsViewEvent
import com.nassdk.flights.presentation.mvi.FlightsViewState

interface FlightsApi {

fun provideViewModel(): BaseViewModel<FlightsViewState, FlightsViewEvent>
}
17 changes: 17 additions & 0 deletions feature/flights/src/main/java/com/nassdk/flights/FlightsApiImpl.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.nassdk.flights

import com.nassdk.common.base.BaseViewModel
import com.nassdk.flights.presentation.FlightsViewModel
import com.nassdk.flights.presentation.mvi.FlightsViewEvent
import com.nassdk.flights.presentation.mvi.FlightsViewState
import javax.inject.Inject
import javax.inject.Provider

class FlightsApiImpl @Inject constructor() : FlightsApi {

@Inject lateinit var viewModelFactory: Provider<FlightsViewModel>

override fun provideViewModel(): BaseViewModel<FlightsViewState, FlightsViewEvent> {
return viewModelFactory.get()
}
}
25 changes: 25 additions & 0 deletions feature/flights/src/main/java/com/nassdk/flights/FlightsFeature.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.nassdk.flights

import androidx.annotation.MainThread
import com.nassdk.flights.di.DaggerFlightsComponent
import com.nassdk.flights.di.FlightsComponent

object FlightsFeature {

private var component: FlightsComponent? = null

@MainThread
fun getApi(): FlightsApi = getComponent().moduleApi()

internal fun getComponent(): FlightsComponent =
component ?: run {

component = DaggerFlightsComponent.factory().create()

requireNotNull(component)
}

internal fun destroyModuleGraph() {
component = null
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.nassdk.flights.di

import com.nassdk.di.scopes.FeatureScope
import com.nassdk.flights.FlightsApi
import dagger.Component

@Component(modules = [FlightsModule::class])
@FeatureScope
interface FlightsComponent {

@Component.Factory
interface Factory {
fun create(): FlightsComponent
}

fun moduleApi(): FlightsApi
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.nassdk.flights.di

import com.nassdk.di.scopes.FeatureScope
import com.nassdk.flights.FlightsApi
import com.nassdk.flights.FlightsApiImpl
import dagger.Binds
import dagger.Module

@Module
interface FlightsModule {

@Binds
@FeatureScope
fun bindModuleApi(impl: FlightsApiImpl): FlightsApi
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.nassdk.flights.presentation

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import com.nassdk.common.base.BaseViewModel
import com.nassdk.flights.presentation.mvi.FlightsViewEvent
import com.nassdk.flights.presentation.mvi.FlightsViewState
import com.nassdk.ui.theme.AeroTheme

@Composable
fun FlightsScreen(viewModel: BaseViewModel<FlightsViewState, FlightsViewEvent>) {

Box(
modifier = Modifier
.fillMaxSize()
.background(color = AeroTheme.colors.primaryBackground),
contentAlignment = Alignment.Center,
content = {
Text(text = "Flights")
}
)
}
Loading

0 comments on commit 4f7d270

Please sign in to comment.