-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from stslex/dev
Feed
- Loading branch information
Showing
44 changed files
with
740 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package main_screen | ||
|
||
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.tab.Tab | ||
import cafe.adriel.voyager.navigator.tab.TabOptions | ||
import com.stslex.feature.feed.ui.FeedScreenSetup | ||
|
||
object FeedTab : Tab { | ||
|
||
override val options: TabOptions | ||
@Composable | ||
get() { | ||
val title = "feed" | ||
val icon = rememberVectorPainter(Icons.Default.List) | ||
|
||
return remember { | ||
TabOptions( | ||
index = 0u, | ||
title = title, | ||
icon = icon | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
override fun Content() { | ||
FeedScreenSetup() | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
composeApp/src/commonMain/kotlin/main_screen/MainScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
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 | ||
|
||
object MainScreen : Screen { | ||
|
||
@Composable | ||
override fun Content() { | ||
TabNavigator(FeedTab) { | ||
Scaffold( | ||
content = { paddingValues -> | ||
Box( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.padding(paddingValues) | ||
) { | ||
CurrentTab() | ||
} | ||
}, | ||
bottomBar = { | ||
NavigationBar { | ||
TabNavigationItem(FeedTab) | ||
TabNavigationItem(ProfileTab) | ||
} | ||
} | ||
) | ||
} | ||
} | ||
} | ||
|
||
@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 | ||
) | ||
} | ||
) | ||
} | ||
|
33 changes: 33 additions & 0 deletions
33
composeApp/src/commonMain/kotlin/main_screen/ProfileTab.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package main_screen | ||
|
||
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.navigator.tab.Tab | ||
import cafe.adriel.voyager.navigator.tab.TabOptions | ||
|
||
object ProfileTab : Tab { | ||
|
||
override val options: TabOptions | ||
@Composable | ||
get() { | ||
val title = "profile" | ||
val icon = rememberVectorPainter(Icons.Default.AccountBox) | ||
|
||
return remember { | ||
TabOptions( | ||
index = 1u, | ||
title = title, | ||
icon = icon | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
override fun Content() { | ||
Text("Profile") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
feature/feed/src/commonMain/kotlin/com/stslex/feature/feed/data/model/FeedDataModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.stslex.feature.feed.data.model | ||
|
||
data class FeedDataModel( | ||
val films: List<FilmDataModel>, | ||
val hasNextPage: Boolean, | ||
) |
8 changes: 8 additions & 0 deletions
8
feature/feed/src/commonMain/kotlin/com/stslex/feature/feed/data/model/FilmDataModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.stslex.feature.feed.data.model | ||
|
||
data class FilmDataModel( | ||
val id: String, | ||
val title: String, | ||
val description: String, | ||
val imageUrl: String, | ||
) |
8 changes: 8 additions & 0 deletions
8
feature/feed/src/commonMain/kotlin/com/stslex/feature/feed/data/repository/FeedRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.stslex.feature.feed.data.repository | ||
|
||
import com.stslex.feature.feed.data.model.FeedDataModel | ||
|
||
interface FeedRepository { | ||
|
||
suspend fun getFeed(page: Int, pageSize: Int): FeedDataModel | ||
} |
11 changes: 11 additions & 0 deletions
11
.../feed/src/commonMain/kotlin/com/stslex/feature/feed/data/repository/FeedRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.stslex.feature.feed.data.repository | ||
|
||
import com.stslex.feature.feed.data.model.FeedDataModel | ||
|
||
class FeedRepositoryImpl : FeedRepository { | ||
override suspend fun getFeed(page: Int, pageSize: Int): FeedDataModel { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
} | ||
|
29 changes: 29 additions & 0 deletions
29
...d/src/commonMain/kotlin/com/stslex/feature/feed/data/repository/MockFeedRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.stslex.feature.feed.data.repository | ||
|
||
import com.stslex.core.core.Logger | ||
import com.stslex.feature.feed.data.model.FeedDataModel | ||
import com.stslex.feature.feed.data.model.FilmDataModel | ||
import kotlinx.coroutines.delay | ||
|
||
class MockFeedRepositoryImpl : FeedRepository { | ||
|
||
override suspend fun getFeed( | ||
page: Int, | ||
pageSize: Int | ||
): FeedDataModel { | ||
Logger.debug("getFeed page: $page, pageSize: $pageSize") | ||
delay(3000) | ||
return FeedDataModel( | ||
films = Array(pageSize) { index -> | ||
val itemIndex = page.dec() * pageSize + index | ||
FilmDataModel( | ||
id = itemIndex.toString(), | ||
title = "Title $itemIndex", | ||
description = "Description $itemIndex", | ||
imageUrl = "https://picsum.photos/200/300" | ||
) | ||
}.toList(), | ||
hasNextPage = true | ||
) | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
feature/feed/src/commonMain/kotlin/com/stslex/feature/feed/di/FeedModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.stslex.feature.feed.di | ||
|
||
import com.stslex.core.ui.base.viewModelDefinition | ||
import com.stslex.feature.feed.data.repository.FeedRepository | ||
import com.stslex.feature.feed.data.repository.MockFeedRepositoryImpl | ||
import com.stslex.feature.feed.domain.interactor.FeedInteractor | ||
import com.stslex.feature.feed.domain.interactor.FeedInteractorImpl | ||
import com.stslex.feature.feed.navigation.FeedScreenRouter | ||
import com.stslex.feature.feed.navigation.FeedScreenRouterImpl | ||
import com.stslex.feature.feed.ui.store.FeedScreenStore | ||
import org.koin.dsl.module | ||
|
||
val feedModule = module { | ||
viewModelDefinition { | ||
FeedScreenStore( | ||
interactor = get(), | ||
appDispatcher = get(), | ||
router = get() | ||
) | ||
} | ||
|
||
factory<FeedScreenRouter> { FeedScreenRouterImpl(get()) } | ||
factory<FeedInteractor> { FeedInteractorImpl(get()) } | ||
factory<FeedRepository> { MockFeedRepositoryImpl() } | ||
} |
8 changes: 8 additions & 0 deletions
8
...re/feed/src/commonMain/kotlin/com/stslex/feature/feed/domain/interactor/FeedInteractor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.stslex.feature.feed.domain.interactor | ||
|
||
import com.stslex.feature.feed.domain.model.FeedDomainModel | ||
|
||
interface FeedInteractor { | ||
|
||
suspend fun getFeed(page: Int, pageSize: Int): FeedDomainModel | ||
} |
Oops, something went wrong.