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

dev #13

Merged
merged 8 commits into from
Nov 27, 2023
Merged

dev #13

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
2 changes: 1 addition & 1 deletion .github/workflows/build_app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
build:

runs-on: macos-latest
timeout-minutes: 60
timeout-minutes: 100

steps:

Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ plugins {
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.androidLibrary) apply false
alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.jetbrainsKotlinAndroid) apply false
}
2 changes: 2 additions & 0 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ kotlin {

commonMain.dependencies {
implementation(project(":core:core"))
implementation(project(":core:network"))
implementation(project(":core:ui"))
implementation(project(":feature:feed"))
implementation(project(":feature:film"))
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions composeApp/src/commonMain/kotlin/App.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import androidx.compose.runtime.Composable
import com.stslex.core.core.coreModule
import com.stslex.core.network.di.networkModule
import com.stslex.core.ui.theme.AppTheme
import com.stslex.feature.feed.di.feedModule
import com.stslex.feature.film.di.filmModule
import di.appModule
import org.koin.compose.KoinApplication
import org.koin.dsl.KoinAppDeclaration
Expand Down Expand Up @@ -30,7 +32,9 @@ private fun setupModules(): KoinAppDeclaration = {
listOf(
appModule,
coreModule,
networkModule,
feedModule,
filmModule
)
)
}
6 changes: 2 additions & 4 deletions composeApp/src/commonMain/kotlin/di/appModule.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package di

import navigator.AppNavigatorImpl
import com.stslex.core.ui.navigation.AppNavigator
import navigator.AppNavigatorImpl
import org.koin.dsl.module

val appModule = module {
single<AppNavigator> {
AppNavigatorImpl(
lazyOf(get())
)
AppNavigatorImpl()
}
}
37 changes: 6 additions & 31 deletions composeApp/src/commonMain/kotlin/main_screen/MainScreen.kt
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
package main_screen

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Icon
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import cafe.adriel.voyager.core.screen.Screen
import cafe.adriel.voyager.navigator.tab.CurrentTab
import cafe.adriel.voyager.navigator.tab.LocalTabNavigator
import cafe.adriel.voyager.navigator.tab.Tab
import cafe.adriel.voyager.navigator.tab.TabNavigator
import main_screen.bottom_nav_bar.BottomNavigationBar
import main_screen.bottom_nav_bar.FeedTab

object MainScreen : Screen {

@Composable
override fun Content() {
TabNavigator(FeedTab) {
TabNavigator(
tab = FeedTab,
) { tabNavigator ->
Scaffold(
content = { paddingValues ->
Box(
Expand All @@ -33,31 +30,9 @@ object MainScreen : Screen {
}
},
bottomBar = {
NavigationBar {
TabNavigationItem(FeedTab)
TabNavigationItem(ProfileTab)
}
BottomNavigationBar(tabNavigator)
}
)
}
}
}

@Composable
private fun RowScope.TabNavigationItem(tab: Tab) {
val tabNavigator = LocalTabNavigator.current

NavigationBarItem(
selected = tabNavigator.current == tab,
onClick = { tabNavigator.current = tab },
label = { Text(tab.options.title) },
alwaysShowLabel = false,
icon = {
Icon(
painter = checkNotNull(tab.options.icon),
contentDescription = tab.options.title
)
}
)
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package main_screen.bottom_nav_bar

import androidx.compose.foundation.layout.RowScope
import androidx.compose.material3.Icon
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import cafe.adriel.voyager.navigator.tab.Tab
import cafe.adriel.voyager.navigator.tab.TabNavigator

@Composable
fun BottomNavigationBar(
tabNavigator: TabNavigator,
modifier: Modifier = Modifier,
) {
NavigationBar(
modifier = modifier,
) {
BottomNavigationTabs.entries.forEach { tab ->
TabNavigationItem(
tab = tab.tab,
tabNavigator = tabNavigator
)
}
}
}

@Composable
private fun RowScope.TabNavigationItem(
tab: Tab,
tabNavigator: TabNavigator,
modifier: Modifier = Modifier
) {
NavigationBarItem(
modifier = modifier,
selected = tabNavigator.current == tab,
onClick = {
tabNavigator.current = tab
},
label = { Text(tab.options.title) },
alwaysShowLabel = false,
icon = {
Icon(
painter = checkNotNull(tab.options.icon),
contentDescription = tab.options.title
)
}
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package main_screen.bottom_nav_bar

import cafe.adriel.voyager.navigator.tab.Tab

enum class BottomNavigationTabs(
val tab: Tab
) {
FEED(FeedTab),
PROFILE(ProfileTab)
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package main_screen
package main_screen.bottom_nav_bar

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.List
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import cafe.adriel.voyager.navigator.Navigator
import cafe.adriel.voyager.navigator.tab.Tab
import cafe.adriel.voyager.navigator.tab.TabOptions
import com.stslex.feature.feed.ui.FeedScreenSetup
import cafe.adriel.voyager.transitions.SlideTransition
import com.stslex.feature.feed.ui.FeedScreen

object FeedTab : Tab {

Expand All @@ -28,6 +30,8 @@ object FeedTab : Tab {

@Composable
override fun Content() {
FeedScreenSetup()
Navigator(FeedScreen){
SlideTransition(it)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package main_screen
package main_screen.bottom_nav_bar

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AccountBox
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import cafe.adriel.voyager.core.screen.Screen
import cafe.adriel.voyager.navigator.Navigator
import cafe.adriel.voyager.navigator.tab.Tab
import cafe.adriel.voyager.navigator.tab.TabOptions

Expand All @@ -26,6 +28,14 @@ object ProfileTab : Tab {
}
}

@Composable
override fun Content() {
Navigator(ProfileScreen)
}
}

object ProfileScreen : Screen {

@Composable
override fun Content() {
Text("Profile")
Expand Down
18 changes: 14 additions & 4 deletions composeApp/src/commonMain/kotlin/navigator/AppNavigatorImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,27 @@ package navigator
import cafe.adriel.voyager.navigator.Navigator
import com.stslex.core.ui.navigation.AppNavigator
import com.stslex.core.ui.navigation.AppScreen
import com.stslex.feature.film.ui.FilmScreen
import main_screen.MainScreen

class AppNavigatorImpl(
private val navigator: Lazy<Navigator>
) : AppNavigator {
// TODO NAVIGATION beetwen screens after tab crush application
class AppNavigatorImpl : AppNavigator {

private var _navigator: Navigator? = null
private val navigator: Navigator
get() = requireNotNull(_navigator)

override fun setNavigator(navigator: Navigator) {
_navigator = navigator
}

override fun navigate(
screen: AppScreen
) {
when (screen) {
AppScreen.Main -> navigator.value.push(MainScreen)
AppScreen.Back -> navigator.pop()
AppScreen.Main -> navigator.push(MainScreen)
is AppScreen.Film -> navigator.push(FilmScreen(screen.id))
}
}
}
4 changes: 4 additions & 0 deletions core/core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ kotlin {
api(libs.koin.core)
api(libs.koin.compose)
api(libs.kotlinx.collections.immutable)
api(libs.coroutines.core)
}
androidMain.dependencies {
api(libs.coroutines.android)
}
commonTest.dependencies {
implementation(libs.kotlin.test)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.stslex.core.core

import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.MainCoroutineDispatcher

interface AppDispatcher {
Expand All @@ -10,8 +9,3 @@ interface AppDispatcher {
val default: CoroutineDispatcher
}

class AppDispatcherImpl : AppDispatcher {
override val io: CoroutineDispatcher = Dispatchers.Default // TODO IO
override val main: MainCoroutineDispatcher = Dispatchers.Main
override val default: CoroutineDispatcher = Dispatchers.Default
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.stslex.core.core

import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.IO
import kotlinx.coroutines.MainCoroutineDispatcher

class AppDispatcherImpl : AppDispatcher {
override val io: CoroutineDispatcher = Dispatchers.IO
override val main: MainCoroutineDispatcher = Dispatchers.Main
override val default: CoroutineDispatcher = Dispatchers.Default
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import co.touchlab.kermit.Logger as Log

object Logger {

private const val DEFAULT_TAG = "WIZARD"
const val DEFAULT_TAG = "WIZARD"

fun exception(
throwable: Throwable,
Expand Down
51 changes: 51 additions & 0 deletions core/network/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidLibrary)
alias(libs.plugins.jetbrainsCompose)
kotlin("plugin.serialization") version "1.9.20"
}

kotlin {
androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}

jvm("desktop")

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "network"
isStatic = true
}
}

sourceSets {
commonMain.dependencies {
implementation(project(":core:core"))
implementation(libs.bundles.ktor)
implementation(libs.kotlinx.serialization.json)
implementation(libs.slf4j.simple)

implementation(libs.kamel)
}
commonTest.dependencies {
implementation(libs.kotlin.test)
}
}
}

android {
namespace = "com.stslex.core.network"
compileSdk = libs.versions.android.compileSdk.get().toInt()
defaultConfig {
minSdk = libs.versions.android.minSdk.get().toInt()
}
}
Loading
Loading