From 8d43411ef581c2f41544392e0b42cff498874bc1 Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Fri, 5 Apr 2024 17:27:19 +0100 Subject: [PATCH 01/33] base navigation --- .../pinkroom/marketsight/ui/MainActivity.kt | 44 ++++++++++--------- .../ui/core/navigation/BottomBarItem.kt | 21 +++++++++ .../ui/core/navigation/NavigationAppHost.kt | 33 ++++++++++++++ .../ui/core/navigation/NavigationBottomBar.kt | 10 +++++ .../marketsight/ui/core/navigation/Route.kt | 7 +++ .../marketsight/ui/{ => core}/theme/Color.kt | 2 +- .../ui/{ => core}/theme/Dimensions.kt | 2 +- .../marketsight/ui/{ => core}/theme/Theme.kt | 2 +- .../marketsight/ui/{ => core}/theme/Type.kt | 2 +- .../ui/detail_screen/DetailScreen.kt | 31 +++++++++++++ .../marketsight/ui/home_screen/HomeScreen.kt | 31 +++++++++++++ .../marketsight/ui/news_screen/NewsScreen.kt | 31 +++++++++++++ .../main/res/drawable/icon_filled_article.xml | 5 +++ .../main/res/drawable/icon_filled_home.xml | 5 +++ .../res/drawable/icon_outline_article.xml | 7 +++ .../main/res/drawable/icon_outline_home.xml | 5 +++ 16 files changed, 213 insertions(+), 25 deletions(-) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/BottomBarItem.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationBottomBar.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/Route.kt rename app/src/main/java/dev/pinkroom/marketsight/ui/{ => core}/theme/Color.kt (87%) rename app/src/main/java/dev/pinkroom/marketsight/ui/{ => core}/theme/Dimensions.kt (97%) rename app/src/main/java/dev/pinkroom/marketsight/ui/{ => core}/theme/Theme.kt (97%) rename app/src/main/java/dev/pinkroom/marketsight/ui/{ => core}/theme/Type.kt (98%) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/detail_screen/DetailScreen.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/home_screen/HomeScreen.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt create mode 100644 app/src/main/res/drawable/icon_filled_article.xml create mode 100644 app/src/main/res/drawable/icon_filled_home.xml create mode 100644 app/src/main/res/drawable/icon_outline_article.xml create mode 100644 app/src/main/res/drawable/icon_outline_home.xml diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt index 4452a9a..3a8f129 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt @@ -6,15 +6,22 @@ import android.view.View import android.view.animation.LinearInterpolator import androidx.activity.ComponentActivity import androidx.activity.compose.setContent +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Scaffold import androidx.compose.material3.Surface import androidx.compose.material3.Text -import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp import androidx.core.animation.doOnEnd import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen -import dev.pinkroom.marketsight.ui.theme.MarketSightTheme +import androidx.navigation.compose.rememberNavController +import dev.pinkroom.marketsight.ui.core.navigation.NavigationAppHost +import dev.pinkroom.marketsight.ui.core.navigation.Route +import dev.pinkroom.marketsight.ui.core.theme.MarketSightTheme class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -35,30 +42,25 @@ class MainActivity : ComponentActivity() { super.onCreate(savedInstanceState) setContent { + //val navController = rememberNavController() + MarketSightTheme { - // A surface container using the 'background' color from the theme Surface( modifier = Modifier.fillMaxSize(), ) { - Greeting("Android") + /*Scaffold( + modifier = Modifier.fillMaxSize().background(MaterialTheme.colorScheme.primary), + //bottomBar = + ) { padding -> + NavigationAppHost( + modifier = Modifier.padding(padding), + navController = navController, + startDestination = Route.NewsScreen + ) + }*/ + Text(text = "Hello", modifier = Modifier.fillMaxSize()) } } } } -} - -@Composable -fun Greeting(name: String, modifier: Modifier = Modifier) { - Text( - text = "Hello $name!", - modifier = modifier - ) -} - -@Preview(showBackground = true, showSystemUi = true) -@Composable -fun GreetingPreview() { - MarketSightTheme { - Greeting("Android") - } } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/BottomBarItem.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/BottomBarItem.kt new file mode 100644 index 0000000..802b294 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/BottomBarItem.kt @@ -0,0 +1,21 @@ +package dev.pinkroom.marketsight.ui.core.navigation + +import androidx.annotation.DrawableRes +import dev.pinkroom.marketsight.R + +sealed class BottomBarItem( + @DrawableRes val selectedIcon: Int, + @DrawableRes val unselectedIcon: Int, + val route: String, +){ + data object Home: BottomBarItem( + selectedIcon = R.drawable.icon_filled_home, + unselectedIcon = R.drawable.icon_outline_home, + route = Route.HomeScreen.route, + ) + data object News: BottomBarItem( + selectedIcon = R.drawable.icon_filled_article, + unselectedIcon = R.drawable.icon_outline_article, + route = Route.NewsScreen.route, + ) +} diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt new file mode 100644 index 0000000..dd035b1 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt @@ -0,0 +1,33 @@ +package dev.pinkroom.marketsight.ui.core.navigation + +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.navigation.NavHostController +import androidx.navigation.compose.NavHost +import androidx.navigation.compose.composable +import dev.pinkroom.marketsight.ui.detail_screen.DetailScreen +import dev.pinkroom.marketsight.ui.home_screen.HomeScreen +import dev.pinkroom.marketsight.ui.news_screen.NewsScreen + +@Composable +fun NavigationAppHost( + modifier: Modifier = Modifier, + navController: NavHostController, + startDestination: Route, +){ + NavHost( + navController = navController, + startDestination = startDestination.route, + modifier = modifier + ) { + composable(Route.HomeScreen.route) { + HomeScreen() + } + composable(Route.NewsScreen.route) { + NewsScreen() + } + composable(Route.DetailScreen.route) { + DetailScreen() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationBottomBar.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationBottomBar.kt new file mode 100644 index 0000000..5dc0e8f --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationBottomBar.kt @@ -0,0 +1,10 @@ +package dev.pinkroom.marketsight.ui.core.navigation + +import androidx.compose.runtime.Composable + +@Composable +fun NavigationBottomBar( + +){ + +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/Route.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/Route.kt new file mode 100644 index 0000000..5131c22 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/Route.kt @@ -0,0 +1,7 @@ +package dev.pinkroom.marketsight.ui.core.navigation + +sealed class Route(val route: String){ + data object HomeScreen: Route("home-screen") + data object NewsScreen: Route("news-screen") + data object DetailScreen: Route("detail-screen") +} diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/theme/Color.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Color.kt similarity index 87% rename from app/src/main/java/dev/pinkroom/marketsight/ui/theme/Color.kt rename to app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Color.kt index f223094..3d49884 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/theme/Color.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Color.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.theme +package dev.pinkroom.marketsight.ui.core.theme import androidx.compose.ui.graphics.Color diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/theme/Dimensions.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt similarity index 97% rename from app/src/main/java/dev/pinkroom/marketsight/ui/theme/Dimensions.kt rename to app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt index 8ed6b18..44e8722 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/theme/Dimensions.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.theme +package dev.pinkroom.marketsight.ui.core.theme import androidx.compose.runtime.Composable import androidx.compose.ui.platform.LocalConfiguration diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/theme/Theme.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Theme.kt similarity index 97% rename from app/src/main/java/dev/pinkroom/marketsight/ui/theme/Theme.kt rename to app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Theme.kt index de2d2f6..83be03d 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/theme/Theme.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Theme.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.theme +package dev.pinkroom.marketsight.ui.core.theme import android.app.Activity import android.os.Build diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/theme/Type.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Type.kt similarity index 98% rename from app/src/main/java/dev/pinkroom/marketsight/ui/theme/Type.kt rename to app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Type.kt index 9d82a5d..ba9b22c 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/theme/Type.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Type.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.theme +package dev.pinkroom.marketsight.ui.core.theme import androidx.compose.material3.Typography import androidx.compose.runtime.Composable diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/detail_screen/DetailScreen.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/detail_screen/DetailScreen.kt new file mode 100644 index 0000000..4ff4581 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/detail_screen/DetailScreen.kt @@ -0,0 +1,31 @@ +package dev.pinkroom.marketsight.ui.detail_screen + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview + +@Composable +fun DetailScreen( + modifier: Modifier = Modifier, +){ + Column( + modifier = modifier + .fillMaxSize(), + ) { + Text( + text = "Detail Screen", + ) + } +} + +@Preview( + showBackground = true, + showSystemUi = true, +) +@Composable +fun DetailScreenPreview(){ + DetailScreen() +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/home_screen/HomeScreen.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/home_screen/HomeScreen.kt new file mode 100644 index 0000000..87058cf --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/home_screen/HomeScreen.kt @@ -0,0 +1,31 @@ +package dev.pinkroom.marketsight.ui.home_screen + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview + +@Composable +fun HomeScreen( + modifier: Modifier = Modifier, +){ + Column( + modifier = modifier + .fillMaxSize(), + ) { + Text( + text = "Home Screen", + ) + } +} + +@Preview( + showBackground = true, + showSystemUi = true, +) +@Composable +fun HomeScreenPreview(){ + HomeScreen() +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt new file mode 100644 index 0000000..73c0698 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt @@ -0,0 +1,31 @@ +package dev.pinkroom.marketsight.ui.news_screen + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview + +@Composable +fun NewsScreen( + modifier: Modifier = Modifier, +){ + Column( + modifier = modifier + .fillMaxSize(), + ) { + Text( + text = "News Screen", + ) + } +} + +@Preview( + showBackground = true, + showSystemUi = true, +) +@Composable +fun NewsScreenPreview(){ + NewsScreen() +} \ No newline at end of file diff --git a/app/src/main/res/drawable/icon_filled_article.xml b/app/src/main/res/drawable/icon_filled_article.xml new file mode 100644 index 0000000..30d5d26 --- /dev/null +++ b/app/src/main/res/drawable/icon_filled_article.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/icon_filled_home.xml b/app/src/main/res/drawable/icon_filled_home.xml new file mode 100644 index 0000000..20cb4d6 --- /dev/null +++ b/app/src/main/res/drawable/icon_filled_home.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/icon_outline_article.xml b/app/src/main/res/drawable/icon_outline_article.xml new file mode 100644 index 0000000..5844840 --- /dev/null +++ b/app/src/main/res/drawable/icon_outline_article.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/app/src/main/res/drawable/icon_outline_home.xml b/app/src/main/res/drawable/icon_outline_home.xml new file mode 100644 index 0000000..4d8dd31 --- /dev/null +++ b/app/src/main/res/drawable/icon_outline_home.xml @@ -0,0 +1,5 @@ + + + + + From 907f2ce38c449d3ca95b33b5482f7f135538a723 Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Mon, 8 Apr 2024 10:48:28 +0100 Subject: [PATCH 02/33] update colors background and add scaffold to support bottom bar --- .../pinkroom/marketsight/ui/MainActivity.kt | 32 +++---------------- .../marketsight/ui/core/theme/Theme.kt | 4 +++ 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt index 192424d..094ca73 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt @@ -3,18 +3,11 @@ package dev.pinkroom.marketsight.ui import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding -import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold import androidx.compose.material3.Surface -import androidx.compose.material3.Text import androidx.compose.ui.Modifier -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.unit.dp -import androidx.core.animation.doOnEnd import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import androidx.navigation.compose.rememberNavController import dev.pinkroom.marketsight.ui.core.navigation.NavigationAppHost @@ -27,14 +20,14 @@ class MainActivity : ComponentActivity() { super.onCreate(savedInstanceState) setContent { - //val navController = rememberNavController() + val navController = rememberNavController() MarketSightTheme { Surface( modifier = Modifier.fillMaxSize(), ) { - /*Scaffold( - modifier = Modifier.fillMaxSize().background(MaterialTheme.colorScheme.primary), + Scaffold( + modifier = Modifier.fillMaxSize(), //bottomBar = ) { padding -> NavigationAppHost( @@ -42,26 +35,9 @@ class MainActivity : ComponentActivity() { navController = navController, startDestination = Route.NewsScreen ) - }*/ - Text(text = "Hello", modifier = Modifier.fillMaxSize()) + } } } } } -} - -@Composable -fun Greeting(name: String, modifier: Modifier = Modifier) { - Text( - text = "Hello $name!", - modifier = modifier - ) -} - -@Preview(showBackground = true, showSystemUi = true) -@Composable -fun GreetingPreview() { - MarketSightTheme { - Greeting("Android") - } } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Theme.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Theme.kt index 83be03d..eb8cf37 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Theme.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Theme.kt @@ -21,6 +21,8 @@ private val DarkColorScheme = darkColorScheme( surfaceVariant = Gray, surface = WoodSmoke, onSurfaceVariant = White, + background = WoodSmoke, + onBackground = White, ) private val LightColorScheme = lightColorScheme( @@ -29,6 +31,8 @@ private val LightColorScheme = lightColorScheme( surfaceVariant = White, surface = GrayAthens, onSurfaceVariant = Black, + background = GrayAthens, + onBackground = Black, ) @Composable From 14c67a36906c869fa964b9686b2efa795d506a8e Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Mon, 8 Apr 2024 14:10:45 +0100 Subject: [PATCH 03/33] bottom bar --- .../pinkroom/marketsight/ui/MainActivity.kt | 15 ++- .../ui/core/navigation/BottomBarItem.kt | 4 + .../ui/core/navigation/NavigationBottomBar.kt | 119 ++++++++++++++++++ app/src/main/res/values/strings.xml | 3 + 4 files changed, 138 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt index 094ca73..5dc3de5 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt @@ -1,5 +1,6 @@ package dev.pinkroom.marketsight.ui +import android.annotation.SuppressLint import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent @@ -11,16 +12,19 @@ import androidx.compose.ui.Modifier import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import androidx.navigation.compose.rememberNavController import dev.pinkroom.marketsight.ui.core.navigation.NavigationAppHost +import dev.pinkroom.marketsight.ui.core.navigation.NavigationBottomBar import dev.pinkroom.marketsight.ui.core.navigation.Route import dev.pinkroom.marketsight.ui.core.theme.MarketSightTheme class MainActivity : ComponentActivity() { + @SuppressLint("UnusedMaterial3ScaffoldPaddingParameter") override fun onCreate(savedInstanceState: Bundle?) { installSplashScreen() super.onCreate(savedInstanceState) setContent { val navController = rememberNavController() + val startDestination = Route.HomeScreen MarketSightTheme { Surface( @@ -28,12 +32,17 @@ class MainActivity : ComponentActivity() { ) { Scaffold( modifier = Modifier.fillMaxSize(), - //bottomBar = - ) { padding -> + bottomBar = { + NavigationBottomBar( + navController = navController, + startDestination = startDestination, + ) + } + ) { padding -> NavigationAppHost( modifier = Modifier.padding(padding), navController = navController, - startDestination = Route.NewsScreen + startDestination = startDestination, ) } } diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/BottomBarItem.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/BottomBarItem.kt index 802b294..8968ef9 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/BottomBarItem.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/BottomBarItem.kt @@ -1,19 +1,23 @@ package dev.pinkroom.marketsight.ui.core.navigation import androidx.annotation.DrawableRes +import androidx.annotation.StringRes import dev.pinkroom.marketsight.R sealed class BottomBarItem( + @StringRes val title: Int, @DrawableRes val selectedIcon: Int, @DrawableRes val unselectedIcon: Int, val route: String, ){ data object Home: BottomBarItem( + title = R.string.home, selectedIcon = R.drawable.icon_filled_home, unselectedIcon = R.drawable.icon_outline_home, route = Route.HomeScreen.route, ) data object News: BottomBarItem( + title = R.string.news, selectedIcon = R.drawable.icon_filled_article, unselectedIcon = R.drawable.icon_outline_article, route = Route.NewsScreen.route, diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationBottomBar.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationBottomBar.kt index 5dc0e8f..4b164df 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationBottomBar.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationBottomBar.kt @@ -1,10 +1,129 @@ package dev.pinkroom.marketsight.ui.core.navigation +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.core.animateDpAsState +import androidx.compose.animation.core.tween +import androidx.compose.animation.slideInVertically +import androidx.compose.animation.slideOutVertically +import androidx.compose.foundation.layout.RowScope +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.NavigationBar +import androidx.compose.material3.NavigationBarItem +import androidx.compose.material3.NavigationBarItemDefaults import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import androidx.navigation.NavHostController +import androidx.navigation.compose.currentBackStackEntryAsState +import dev.pinkroom.marketsight.R @Composable fun NavigationBottomBar( + navController: NavHostController, + startDestination: Route.HomeScreen, +){ + val items = listOf( + BottomBarItem.Home, + BottomBarItem.News, + ) + + var bottomBarState by rememberSaveable { + mutableStateOf(true) + } + val navBackStackEntry by navController.currentBackStackEntryAsState() + val currentRoute = navBackStackEntry?.destination?.route + + bottomBarState = when (currentRoute) { + Route.HomeScreen.route, Route.NewsScreen.route -> true + else -> false + } + AnimatedVisibility( + visible = bottomBarState, + enter = slideInVertically(initialOffsetY = { it }), + exit = slideOutVertically(targetOffsetY = { it }), + content = { + Card( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 25.dp) + .padding(bottom = 15.dp), + shape = RoundedCornerShape(10.dp), + elevation = CardDefaults.cardElevation( + defaultElevation = 2.dp + ), + ) { + NavigationBar( + containerColor = Color.Transparent + ) { + items.forEach { bottomBarItem -> + AddItem( + currentRoute = currentRoute, + item = bottomBarItem, + onClick = { + navController.navigate(bottomBarItem.route) { + popUpTo(startDestination.route) { + saveState = true + } + launchSingleTop = true + restoreState = true + } + } + ) + } + } + } + } + ) +} + +@Composable +fun RowScope.AddItem( + currentRoute: String?, + item: BottomBarItem, + onClick: () -> Unit, ){ + val isThisItemTheCurrentRoute = currentRoute == item.route + val icon = if (isThisItemTheCurrentRoute) item.selectedIcon + else item.unselectedIcon + val sizeIcon = animateDpAsState( + targetValue = if (isThisItemTheCurrentRoute) 38.dp else 24.dp, + animationSpec = tween( + durationMillis = 200, + ), + label = "Animation Size Icon Bottom Item", + ) + + val contentDesc = "${stringResource(id = item.title)} ${stringResource(id = R.string.desc_icon_bottom_bar)}" + NavigationBarItem( + selected = isThisItemTheCurrentRoute, + icon = { + Icon( + modifier = Modifier + .size(sizeIcon.value), + painter = painterResource(id = icon), + contentDescription = contentDesc, + tint = MaterialTheme.colorScheme.onPrimary + ) + }, + colors = NavigationBarItemDefaults.colors( + indicatorColor = Color.Transparent, + ), + onClick = onClick, + ) } \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 174c026..32fce48 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,6 @@ MarketSight + News + Home + icon bottom bar \ No newline at end of file From 388f4f22899cd7f0d7d3060dd1b5c5d5a21edf12 Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Mon, 8 Apr 2024 14:46:36 +0100 Subject: [PATCH 04/33] route with arg symbolId on Detail screen --- app/src/main/AndroidManifest.xml | 1 + .../ui/core/navigation/NavigationAppHost.kt | 20 ++++++++++++++++--- .../marketsight/ui/core/navigation/Route.kt | 13 +++++++++++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 48f45e9..a761a98 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,6 +10,7 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" + android:enableOnBackInvokedCallback="true" android:theme="@style/Theme.MarketSight.Splash" tools:targetApi="34" android:name=".MarketSightApp"> diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt index dd035b1..2682fcf 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt @@ -3,8 +3,11 @@ package dev.pinkroom.marketsight.ui.core.navigation import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.navigation.NavHostController +import androidx.navigation.NavType import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable +import androidx.navigation.navArgument +import dev.pinkroom.marketsight.ui.core.navigation.Args.SYMBOL_ID import dev.pinkroom.marketsight.ui.detail_screen.DetailScreen import dev.pinkroom.marketsight.ui.home_screen.HomeScreen import dev.pinkroom.marketsight.ui.news_screen.NewsScreen @@ -20,13 +23,24 @@ fun NavigationAppHost( startDestination = startDestination.route, modifier = modifier ) { - composable(Route.HomeScreen.route) { + composable( + route = Route.HomeScreen.route, + ) { HomeScreen() } - composable(Route.NewsScreen.route) { + composable( + route = Route.NewsScreen.route, + ) { NewsScreen() } - composable(Route.DetailScreen.route) { + composable( + route = Route.DetailScreen.route, + arguments = listOf( + navArgument(name = SYMBOL_ID){ + type = NavType.StringType + }, + ) + ) { DetailScreen() } } diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/Route.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/Route.kt index 5131c22..a21306a 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/Route.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/Route.kt @@ -1,7 +1,18 @@ package dev.pinkroom.marketsight.ui.core.navigation +import dev.pinkroom.marketsight.ui.core.navigation.Args.SYMBOL_ID + sealed class Route(val route: String){ data object HomeScreen: Route("home-screen") data object NewsScreen: Route("news-screen") - data object DetailScreen: Route("detail-screen") + data object DetailScreen: Route("detail-screen/{$SYMBOL_ID}"){ + fun withSymbol(symbolId: String): String { + return this.route.replace(oldValue = "{$SYMBOL_ID}", newValue = symbolId) + } + } } + + +object Args { + const val SYMBOL_ID = "symbolId" +} \ No newline at end of file From 398453d7273fa54413ddaf7c465d4f924ca440ac Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Mon, 8 Apr 2024 16:42:04 +0100 Subject: [PATCH 05/33] initial setup alpaca API --- app/build.gradle.kts | 21 +++++++- .../common/FlowStreamAdapterFactory.kt | 22 +++++++++ .../HelperIdentifierMessagesAlpacaService.kt | 12 +++++ .../dev/pinkroom/marketsight/common/Utils.kt | 5 ++ .../marketsight/data/remote/AlpacaApi.kt | 4 ++ .../marketsight/data/remote/AlpacaService.kt | 19 +++++++ .../data/remote/model/dto/MessageErrorDto.kt | 6 +++ .../data/remote/model/dto/NewsMessageDto.kt | 16 ++++++ .../model/dto/ResponseAlpacaServiceDto.kt | 5 ++ .../model/request/MessageAlpacaService.kt | 8 +++ .../dev/pinkroom/marketsight/di/AppModule.kt | 49 +++++++++++++++++++ .../domain/repository/NewsRepository.kt | 4 ++ gradle/libs.versions.toml | 5 +- 13 files changed, 174 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/common/FlowStreamAdapterFactory.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/common/HelperIdentifierMessagesAlpacaService.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaApi.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaService.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/MessageErrorDto.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/NewsMessageDto.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/ResponseAlpacaServiceDto.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/request/MessageAlpacaService.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index ceec6cf..8e104d2 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,3 +1,6 @@ +import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties +import java.util.Properties + plugins { kotlin("kapt") alias(libs.plugins.androidApplication) @@ -19,6 +22,18 @@ android { vectorDrawables { useSupportLibrary = true } + + val keystoreFile = project.rootProject.file("local.properties") + val properties = Properties() + properties.load(keystoreFile.inputStream()) + + val alpacaStreamUrl = properties.getProperty("ALPACA_STREAM_URL") ?: "" + val alpacaApiId = properties.getProperty("ALPACA_API_ID") ?: "" + val alpacaApiSecret = properties.getProperty("ALPACA_API_SECRET") ?: "" + + buildConfigField(type = "String", name = "ALPACA_STREAM_URL", value = alpacaStreamUrl) + buildConfigField(type = "String", name = "ALPACA_API_ID", value = alpacaApiId) + buildConfigField(type = "String", name = "ALPACA_API_SECRET", value = alpacaApiSecret) } buildTypes { @@ -39,6 +54,7 @@ android { } buildFeatures { compose = true + buildConfig = true } composeOptions { kotlinCompilerExtensionVersion = "1.5.10" @@ -72,7 +88,10 @@ dependencies { implementation(libs.okhttp.interceptor) // SCARLET - implementation(libs.scarlet) + implementation(libs.scarlet.core) + implementation(libs.scarlet.stream) + implementation(libs.scarlet.gson) + implementation(libs.scarlet.okhttp) // DAGGER HILT kapt(libs.hilt.compiler) diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/FlowStreamAdapterFactory.kt b/app/src/main/java/dev/pinkroom/marketsight/common/FlowStreamAdapterFactory.kt new file mode 100644 index 0000000..c8dbde4 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/common/FlowStreamAdapterFactory.kt @@ -0,0 +1,22 @@ +package dev.pinkroom.marketsight.common + +import com.tinder.scarlet.Stream +import com.tinder.scarlet.StreamAdapter +import com.tinder.scarlet.utils.getRawType +import kotlinx.coroutines.flow.Flow +import java.lang.reflect.Type +import kotlinx.coroutines.reactive.asFlow + +class FlowStreamAdapterFactory : StreamAdapter.Factory { + + override fun create(type: Type): StreamAdapter { + return when (type.getRawType()) { + Flow::class.java -> FlowStreamAdapter() + else -> throw IllegalArgumentException() + } + } +} + +private class FlowStreamAdapter : StreamAdapter> where T : Any { + override fun adapt(stream: Stream) = stream.asFlow() +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/HelperIdentifierMessagesAlpacaService.kt b/app/src/main/java/dev/pinkroom/marketsight/common/HelperIdentifierMessagesAlpacaService.kt new file mode 100644 index 0000000..db52467 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/common/HelperIdentifierMessagesAlpacaService.kt @@ -0,0 +1,12 @@ +package dev.pinkroom.marketsight.common + +sealed class HelperIdentifierMessagesAlpacaService( + val identifier: String, +){ + data object News: HelperIdentifierMessagesAlpacaService(identifier = "n") + data object Stocks: HelperIdentifierMessagesAlpacaService(identifier = "q") + data object Crypto: HelperIdentifierMessagesAlpacaService(identifier = "t") + data object Success: HelperIdentifierMessagesAlpacaService(identifier = "success") + data object Error: HelperIdentifierMessagesAlpacaService(identifier = "error") + data object Subscription: HelperIdentifierMessagesAlpacaService(identifier = "subscription") +} diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt b/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt new file mode 100644 index 0000000..40157db --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt @@ -0,0 +1,5 @@ +package dev.pinkroom.marketsight.common + +import okhttp3.OkHttpClient +import okhttp3.logging.HttpLoggingInterceptor + diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaApi.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaApi.kt new file mode 100644 index 0000000..b134966 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaApi.kt @@ -0,0 +1,4 @@ +package dev.pinkroom.marketsight.data.remote + +interface AlpacaApi { +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaService.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaService.kt new file mode 100644 index 0000000..ad8659a --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaService.kt @@ -0,0 +1,19 @@ +package dev.pinkroom.marketsight.data.remote + +import com.tinder.scarlet.WebSocket +import com.tinder.scarlet.ws.Receive +import com.tinder.scarlet.ws.Send +import dev.pinkroom.marketsight.data.remote.model.dto.ResponseAlpacaServiceDto +import dev.pinkroom.marketsight.data.remote.model.request.MessageAlpacaService +import kotlinx.coroutines.flow.Flow + +interface AlpacaService { + @Send + fun sendSubscribe(message: MessageAlpacaService) + + @Receive + fun observeResponse(): Flow + + @Receive + fun observeOnConnectionEvent(): Flow +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/MessageErrorDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/MessageErrorDto.kt new file mode 100644 index 0000000..aa322c5 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/MessageErrorDto.kt @@ -0,0 +1,6 @@ +package dev.pinkroom.marketsight.data.remote.model.dto + +data class MessageErrorDto( + val code: Int, + val msg: String, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/NewsMessageDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/NewsMessageDto.kt new file mode 100644 index 0000000..10a515f --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/NewsMessageDto.kt @@ -0,0 +1,16 @@ +package dev.pinkroom.marketsight.data.remote.model.dto + +import com.google.gson.annotations.SerializedName + +data class NewsMessageDto( + val id: Int, + val headline: String, + val summary: String, + val author: String, + @SerializedName("created_at") val createdAt: String, + @SerializedName("updated_at") val updatedAt: String, + val url: String, + val content: String, + val symbols: List, + val source: String, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/ResponseAlpacaServiceDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/ResponseAlpacaServiceDto.kt new file mode 100644 index 0000000..d6a3ab3 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/ResponseAlpacaServiceDto.kt @@ -0,0 +1,5 @@ +package dev.pinkroom.marketsight.data.remote.model.dto + +data class ResponseAlpacaServiceDto( + val data: List = emptyList(), +) \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/request/MessageAlpacaService.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/request/MessageAlpacaService.kt new file mode 100644 index 0000000..7e3cd8a --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/request/MessageAlpacaService.kt @@ -0,0 +1,8 @@ +package dev.pinkroom.marketsight.data.remote.model.request + +data class MessageAlpacaService( + val action: String, // subscribe / unsubscribe + val trades: List = emptyList(), + val quotes: List = emptyList(), + val news: List = emptyList(), +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt b/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt index 170ab50..3f63942 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt @@ -1,4 +1,53 @@ package dev.pinkroom.marketsight.di +import com.tinder.scarlet.Scarlet +import com.tinder.scarlet.messageadapter.gson.GsonMessageAdapter +import com.tinder.scarlet.websocket.okhttp.newWebSocketFactory +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import dev.pinkroom.marketsight.BuildConfig +import dev.pinkroom.marketsight.common.FlowStreamAdapterFactory +import dev.pinkroom.marketsight.data.remote.AlpacaService +import okhttp3.OkHttpClient +import java.util.concurrent.TimeUnit +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) object AppModule { + + private const val ALPACA_STREAM_URL_NEWS = BuildConfig.ALPACA_STREAM_URL + "v1beta1/news" + private const val API_TIMEOUT = 60L + @Provides + @Singleton + fun provideOkHttpClient() = OkHttpClient.Builder() + .connectTimeout(API_TIMEOUT, TimeUnit.SECONDS) + .readTimeout(API_TIMEOUT, TimeUnit.SECONDS) + .writeTimeout(API_TIMEOUT, TimeUnit.SECONDS) + .addInterceptor { chain -> + val original = chain.request() + + // Request customization: add request headers + val requestBuilder = original.newBuilder() + .addHeader("APCA-API-KEY-ID", BuildConfig.ALPACA_API_ID) + .addHeader("APCA-API-SECRET-KEY", BuildConfig.ALPACA_API_SECRET) + + val request = requestBuilder.build() + chain.proceed(request) + } + .build() + + @Provides + @Singleton + fun provideAlpacaNewsService(okHttpClient: OkHttpClient): AlpacaService { + val scarlet = Scarlet.Builder() + .webSocketFactory(okHttpClient.newWebSocketFactory(ALPACA_STREAM_URL_NEWS)) + .addMessageAdapterFactory(GsonMessageAdapter.Factory()) + .addStreamAdapterFactory(FlowStreamAdapterFactory()) + .build() + + return scarlet.create(AlpacaService::class.java) + } } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt new file mode 100644 index 0000000..f7ff5cb --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt @@ -0,0 +1,4 @@ +package dev.pinkroom.marketsight.domain.repository + +interface NewsRepository { +} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0cf5180..ec3615f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -38,7 +38,10 @@ okhttp-core = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = " okhttp-interceptor = { group = "com.squareup.okhttp3", name = "logging-interceptor", version.ref = "okHttpVersion" } # SCARLET -scarlet = { group = "com.tinder.scarlet", name = "scarlet", version.ref = "scarletVersion" } +scarlet-core = { group = "com.tinder.scarlet", name = "scarlet", version.ref = "scarletVersion" } +scarlet-stream = { group = "com.tinder.scarlet", name = "stream-adapter-coroutines", version.ref = "scarletVersion" } +scarlet-gson = { group = "com.tinder.scarlet", name = "message-adapter-gson", version.ref = "scarletVersion" } +scarlet-okhttp = { group = "com.tinder.scarlet", name = "websocket-okhttp", version.ref = "scarletVersion" } # DAGGER HILT hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hiltVersion" } From 3f5ed1fad6e020b6b17b58e4b76e41e5fa4c7122 Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Mon, 8 Apr 2024 16:52:15 +0100 Subject: [PATCH 06/33] update dimensions --- .../ui/core/navigation/NavigationBottomBar.kt | 12 +++++------ .../marketsight/ui/core/theme/Dimensions.kt | 20 +++++++++++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationBottomBar.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationBottomBar.kt index 4b164df..0359eb5 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationBottomBar.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationBottomBar.kt @@ -26,10 +26,10 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource -import androidx.compose.ui.unit.dp import androidx.navigation.NavHostController import androidx.navigation.compose.currentBackStackEntryAsState import dev.pinkroom.marketsight.R +import dev.pinkroom.marketsight.ui.core.theme.dimens @Composable fun NavigationBottomBar( @@ -60,11 +60,11 @@ fun NavigationBottomBar( Card( modifier = Modifier .fillMaxWidth() - .padding(horizontal = 25.dp) - .padding(bottom = 15.dp), - shape = RoundedCornerShape(10.dp), + .padding(horizontal = dimens.horizontalPadding) + .padding(bottom = dimens.menuBottomPadding), + shape = RoundedCornerShape(dimens.smallShape), elevation = CardDefaults.cardElevation( - defaultElevation = 2.dp + defaultElevation = dimens.lowElevation, ), ) { NavigationBar( @@ -101,7 +101,7 @@ fun RowScope.AddItem( val icon = if (isThisItemTheCurrentRoute) item.selectedIcon else item.unselectedIcon val sizeIcon = animateDpAsState( - targetValue = if (isThisItemTheCurrentRoute) 38.dp else 24.dp, + targetValue = if (isThisItemTheCurrentRoute) dimens.largeIconSize else dimens.normalIconSize, animationSpec = tween( durationMillis = 200, ), diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt index 44e8722..2b30d7a 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt @@ -31,6 +31,26 @@ class Dimensions( val normalPadding: Dp = 16.dp, val largePadding: Dp = 24.dp, val xLargePadding: Dp = 32.dp, + + // Icon + val normalIconSize: Dp = 24.dp, + val largeIconSize: Dp = 38.dp, + + // Elevation + val lowElevation: Dp = 2.dp, + val normalElevation: Dp = 5.dp, + val largeElevation: Dp = 8.dp, + + // Shape + val smallShape: Dp = 10.dp, + val normalShape: Dp = 15.dp, + val largeShape: Dp = 22.dp, + + // Page Padding + val horizontalPadding: Dp = 25.dp, + + // Others + val menuBottomPadding: Dp = 15.dp, ) val dimens: Dimensions From 31d797ea432f769ae6ec695d21039086fea8c5fe Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Wed, 10 Apr 2024 18:34:23 +0100 Subject: [PATCH 07/33] update alpaca news service --- app/build.gradle.kts | 10 ++- app/src/main/AndroidManifest.xml | 2 + .../pinkroom/marketsight/MarketSightApp.kt | 2 + .../marketsight/common/DefaultDispatchers.kt | 18 ++++ .../pinkroom/marketsight/common/GsonUtils.kt | 24 ++++++ .../HelperIdentifierMessagesAlpacaService.kt | 19 +++-- .../pinkroom/marketsight/common/Resource.kt | 13 +++ .../dev/pinkroom/marketsight/common/Utils.kt | 27 ++++++ .../data_source/AlpacaRemoteDataSource.kt | 85 +++++++++++++++++++ .../marketsight/data/mapper/RemoteMapper.kt | 48 +++++++++++ .../marketsight/data/remote/AlpacaService.kt | 9 +- ...{MessageErrorDto.kt => ErrorMessageDto.kt} | 2 +- .../data/remote/model/dto/NewsMessageDto.kt | 5 +- .../model/dto/ResponseAlpacaServiceDto.kt | 5 -- .../model/dto/SubscriptionMessageDto.kt | 7 ++ .../data/remote/model/dto/TypeMessageDto.kt | 7 ++ .../data/repository/NewsRepositoryImp.kt | 44 ++++++++++ .../dev/pinkroom/marketsight/di/AppModule.kt | 51 ++++++++--- .../marketsight/domain/model/ErrorMessage.kt | 6 ++ .../marketsight/domain/model/NewsInfo.kt | 15 ++++ .../domain/model/SubscriptionMessage.kt | 7 ++ .../domain/repository/NewsRepository.kt | 14 +++ .../pinkroom/marketsight/ui/MainActivity.kt | 4 +- .../ui/core/navigation/NavigationAppHost.kt | 3 + .../ui/home_screen/HomeViewModel.kt | 33 +++++++ build.gradle.kts | 2 + gradle/libs.versions.toml | 14 ++- 27 files changed, 439 insertions(+), 37 deletions(-) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/common/DefaultDispatchers.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/common/GsonUtils.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/common/Resource.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/data_source/AlpacaRemoteDataSource.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt rename app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/{MessageErrorDto.kt => ErrorMessageDto.kt} (77%) delete mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/ResponseAlpacaServiceDto.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/SubscriptionMessageDto.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/TypeMessageDto.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/model/ErrorMessage.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/model/NewsInfo.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/model/SubscriptionMessage.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/home_screen/HomeViewModel.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 8e104d2..381da7e 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,10 +1,11 @@ -import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties import java.util.Properties plugins { kotlin("kapt") alias(libs.plugins.androidApplication) alias(libs.plugins.jetbrainsKotlinAndroid) + alias(libs.plugins.hiltAndroid) + alias(libs.plugins.jsonSerialization) } android { @@ -46,6 +47,7 @@ android { } } compileOptions { + isCoreLibraryDesugaringEnabled = true sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } @@ -68,6 +70,7 @@ android { dependencies { // CORE + coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4") implementation(libs.androidx.core.ktx) implementation(libs.androidx.lifecycle.runtime.ktx) implementation(libs.androidx.ui) @@ -92,6 +95,8 @@ dependencies { implementation(libs.scarlet.stream) implementation(libs.scarlet.gson) implementation(libs.scarlet.okhttp) + implementation(libs.scarlet.lifecycle) + implementation(libs.scarlet.moshi) // DAGGER HILT kapt(libs.hilt.compiler) @@ -101,6 +106,9 @@ dependencies { // SPLASH implementation(libs.splash) + // JSON + implementation(libs.json) + // UNIT TEST testImplementation(libs.junit) testImplementation(libs.junit.api) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a761a98..6396822 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,6 +2,8 @@ + + Gson.toJsonValue(value: Any?, classOfT: Class): T = fromJson(toJson(value), classOfT) + +fun Gson.toObject(value: Any, helperIdentifier: HelperIdentifierMessagesAlpacaService): T? { + val typeMessage = toJsonValue(value, TypeMessageDto::class.java) + return if (typeMessage.value == helperIdentifier.identifier && helperIdentifier.classOfT != null){ + toJsonValue(value, helperIdentifier.classOfT) + } else null +} + +fun Gson.verifyIfIsError(jsonValue: String): ErrorMessageDto? { + val helperIdentifier = HelperIdentifierMessagesAlpacaService.Error + fromJson(jsonValue, Array::class.java).toList().forEach { data -> + toObject(value = data, helperIdentifier = helperIdentifier)?.let { + return it + } + } + return null +} diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/HelperIdentifierMessagesAlpacaService.kt b/app/src/main/java/dev/pinkroom/marketsight/common/HelperIdentifierMessagesAlpacaService.kt index db52467..6205a35 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/common/HelperIdentifierMessagesAlpacaService.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/common/HelperIdentifierMessagesAlpacaService.kt @@ -1,12 +1,17 @@ package dev.pinkroom.marketsight.common -sealed class HelperIdentifierMessagesAlpacaService( +import dev.pinkroom.marketsight.data.remote.model.dto.ErrorMessageDto +import dev.pinkroom.marketsight.data.remote.model.dto.NewsMessageDto +import dev.pinkroom.marketsight.data.remote.model.dto.SubscriptionMessageDto + +sealed class HelperIdentifierMessagesAlpacaService( val identifier: String, + val classOfT: Class? = null, ){ - data object News: HelperIdentifierMessagesAlpacaService(identifier = "n") - data object Stocks: HelperIdentifierMessagesAlpacaService(identifier = "q") - data object Crypto: HelperIdentifierMessagesAlpacaService(identifier = "t") - data object Success: HelperIdentifierMessagesAlpacaService(identifier = "success") - data object Error: HelperIdentifierMessagesAlpacaService(identifier = "error") - data object Subscription: HelperIdentifierMessagesAlpacaService(identifier = "subscription") + data object News: HelperIdentifierMessagesAlpacaService(identifier = "n", classOfT = NewsMessageDto::class.java) + data object Stocks: HelperIdentifierMessagesAlpacaService(identifier = "q") + data object Crypto: HelperIdentifierMessagesAlpacaService(identifier = "t") + data object Success: HelperIdentifierMessagesAlpacaService(identifier = "success") + data object Error: HelperIdentifierMessagesAlpacaService(identifier = "error", classOfT = ErrorMessageDto::class.java) + data object Subscription: HelperIdentifierMessagesAlpacaService(identifier = "subscription", classOfT = SubscriptionMessageDto::class.java) } diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/Resource.kt b/app/src/main/java/dev/pinkroom/marketsight/common/Resource.kt new file mode 100644 index 0000000..c82f995 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/common/Resource.kt @@ -0,0 +1,13 @@ +package dev.pinkroom.marketsight.common + +import dev.pinkroom.marketsight.domain.model.ErrorMessage + +sealed class Resource{ + data class Success(val data: T?): Resource() + data class Error( + val message: String? = null, + val errorInfo: ErrorMessage? = null, + val data: T? = null + ): Resource() + data class Loading(val isLoading: Boolean=true): Resource() +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt b/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt index 40157db..5c285c3 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt @@ -1,5 +1,32 @@ package dev.pinkroom.marketsight.common +import dev.pinkroom.marketsight.BuildConfig import okhttp3.OkHttpClient import okhttp3.logging.HttpLoggingInterceptor +fun OkHttpClient.Builder.addAuthenticationInterceptor(): OkHttpClient.Builder { + addInterceptor { chain -> + val original = chain.request() + val requestBuilder = original.newBuilder() + .addHeader("APCA-API-KEY-ID", BuildConfig.ALPACA_API_ID) + .addHeader("APCA-API-SECRET-KEY", BuildConfig.ALPACA_API_SECRET) + + val request = requestBuilder.build() + chain.proceed(request) + } + return this +} + +fun OkHttpClient.Builder.addLoggingInterceptor(): OkHttpClient.Builder { + if (BuildConfig.DEBUG) { + val loggingInterceptor = HttpLoggingInterceptor() + loggingInterceptor.level = HttpLoggingInterceptor.Level.BODY + addInterceptor(loggingInterceptor) + } + return this +} + +sealed class ActionAlpaca(val action: String) { + data object Subscribe: ActionAlpaca(action = "subscribe") + data object Unsubscribe: ActionAlpaca(action = "unsubscribe") +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/AlpacaRemoteDataSource.kt b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/AlpacaRemoteDataSource.kt new file mode 100644 index 0000000..494501c --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/AlpacaRemoteDataSource.kt @@ -0,0 +1,85 @@ +package dev.pinkroom.marketsight.data.data_source + +import android.util.Log +import com.google.gson.Gson +import com.tinder.scarlet.Message +import com.tinder.scarlet.WebSocket +import dev.pinkroom.marketsight.common.ActionAlpaca +import dev.pinkroom.marketsight.common.DispatcherProvider +import dev.pinkroom.marketsight.common.HelperIdentifierMessagesAlpacaService +import dev.pinkroom.marketsight.common.Resource +import dev.pinkroom.marketsight.common.toObject +import dev.pinkroom.marketsight.common.verifyIfIsError +import dev.pinkroom.marketsight.data.mapper.toErrorMessage +import dev.pinkroom.marketsight.data.mapper.toNewsInfo +import dev.pinkroom.marketsight.data.mapper.toSubscriptionMessage +import dev.pinkroom.marketsight.data.remote.AlpacaService +import dev.pinkroom.marketsight.data.remote.model.dto.NewsMessageDto +import dev.pinkroom.marketsight.data.remote.model.request.MessageAlpacaService +import dev.pinkroom.marketsight.domain.model.NewsInfo +import dev.pinkroom.marketsight.domain.model.SubscriptionMessage +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.flowOn +import kotlinx.coroutines.flow.take +import javax.inject.Inject + +class AlpacaRemoteDataSource @Inject constructor( + private val gson: Gson, + private val alpacaService: AlpacaService, + private val dispatchers: DispatcherProvider, +) { + fun subscribeNews(symbols: List = listOf("*")): Flow> = flow> { + alpacaService.observeOnConnectionEvent().collect{ + when(it){ + is WebSocket.Event.OnConnectionOpened<*> -> { + alpacaService.sendSubscribe(message = MessageAlpacaService(action = ActionAlpaca.Subscribe.action, news = symbols)) + } + is WebSocket.Event.OnMessageReceived -> { + Log.d(TAG,"Received: ${it.message}") + if (it.message is Message.Text){ + gson.verifyIfIsError(jsonValue = (it.message as Message.Text).value)?.let { errorMessage -> + emit(Resource.Error(message = errorMessage.msg, errorInfo = errorMessage.toErrorMessage())) + } ?: run { + emit(Resource.Success(it)) + } + } + } + is WebSocket.Event.OnConnectionFailed -> { + emit(Resource.Error(message = it.throwable.message, data = it)) + } + else -> Log.d(TAG,it.toString()) + } + } + }.flowOn(dispatchers.IO) + + fun getRealTimeNews(): Flow>> = flow { + alpacaService.observeResponse().collect{ data -> + Log.d("TESTE","AQUI SEMPRE") + val listNews = mutableListOf() + data.forEach { + gson.toObject(value = it, helperIdentifier = HelperIdentifierMessagesAlpacaService.News)?.let { news -> + listNews.add(news) + } + } + emit(Resource.Success(listNews.map { it.toNewsInfo() })) + } + }.flowOn(dispatchers.IO) + + fun sendMessageToAlpacaService(message: MessageAlpacaService): Flow> = flow> { + alpacaService.sendSubscribe(message = message) + alpacaService.observeResponse().collect { data -> + data.forEach { + gson.toObject(value = it, helperIdentifier = HelperIdentifierMessagesAlpacaService.Subscription)?.let { sub -> + emit(Resource.Success(sub.toSubscriptionMessage())) + } ?: run { + emit(Resource.Error(message = "Something went wrong on subscribe")) + } + } + } + }.flowOn(dispatchers.IO).take(1) + + companion object { + const val TAG = "AlpacaRemote" + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt b/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt new file mode 100644 index 0000000..37a3fe0 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt @@ -0,0 +1,48 @@ +package dev.pinkroom.marketsight.data.mapper + +import dev.pinkroom.marketsight.data.remote.model.dto.ErrorMessageDto +import dev.pinkroom.marketsight.data.remote.model.dto.NewsMessageDto +import dev.pinkroom.marketsight.data.remote.model.dto.SubscriptionMessageDto +import dev.pinkroom.marketsight.domain.model.ErrorMessage +import dev.pinkroom.marketsight.domain.model.NewsInfo +import dev.pinkroom.marketsight.domain.model.SubscriptionMessage +import java.time.LocalDateTime +import java.time.ZoneId +import java.time.ZoneOffset +import java.time.format.DateTimeFormatter +import java.util.Locale + +fun NewsMessageDto.toNewsInfo(): NewsInfo { + return NewsInfo( + author = this.author, + createdAt = this.createdAt.toLocalDateTime(), + headline = this.headline, + id = this.id, + source = this.source, + summary = this.summary, + symbols = this.symbols, + updatedAt = this.updatedAt.toLocalDateTime(), + url = this.url, + ) +} + +fun ErrorMessageDto.toErrorMessage(): ErrorMessage { + return ErrorMessage( + code = this.code, + msg = this.msg, + ) +} + +fun SubscriptionMessageDto.toSubscriptionMessage(): SubscriptionMessage { + return SubscriptionMessage( + news = this.news, + quotes = this.quotes, + trades = this.trades, + ) +} + +fun String.toLocalDateTime(): LocalDateTime { + val parser = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.getDefault()) + val date = LocalDateTime.parse(this, parser) + return date.atZone(ZoneOffset.UTC).withZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime() +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaService.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaService.kt index ad8659a..082e7a6 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaService.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaService.kt @@ -3,17 +3,16 @@ package dev.pinkroom.marketsight.data.remote import com.tinder.scarlet.WebSocket import com.tinder.scarlet.ws.Receive import com.tinder.scarlet.ws.Send -import dev.pinkroom.marketsight.data.remote.model.dto.ResponseAlpacaServiceDto import dev.pinkroom.marketsight.data.remote.model.request.MessageAlpacaService import kotlinx.coroutines.flow.Flow interface AlpacaService { + @Receive + fun observeOnConnectionEvent(): Flow + @Send fun sendSubscribe(message: MessageAlpacaService) @Receive - fun observeResponse(): Flow - - @Receive - fun observeOnConnectionEvent(): Flow + fun observeResponse(): Flow> } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/MessageErrorDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/ErrorMessageDto.kt similarity index 77% rename from app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/MessageErrorDto.kt rename to app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/ErrorMessageDto.kt index aa322c5..8ab15fc 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/MessageErrorDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/ErrorMessageDto.kt @@ -1,6 +1,6 @@ package dev.pinkroom.marketsight.data.remote.model.dto -data class MessageErrorDto( +data class ErrorMessageDto( val code: Int, val msg: String, ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/NewsMessageDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/NewsMessageDto.kt index 10a515f..4a691be 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/NewsMessageDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/NewsMessageDto.kt @@ -2,8 +2,9 @@ package dev.pinkroom.marketsight.data.remote.model.dto import com.google.gson.annotations.SerializedName + data class NewsMessageDto( - val id: Int, + val id: Long, val headline: String, val summary: String, val author: String, @@ -11,6 +12,6 @@ data class NewsMessageDto( @SerializedName("updated_at") val updatedAt: String, val url: String, val content: String, - val symbols: List, + val symbols: List = emptyList(), val source: String, ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/ResponseAlpacaServiceDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/ResponseAlpacaServiceDto.kt deleted file mode 100644 index d6a3ab3..0000000 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/ResponseAlpacaServiceDto.kt +++ /dev/null @@ -1,5 +0,0 @@ -package dev.pinkroom.marketsight.data.remote.model.dto - -data class ResponseAlpacaServiceDto( - val data: List = emptyList(), -) \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/SubscriptionMessageDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/SubscriptionMessageDto.kt new file mode 100644 index 0000000..34a55b6 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/SubscriptionMessageDto.kt @@ -0,0 +1,7 @@ +package dev.pinkroom.marketsight.data.remote.model.dto + +data class SubscriptionMessageDto( + val news: List? = null, + val quotes: List? = null, + val trades: List? = null, +) \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/TypeMessageDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/TypeMessageDto.kt new file mode 100644 index 0000000..4bf03de --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/TypeMessageDto.kt @@ -0,0 +1,7 @@ +package dev.pinkroom.marketsight.data.remote.model.dto + +import com.google.gson.annotations.SerializedName + +data class TypeMessageDto( + @SerializedName("T") val value: String, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt b/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt new file mode 100644 index 0000000..08819b4 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt @@ -0,0 +1,44 @@ +package dev.pinkroom.marketsight.data.repository + +import android.util.Log +import com.tinder.scarlet.WebSocket +import dev.pinkroom.marketsight.common.ActionAlpaca +import dev.pinkroom.marketsight.common.DispatcherProvider +import dev.pinkroom.marketsight.common.Resource +import dev.pinkroom.marketsight.data.data_source.AlpacaRemoteDataSource +import dev.pinkroom.marketsight.data.remote.model.request.MessageAlpacaService +import dev.pinkroom.marketsight.domain.model.NewsInfo +import dev.pinkroom.marketsight.domain.model.SubscriptionMessage +import dev.pinkroom.marketsight.domain.repository.NewsRepository +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.flowOn +import javax.inject.Inject + +class NewsRepositoryImp @Inject constructor( + private val remoteDataSource: AlpacaRemoteDataSource, + private val dispatchers: DispatcherProvider, +): NewsRepository { + override fun subscribeNews( + symbols: List, + ): Flow> = flow { + remoteDataSource.subscribeNews(symbols = symbols).collect{ + emit(it) + } + }.flowOn(dispatchers.IO) + + override fun getRealTimeNews(): Flow>> = flow { + remoteDataSource.getRealTimeNews().collect{ + emit(it) + } + }.flowOn(dispatchers.IO) + + override fun changeFilterNews( + symbolsToSubscribe: List?, + symbolsToUnsubscribe: List? + ): Flow> = flow> { + remoteDataSource.sendMessageToAlpacaService(message = MessageAlpacaService(action = ActionAlpaca.Subscribe.action, news = listOf("*"))).collect{ + + } + }.flowOn(dispatchers.IO) +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt b/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt index 3f63942..d5f9874 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt @@ -1,15 +1,28 @@ package dev.pinkroom.marketsight.di +import android.content.Context +import com.google.gson.Gson +import com.tinder.scarlet.Lifecycle import com.tinder.scarlet.Scarlet +import com.tinder.scarlet.lifecycle.android.AndroidLifecycle import com.tinder.scarlet.messageadapter.gson.GsonMessageAdapter import com.tinder.scarlet.websocket.okhttp.newWebSocketFactory import dagger.Module import dagger.Provides import dagger.hilt.InstallIn +import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent import dev.pinkroom.marketsight.BuildConfig +import dev.pinkroom.marketsight.MarketSightApp +import dev.pinkroom.marketsight.common.DefaultDispatchers +import dev.pinkroom.marketsight.common.DispatcherProvider import dev.pinkroom.marketsight.common.FlowStreamAdapterFactory +import dev.pinkroom.marketsight.common.addAuthenticationInterceptor +import dev.pinkroom.marketsight.common.addLoggingInterceptor +import dev.pinkroom.marketsight.data.data_source.AlpacaRemoteDataSource import dev.pinkroom.marketsight.data.remote.AlpacaService +import dev.pinkroom.marketsight.data.repository.NewsRepositoryImp +import dev.pinkroom.marketsight.domain.repository.NewsRepository import okhttp3.OkHttpClient import java.util.concurrent.TimeUnit import javax.inject.Singleton @@ -26,28 +39,42 @@ object AppModule { .connectTimeout(API_TIMEOUT, TimeUnit.SECONDS) .readTimeout(API_TIMEOUT, TimeUnit.SECONDS) .writeTimeout(API_TIMEOUT, TimeUnit.SECONDS) - .addInterceptor { chain -> - val original = chain.request() - - // Request customization: add request headers - val requestBuilder = original.newBuilder() - .addHeader("APCA-API-KEY-ID", BuildConfig.ALPACA_API_ID) - .addHeader("APCA-API-SECRET-KEY", BuildConfig.ALPACA_API_SECRET) - - val request = requestBuilder.build() - chain.proceed(request) - } + .addAuthenticationInterceptor() + .addLoggingInterceptor() .build() @Provides @Singleton - fun provideAlpacaNewsService(okHttpClient: OkHttpClient): AlpacaService { + fun provideLifeCycle(@ApplicationContext context: Context): Lifecycle = AndroidLifecycle.ofApplicationForeground( + context as MarketSightApp + ) + + @Provides + @Singleton + fun provideAlpacaNewsService(okHttpClient: OkHttpClient, lifecycle: Lifecycle): AlpacaService { val scarlet = Scarlet.Builder() .webSocketFactory(okHttpClient.newWebSocketFactory(ALPACA_STREAM_URL_NEWS)) .addMessageAdapterFactory(GsonMessageAdapter.Factory()) .addStreamAdapterFactory(FlowStreamAdapterFactory()) + //.lifecycle(lifecycle) .build() return scarlet.create(AlpacaService::class.java) } + + @Provides + @Singleton + fun provideGson(): Gson = Gson() + + @Provides + @Singleton + fun provideDispatchers(): DispatcherProvider{ + return DefaultDispatchers() + } + + @Provides + @Singleton + fun provideNewsRepository(alpacaRemoteDataSource: AlpacaRemoteDataSource, dispatcherProvider: DispatcherProvider): NewsRepository { + return NewsRepositoryImp(remoteDataSource = alpacaRemoteDataSource, dispatchers = dispatcherProvider) + } } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/ErrorMessage.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/ErrorMessage.kt new file mode 100644 index 0000000..fd49ed2 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/ErrorMessage.kt @@ -0,0 +1,6 @@ +package dev.pinkroom.marketsight.domain.model + +data class ErrorMessage( + val code: Int, + val msg: String, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/NewsInfo.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/NewsInfo.kt new file mode 100644 index 0000000..cdc979c --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/NewsInfo.kt @@ -0,0 +1,15 @@ +package dev.pinkroom.marketsight.domain.model + +import java.time.LocalDateTime + +data class NewsInfo( + val id: Long, + val headline: String, + val summary: String, + val author: String, + val createdAt: LocalDateTime, + val updatedAt: LocalDateTime, + val url: String, + val symbols: List, + val source: String, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/SubscriptionMessage.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/SubscriptionMessage.kt new file mode 100644 index 0000000..9922f47 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/SubscriptionMessage.kt @@ -0,0 +1,7 @@ +package dev.pinkroom.marketsight.domain.model + +data class SubscriptionMessage( + val news: List? = null, + val quotes: List? = null, + val trades: List? = null, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt index f7ff5cb..8d9eaf6 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt @@ -1,4 +1,18 @@ package dev.pinkroom.marketsight.domain.repository +import com.tinder.scarlet.WebSocket +import dev.pinkroom.marketsight.common.Resource +import dev.pinkroom.marketsight.domain.model.NewsInfo +import dev.pinkroom.marketsight.domain.model.SubscriptionMessage +import kotlinx.coroutines.flow.Flow + interface NewsRepository { + fun subscribeNews( + symbols: List = listOf("*"), + ): Flow> + fun getRealTimeNews(): Flow>> + fun changeFilterNews( + symbolsToSubscribe: List? = null, + symbolsToUnsubscribe: List? = null, + ): Flow> } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt index 5dc3de5..16fefa9 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt @@ -1,6 +1,5 @@ package dev.pinkroom.marketsight.ui -import android.annotation.SuppressLint import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent @@ -11,13 +10,14 @@ import androidx.compose.material3.Surface import androidx.compose.ui.Modifier import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import androidx.navigation.compose.rememberNavController +import dagger.hilt.android.AndroidEntryPoint import dev.pinkroom.marketsight.ui.core.navigation.NavigationAppHost import dev.pinkroom.marketsight.ui.core.navigation.NavigationBottomBar import dev.pinkroom.marketsight.ui.core.navigation.Route import dev.pinkroom.marketsight.ui.core.theme.MarketSightTheme +@AndroidEntryPoint class MainActivity : ComponentActivity() { - @SuppressLint("UnusedMaterial3ScaffoldPaddingParameter") override fun onCreate(savedInstanceState: Bundle?) { installSplashScreen() super.onCreate(savedInstanceState) diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt index 2682fcf..bc34185 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt @@ -2,6 +2,7 @@ package dev.pinkroom.marketsight.ui.core.navigation import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.hilt.navigation.compose.hiltViewModel import androidx.navigation.NavHostController import androidx.navigation.NavType import androidx.navigation.compose.NavHost @@ -10,6 +11,7 @@ import androidx.navigation.navArgument import dev.pinkroom.marketsight.ui.core.navigation.Args.SYMBOL_ID import dev.pinkroom.marketsight.ui.detail_screen.DetailScreen import dev.pinkroom.marketsight.ui.home_screen.HomeScreen +import dev.pinkroom.marketsight.ui.home_screen.HomeViewModel import dev.pinkroom.marketsight.ui.news_screen.NewsScreen @Composable @@ -26,6 +28,7 @@ fun NavigationAppHost( composable( route = Route.HomeScreen.route, ) { + val viewModel = hiltViewModel() HomeScreen() } composable( diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/home_screen/HomeViewModel.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/home_screen/HomeViewModel.kt new file mode 100644 index 0000000..fe5637d --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/home_screen/HomeViewModel.kt @@ -0,0 +1,33 @@ +package dev.pinkroom.marketsight.ui.home_screen + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import dagger.hilt.android.lifecycle.HiltViewModel +import dev.pinkroom.marketsight.domain.repository.NewsRepository +import kotlinx.coroutines.delay +import kotlinx.coroutines.launch +import javax.inject.Inject + +@HiltViewModel +class HomeViewModel @Inject constructor( + newsRepository: NewsRepository +): ViewModel(){ + init { + viewModelScope.launch { + newsRepository.subscribeNews().collect{ + + } + } + viewModelScope.launch { + newsRepository.getRealTimeNews().collect{ + + } + } + viewModelScope.launch { + delay(10000) + newsRepository.changeFilterNews().collect{ + + } + } + } +} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 173ec13..86c6d48 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,4 +3,6 @@ plugins { alias(libs.plugins.androidApplication) apply false alias(libs.plugins.jetbrainsKotlinAndroid) apply false alias(libs.plugins.hiltAndroid) apply false + alias(libs.plugins.jvm) apply false + alias(libs.plugins.jsonSerialization) apply false } \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ec3615f..70d6491 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,13 +7,15 @@ junitVersion = "1.1.5" espressoCore = "3.5.1" lifecycleRuntimeKtx = "2.7.0" activityCompose = "1.8.2" -composeBom = "2024.03.00" +composeBom = "2024.04.00" retrofitVersion = "2.11.0" okHttpVersion = "4.12.0" scarletVersion = "0.1.12" hiltVersion = "2.51.1" hiltNavigationVersion = "1.2.0" splashVersion = "1.0.1" +jsonVersion = "1.6.0" +jsonPluginVersion = "1.9.23" [libraries] @@ -33,6 +35,10 @@ androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", versi retrofit-core = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofitVersion" } retrofit-gson = { group = "com.squareup.retrofit2", name = "converter-gson", version.ref = "retrofitVersion" } +# JSON +json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "jsonVersion" } + + # OkHTTP okhttp-core = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okHttpVersion" } okhttp-interceptor = { group = "com.squareup.okhttp3", name = "logging-interceptor", version.ref = "okHttpVersion" } @@ -41,12 +47,14 @@ okhttp-interceptor = { group = "com.squareup.okhttp3", name = "logging-intercept scarlet-core = { group = "com.tinder.scarlet", name = "scarlet", version.ref = "scarletVersion" } scarlet-stream = { group = "com.tinder.scarlet", name = "stream-adapter-coroutines", version.ref = "scarletVersion" } scarlet-gson = { group = "com.tinder.scarlet", name = "message-adapter-gson", version.ref = "scarletVersion" } +scarlet-moshi = { group = "com.tinder.scarlet", name="message-adapter-moshi", version.ref = "scarletVersion" } scarlet-okhttp = { group = "com.tinder.scarlet", name = "websocket-okhttp", version.ref = "scarletVersion" } +scarlet-lifecycle = { group = "com.tinder.scarlet", name = "lifecycle-android", version.ref = "scarletVersion" } # DAGGER HILT hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hiltVersion" } hilt-navigation = { group = "androidx.hilt", name = "hilt-navigation-compose", version.ref = "hiltNavigationVersion" } -hilt-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hiltVersion" } +hilt-compiler = { group = "com.google.dagger", name = "hilt-compiler", version.ref = "hiltVersion" } # SPLASH splash = { group = "androidx.core", name = "core-splashscreen", version.ref= "splashVersion" } @@ -68,4 +76,6 @@ androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-man androidApplication = { id = "com.android.application", version.ref = "agp" } jetbrainsKotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } hiltAndroid = { id = "com.google.dagger.hilt.android", version.ref = "hiltVersion" } +jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin"} +jsonSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin"} From 739ee0136f4c3bded2b78c7b260fcaf6c6ddd78d Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Thu, 11 Apr 2024 12:55:09 +0100 Subject: [PATCH 08/33] - refactor alpaca news ws service - use case to get News --- .../pinkroom/marketsight/common/Resource.kt | 2 +- .../data_source/AlpacaRemoteDataSource.kt | 15 +++---- .../marketsight/data/remote/AlpacaService.kt | 2 +- .../data/repository/NewsRepositoryImp.kt | 31 +++++++------ .../domain/repository/NewsRepository.kt | 12 +++--- .../domain/use_case/news/ChangeFilterNews.kt | 43 +++++++++++++++++++ .../domain/use_case/news/GetRealTimeNews.kt | 16 +++++++ .../domain/use_case/news/SubscribeNews.kt | 16 +++++++ .../ui/home_screen/HomeViewModel.kt | 22 ---------- 9 files changed, 104 insertions(+), 55 deletions(-) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/ChangeFilterNews.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/GetRealTimeNews.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/SubscribeNews.kt diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/Resource.kt b/app/src/main/java/dev/pinkroom/marketsight/common/Resource.kt index c82f995..4317137 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/common/Resource.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/common/Resource.kt @@ -3,7 +3,7 @@ package dev.pinkroom.marketsight.common import dev.pinkroom.marketsight.domain.model.ErrorMessage sealed class Resource{ - data class Success(val data: T?): Resource() + data class Success(val data: T): Resource() data class Error( val message: String? = null, val errorInfo: ErrorMessage? = null, diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/AlpacaRemoteDataSource.kt b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/AlpacaRemoteDataSource.kt index 494501c..49ac30b 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/AlpacaRemoteDataSource.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/AlpacaRemoteDataSource.kt @@ -16,9 +16,7 @@ import dev.pinkroom.marketsight.data.mapper.toSubscriptionMessage import dev.pinkroom.marketsight.data.remote.AlpacaService import dev.pinkroom.marketsight.data.remote.model.dto.NewsMessageDto import dev.pinkroom.marketsight.data.remote.model.request.MessageAlpacaService -import dev.pinkroom.marketsight.domain.model.NewsInfo import dev.pinkroom.marketsight.domain.model.SubscriptionMessage -import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.take @@ -29,11 +27,11 @@ class AlpacaRemoteDataSource @Inject constructor( private val alpacaService: AlpacaService, private val dispatchers: DispatcherProvider, ) { - fun subscribeNews(symbols: List = listOf("*")): Flow> = flow> { + fun subscribeNews(symbols: List = listOf("*")) = flow> { alpacaService.observeOnConnectionEvent().collect{ when(it){ is WebSocket.Event.OnConnectionOpened<*> -> { - alpacaService.sendSubscribe(message = MessageAlpacaService(action = ActionAlpaca.Subscribe.action, news = symbols)) + alpacaService.sendMessage(message = MessageAlpacaService(action = ActionAlpaca.Subscribe.action, news = symbols)) } is WebSocket.Event.OnMessageReceived -> { Log.d(TAG,"Received: ${it.message}") @@ -53,21 +51,20 @@ class AlpacaRemoteDataSource @Inject constructor( } }.flowOn(dispatchers.IO) - fun getRealTimeNews(): Flow>> = flow { + fun getRealTimeNews() = flow { alpacaService.observeResponse().collect{ data -> - Log.d("TESTE","AQUI SEMPRE") val listNews = mutableListOf() data.forEach { gson.toObject(value = it, helperIdentifier = HelperIdentifierMessagesAlpacaService.News)?.let { news -> listNews.add(news) } } - emit(Resource.Success(listNews.map { it.toNewsInfo() })) + if (listNews.isNotEmpty()) emit(listNews.map { it.toNewsInfo() }) } }.flowOn(dispatchers.IO) - fun sendMessageToAlpacaService(message: MessageAlpacaService): Flow> = flow> { - alpacaService.sendSubscribe(message = message) + fun sendMessageToAlpacaService(message: MessageAlpacaService) = flow> { + alpacaService.sendMessage(message = message) alpacaService.observeResponse().collect { data -> data.forEach { gson.toObject(value = it, helperIdentifier = HelperIdentifierMessagesAlpacaService.Subscription)?.let { sub -> diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaService.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaService.kt index 082e7a6..bf44654 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaService.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaService.kt @@ -11,7 +11,7 @@ interface AlpacaService { fun observeOnConnectionEvent(): Flow @Send - fun sendSubscribe(message: MessageAlpacaService) + fun sendMessage(message: MessageAlpacaService) @Receive fun observeResponse(): Flow> diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt b/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt index 08819b4..d35287c 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt @@ -1,44 +1,43 @@ package dev.pinkroom.marketsight.data.repository -import android.util.Log -import com.tinder.scarlet.WebSocket import dev.pinkroom.marketsight.common.ActionAlpaca import dev.pinkroom.marketsight.common.DispatcherProvider import dev.pinkroom.marketsight.common.Resource import dev.pinkroom.marketsight.data.data_source.AlpacaRemoteDataSource import dev.pinkroom.marketsight.data.remote.model.request.MessageAlpacaService -import dev.pinkroom.marketsight.domain.model.NewsInfo -import dev.pinkroom.marketsight.domain.model.SubscriptionMessage import dev.pinkroom.marketsight.domain.repository.NewsRepository -import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOn +import kotlinx.coroutines.flow.single import javax.inject.Inject class NewsRepositoryImp @Inject constructor( private val remoteDataSource: AlpacaRemoteDataSource, private val dispatchers: DispatcherProvider, ): NewsRepository { - override fun subscribeNews( - symbols: List, - ): Flow> = flow { + override fun subscribeNews(symbols: List) = flow { remoteDataSource.subscribeNews(symbols = symbols).collect{ emit(it) } }.flowOn(dispatchers.IO) - override fun getRealTimeNews(): Flow>> = flow { + override fun getRealTimeNews() = flow { remoteDataSource.getRealTimeNews().collect{ emit(it) } }.flowOn(dispatchers.IO) - override fun changeFilterNews( - symbolsToSubscribe: List?, - symbolsToUnsubscribe: List? - ): Flow> = flow> { - remoteDataSource.sendMessageToAlpacaService(message = MessageAlpacaService(action = ActionAlpaca.Subscribe.action, news = listOf("*"))).collect{ - + override suspend fun changeFilterNews( + symbols: List, + actionAlpaca: ActionAlpaca, + ): Resource> = flow { + val message = MessageAlpacaService(action = actionAlpaca.action, news = symbols) + remoteDataSource.sendMessageToAlpacaService(message = message).collect{ response -> + when(response){ + is Resource.Error -> emit(Resource.Error(data = symbols)) + is Resource.Success -> emit(Resource.Success(data = response.data.news ?: symbols)) + else -> Unit + } } - }.flowOn(dispatchers.IO) + }.flowOn(dispatchers.IO).single() } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt index 8d9eaf6..bbb50c1 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt @@ -1,18 +1,18 @@ package dev.pinkroom.marketsight.domain.repository import com.tinder.scarlet.WebSocket +import dev.pinkroom.marketsight.common.ActionAlpaca import dev.pinkroom.marketsight.common.Resource import dev.pinkroom.marketsight.domain.model.NewsInfo -import dev.pinkroom.marketsight.domain.model.SubscriptionMessage import kotlinx.coroutines.flow.Flow interface NewsRepository { fun subscribeNews( symbols: List = listOf("*"), ): Flow> - fun getRealTimeNews(): Flow>> - fun changeFilterNews( - symbolsToSubscribe: List? = null, - symbolsToUnsubscribe: List? = null, - ): Flow> + fun getRealTimeNews(): Flow> + suspend fun changeFilterNews( + symbols: List, + actionAlpaca: ActionAlpaca, + ): Resource> } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/ChangeFilterNews.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/ChangeFilterNews.kt new file mode 100644 index 0000000..d34b755 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/ChangeFilterNews.kt @@ -0,0 +1,43 @@ +package dev.pinkroom.marketsight.domain.use_case.news + +import dev.pinkroom.marketsight.common.ActionAlpaca +import dev.pinkroom.marketsight.common.DispatcherProvider +import dev.pinkroom.marketsight.common.Resource +import dev.pinkroom.marketsight.domain.repository.NewsRepository +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.flowOn +import javax.inject.Inject + +class ChangeFilterNews @Inject constructor( + private val newsRepository: NewsRepository, + private val dispatchers: DispatcherProvider, +){ + operator fun invoke( + subscribeSymbols: List? = null, + unsubscribeSymbols: List? = null, + ) = flow>> { + val symbolsToRevert = mutableListOf() + unsubscribeSymbols?.let { symbols -> + val response = newsRepository.changeFilterNews(symbols = symbols, actionAlpaca = ActionAlpaca.Unsubscribe) + when(response){ + is Resource.Error -> { + symbolsToRevert.addAll(unsubscribeSymbols) + } + else -> Unit + } + } + + subscribeSymbols?.let { symbols -> + val response = newsRepository.changeFilterNews(symbols = symbols, actionAlpaca = ActionAlpaca.Subscribe) + when(response){ + is Resource.Success -> emit(Resource.Success(data = response.data)) + is Resource.Error -> { + symbolsToRevert.addAll(subscribeSymbols) + } + else -> Unit + } + } + + if (symbolsToRevert.isNotEmpty()) emit(Resource.Error(data = symbolsToRevert)) + }.flowOn(dispatchers.IO) +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/GetRealTimeNews.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/GetRealTimeNews.kt new file mode 100644 index 0000000..2229ddb --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/GetRealTimeNews.kt @@ -0,0 +1,16 @@ +package dev.pinkroom.marketsight.domain.use_case.news + +import dev.pinkroom.marketsight.common.DispatcherProvider +import dev.pinkroom.marketsight.domain.repository.NewsRepository +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.flowOn +import javax.inject.Inject + +class GetRealTimeNews @Inject constructor( + private val newsRepository: NewsRepository, + private val dispatchers: DispatcherProvider, +){ + operator fun invoke() = flow { + emit(newsRepository.getRealTimeNews()) + }.flowOn(dispatchers.IO) +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/SubscribeNews.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/SubscribeNews.kt new file mode 100644 index 0000000..79ca029 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/SubscribeNews.kt @@ -0,0 +1,16 @@ +package dev.pinkroom.marketsight.domain.use_case.news + +import dev.pinkroom.marketsight.common.DispatcherProvider +import dev.pinkroom.marketsight.domain.repository.NewsRepository +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.flowOn +import javax.inject.Inject + +class SubscribeNews @Inject constructor( + private val newsRepository: NewsRepository, + private val dispatchers: DispatcherProvider, +){ + operator fun invoke() = flow { + emit(newsRepository.subscribeNews()) + }.flowOn(dispatchers.IO) +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/home_screen/HomeViewModel.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/home_screen/HomeViewModel.kt index fe5637d..54bdcf1 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/home_screen/HomeViewModel.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/home_screen/HomeViewModel.kt @@ -1,33 +1,11 @@ package dev.pinkroom.marketsight.ui.home_screen import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel -import dev.pinkroom.marketsight.domain.repository.NewsRepository -import kotlinx.coroutines.delay -import kotlinx.coroutines.launch import javax.inject.Inject @HiltViewModel class HomeViewModel @Inject constructor( - newsRepository: NewsRepository ): ViewModel(){ - init { - viewModelScope.launch { - newsRepository.subscribeNews().collect{ - } - } - viewModelScope.launch { - newsRepository.getRealTimeNews().collect{ - - } - } - viewModelScope.launch { - delay(10000) - newsRepository.changeFilterNews().collect{ - - } - } - } } \ No newline at end of file From 201b4b2126144c0a3257eb0ac151d79beabd3eaf Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Thu, 11 Apr 2024 16:21:04 +0100 Subject: [PATCH 09/33] - alpaca news API --- app/build.gradle.kts | 4 +- .../pinkroom/marketsight/common/GsonUtils.kt | 4 +- .../HelperIdentifierMessagesAlpacaService.kt | 6 +- .../pinkroom/marketsight/common/Resource.kt | 2 +- .../dev/pinkroom/marketsight/common/Utils.kt | 5 ++ .../data_source/AlpacaRemoteDataSource.kt | 43 ++++++++++++--- .../marketsight/data/mapper/RemoteMapper.kt | 55 +++++++++++++++++-- .../marketsight/data/remote/AlpacaApi.kt | 4 -- .../marketsight/data/remote/AlpacaNewsApi.kt | 15 +++++ ...{AlpacaService.kt => AlpacaNewsService.kt} | 2 +- .../data/remote/model/dto/ErrorMessageDto.kt | 6 -- .../dto/alpaca_news_api/ImagesNewsDto.kt | 6 ++ .../model/dto/alpaca_news_api/NewsDto.kt | 16 ++++++ .../dto/alpaca_news_api/NewsResponseDto.kt | 8 +++ .../alpaca_news_service/ErrorMessageDto.kt | 6 ++ .../NewsMessageDto.kt | 3 +- .../SubscriptionMessageDto.kt | 2 +- .../TypeMessageDto.kt | 2 +- .../data/repository/NewsRepositoryImp.kt | 16 ++++++ .../dev/pinkroom/marketsight/di/AppModule.kt | 21 ++++++- .../domain/model/{ => common}/ErrorMessage.kt | 2 +- .../model/{ => common}/SubscriptionMessage.kt | 2 +- .../domain/model/news/ImageSize.kt | 7 +++ .../domain/model/news/ImagesNews.kt | 6 ++ .../domain/model/{ => news}/NewsInfo.kt | 3 +- .../domain/model/news/NewsResponse.kt | 6 ++ .../domain/repository/NewsRepository.kt | 11 +++- .../domain/use_case/news/GetNews.kt | 12 ++++ 28 files changed, 231 insertions(+), 44 deletions(-) delete mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaApi.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaNewsApi.kt rename app/src/main/java/dev/pinkroom/marketsight/data/remote/{AlpacaService.kt => AlpacaNewsService.kt} (93%) delete mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/ErrorMessageDto.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/ImagesNewsDto.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/NewsDto.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/NewsResponseDto.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/ErrorMessageDto.kt rename app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/{ => alpaca_news_service}/NewsMessageDto.kt (82%) rename app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/{ => alpaca_news_service}/SubscriptionMessageDto.kt (66%) rename app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/{ => alpaca_news_service}/TypeMessageDto.kt (62%) rename app/src/main/java/dev/pinkroom/marketsight/domain/model/{ => common}/ErrorMessage.kt (56%) rename app/src/main/java/dev/pinkroom/marketsight/domain/model/{ => common}/SubscriptionMessage.kt (73%) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/model/news/ImageSize.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/model/news/ImagesNews.kt rename app/src/main/java/dev/pinkroom/marketsight/domain/model/{ => news}/NewsInfo.kt (75%) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/model/news/NewsResponse.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/GetNews.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 381da7e..c8fcf6f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -29,10 +29,12 @@ android { properties.load(keystoreFile.inputStream()) val alpacaStreamUrl = properties.getProperty("ALPACA_STREAM_URL") ?: "" + val alpacaDataUrl = properties.getProperty("ALPACA_DATA_URL") ?: "" val alpacaApiId = properties.getProperty("ALPACA_API_ID") ?: "" val alpacaApiSecret = properties.getProperty("ALPACA_API_SECRET") ?: "" buildConfigField(type = "String", name = "ALPACA_STREAM_URL", value = alpacaStreamUrl) + buildConfigField(type = "String", name = "ALPACA_DATA_URL", value = alpacaDataUrl) buildConfigField(type = "String", name = "ALPACA_API_ID", value = alpacaApiId) buildConfigField(type = "String", name = "ALPACA_API_SECRET", value = alpacaApiSecret) } @@ -70,7 +72,7 @@ android { dependencies { // CORE - coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4") + coreLibraryDesugaring(libs.androidx.desugar) implementation(libs.androidx.core.ktx) implementation(libs.androidx.lifecycle.runtime.ktx) implementation(libs.androidx.ui) diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/GsonUtils.kt b/app/src/main/java/dev/pinkroom/marketsight/common/GsonUtils.kt index f31803f..c504068 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/common/GsonUtils.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/common/GsonUtils.kt @@ -1,8 +1,8 @@ package dev.pinkroom.marketsight.common import com.google.gson.Gson -import dev.pinkroom.marketsight.data.remote.model.dto.ErrorMessageDto -import dev.pinkroom.marketsight.data.remote.model.dto.TypeMessageDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.ErrorMessageDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.TypeMessageDto fun Gson.toJsonValue(value: Any?, classOfT: Class): T = fromJson(toJson(value), classOfT) diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/HelperIdentifierMessagesAlpacaService.kt b/app/src/main/java/dev/pinkroom/marketsight/common/HelperIdentifierMessagesAlpacaService.kt index 6205a35..50099b0 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/common/HelperIdentifierMessagesAlpacaService.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/common/HelperIdentifierMessagesAlpacaService.kt @@ -1,8 +1,8 @@ package dev.pinkroom.marketsight.common -import dev.pinkroom.marketsight.data.remote.model.dto.ErrorMessageDto -import dev.pinkroom.marketsight.data.remote.model.dto.NewsMessageDto -import dev.pinkroom.marketsight.data.remote.model.dto.SubscriptionMessageDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.ErrorMessageDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.NewsMessageDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.SubscriptionMessageDto sealed class HelperIdentifierMessagesAlpacaService( val identifier: String, diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/Resource.kt b/app/src/main/java/dev/pinkroom/marketsight/common/Resource.kt index 4317137..610ce0c 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/common/Resource.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/common/Resource.kt @@ -1,6 +1,6 @@ package dev.pinkroom.marketsight.common -import dev.pinkroom.marketsight.domain.model.ErrorMessage +import dev.pinkroom.marketsight.domain.model.common.ErrorMessage sealed class Resource{ data class Success(val data: T): Resource() diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt b/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt index 5c285c3..e93c9db 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt @@ -29,4 +29,9 @@ fun OkHttpClient.Builder.addLoggingInterceptor(): OkHttpClient.Builder { sealed class ActionAlpaca(val action: String) { data object Subscribe: ActionAlpaca(action = "subscribe") data object Unsubscribe: ActionAlpaca(action = "unsubscribe") +} + +sealed class SortType(val type: String){ + data object DESC: SortType(type = "desc") + data object ASC: SortType(type = "asc") } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/AlpacaRemoteDataSource.kt b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/AlpacaRemoteDataSource.kt index 49ac30b..1955882 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/AlpacaRemoteDataSource.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/AlpacaRemoteDataSource.kt @@ -8,15 +8,19 @@ import dev.pinkroom.marketsight.common.ActionAlpaca import dev.pinkroom.marketsight.common.DispatcherProvider import dev.pinkroom.marketsight.common.HelperIdentifierMessagesAlpacaService import dev.pinkroom.marketsight.common.Resource +import dev.pinkroom.marketsight.common.SortType import dev.pinkroom.marketsight.common.toObject import dev.pinkroom.marketsight.common.verifyIfIsError import dev.pinkroom.marketsight.data.mapper.toErrorMessage import dev.pinkroom.marketsight.data.mapper.toNewsInfo +import dev.pinkroom.marketsight.data.mapper.toNewsResponse import dev.pinkroom.marketsight.data.mapper.toSubscriptionMessage -import dev.pinkroom.marketsight.data.remote.AlpacaService -import dev.pinkroom.marketsight.data.remote.model.dto.NewsMessageDto +import dev.pinkroom.marketsight.data.remote.AlpacaNewsApi +import dev.pinkroom.marketsight.data.remote.AlpacaNewsService +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.NewsMessageDto import dev.pinkroom.marketsight.data.remote.model.request.MessageAlpacaService -import dev.pinkroom.marketsight.domain.model.SubscriptionMessage +import dev.pinkroom.marketsight.domain.model.common.SubscriptionMessage +import dev.pinkroom.marketsight.domain.model.news.NewsResponse import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.take @@ -24,14 +28,15 @@ import javax.inject.Inject class AlpacaRemoteDataSource @Inject constructor( private val gson: Gson, - private val alpacaService: AlpacaService, + private val alpacaNewsService: AlpacaNewsService, + private val alpacaNewsApi: AlpacaNewsApi, private val dispatchers: DispatcherProvider, ) { fun subscribeNews(symbols: List = listOf("*")) = flow> { - alpacaService.observeOnConnectionEvent().collect{ + alpacaNewsService.observeOnConnectionEvent().collect{ when(it){ is WebSocket.Event.OnConnectionOpened<*> -> { - alpacaService.sendMessage(message = MessageAlpacaService(action = ActionAlpaca.Subscribe.action, news = symbols)) + alpacaNewsService.sendMessage(message = MessageAlpacaService(action = ActionAlpaca.Subscribe.action, news = symbols)) } is WebSocket.Event.OnMessageReceived -> { Log.d(TAG,"Received: ${it.message}") @@ -52,7 +57,7 @@ class AlpacaRemoteDataSource @Inject constructor( }.flowOn(dispatchers.IO) fun getRealTimeNews() = flow { - alpacaService.observeResponse().collect{ data -> + alpacaNewsService.observeResponse().collect{ data -> val listNews = mutableListOf() data.forEach { gson.toObject(value = it, helperIdentifier = HelperIdentifierMessagesAlpacaService.News)?.let { news -> @@ -64,8 +69,8 @@ class AlpacaRemoteDataSource @Inject constructor( }.flowOn(dispatchers.IO) fun sendMessageToAlpacaService(message: MessageAlpacaService) = flow> { - alpacaService.sendMessage(message = message) - alpacaService.observeResponse().collect { data -> + alpacaNewsService.sendMessage(message = message) + alpacaNewsService.observeResponse().collect { data -> data.forEach { gson.toObject(value = it, helperIdentifier = HelperIdentifierMessagesAlpacaService.Subscription)?.let { sub -> emit(Resource.Success(sub.toSubscriptionMessage())) @@ -76,6 +81,26 @@ class AlpacaRemoteDataSource @Inject constructor( } }.flowOn(dispatchers.IO).take(1) + suspend fun getNews( + symbols: List?, + limit: Int?, + pageToken: String?, + sort: SortType? + ): Resource{ + return try { + val response = alpacaNewsApi.getNews( + symbols = symbols?.joinToString(","), + perPage = limit, + pageToken = pageToken, + sort = sort?.type, + ) + Resource.Success(data = response.toNewsResponse()) + } catch (e: Exception){ + e.printStackTrace() + Resource.Error(message = e.message ?: "Something Went Wrong") + } + } + companion object { const val TAG = "AlpacaRemote" } diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt b/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt index 37a3fe0..8f7552a 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt @@ -1,11 +1,17 @@ package dev.pinkroom.marketsight.data.mapper -import dev.pinkroom.marketsight.data.remote.model.dto.ErrorMessageDto -import dev.pinkroom.marketsight.data.remote.model.dto.NewsMessageDto -import dev.pinkroom.marketsight.data.remote.model.dto.SubscriptionMessageDto -import dev.pinkroom.marketsight.domain.model.ErrorMessage -import dev.pinkroom.marketsight.domain.model.NewsInfo -import dev.pinkroom.marketsight.domain.model.SubscriptionMessage +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.ImagesNewsDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.NewsDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.NewsResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.ErrorMessageDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.NewsMessageDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.SubscriptionMessageDto +import dev.pinkroom.marketsight.domain.model.common.ErrorMessage +import dev.pinkroom.marketsight.domain.model.common.SubscriptionMessage +import dev.pinkroom.marketsight.domain.model.news.ImageSize +import dev.pinkroom.marketsight.domain.model.news.ImagesNews +import dev.pinkroom.marketsight.domain.model.news.NewsInfo +import dev.pinkroom.marketsight.domain.model.news.NewsResponse import java.time.LocalDateTime import java.time.ZoneId import java.time.ZoneOffset @@ -45,4 +51,41 @@ fun String.toLocalDateTime(): LocalDateTime { val parser = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.getDefault()) val date = LocalDateTime.parse(this, parser) return date.atZone(ZoneOffset.UTC).withZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime() +} + +fun NewsResponseDto.toNewsResponse(): NewsResponse { + return NewsResponse( + news = this.news.map { it.toNewsInfo() }, + nextPageToken = this.nextPageToken, + ) +} + +fun NewsDto.toNewsInfo(): NewsInfo { + return NewsInfo( + author = this.author, + createdAt = this.createdAt.toLocalDateTime(), + headline = this.headline, + id = this.id, + source = this.source, + summary = this.summary, + symbols = this.symbols, + updatedAt = this.updatedAt.toLocalDateTime(), + url = this.url, + images = this.images.map { it.toImagesNews() } + ) +} + +fun ImagesNewsDto.toImagesNews(): ImagesNews { + return ImagesNews( + url = this.url, + size = this.size.toImageSize(), + ) +} + +fun String.toImageSize(): ImageSize { + return when(this){ + "large" -> ImageSize.Large + "small" -> ImageSize.Small + else -> ImageSize.Thumb + } } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaApi.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaApi.kt deleted file mode 100644 index b134966..0000000 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaApi.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.pinkroom.marketsight.data.remote - -interface AlpacaApi { -} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaNewsApi.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaNewsApi.kt new file mode 100644 index 0000000..2bbf17f --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaNewsApi.kt @@ -0,0 +1,15 @@ +package dev.pinkroom.marketsight.data.remote + +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.NewsResponseDto +import retrofit2.http.GET +import retrofit2.http.Query + +interface AlpacaNewsApi { + @GET("news") + suspend fun getNews( + @Query("symbols") symbols: String? = null, + @Query("limit") perPage: Int? = null, + @Query("page_token") pageToken: String? = null, + @Query("sort") sort: String? = null, + ): NewsResponseDto +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaService.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaNewsService.kt similarity index 93% rename from app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaService.kt rename to app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaNewsService.kt index bf44654..543c05e 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaService.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaNewsService.kt @@ -6,7 +6,7 @@ import com.tinder.scarlet.ws.Send import dev.pinkroom.marketsight.data.remote.model.request.MessageAlpacaService import kotlinx.coroutines.flow.Flow -interface AlpacaService { +interface AlpacaNewsService { @Receive fun observeOnConnectionEvent(): Flow diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/ErrorMessageDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/ErrorMessageDto.kt deleted file mode 100644 index 8ab15fc..0000000 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/ErrorMessageDto.kt +++ /dev/null @@ -1,6 +0,0 @@ -package dev.pinkroom.marketsight.data.remote.model.dto - -data class ErrorMessageDto( - val code: Int, - val msg: String, -) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/ImagesNewsDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/ImagesNewsDto.kt new file mode 100644 index 0000000..c9aa082 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/ImagesNewsDto.kt @@ -0,0 +1,6 @@ +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api + +data class ImagesNewsDto( + val size: String, + val url: String, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/NewsDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/NewsDto.kt new file mode 100644 index 0000000..236fb7f --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/NewsDto.kt @@ -0,0 +1,16 @@ +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api + +import com.google.gson.annotations.SerializedName + +data class NewsDto( + val id: Long, + val headline: String, + val summary: String, + val author: String, + @SerializedName("created_at") val createdAt: String, + @SerializedName("updated_at") val updatedAt: String, + val url: String, + val symbols: List = emptyList(), + val source: String, + val images: List = emptyList(), +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/NewsResponseDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/NewsResponseDto.kt new file mode 100644 index 0000000..e6a1998 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/NewsResponseDto.kt @@ -0,0 +1,8 @@ +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api + +import com.google.gson.annotations.SerializedName + +data class NewsResponseDto( + val news: List, + @SerializedName("next_page_token") val nextPageToken: String, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/ErrorMessageDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/ErrorMessageDto.kt new file mode 100644 index 0000000..5899a08 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/ErrorMessageDto.kt @@ -0,0 +1,6 @@ +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service + +data class ErrorMessageDto( + val code: Int, + val msg: String, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/NewsMessageDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/NewsMessageDto.kt similarity index 82% rename from app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/NewsMessageDto.kt rename to app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/NewsMessageDto.kt index 4a691be..d5e5531 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/NewsMessageDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/NewsMessageDto.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.data.remote.model.dto +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service import com.google.gson.annotations.SerializedName @@ -11,7 +11,6 @@ data class NewsMessageDto( @SerializedName("created_at") val createdAt: String, @SerializedName("updated_at") val updatedAt: String, val url: String, - val content: String, val symbols: List = emptyList(), val source: String, ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/SubscriptionMessageDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/SubscriptionMessageDto.kt similarity index 66% rename from app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/SubscriptionMessageDto.kt rename to app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/SubscriptionMessageDto.kt index 34a55b6..6adc20f 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/SubscriptionMessageDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/SubscriptionMessageDto.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.data.remote.model.dto +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service data class SubscriptionMessageDto( val news: List? = null, diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/TypeMessageDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/TypeMessageDto.kt similarity index 62% rename from app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/TypeMessageDto.kt rename to app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/TypeMessageDto.kt index 4bf03de..c2cfd76 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/TypeMessageDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/TypeMessageDto.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.data.remote.model.dto +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service import com.google.gson.annotations.SerializedName diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt b/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt index d35287c..30934df 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt @@ -3,8 +3,10 @@ package dev.pinkroom.marketsight.data.repository import dev.pinkroom.marketsight.common.ActionAlpaca import dev.pinkroom.marketsight.common.DispatcherProvider import dev.pinkroom.marketsight.common.Resource +import dev.pinkroom.marketsight.common.SortType import dev.pinkroom.marketsight.data.data_source.AlpacaRemoteDataSource import dev.pinkroom.marketsight.data.remote.model.request.MessageAlpacaService +import dev.pinkroom.marketsight.domain.model.news.NewsResponse import dev.pinkroom.marketsight.domain.repository.NewsRepository import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOn @@ -40,4 +42,18 @@ class NewsRepositoryImp @Inject constructor( } } }.flowOn(dispatchers.IO).single() + + override suspend fun getNews( + symbols: List?, + limit: Int?, + pageToken: String?, + sort: SortType? + ): Resource { + return remoteDataSource.getNews( + symbols = symbols, + limit = limit, + pageToken = pageToken, + sort = sort, + ) + } } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt b/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt index d5f9874..cf240ad 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt @@ -20,10 +20,14 @@ import dev.pinkroom.marketsight.common.FlowStreamAdapterFactory import dev.pinkroom.marketsight.common.addAuthenticationInterceptor import dev.pinkroom.marketsight.common.addLoggingInterceptor import dev.pinkroom.marketsight.data.data_source.AlpacaRemoteDataSource -import dev.pinkroom.marketsight.data.remote.AlpacaService +import dev.pinkroom.marketsight.data.remote.AlpacaNewsApi +import dev.pinkroom.marketsight.data.remote.AlpacaNewsService import dev.pinkroom.marketsight.data.repository.NewsRepositoryImp import dev.pinkroom.marketsight.domain.repository.NewsRepository import okhttp3.OkHttpClient +import retrofit2.Retrofit +import retrofit2.converter.gson.GsonConverterFactory +import retrofit2.create import java.util.concurrent.TimeUnit import javax.inject.Singleton @@ -51,7 +55,7 @@ object AppModule { @Provides @Singleton - fun provideAlpacaNewsService(okHttpClient: OkHttpClient, lifecycle: Lifecycle): AlpacaService { + fun provideAlpacaNewsService(okHttpClient: OkHttpClient, lifecycle: Lifecycle): AlpacaNewsService { val scarlet = Scarlet.Builder() .webSocketFactory(okHttpClient.newWebSocketFactory(ALPACA_STREAM_URL_NEWS)) .addMessageAdapterFactory(GsonMessageAdapter.Factory()) @@ -59,7 +63,18 @@ object AppModule { //.lifecycle(lifecycle) .build() - return scarlet.create(AlpacaService::class.java) + return scarlet.create(AlpacaNewsService::class.java) + } + + @Provides + @Singleton + fun provideAlpacaNewsApi(okHttpClient: OkHttpClient): AlpacaNewsApi { + return Retrofit.Builder() + .baseUrl(BuildConfig.ALPACA_DATA_URL) + .addConverterFactory(GsonConverterFactory.create()) + .client(okHttpClient) + .build() + .create() } @Provides diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/ErrorMessage.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/common/ErrorMessage.kt similarity index 56% rename from app/src/main/java/dev/pinkroom/marketsight/domain/model/ErrorMessage.kt rename to app/src/main/java/dev/pinkroom/marketsight/domain/model/common/ErrorMessage.kt index fd49ed2..6910af4 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/model/ErrorMessage.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/common/ErrorMessage.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.domain.model +package dev.pinkroom.marketsight.domain.model.common data class ErrorMessage( val code: Int, diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/SubscriptionMessage.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/common/SubscriptionMessage.kt similarity index 73% rename from app/src/main/java/dev/pinkroom/marketsight/domain/model/SubscriptionMessage.kt rename to app/src/main/java/dev/pinkroom/marketsight/domain/model/common/SubscriptionMessage.kt index 9922f47..fe1aacb 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/model/SubscriptionMessage.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/common/SubscriptionMessage.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.domain.model +package dev.pinkroom.marketsight.domain.model.common data class SubscriptionMessage( val news: List? = null, diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/ImageSize.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/ImageSize.kt new file mode 100644 index 0000000..cdba1e7 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/ImageSize.kt @@ -0,0 +1,7 @@ +package dev.pinkroom.marketsight.domain.model.news + +sealed interface ImageSize { + data object Large: ImageSize + data object Small: ImageSize + data object Thumb: ImageSize +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/ImagesNews.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/ImagesNews.kt new file mode 100644 index 0000000..8996353 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/ImagesNews.kt @@ -0,0 +1,6 @@ +package dev.pinkroom.marketsight.domain.model.news + +data class ImagesNews( + val size: ImageSize, + val url: String, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/NewsInfo.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/NewsInfo.kt similarity index 75% rename from app/src/main/java/dev/pinkroom/marketsight/domain/model/NewsInfo.kt rename to app/src/main/java/dev/pinkroom/marketsight/domain/model/news/NewsInfo.kt index cdc979c..db4182b 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/model/NewsInfo.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/NewsInfo.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.domain.model +package dev.pinkroom.marketsight.domain.model.news import java.time.LocalDateTime @@ -12,4 +12,5 @@ data class NewsInfo( val url: String, val symbols: List, val source: String, + val images: List? = null, ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/NewsResponse.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/NewsResponse.kt new file mode 100644 index 0000000..e8f6933 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/NewsResponse.kt @@ -0,0 +1,6 @@ +package dev.pinkroom.marketsight.domain.model.news + +data class NewsResponse( + val news: List, + val nextPageToken: String, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt index bbb50c1..dd2f56c 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt @@ -3,7 +3,9 @@ package dev.pinkroom.marketsight.domain.repository import com.tinder.scarlet.WebSocket import dev.pinkroom.marketsight.common.ActionAlpaca import dev.pinkroom.marketsight.common.Resource -import dev.pinkroom.marketsight.domain.model.NewsInfo +import dev.pinkroom.marketsight.common.SortType +import dev.pinkroom.marketsight.domain.model.news.NewsInfo +import dev.pinkroom.marketsight.domain.model.news.NewsResponse import kotlinx.coroutines.flow.Flow interface NewsRepository { @@ -15,4 +17,11 @@ interface NewsRepository { symbols: List, actionAlpaca: ActionAlpaca, ): Resource> + + suspend fun getNews( + symbols: List? = null, + limit: Int? = null, + pageToken: String? = null, + sort: SortType? = SortType.DESC, + ): Resource } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/GetNews.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/GetNews.kt new file mode 100644 index 0000000..42e6cca --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/GetNews.kt @@ -0,0 +1,12 @@ +package dev.pinkroom.marketsight.domain.use_case.news + +import dev.pinkroom.marketsight.domain.repository.NewsRepository +import javax.inject.Inject + +class GetNews @Inject constructor( + private val newsRepository: NewsRepository, +){ + suspend operator fun invoke(){ + newsRepository.getNews() + } +} \ No newline at end of file From b539b0cb5cbb9f24abf62f19d0d683ec5da1f0b5 Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Thu, 11 Apr 2024 16:21:16 +0100 Subject: [PATCH 10/33] - alpaca news API --- gradle/libs.versions.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 70d6491..0b8bbcb 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -15,7 +15,7 @@ hiltVersion = "2.51.1" hiltNavigationVersion = "1.2.0" splashVersion = "1.0.1" jsonVersion = "1.6.0" -jsonPluginVersion = "1.9.23" +desugarVersion = "2.0.4" [libraries] @@ -26,6 +26,7 @@ androidx-ui = { group = "androidx.compose.ui", name = "ui" } androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" } androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview"} androidx-material3 = { group = "androidx.compose.material3", name = "material3" } +androidx-desugar = { group = "com.android.tools", name = "desugar_jdk_libs", version.ref = "desugarVersion" } # COMPOSE androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" } From 27987744f73175ba751a1ac942ab5e61254e3c7e Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Thu, 11 Apr 2024 18:32:32 +0100 Subject: [PATCH 11/33] - setup Unit Test libs - assertK - mockK - JUnit - coroutine test --- app/build.gradle.kts | 5 ++++- .../dev/pinkroom/marketsight/ExampleUnitTest.kt | 17 ----------------- .../data_source/AlpacaRemoteDataSourceTest.kt | 4 ++++ gradle/libs.versions.toml | 17 +++++++++++++---- 4 files changed, 21 insertions(+), 22 deletions(-) delete mode 100644 app/src/test/java/dev/pinkroom/marketsight/ExampleUnitTest.kt create mode 100644 app/src/test/java/dev/pinkroom/marketsight/data/data_source/AlpacaRemoteDataSourceTest.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c8fcf6f..49b348d 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -113,7 +113,10 @@ dependencies { // UNIT TEST testImplementation(libs.junit) - testImplementation(libs.junit.api) + testImplementation(libs.mockk.android) + testImplementation(libs.mockk.agent) + testImplementation(libs.coroutine.test) + testImplementation(libs.assertk) // END-TO-END TEST androidTestImplementation(libs.androidx.junit) diff --git a/app/src/test/java/dev/pinkroom/marketsight/ExampleUnitTest.kt b/app/src/test/java/dev/pinkroom/marketsight/ExampleUnitTest.kt deleted file mode 100644 index ab046ad..0000000 --- a/app/src/test/java/dev/pinkroom/marketsight/ExampleUnitTest.kt +++ /dev/null @@ -1,17 +0,0 @@ -package dev.pinkroom.marketsight - -import org.junit.Test - -import org.junit.Assert.* - -/** - * Example local unit test, which will execute on the development machine (host). - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -class ExampleUnitTest { - @Test - fun addition_isCorrect() { - assertEquals(4, 2 + 2) - } -} \ No newline at end of file diff --git a/app/src/test/java/dev/pinkroom/marketsight/data/data_source/AlpacaRemoteDataSourceTest.kt b/app/src/test/java/dev/pinkroom/marketsight/data/data_source/AlpacaRemoteDataSourceTest.kt new file mode 100644 index 0000000..a990efb --- /dev/null +++ b/app/src/test/java/dev/pinkroom/marketsight/data/data_source/AlpacaRemoteDataSourceTest.kt @@ -0,0 +1,4 @@ +package dev.pinkroom.marketsight.data.data_source + +class AlpacaRemoteDataSourceTest{ +} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0b8bbcb..7013a6f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,7 +2,6 @@ agp = "8.3.1" kotlin = "1.9.22" coreKtx = "1.12.0" -junit = "5.10.2" junitVersion = "1.1.5" espressoCore = "3.5.1" lifecycleRuntimeKtx = "2.7.0" @@ -16,6 +15,10 @@ hiltNavigationVersion = "1.2.0" splashVersion = "1.0.1" jsonVersion = "1.6.0" desugarVersion = "2.0.4" +junit4 = "4.13.2" +mockkVersion = "1.13.10" +coroutineVersion = "1.8.0" +assertkVersion = "0.28.0" [libraries] @@ -39,7 +42,6 @@ retrofit-gson = { group = "com.squareup.retrofit2", name = "converter-gson", ver # JSON json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "jsonVersion" } - # OkHTTP okhttp-core = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okHttpVersion" } okhttp-interceptor = { group = "com.squareup.okhttp3", name = "logging-interceptor", version.ref = "okHttpVersion" } @@ -61,8 +63,15 @@ hilt-compiler = { group = "com.google.dagger", name = "hilt-compiler", version.r splash = { group = "androidx.core", name = "core-splashscreen", version.ref= "splashVersion" } # UNIT TEST -junit = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "junit" } -junit-api = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "junit" } +junit = { group = "junit", name = "junit", version.ref = "junit4" } +coroutine-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "coroutineVersion" } + +# ASSERTK +assertk = { group = "com.willowtreeapps.assertk", name = "assertk", version.ref = "assertkVersion"} + +# MOCKK +mockk-android = { group = "io.mockk", name = "mockk-android", version.ref = "mockkVersion" } +mockk-agent = { group = "io.mockk", name = "mockk-agent", version.ref = "mockkVersion" } # END-TO-END TEST androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } From d26ca4fc6229ffb050631b8ff90cee34e3aef524 Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Fri, 12 Apr 2024 15:43:55 +0100 Subject: [PATCH 12/33] - faker dependency - unit test (NewsRemoteDataSource) - refactor code --- app/build.gradle.kts | 1 + ...eDataSource.kt => NewsRemoteDataSource.kt} | 4 +- .../alpaca_news_service/ErrorMessageDto.kt | 3 + .../dto/alpaca_news_service/NewsMessageDto.kt | 1 + .../SubscriptionMessageDto.kt | 3 + .../model/request/MessageAlpacaService.kt | 6 +- .../data/repository/NewsRepositoryImp.kt | 12 +- .../dev/pinkroom/marketsight/di/AppModule.kt | 6 +- .../domain/use_case/news/GetNews.kt | 4 +- .../domain/use_case/news/GetRealTimeNews.kt | 5 +- .../domain/use_case/news/SubscribeNews.kt | 5 +- .../ui/home_screen/HomeViewModel.kt | 1 - .../data_source/AlpacaRemoteDataSourceTest.kt | 4 - .../data_source/NewsRemoteDataSourceTest.kt | 288 ++++++++++++++++++ .../marketsight/factories/BaseFactory.kt | 6 + .../marketsight/factories/ImagesFactory.kt | 19 ++ .../marketsight/factories/NewsDtoFactory.kt | 22 ++ .../marketsight/factories/NewsFactory.kt | 22 ++ .../marketsight/util/MainCoroutineRule.kt | 26 ++ .../util/TestDispatcherProvider.kt | 16 + gradle/libs.versions.toml | 6 +- 21 files changed, 429 insertions(+), 31 deletions(-) rename app/src/main/java/dev/pinkroom/marketsight/data/data_source/{AlpacaRemoteDataSource.kt => NewsRemoteDataSource.kt} (96%) delete mode 100644 app/src/test/java/dev/pinkroom/marketsight/data/data_source/AlpacaRemoteDataSourceTest.kt create mode 100644 app/src/test/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSourceTest.kt create mode 100644 app/src/test/java/dev/pinkroom/marketsight/factories/BaseFactory.kt create mode 100644 app/src/test/java/dev/pinkroom/marketsight/factories/ImagesFactory.kt create mode 100644 app/src/test/java/dev/pinkroom/marketsight/factories/NewsDtoFactory.kt create mode 100644 app/src/test/java/dev/pinkroom/marketsight/factories/NewsFactory.kt create mode 100644 app/src/test/java/dev/pinkroom/marketsight/util/MainCoroutineRule.kt create mode 100644 app/src/test/java/dev/pinkroom/marketsight/util/TestDispatcherProvider.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 49b348d..ecc4305 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -117,6 +117,7 @@ dependencies { testImplementation(libs.mockk.agent) testImplementation(libs.coroutine.test) testImplementation(libs.assertk) + testImplementation(libs.faker) // END-TO-END TEST androidTestImplementation(libs.androidx.junit) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/AlpacaRemoteDataSource.kt b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt similarity index 96% rename from app/src/main/java/dev/pinkroom/marketsight/data/data_source/AlpacaRemoteDataSource.kt rename to app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt index 1955882..28f601d 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/AlpacaRemoteDataSource.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt @@ -26,7 +26,7 @@ import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.take import javax.inject.Inject -class AlpacaRemoteDataSource @Inject constructor( +class NewsRemoteDataSource @Inject constructor( private val gson: Gson, private val alpacaNewsService: AlpacaNewsService, private val alpacaNewsApi: AlpacaNewsApi, @@ -68,7 +68,7 @@ class AlpacaRemoteDataSource @Inject constructor( } }.flowOn(dispatchers.IO) - fun sendMessageToAlpacaService(message: MessageAlpacaService) = flow> { + fun sendSubscribeMessageToAlpacaService(message: MessageAlpacaService) = flow> { alpacaNewsService.sendMessage(message = message) alpacaNewsService.observeResponse().collect { data -> data.forEach { diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/ErrorMessageDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/ErrorMessageDto.kt index 5899a08..1448e51 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/ErrorMessageDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/ErrorMessageDto.kt @@ -1,6 +1,9 @@ package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service +import com.google.gson.annotations.SerializedName + data class ErrorMessageDto( + @SerializedName("T") val type: String, val code: Int, val msg: String, ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/NewsMessageDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/NewsMessageDto.kt index d5e5531..fe7b1f2 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/NewsMessageDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/NewsMessageDto.kt @@ -4,6 +4,7 @@ import com.google.gson.annotations.SerializedName data class NewsMessageDto( + @SerializedName("T") val type: String, val id: Long, val headline: String, val summary: String, diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/SubscriptionMessageDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/SubscriptionMessageDto.kt index 6adc20f..ccbd2d3 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/SubscriptionMessageDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/SubscriptionMessageDto.kt @@ -1,6 +1,9 @@ package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service +import com.google.gson.annotations.SerializedName + data class SubscriptionMessageDto( + @SerializedName("T") val type: String, val news: List? = null, val quotes: List? = null, val trades: List? = null, diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/request/MessageAlpacaService.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/request/MessageAlpacaService.kt index 7e3cd8a..ea1a837 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/request/MessageAlpacaService.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/request/MessageAlpacaService.kt @@ -2,7 +2,7 @@ package dev.pinkroom.marketsight.data.remote.model.request data class MessageAlpacaService( val action: String, // subscribe / unsubscribe - val trades: List = emptyList(), - val quotes: List = emptyList(), - val news: List = emptyList(), + val trades: List? = null, + val quotes: List? = null, + val news: List? = null, ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt b/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt index 30934df..4b54717 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt @@ -4,7 +4,7 @@ import dev.pinkroom.marketsight.common.ActionAlpaca import dev.pinkroom.marketsight.common.DispatcherProvider import dev.pinkroom.marketsight.common.Resource import dev.pinkroom.marketsight.common.SortType -import dev.pinkroom.marketsight.data.data_source.AlpacaRemoteDataSource +import dev.pinkroom.marketsight.data.data_source.NewsRemoteDataSource import dev.pinkroom.marketsight.data.remote.model.request.MessageAlpacaService import dev.pinkroom.marketsight.domain.model.news.NewsResponse import dev.pinkroom.marketsight.domain.repository.NewsRepository @@ -14,17 +14,17 @@ import kotlinx.coroutines.flow.single import javax.inject.Inject class NewsRepositoryImp @Inject constructor( - private val remoteDataSource: AlpacaRemoteDataSource, + private val newsRemoteDataSource: NewsRemoteDataSource, private val dispatchers: DispatcherProvider, ): NewsRepository { override fun subscribeNews(symbols: List) = flow { - remoteDataSource.subscribeNews(symbols = symbols).collect{ + newsRemoteDataSource.subscribeNews(symbols = symbols).collect{ emit(it) } }.flowOn(dispatchers.IO) override fun getRealTimeNews() = flow { - remoteDataSource.getRealTimeNews().collect{ + newsRemoteDataSource.getRealTimeNews().collect{ emit(it) } }.flowOn(dispatchers.IO) @@ -34,7 +34,7 @@ class NewsRepositoryImp @Inject constructor( actionAlpaca: ActionAlpaca, ): Resource> = flow { val message = MessageAlpacaService(action = actionAlpaca.action, news = symbols) - remoteDataSource.sendMessageToAlpacaService(message = message).collect{ response -> + newsRemoteDataSource.sendSubscribeMessageToAlpacaService(message = message).collect{ response -> when(response){ is Resource.Error -> emit(Resource.Error(data = symbols)) is Resource.Success -> emit(Resource.Success(data = response.data.news ?: symbols)) @@ -49,7 +49,7 @@ class NewsRepositoryImp @Inject constructor( pageToken: String?, sort: SortType? ): Resource { - return remoteDataSource.getNews( + return newsRemoteDataSource.getNews( symbols = symbols, limit = limit, pageToken = pageToken, diff --git a/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt b/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt index cf240ad..2896c7d 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt @@ -19,7 +19,7 @@ import dev.pinkroom.marketsight.common.DispatcherProvider import dev.pinkroom.marketsight.common.FlowStreamAdapterFactory import dev.pinkroom.marketsight.common.addAuthenticationInterceptor import dev.pinkroom.marketsight.common.addLoggingInterceptor -import dev.pinkroom.marketsight.data.data_source.AlpacaRemoteDataSource +import dev.pinkroom.marketsight.data.data_source.NewsRemoteDataSource import dev.pinkroom.marketsight.data.remote.AlpacaNewsApi import dev.pinkroom.marketsight.data.remote.AlpacaNewsService import dev.pinkroom.marketsight.data.repository.NewsRepositoryImp @@ -89,7 +89,7 @@ object AppModule { @Provides @Singleton - fun provideNewsRepository(alpacaRemoteDataSource: AlpacaRemoteDataSource, dispatcherProvider: DispatcherProvider): NewsRepository { - return NewsRepositoryImp(remoteDataSource = alpacaRemoteDataSource, dispatchers = dispatcherProvider) + fun provideNewsRepository(newsRemoteDataSource: NewsRemoteDataSource, dispatcherProvider: DispatcherProvider): NewsRepository { + return NewsRepositoryImp(newsRemoteDataSource = newsRemoteDataSource, dispatchers = dispatcherProvider) } } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/GetNews.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/GetNews.kt index 42e6cca..852c9aa 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/GetNews.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/GetNews.kt @@ -6,7 +6,5 @@ import javax.inject.Inject class GetNews @Inject constructor( private val newsRepository: NewsRepository, ){ - suspend operator fun invoke(){ - newsRepository.getNews() - } + suspend operator fun invoke() = newsRepository.getNews() } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/GetRealTimeNews.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/GetRealTimeNews.kt index 2229ddb..625119a 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/GetRealTimeNews.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/GetRealTimeNews.kt @@ -2,7 +2,6 @@ package dev.pinkroom.marketsight.domain.use_case.news import dev.pinkroom.marketsight.common.DispatcherProvider import dev.pinkroom.marketsight.domain.repository.NewsRepository -import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOn import javax.inject.Inject @@ -10,7 +9,5 @@ class GetRealTimeNews @Inject constructor( private val newsRepository: NewsRepository, private val dispatchers: DispatcherProvider, ){ - operator fun invoke() = flow { - emit(newsRepository.getRealTimeNews()) - }.flowOn(dispatchers.IO) + operator fun invoke() = newsRepository.getRealTimeNews().flowOn(dispatchers.IO) } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/SubscribeNews.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/SubscribeNews.kt index 79ca029..68b70b4 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/SubscribeNews.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/SubscribeNews.kt @@ -2,7 +2,6 @@ package dev.pinkroom.marketsight.domain.use_case.news import dev.pinkroom.marketsight.common.DispatcherProvider import dev.pinkroom.marketsight.domain.repository.NewsRepository -import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOn import javax.inject.Inject @@ -10,7 +9,5 @@ class SubscribeNews @Inject constructor( private val newsRepository: NewsRepository, private val dispatchers: DispatcherProvider, ){ - operator fun invoke() = flow { - emit(newsRepository.subscribeNews()) - }.flowOn(dispatchers.IO) + operator fun invoke() = newsRepository.subscribeNews().flowOn(dispatchers.IO) } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/home_screen/HomeViewModel.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/home_screen/HomeViewModel.kt index 54bdcf1..5421ff5 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/home_screen/HomeViewModel.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/home_screen/HomeViewModel.kt @@ -7,5 +7,4 @@ import javax.inject.Inject @HiltViewModel class HomeViewModel @Inject constructor( ): ViewModel(){ - } \ No newline at end of file diff --git a/app/src/test/java/dev/pinkroom/marketsight/data/data_source/AlpacaRemoteDataSourceTest.kt b/app/src/test/java/dev/pinkroom/marketsight/data/data_source/AlpacaRemoteDataSourceTest.kt deleted file mode 100644 index a990efb..0000000 --- a/app/src/test/java/dev/pinkroom/marketsight/data/data_source/AlpacaRemoteDataSourceTest.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.pinkroom.marketsight.data.data_source - -class AlpacaRemoteDataSourceTest{ -} \ No newline at end of file diff --git a/app/src/test/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSourceTest.kt b/app/src/test/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSourceTest.kt new file mode 100644 index 0000000..7a1e206 --- /dev/null +++ b/app/src/test/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSourceTest.kt @@ -0,0 +1,288 @@ +package dev.pinkroom.marketsight.data.data_source + +import assertk.assertThat +import assertk.assertions.any +import assertk.assertions.isEqualTo +import assertk.assertions.isNotEmpty +import assertk.assertions.isNull +import assertk.assertions.isTrue +import com.github.javafaker.Faker +import com.google.gson.Gson +import com.tinder.scarlet.WebSocket +import dev.pinkroom.marketsight.common.ActionAlpaca +import dev.pinkroom.marketsight.common.Resource +import dev.pinkroom.marketsight.common.SortType +import dev.pinkroom.marketsight.data.remote.AlpacaNewsApi +import dev.pinkroom.marketsight.data.remote.AlpacaNewsService +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.NewsResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.ErrorMessageDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.NewsMessageDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.SubscriptionMessageDto +import dev.pinkroom.marketsight.data.remote.model.request.MessageAlpacaService +import dev.pinkroom.marketsight.factories.NewsDtoFactory +import dev.pinkroom.marketsight.factories.NewsFactory +import dev.pinkroom.marketsight.util.MainCoroutineRule +import dev.pinkroom.marketsight.util.TestDispatcherProvider +import io.mockk.coEvery +import io.mockk.coVerify +import io.mockk.every +import io.mockk.mockk +import io.mockk.verify +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.delay +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.flow.firstOrNull +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.toList +import kotlinx.coroutines.test.runTest +import org.junit.Rule +import org.junit.Test + +@ExperimentalCoroutinesApi +class NewsRemoteDataSourceTest { + + @get:Rule + val coroutineRule = MainCoroutineRule() + + private val gson = Gson() + private val faker = Faker() + private val newsFactory = NewsFactory() + private val newsDtoFactory = NewsDtoFactory() + private val alpacaNewsService = mockk(relaxed = true, relaxUnitFun = true) + private val alpacaNewsApi = mockk() + private val dispatchers = TestDispatcherProvider() + private val alpacaRemoteDataSource = NewsRemoteDataSource( + gson = gson, + alpacaNewsService = alpacaNewsService, + alpacaNewsApi = alpacaNewsApi, + dispatchers = dispatchers, + ) + + @Test + fun `Given params, when init subscribe news with all topics, then sendMessage is called with correct params`() = runTest { + // GIVEN + mockStartAlpacaServiceWithSuccess() + val symbols = listOf("*") + + // WHEN + alpacaRemoteDataSource.subscribeNews(symbols = symbols).firstOrNull() + + // THEN + val expectedMessageArgs = MessageAlpacaService(action = ActionAlpaca.Subscribe.action, news = symbols) + verify { alpacaNewsService.sendMessage(message = expectedMessageArgs) } + } + + @Test + fun `Given params, when send subscribe message to service, then sendMessage is called with correct params`() = runTest { + // GIVEN + val messageToSend = MessageAlpacaService(action = ActionAlpaca.Subscribe.action, news = listOf("TSLA","AAPL"), quotes = listOf("TSLA")) + mockMessageSubscriptionServiceWithSuccess(messageToSend) + + // WHEN + val response = alpacaRemoteDataSource.sendSubscribeMessageToAlpacaService(message = messageToSend).first() + + // THEN + verify { alpacaNewsService.sendMessage(message = messageToSend) } + assertThat(response is Resource.Success).isTrue() + val data = response as Resource.Success + assertThat(data.data.news).isEqualTo(messageToSend.news) + assertThat(data.data.quotes).isEqualTo(messageToSend.quotes) + assertThat(data.data.trades).isEqualTo(messageToSend.trades) + } + + @Test + fun `When receive message on getRealTimeNews, then try to parse Json to NewsInfo class`() = runTest { + // GIVEN + val listNews = newsFactory.buildList() + mockNewsServiceWithSuccess(newsList = listNews) + + // WHEN + val response = alpacaRemoteDataSource.getRealTimeNews().toList() + + // THEN + verify { alpacaNewsService.observeResponse() } + val allIdsSent = listNews.map { it.id } + assertThat(response).isNotEmpty() + response.forEach { newsReturned -> + assertThat(newsReturned).isNotEmpty() + newsReturned.forEach { news -> + assertThat(allIdsSent).any { it.isEqualTo(news.id)} + } + } + } + + @Test + fun `Given params, then alpaca api call getNews is called with correct params`() = runTest { + // GIVEN + val symbols = listOf("*") + val limit = 15 + val pageToken = null + val sort = SortType.DESC + mockNewsResponseApiWithSuccess(limit) + + // WHEN + val response = alpacaRemoteDataSource.getNews( + symbols = symbols, + limit = limit, + pageToken = pageToken, + sort = sort + ) + + // THEN + coVerify { + alpacaNewsApi.getNews( + symbols = symbols.joinToString(","), + perPage = limit, + pageToken = pageToken, + sort = sort.type, + ) + } + assertThat(response is Resource.Success).isTrue() + val data = response as Resource.Success + assertThat(data.data.news.size).isEqualTo(limit) + } + + @Test + fun `Given params, then alpaca api throw error on call getNews`() = runTest { + // GIVEN + mockNewsResponseApiWithError() + + // WHEN + val response = alpacaRemoteDataSource.getNews( + symbols = null, + limit = null, + pageToken = null, + sort = null + ) + + // THEN + coVerify { + alpacaNewsApi.getNews( + symbols = any(), + pageToken = any(), + sort = any(), + perPage = any(), + ) + } + assertThat(response is Resource.Error).isTrue() + } + + @Test + fun `When receive message from WS, then message is not related with news on getRealTimeNews`() = runTest { + // GIVEN + mockNewsServiceWithMessageNotExpected() + + // WHEN + val response = alpacaRemoteDataSource.getRealTimeNews().firstOrNull() + + // THEN + verify { alpacaNewsService.observeResponse() } + assertThat(response).isNull() + } + + @Test + fun `When receive message from WS, then alpaca service receive error message on sendSubscribeMessageToAlpacaService`() = runTest { + // GIVEN + val messageToSend = MessageAlpacaService(action = ActionAlpaca.Subscribe.action, news = listOf("TSLA","AAPL"), quotes = listOf("TSLA")) + mockMessageSubscriptionServiceWithError() + + // WHEN + val response = alpacaRemoteDataSource.sendSubscribeMessageToAlpacaService(messageToSend).first() + + // THEN + verify { alpacaNewsService.observeResponse() } + assertThat(response is Resource.Error).isTrue() + } + + private fun mockNewsResponseApiWithError() { + coEvery { alpacaNewsApi.getNews( + symbols = any(), + perPage = any(), + pageToken = any(), + sort = any(), + ) }.throws( + Exception("Test Error") + ) + } + + private fun mockNewsResponseApiWithSuccess(limit: Int) { + coEvery { alpacaNewsApi.getNews( + symbols = any(), + perPage = any(), + pageToken = any(), + sort = any(), + ) }.returns( + NewsResponseDto( + news = newsDtoFactory.buildList(number = limit), + nextPageToken = faker.lorem().word() + ) + ) + } + + private fun mockNewsServiceWithSuccess(newsList: List) { + every { alpacaNewsService.observeResponse() }.returns( + flow { + emit(listOf(gson.toJsonTree(newsList.first()))) + delay(3000) // Simulate WS API + val listNewsJson = newsList.map { + gson.toJsonTree(it) + } + emit(listNewsJson) + } + ) + } + + private fun mockNewsServiceWithMessageNotExpected() { + every { alpacaNewsService.observeResponse() }.returns( + flow { + emit(listOf(gson.toJsonTree( + ErrorMessageDto( + type = "error", + code = 403, + msg = "Not authenticated" + ) + ))) + } + ) + } + + private fun mockStartAlpacaServiceWithSuccess() { + every { alpacaNewsService.sendMessage(any()) }.returns(Unit) + + every { alpacaNewsService.observeOnConnectionEvent() }.returns( + flow { + emit(WebSocket.Event.OnConnectionOpened(webSocket = Any())) + } + ) + } + + private fun mockMessageSubscriptionServiceWithSuccess(messageAlpacaService: MessageAlpacaService) { + val returnedMessageService = SubscriptionMessageDto( + type = "subscription", + news = messageAlpacaService.news, + quotes = messageAlpacaService.quotes, + trades = messageAlpacaService.trades, + ) + + every { alpacaNewsService.sendMessage(any()) } returns(Unit) + every { alpacaNewsService.observeResponse() }.returns( + flow { + emit(listOf(gson.toJsonTree(returnedMessageService))) + } + ) + } + + private fun mockMessageSubscriptionServiceWithError() { + val errorMessage = ErrorMessageDto( + type = "error", + msg = "Not Found", + code = 404, + ) + every { alpacaNewsService.sendMessage(any()) } returns(Unit) + every { alpacaNewsService.observeResponse() }.returns( + flow { + emit(listOf(gson.toJsonTree(errorMessage))) + } + ) + } +} \ No newline at end of file diff --git a/app/src/test/java/dev/pinkroom/marketsight/factories/BaseFactory.kt b/app/src/test/java/dev/pinkroom/marketsight/factories/BaseFactory.kt new file mode 100644 index 0000000..099b918 --- /dev/null +++ b/app/src/test/java/dev/pinkroom/marketsight/factories/BaseFactory.kt @@ -0,0 +1,6 @@ +package dev.pinkroom.marketsight.factories + +interface BaseFactory { + fun build(): T + fun buildList(number: Int = 3) = List(number) { build() } +} \ No newline at end of file diff --git a/app/src/test/java/dev/pinkroom/marketsight/factories/ImagesFactory.kt b/app/src/test/java/dev/pinkroom/marketsight/factories/ImagesFactory.kt new file mode 100644 index 0000000..97fce1d --- /dev/null +++ b/app/src/test/java/dev/pinkroom/marketsight/factories/ImagesFactory.kt @@ -0,0 +1,19 @@ +package dev.pinkroom.marketsight.factories + +import com.github.javafaker.Faker +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.ImagesNewsDto +import kotlin.random.Random + +class ImagesFactory: BaseFactory { + + private val faker = Faker() + override fun build(): ImagesNewsDto = ImagesNewsDto( + size = getImageSizeRandom(), + url = faker.internet().url() + ) + + private fun getImageSizeRandom(): String { + val sizeValues = listOf("large","small","thumb") + return sizeValues[Random.nextInt(from = 0, until = sizeValues.size)] + } +} \ No newline at end of file diff --git a/app/src/test/java/dev/pinkroom/marketsight/factories/NewsDtoFactory.kt b/app/src/test/java/dev/pinkroom/marketsight/factories/NewsDtoFactory.kt new file mode 100644 index 0000000..4d6b0ae --- /dev/null +++ b/app/src/test/java/dev/pinkroom/marketsight/factories/NewsDtoFactory.kt @@ -0,0 +1,22 @@ +package dev.pinkroom.marketsight.factories + +import com.github.javafaker.Faker +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.NewsDto + +class NewsDtoFactory: BaseFactory { + + private val faker = Faker() + private val imagesFactory = ImagesFactory() + override fun build() = NewsDto( + id = faker.number().randomNumber(), + headline = faker.lorem().sentence(), + summary = faker.lorem().paragraph(), + author = faker.name().fullName(), + createdAt = "2024-04-11T13:45:17Z", + updatedAt = "2024-04-11T13:45:17Z", + url = faker.internet().url(), + symbols = listOf(faker.stock().nsdqSymbol()), + source = faker.lorem().word(), + images = imagesFactory.buildList(), + ) +} \ No newline at end of file diff --git a/app/src/test/java/dev/pinkroom/marketsight/factories/NewsFactory.kt b/app/src/test/java/dev/pinkroom/marketsight/factories/NewsFactory.kt new file mode 100644 index 0000000..f537e6c --- /dev/null +++ b/app/src/test/java/dev/pinkroom/marketsight/factories/NewsFactory.kt @@ -0,0 +1,22 @@ +package dev.pinkroom.marketsight.factories + +import com.github.javafaker.Faker +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.NewsMessageDto + +class NewsFactory: BaseFactory { + + private val faker = Faker() + override fun build() = NewsMessageDto( + author = faker.name().fullName(), + symbols = listOf(faker.stock().nsdqSymbol()), + url = faker.internet().url(), + updatedAt = "2024-04-11T13:45:17Z", + summary = faker.lorem().sentence(), + source = faker.lorem().word(), + id = faker.number().randomNumber(), + headline = faker.lorem().sentence(), + createdAt = "2024-04-11T13:45:17Z", + type = "n", + ) + +} \ No newline at end of file diff --git a/app/src/test/java/dev/pinkroom/marketsight/util/MainCoroutineRule.kt b/app/src/test/java/dev/pinkroom/marketsight/util/MainCoroutineRule.kt new file mode 100644 index 0000000..394a011 --- /dev/null +++ b/app/src/test/java/dev/pinkroom/marketsight/util/MainCoroutineRule.kt @@ -0,0 +1,26 @@ +package dev.pinkroom.marketsight.util + +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.test.StandardTestDispatcher +import kotlinx.coroutines.test.TestDispatcher +import kotlinx.coroutines.test.resetMain +import kotlinx.coroutines.test.setMain +import org.junit.rules.TestWatcher +import org.junit.runner.Description + +@ExperimentalCoroutinesApi +class MainCoroutineRule( + private val dispatcher: TestDispatcher = StandardTestDispatcher() +) : TestWatcher() { + + override fun starting(description: Description?) { + super.starting(description) + Dispatchers.setMain(dispatcher) + } + + override fun finished(description: Description?) { + super.finished(description) + Dispatchers.resetMain() + } +} \ No newline at end of file diff --git a/app/src/test/java/dev/pinkroom/marketsight/util/TestDispatcherProvider.kt b/app/src/test/java/dev/pinkroom/marketsight/util/TestDispatcherProvider.kt new file mode 100644 index 0000000..4841549 --- /dev/null +++ b/app/src/test/java/dev/pinkroom/marketsight/util/TestDispatcherProvider.kt @@ -0,0 +1,16 @@ +package dev.pinkroom.marketsight.util + +import dev.pinkroom.marketsight.common.DispatcherProvider +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.Dispatchers + +class TestDispatcherProvider( + private val testDispatcher: CoroutineDispatcher = Dispatchers.Main +) : DispatcherProvider { + override val Main: CoroutineDispatcher + get() = testDispatcher + override val IO: CoroutineDispatcher + get() = testDispatcher + override val Default: CoroutineDispatcher + get() = testDispatcher +} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7013a6f..9f7d112 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -19,6 +19,7 @@ junit4 = "4.13.2" mockkVersion = "1.13.10" coroutineVersion = "1.8.0" assertkVersion = "0.28.0" +fakerVersion = "1.0.2" [libraries] @@ -60,12 +61,15 @@ hilt-navigation = { group = "androidx.hilt", name = "hilt-navigation-compose", v hilt-compiler = { group = "com.google.dagger", name = "hilt-compiler", version.ref = "hiltVersion" } # SPLASH -splash = { group = "androidx.core", name = "core-splashscreen", version.ref= "splashVersion" } +splash = { group = "androidx.core", name = "core-splashscreen", version.ref = "splashVersion" } # UNIT TEST junit = { group = "junit", name = "junit", version.ref = "junit4" } coroutine-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "coroutineVersion" } +# FAKER +faker = { group = "com.github.javafaker", name = "javafaker", version.ref = "fakerVersion"} + # ASSERTK assertk = { group = "com.willowtreeapps.assertk", name = "assertk", version.ref = "assertkVersion"} From 2b44d41a284854f33ecdee18beeb9cc6bbdd0b36 Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Fri, 12 Apr 2024 17:05:20 +0100 Subject: [PATCH 13/33] - unit test (NewsRepository) - refactor code --- .../data/data_source/NewsRemoteDataSource.kt | 33 +-- .../data/repository/NewsRepositoryImp.kt | 22 +- .../data_source/NewsRemoteDataSourceTest.kt | 42 +--- .../data/repository/NewsRepositoryTest.kt | 234 ++++++++++++++++++ 4 files changed, 263 insertions(+), 68 deletions(-) create mode 100644 app/src/test/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryTest.kt diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt index 28f601d..b76e9fd 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt @@ -12,15 +12,12 @@ import dev.pinkroom.marketsight.common.SortType import dev.pinkroom.marketsight.common.toObject import dev.pinkroom.marketsight.common.verifyIfIsError import dev.pinkroom.marketsight.data.mapper.toErrorMessage -import dev.pinkroom.marketsight.data.mapper.toNewsInfo -import dev.pinkroom.marketsight.data.mapper.toNewsResponse -import dev.pinkroom.marketsight.data.mapper.toSubscriptionMessage import dev.pinkroom.marketsight.data.remote.AlpacaNewsApi import dev.pinkroom.marketsight.data.remote.AlpacaNewsService +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.NewsResponseDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.NewsMessageDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.SubscriptionMessageDto import dev.pinkroom.marketsight.data.remote.model.request.MessageAlpacaService -import dev.pinkroom.marketsight.domain.model.common.SubscriptionMessage -import dev.pinkroom.marketsight.domain.model.news.NewsResponse import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.take @@ -64,16 +61,16 @@ class NewsRemoteDataSource @Inject constructor( listNews.add(news) } } - if (listNews.isNotEmpty()) emit(listNews.map { it.toNewsInfo() }) + if (listNews.isNotEmpty()) emit(listNews.toList()) } }.flowOn(dispatchers.IO) - fun sendSubscribeMessageToAlpacaService(message: MessageAlpacaService) = flow> { + fun sendSubscribeMessageToAlpacaService(message: MessageAlpacaService) = flow> { alpacaNewsService.sendMessage(message = message) alpacaNewsService.observeResponse().collect { data -> data.forEach { gson.toObject(value = it, helperIdentifier = HelperIdentifierMessagesAlpacaService.Subscription)?.let { sub -> - emit(Resource.Success(sub.toSubscriptionMessage())) + emit(Resource.Success(sub)) } ?: run { emit(Resource.Error(message = "Something went wrong on subscribe")) } @@ -86,19 +83,13 @@ class NewsRemoteDataSource @Inject constructor( limit: Int?, pageToken: String?, sort: SortType? - ): Resource{ - return try { - val response = alpacaNewsApi.getNews( - symbols = symbols?.joinToString(","), - perPage = limit, - pageToken = pageToken, - sort = sort?.type, - ) - Resource.Success(data = response.toNewsResponse()) - } catch (e: Exception){ - e.printStackTrace() - Resource.Error(message = e.message ?: "Something Went Wrong") - } + ): NewsResponseDto { + return alpacaNewsApi.getNews( + symbols = symbols?.joinToString(","), + perPage = limit, + pageToken = pageToken, + sort = sort?.type, + ) } companion object { diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt b/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt index 4b54717..db23693 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt @@ -5,6 +5,8 @@ import dev.pinkroom.marketsight.common.DispatcherProvider import dev.pinkroom.marketsight.common.Resource import dev.pinkroom.marketsight.common.SortType import dev.pinkroom.marketsight.data.data_source.NewsRemoteDataSource +import dev.pinkroom.marketsight.data.mapper.toNewsInfo +import dev.pinkroom.marketsight.data.mapper.toNewsResponse import dev.pinkroom.marketsight.data.remote.model.request.MessageAlpacaService import dev.pinkroom.marketsight.domain.model.news.NewsResponse import dev.pinkroom.marketsight.domain.repository.NewsRepository @@ -25,7 +27,7 @@ class NewsRepositoryImp @Inject constructor( override fun getRealTimeNews() = flow { newsRemoteDataSource.getRealTimeNews().collect{ - emit(it) + emit(it.map { item -> item.toNewsInfo() }) } }.flowOn(dispatchers.IO) @@ -49,11 +51,17 @@ class NewsRepositoryImp @Inject constructor( pageToken: String?, sort: SortType? ): Resource { - return newsRemoteDataSource.getNews( - symbols = symbols, - limit = limit, - pageToken = pageToken, - sort = sort, - ) + return try { + val response = newsRemoteDataSource.getNews( + symbols = symbols, + limit = limit, + pageToken = pageToken, + sort = sort, + ) + Resource.Success(data = response.toNewsResponse()) + } catch (e: Exception){ + e.printStackTrace() + Resource.Error(message = e.message ?: "Something Went Wrong") + } } } \ No newline at end of file diff --git a/app/src/test/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSourceTest.kt b/app/src/test/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSourceTest.kt index 7a1e206..4ff5fd8 100644 --- a/app/src/test/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSourceTest.kt +++ b/app/src/test/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSourceTest.kt @@ -91,7 +91,7 @@ class NewsRemoteDataSourceTest { } @Test - fun `When receive message on getRealTimeNews, then try to parse Json to NewsInfo class`() = runTest { + fun `When receive message on getRealTimeNews, then try to parse Json to NewsInfoDto class`() = runTest { // GIVEN val listNews = newsFactory.buildList() mockNewsServiceWithSuccess(newsList = listNews) @@ -137,34 +137,7 @@ class NewsRemoteDataSourceTest { sort = sort.type, ) } - assertThat(response is Resource.Success).isTrue() - val data = response as Resource.Success - assertThat(data.data.news.size).isEqualTo(limit) - } - - @Test - fun `Given params, then alpaca api throw error on call getNews`() = runTest { - // GIVEN - mockNewsResponseApiWithError() - - // WHEN - val response = alpacaRemoteDataSource.getNews( - symbols = null, - limit = null, - pageToken = null, - sort = null - ) - - // THEN - coVerify { - alpacaNewsApi.getNews( - symbols = any(), - pageToken = any(), - sort = any(), - perPage = any(), - ) - } - assertThat(response is Resource.Error).isTrue() + assertThat(response.news.size).isEqualTo(limit) } @Test @@ -194,17 +167,6 @@ class NewsRemoteDataSourceTest { assertThat(response is Resource.Error).isTrue() } - private fun mockNewsResponseApiWithError() { - coEvery { alpacaNewsApi.getNews( - symbols = any(), - perPage = any(), - pageToken = any(), - sort = any(), - ) }.throws( - Exception("Test Error") - ) - } - private fun mockNewsResponseApiWithSuccess(limit: Int) { coEvery { alpacaNewsApi.getNews( symbols = any(), diff --git a/app/src/test/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryTest.kt b/app/src/test/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryTest.kt new file mode 100644 index 0000000..7f743ad --- /dev/null +++ b/app/src/test/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryTest.kt @@ -0,0 +1,234 @@ +package dev.pinkroom.marketsight.data.repository + +import assertk.assertThat +import assertk.assertions.isEqualTo +import assertk.assertions.isNotEmpty +import assertk.assertions.isTrue +import com.github.javafaker.Faker +import com.tinder.scarlet.WebSocket +import dev.pinkroom.marketsight.common.ActionAlpaca +import dev.pinkroom.marketsight.common.Resource +import dev.pinkroom.marketsight.common.SortType +import dev.pinkroom.marketsight.data.data_source.NewsRemoteDataSource +import dev.pinkroom.marketsight.data.mapper.toNewsInfo +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.NewsResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.NewsMessageDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.SubscriptionMessageDto +import dev.pinkroom.marketsight.data.remote.model.request.MessageAlpacaService +import dev.pinkroom.marketsight.factories.NewsDtoFactory +import dev.pinkroom.marketsight.factories.NewsFactory +import dev.pinkroom.marketsight.util.MainCoroutineRule +import dev.pinkroom.marketsight.util.TestDispatcherProvider +import io.mockk.coEvery +import io.mockk.coVerify +import io.mockk.every +import io.mockk.mockk +import io.mockk.verify +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.test.runTest +import org.junit.Rule +import org.junit.Test + +@ExperimentalCoroutinesApi +class NewsRepositoryTest{ + + @get:Rule + val coroutineRule = MainCoroutineRule() + + private val faker = Faker() + private val newsFactory = NewsFactory() + private val newsDtoFactory = NewsDtoFactory() + private val newsRemoteDataSource = mockk(relaxed = true, relaxUnitFun = true) + private val dispatchers = TestDispatcherProvider() + private val newsRepository = NewsRepositoryImp( + newsRemoteDataSource = newsRemoteDataSource, + dispatchers = dispatchers, + ) + + @Test + fun `Given params, when init subscribe news, then subscribeNews is called with correct params and emit values`() = runTest { + // GIVEN + mockSubscribeNewsWithSuccess() + + // WHEN + val response = newsRepository.subscribeNews().first() + + // THEN + assertThat(response is Resource.Success).isTrue() + } + + @Test + fun `When receive message on getRealTimeNews, then emit NewsInfo class`() = runTest { + // GIVEN + val listNews = newsFactory.buildList() + mockNewsServiceWithSuccess(newsList = listNews) + + // WHEN + val response = newsRepository.getRealTimeNews().first() + + // THEN + verify { newsRemoteDataSource.getRealTimeNews() } + val expectedResult = listNews.map { it.toNewsInfo() } + assertThat(response).isNotEmpty() + assertThat(response).isEqualTo(expectedResult) + } + + @Test + fun `Given params, then alpaca api call getNews is called with correct params`() = runTest { + // GIVEN + val symbols = listOf("*") + val limit = 15 + val pageToken = null + val sort = SortType.DESC + mockNewsResponseApiWithSuccess(limit) + + // WHEN + val response = newsRepository.getNews( + symbols = symbols, + limit = limit, + pageToken = pageToken, + sort = sort + ) + + // THEN + coVerify { + newsRemoteDataSource.getNews( + symbols = symbols, + limit = limit, + pageToken = pageToken, + sort = sort, + ) + } + assertThat(response is Resource.Success).isTrue() + val data = response as Resource.Success + assertThat(data.data.news.size).isEqualTo(limit) + } + + @Test + fun `Given params, then alpaca api throw error on call getNews`() = runTest { + // GIVEN + mockNewsResponseApiWithError() + + // WHEN + val response = newsRepository.getNews( + symbols = null, + limit = null, + pageToken = null, + sort = null + ) + + // THEN + coVerify { + newsRemoteDataSource.getNews( + symbols = any(), + pageToken = any(), + sort = any(), + limit = any(), + ) + } + assertThat(response is Resource.Error).isTrue() + } + + @Test + fun `Given params, when change filters, then receive list with symbols subscribed`() = runTest { + // GIVEN + val messageToSend = MessageAlpacaService(action = ActionAlpaca.Subscribe.action, news = listOf("TSLA","AAPL")) + mockMessageSubscriptionServiceWithSuccess(messageToSend) + + // WHEN + val response = newsRepository.changeFilterNews(symbols = messageToSend.news!!, actionAlpaca = ActionAlpaca.Subscribe) + + // THEN + verify { newsRemoteDataSource.sendSubscribeMessageToAlpacaService(message = messageToSend) } + assertThat(response is Resource.Success).isTrue() + val data = response as Resource.Success + assertThat(data.data).isEqualTo(messageToSend.news) + } + + @Test + fun `Given params, when change filters, then error occur and return list with symbols that fail to subscribe`() = runTest { + // GIVEN + val messageToSend = MessageAlpacaService(action = ActionAlpaca.Subscribe.action, news = listOf("TSLA","AAPL")) + mockMessageSubscriptionServiceWithError() + + // WHEN + val response = newsRepository.changeFilterNews(symbols = messageToSend.news!!, actionAlpaca = ActionAlpaca.Subscribe) + + // THEN + verify { newsRemoteDataSource.sendSubscribeMessageToAlpacaService(message = messageToSend) } + assertThat(response is Resource.Error).isTrue() + val data = response as Resource.Error + assertThat(data.data).isEqualTo(messageToSend.news) + } + + + private fun mockNewsResponseApiWithSuccess(limit: Int) { + coEvery { + newsRemoteDataSource.getNews( + symbols = any(), + limit = any(), + pageToken = any(), + sort = any(), + ) + }.returns( + NewsResponseDto( + news = newsDtoFactory.buildList(number = limit), + nextPageToken = faker.lorem().word() + ) + ) + } + + private fun mockNewsResponseApiWithError() { + coEvery { + newsRemoteDataSource.getNews( + symbols = any(), + limit = any(), + pageToken = any(), + sort = any(), + ) + }.throws( + Exception("Test Error") + ) + } + + private fun mockNewsServiceWithSuccess(newsList: List) { + every { newsRemoteDataSource.getRealTimeNews() }.returns( + flow { + emit(newsList) + } + ) + } + + private fun mockSubscribeNewsWithSuccess(){ + every { newsRemoteDataSource.subscribeNews(any()) }.returns( + flow { + emit(Resource.Success(data = WebSocket.Event.OnConnectionOpened(webSocket = Any()))) + } + ) + } + + private fun mockMessageSubscriptionServiceWithSuccess(messageAlpacaService: MessageAlpacaService) { + val returnedMessageService = SubscriptionMessageDto( + type = "subscription", + news = messageAlpacaService.news, + quotes = messageAlpacaService.quotes, + trades = messageAlpacaService.trades, + ) + + every { newsRemoteDataSource.sendSubscribeMessageToAlpacaService(any()) } returns( + flow { + emit(Resource.Success(data = returnedMessageService)) + } + ) + } + + private fun mockMessageSubscriptionServiceWithError() { + every { newsRemoteDataSource.sendSubscribeMessageToAlpacaService(any()) } returns( + flow { + emit(Resource.Error()) + } + ) + } +} \ No newline at end of file From 734e555772d2a0baa1308f0b9d28fba8cf55d9f0 Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Fri, 12 Apr 2024 17:45:31 +0100 Subject: [PATCH 14/33] - unit test (ChangeFilterNews UseCase) - refactor code --- .../use_case/news/ChangeFilterNewsTest.kt | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 app/src/test/java/dev/pinkroom/marketsight/domain/use_case/news/ChangeFilterNewsTest.kt diff --git a/app/src/test/java/dev/pinkroom/marketsight/domain/use_case/news/ChangeFilterNewsTest.kt b/app/src/test/java/dev/pinkroom/marketsight/domain/use_case/news/ChangeFilterNewsTest.kt new file mode 100644 index 0000000..0ab95d6 --- /dev/null +++ b/app/src/test/java/dev/pinkroom/marketsight/domain/use_case/news/ChangeFilterNewsTest.kt @@ -0,0 +1,122 @@ +package dev.pinkroom.marketsight.domain.use_case.news + +import assertk.assertThat +import assertk.assertions.isEqualTo +import assertk.assertions.isNotEmpty +import assertk.assertions.isTrue +import dev.pinkroom.marketsight.common.ActionAlpaca +import dev.pinkroom.marketsight.common.Resource +import dev.pinkroom.marketsight.domain.repository.NewsRepository +import dev.pinkroom.marketsight.util.MainCoroutineRule +import dev.pinkroom.marketsight.util.TestDispatcherProvider +import io.mockk.coEvery +import io.mockk.coVerify +import io.mockk.mockk +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.flow.last +import kotlinx.coroutines.flow.toList +import kotlinx.coroutines.test.runTest +import org.junit.Rule +import org.junit.Test + +@ExperimentalCoroutinesApi +class ChangeFilterNewsTest{ + + @get:Rule + val coroutineRule = MainCoroutineRule() + + private val dispatchers = TestDispatcherProvider() + private val newsRepository = mockk(relaxed = true, relaxUnitFun = true) + private val changeFilterNews = ChangeFilterNews( + newsRepository = newsRepository, + dispatchers = dispatchers, + ) + + @Test + fun `Given params, then call changeFilterNews and return list with subscribed symbols`() = runTest { + // GIVEN + val subscribeSymbols = listOf("TSLA","AAPL") + val unsubscribeSymbols = listOf("AAA") + mockChangeFilterNewsSuccess(subscribeSymbols) + + // WHEN + val response = changeFilterNews( + subscribeSymbols = subscribeSymbols, + unsubscribeSymbols = unsubscribeSymbols + ).toList() + + // THEN + coVerify { + newsRepository.changeFilterNews( + symbols = unsubscribeSymbols, + actionAlpaca = ActionAlpaca.Unsubscribe, + ) + } + coVerify { + newsRepository.changeFilterNews( + symbols = subscribeSymbols, + actionAlpaca = ActionAlpaca.Subscribe, + ) + } + assertThat(response).isNotEmpty() + response.forEachIndexed { index, it -> + assertThat(it is Resource.Success).isTrue() + val data = it as Resource.Success + val expectedResult = if (index == response.size) emptyList() + else subscribeSymbols + assertThat(data.data).isEqualTo(expectedResult) + } + } + + @Test + fun `Given params, then call changeFilterNews and return error`() = runTest { + // GIVEN + val subscribeSymbols = listOf("TSLA","AAPL") + val unsubscribeSymbols = listOf("AAA") + mockChangeFilterNewsError( + subscribedSymbols = subscribeSymbols, + unsubscribedSymbols = unsubscribeSymbols + ) + + // WHEN + val response = changeFilterNews( + subscribeSymbols = subscribeSymbols, + unsubscribeSymbols = unsubscribeSymbols + ).last() + + // THEN + coVerify { + newsRepository.changeFilterNews( + symbols = unsubscribeSymbols, + actionAlpaca = ActionAlpaca.Unsubscribe, + ) + } + coVerify { + newsRepository.changeFilterNews( + symbols = subscribeSymbols, + actionAlpaca = ActionAlpaca.Subscribe, + ) + } + assertThat(response is Resource.Error).isTrue() + val data = response as Resource.Error + val expectedResult = unsubscribeSymbols + subscribeSymbols + assertThat(data.data).isEqualTo(expectedResult) + } + + private fun mockChangeFilterNewsSuccess( + subscribedSymbols: List, + ){ + coEvery { newsRepository.changeFilterNews(any(),any()) }.returnsMany( + Resource.Success(data = emptyList()), Resource.Success(data = subscribedSymbols) + ) + } + + private fun mockChangeFilterNewsError( + subscribedSymbols: List, + unsubscribedSymbols: List, + ){ + coEvery { newsRepository.changeFilterNews(any(),any()) }.returns( + Resource.Error(data = subscribedSymbols + unsubscribedSymbols) + ) + } +} \ No newline at end of file From e487af320d6f72ac5cb475fbbbc05c874a7d31fc Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Wed, 17 Apr 2024 17:54:59 +0100 Subject: [PATCH 15/33] - main carousel news --- app/build.gradle.kts | 4 + .../pinkroom/marketsight/MarketSightApp.kt | 12 +- .../domain/model/common/SubInfoSymbols.kt | 7 + .../domain/model/news/ImageSize.kt | 6 + .../marketsight/domain/model/news/NewsInfo.kt | 18 +- .../pinkroom/marketsight/ui/MainActivity.kt | 2 +- .../ui/core/navigation/NavigationAppHost.kt | 11 +- .../ui/core/navigation/NavigationBottomBar.kt | 2 +- .../marketsight/ui/core/theme/Color.kt | 4 +- .../marketsight/ui/core/theme/Dimensions.kt | 22 ++- .../ui/core/theme/ShimmerEffect.kt | 45 +++++ .../marketsight/ui/news_screen/NewsScreen.kt | 105 +++++++++++- .../marketsight/ui/news_screen/NewsUiState.kt | 49 ++++++ .../ui/news_screen/NewsViewModel.kt | 26 +++ .../components/IndicatorPageCarousel.kt | 62 +++++++ .../ui/news_screen/components/MainNews.kt | 44 +++++ .../ui/news_screen/components/MainNewsCard.kt | 162 ++++++++++++++++++ .../main/res/drawable/default_news_large.jpeg | Bin 0 -> 153161 bytes .../main/res/drawable/default_news_small.jpeg | Bin 0 -> 53466 bytes .../main/res/drawable/default_news_thumb.jpeg | Bin 0 -> 6743 bytes gradle/libs.versions.toml | 5 + 21 files changed, 568 insertions(+), 18 deletions(-) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/model/common/SubInfoSymbols.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/ShimmerEffect.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/IndicatorPageCarousel.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNews.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNewsCard.kt create mode 100644 app/src/main/res/drawable/default_news_large.jpeg create mode 100644 app/src/main/res/drawable/default_news_small.jpeg create mode 100644 app/src/main/res/drawable/default_news_thumb.jpeg diff --git a/app/build.gradle.kts b/app/build.gradle.kts index ecc4305..a2d2aa1 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -75,6 +75,7 @@ dependencies { coreLibraryDesugaring(libs.androidx.desugar) implementation(libs.androidx.core.ktx) implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.lifecycle.runtime.compose) implementation(libs.androidx.ui) implementation(libs.androidx.ui.graphics) implementation(libs.androidx.ui.tooling.preview) @@ -108,6 +109,9 @@ dependencies { // SPLASH implementation(libs.splash) + // COIL + implementation(libs.coil) + // JSON implementation(libs.json) diff --git a/app/src/main/java/dev/pinkroom/marketsight/MarketSightApp.kt b/app/src/main/java/dev/pinkroom/marketsight/MarketSightApp.kt index cf87006..e4d710d 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/MarketSightApp.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/MarketSightApp.kt @@ -1,7 +1,17 @@ package dev.pinkroom.marketsight import android.app.Application +import coil.ImageLoader +import coil.ImageLoaderFactory +import coil.util.DebugLogger import dagger.hilt.android.HiltAndroidApp @HiltAndroidApp -class MarketSightApp: Application() \ No newline at end of file +class MarketSightApp: Application(), ImageLoaderFactory{ + override fun newImageLoader(): ImageLoader { + return ImageLoader(this).newBuilder() + .logger(DebugLogger()) + .build() + } + +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/common/SubInfoSymbols.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/common/SubInfoSymbols.kt new file mode 100644 index 0000000..a97d12e --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/common/SubInfoSymbols.kt @@ -0,0 +1,7 @@ +package dev.pinkroom.marketsight.domain.model.common + +data class SubInfoSymbols( + val name: String, + val symbol: String, + val isSubscribed: Boolean = false, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/ImageSize.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/ImageSize.kt index cdba1e7..e0ee24a 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/ImageSize.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/ImageSize.kt @@ -4,4 +4,10 @@ sealed interface ImageSize { data object Large: ImageSize data object Small: ImageSize data object Thumb: ImageSize +} + +fun ImageSize.getAspectRatio() = when(this){ + ImageSize.Large -> 2024f / 1536f + ImageSize.Small -> 1024f / 768f + ImageSize.Thumb -> 250f / 187f } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/NewsInfo.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/NewsInfo.kt index db4182b..cd40d36 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/NewsInfo.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/NewsInfo.kt @@ -1,6 +1,11 @@ package dev.pinkroom.marketsight.domain.model.news import java.time.LocalDateTime +import java.time.ZoneId +import java.time.format.DateTimeFormatter +import java.time.format.FormatStyle +import java.util.Locale + data class NewsInfo( val id: Long, @@ -13,4 +18,15 @@ data class NewsInfo( val symbols: List, val source: String, val images: List? = null, -) +){ + fun getImageUrl(imageSize: ImageSize) = images?.find { it.size == imageSize }?.url + + fun getUpdatedDateFormatted(): String{ + val formatter = DateTimeFormatter + .ofLocalizedDateTime(FormatStyle.LONG, FormatStyle.SHORT) + .withLocale(Locale.getDefault()) + .withZone(ZoneId.systemDefault()) + + return updatedAt.format(formatter) + } +} diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt index 16fefa9..6bd6322 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt @@ -24,7 +24,7 @@ class MainActivity : ComponentActivity() { setContent { val navController = rememberNavController() - val startDestination = Route.HomeScreen + val startDestination = Route.NewsScreen MarketSightTheme { Surface( diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt index bc34185..68a7d28 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt @@ -3,6 +3,7 @@ package dev.pinkroom.marketsight.ui.core.navigation import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.navigation.NavHostController import androidx.navigation.NavType import androidx.navigation.compose.NavHost @@ -13,6 +14,7 @@ import dev.pinkroom.marketsight.ui.detail_screen.DetailScreen import dev.pinkroom.marketsight.ui.home_screen.HomeScreen import dev.pinkroom.marketsight.ui.home_screen.HomeViewModel import dev.pinkroom.marketsight.ui.news_screen.NewsScreen +import dev.pinkroom.marketsight.ui.news_screen.NewsViewModel @Composable fun NavigationAppHost( @@ -34,7 +36,14 @@ fun NavigationAppHost( composable( route = Route.NewsScreen.route, ) { - NewsScreen() + val viewModel = hiltViewModel() + val uiState = viewModel.uiState.collectAsStateWithLifecycle().value + + NewsScreen( + news = uiState.news, + realTimeNews = uiState.realTimeNews, + symbols = uiState.symbols, + ) } composable( route = Route.DetailScreen.route, diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationBottomBar.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationBottomBar.kt index 0359eb5..e73dc8d 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationBottomBar.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationBottomBar.kt @@ -34,7 +34,7 @@ import dev.pinkroom.marketsight.ui.core.theme.dimens @Composable fun NavigationBottomBar( navController: NavHostController, - startDestination: Route.HomeScreen, + startDestination: Route, ){ val items = listOf( BottomBarItem.Home, diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Color.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Color.kt index 3d49884..5d3b9c0 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Color.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Color.kt @@ -10,4 +10,6 @@ val Gray = Color(0xFF8A8A94) val Manatee = Color(0xFF92929C) val Green = Color(0xFF3DD787) val Purple = Color(0xFF7F55E7) -val Red = Color(0xFFE94237) \ No newline at end of file +val Red = Color(0xFFE94237) +val PhilippineSilver = Color(0xFFB8B5B5) +val PhilippineGray = Color(0xFF8F8B8B) \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt index 2b30d7a..3b44de8 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt @@ -6,6 +6,7 @@ import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.TextUnit import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import dev.pinkroom.marketsight.domain.model.news.ImageSize class Dimensions( // Text @@ -38,8 +39,8 @@ class Dimensions( // Elevation val lowElevation: Dp = 2.dp, - val normalElevation: Dp = 5.dp, - val largeElevation: Dp = 8.dp, + val normalElevation: Dp = 9.dp, + val largeElevation: Dp = 12.dp, // Shape val smallShape: Dp = 10.dp, @@ -48,9 +49,14 @@ class Dimensions( // Page Padding val horizontalPadding: Dp = 25.dp, + val contentTopPadding: Dp = 10.dp, + val contentBottomPadding: Dp = 40.dp, // Others val menuBottomPadding: Dp = 15.dp, + val imageSizeMainNews: ImageSize = ImageSize.Small, + val circlePageIndicatorSize: Dp = 9.dp, + val spaceBetweenPageIndicator: Dp = 2.dp, ) val dimens: Dimensions @@ -64,6 +70,12 @@ val dimens: Dimensions } // Here you will override the dimensions needed depending on the screen size -private val smallDimensions = Dimensions() -private val normalDimensions = Dimensions() -private val largeDimensions = Dimensions() \ No newline at end of file +private val smallDimensions = Dimensions( + imageSizeMainNews = ImageSize.Small, +) +private val normalDimensions = Dimensions( + imageSizeMainNews = ImageSize.Small, +) +private val largeDimensions = Dimensions( + imageSizeMainNews = ImageSize.Large, +) \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/ShimmerEffect.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/ShimmerEffect.kt new file mode 100644 index 0000000..7ca4efc --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/ShimmerEffect.kt @@ -0,0 +1,45 @@ +package dev.pinkroom.marketsight.ui.core.theme + +import androidx.compose.animation.core.animateFloat +import androidx.compose.animation.core.infiniteRepeatable +import androidx.compose.animation.core.rememberInfiniteTransition +import androidx.compose.animation.core.tween +import androidx.compose.foundation.background +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.composed +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.graphics.Brush +import androidx.compose.ui.layout.onGloballyPositioned +import androidx.compose.ui.unit.IntSize + +fun Modifier.shimmerEffect(): Modifier = composed { + var size by remember { + mutableStateOf(IntSize.Zero) + } + val transition = rememberInfiniteTransition(label = "Transition Shimmer Effect") + val startOffsetX by transition.animateFloat( + initialValue = -2 * size.width.toFloat(), + targetValue = 2 * size.width.toFloat(), + animationSpec = infiniteRepeatable( + animation = tween(1300) + ), label = "Shimmer Effect" + ) + + background( + brush = Brush.linearGradient( + colors = listOf( + PhilippineSilver, + PhilippineGray, + PhilippineSilver, + ), + start = Offset(startOffsetX, 0f), + end = Offset(startOffsetX + size.width.toFloat(), size.height.toFloat()) + ) + ).onGloballyPositioned { + size = it.size + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt index 73c0698..e326004 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt @@ -1,23 +1,55 @@ package dev.pinkroom.marketsight.ui.news_screen -import androidx.compose.foundation.layout.Column +import android.content.Intent +import android.net.Uri +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.material3.Text +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.tooling.preview.Preview +import dev.pinkroom.marketsight.domain.model.common.SubInfoSymbols +import dev.pinkroom.marketsight.domain.model.news.ImageSize +import dev.pinkroom.marketsight.domain.model.news.ImagesNews +import dev.pinkroom.marketsight.domain.model.news.NewsInfo +import dev.pinkroom.marketsight.ui.core.theme.dimens +import dev.pinkroom.marketsight.ui.news_screen.components.MainNews +import java.time.LocalDateTime @Composable fun NewsScreen( modifier: Modifier = Modifier, + news: List, + realTimeNews: List, + symbols: List, ){ - Column( + val context = LocalContext.current + + LazyColumn( modifier = modifier .fillMaxSize(), - ) { - Text( - text = "News Screen", + contentPadding = PaddingValues( + top = dimens.contentTopPadding, + bottom = dimens.contentBottomPadding, ) + ) { + item { + MainNews( + modifier = Modifier + .fillMaxWidth() + .padding( + horizontal = dimens.horizontalPadding, + ), + newsList = news, + onNewsClick = { + val intent = Intent(Intent.ACTION_VIEW, Uri.parse(it.url)) + context.startActivity(intent) + } + ) + } } } @@ -27,5 +59,64 @@ fun NewsScreen( ) @Composable fun NewsScreenPreview(){ - NewsScreen() + NewsScreen( + news = listOf( + NewsInfo( + id = 1L, + symbols = listOf("TSLA","AAPL","BTC"), + images = listOf( + ImagesNews( + size = ImageSize.Small, + url = "https://cdn.benzinga.com/files/imagecache/1024x768xUP/market-clubhouse-morning-memo_201.png", + ) + ), + source = "Bezinga", + url = "https://www.benzinga.com/", + updatedAt = LocalDateTime.now(), + createdAt = LocalDateTime.now(), + author = "RIPS", + summary = "Good Morning Traders! In today's Market Clubhouse Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, and TSLA.", + headline = "Market Clubhouse Morning Memo - April 11th, 2024 (Trade Strategy For SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", + ), + NewsInfo( + id = 1L, + symbols = listOf("TSLA","AAPL","BTC"), + images = listOf( + ImagesNews( + size = ImageSize.Small, + url = "https://cdn.benzinga.com/files/imagecache/1024x768xUP/market-clubhouse-morning-memo_201.png", + ) + ), + source = "Bezinga", + url = "https://www.benzinga.com/", + updatedAt = LocalDateTime.now(), + createdAt = LocalDateTime.now(), + author = "RIPS", + summary = "Good Morning Traders! In today's Market Clubhouse Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, and TSLA.", + headline = "Market Clubhouse Morning Memo - April 11th, 2024 (Trade Strategy For SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", + ), + ), + realTimeNews = listOf( + NewsInfo( + id = 1L, + symbols = listOf("TSLA","AAPL","BTC"), + images = null, + source = "Bezinga", + url = "https://www.benzinga.com/", + updatedAt = LocalDateTime.now(), + createdAt = LocalDateTime.now(), + author = "RIPS", + summary = "Good Morning Traders! In today's Market Clubhouse Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, and TSLA.", + headline = "Market Clubhouse Morning Memo - April 11th, 2024 (Trade Strategy For SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", + ), + ), + symbols = listOf( + SubInfoSymbols( + name = "TESLA", symbol = "TSLA", + ), + SubInfoSymbols( + name = "APPLE", symbol = "AAPL", + ), + ), + ) } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt new file mode 100644 index 0000000..4ecb74c --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt @@ -0,0 +1,49 @@ +package dev.pinkroom.marketsight.ui.news_screen + +import dev.pinkroom.marketsight.domain.model.common.SubInfoSymbols +import dev.pinkroom.marketsight.domain.model.news.ImageSize +import dev.pinkroom.marketsight.domain.model.news.ImagesNews +import dev.pinkroom.marketsight.domain.model.news.NewsInfo +import java.time.LocalDateTime + +data class NewsUiState( + val isLoading: Boolean = false, + val news: List = listOf( + NewsInfo( + id = 1L, + symbols = listOf("TSLA","AAPL","BTC"), + images = listOf( + ImagesNews( + size = ImageSize.Small, + url = "https://cdn.benzinga.com/files/imagecache/1024x768xUP/market-clubhouse-morning-memo_201.png", + ) + ), + source = "Bezinga", + url = "https://www.benzinga.com/", + updatedAt = LocalDateTime.now(), + createdAt = LocalDateTime.now(), + author = "RIPS", + summary = "Good Morning Traders! In today's Market Clubhouse Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, and TSLA.", + headline = "Market Clubhouse Morning Memo - April 11th, 2024 (Trade Strategy For SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", + ), + NewsInfo( + id = 2L, + symbols = listOf("TSLA","AAPL","BTC"), + images = listOf( + ImagesNews( + size = ImageSize.Small, + url = "https://cdn.benzinga.com/files/imagecache/1024x768xUP/market-clubhouse-morning-memo_201.p", + ) + ), + source = "Bezinga", + url = "https://www.benzinga.com/", + updatedAt = LocalDateTime.now(), + createdAt = LocalDateTime.now(), + author = "RIPS", + summary = "Good Morning Traders! In today's Market Clubhouse Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, and TSLA.", + headline = "Market Clubhouse Morning Memo - April 11th, 2024 (Trade Strategy For SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", + ), + ), + val realTimeNews: List = listOf(), + val symbols: List = listOf(), +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt new file mode 100644 index 0000000..4cec0a4 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt @@ -0,0 +1,26 @@ +package dev.pinkroom.marketsight.ui.news_screen + +import androidx.lifecycle.ViewModel +import dagger.hilt.android.lifecycle.HiltViewModel +import dev.pinkroom.marketsight.domain.use_case.news.ChangeFilterNews +import dev.pinkroom.marketsight.domain.use_case.news.GetNews +import dev.pinkroom.marketsight.domain.use_case.news.GetRealTimeNews +import dev.pinkroom.marketsight.domain.use_case.news.SubscribeNews +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.asStateFlow +import javax.inject.Inject + +@HiltViewModel +class NewsViewModel @Inject constructor( + private val subscribeNews: SubscribeNews, + private val getRealTimeNews: GetRealTimeNews, + private val getNews: GetNews, + private val changeFilterNews: ChangeFilterNews, +): ViewModel() { + private val _uiState = MutableStateFlow(NewsUiState()) + val uiState = _uiState.asStateFlow() + + init { + + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/IndicatorPageCarousel.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/IndicatorPageCarousel.kt new file mode 100644 index 0000000..85e96cb --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/IndicatorPageCarousel.kt @@ -0,0 +1,62 @@ +package dev.pinkroom.marketsight.ui.news_screen.components + +import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.pager.PagerState +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import dev.pinkroom.marketsight.ui.core.theme.PhilippineGray +import dev.pinkroom.marketsight.ui.core.theme.PhilippineSilver +import dev.pinkroom.marketsight.ui.core.theme.dimens +import kotlinx.coroutines.launch + +@OptIn(ExperimentalFoundationApi::class) +@Composable +fun IndicatorPageCarousel( + pagerState: PagerState, +){ + val scope = rememberCoroutineScope() + val interactionSource = remember { MutableInteractionSource() } + Row( + modifier = Modifier + .fillMaxWidth(), + horizontalArrangement = Arrangement.Center, + ) { + repeat(pagerState.pageCount) { iteration -> + val selectedColor = if (isSystemInDarkTheme()) PhilippineSilver else PhilippineGray + val unSelectedColor = if (isSystemInDarkTheme()) PhilippineGray else PhilippineSilver + val color = if (pagerState.currentPage == iteration) selectedColor else unSelectedColor + + Box( + modifier = Modifier + .padding(horizontal = dimens.spaceBetweenPageIndicator) + .clip(CircleShape) + .background(color) + .size(dimens.circlePageIndicatorSize) + .clickable( + indication = null, + interactionSource = interactionSource, + onClick = { + if (pagerState.currentPage != iteration) + scope.launch { + pagerState.animateScrollToPage(page = iteration) + } + } + ), + ) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNews.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNews.kt new file mode 100644 index 0000000..cdbff8a --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNews.kt @@ -0,0 +1,44 @@ +package dev.pinkroom.marketsight.ui.news_screen.components + +import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.pager.HorizontalPager +import androidx.compose.foundation.pager.rememberPagerState +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import dev.pinkroom.marketsight.domain.model.news.NewsInfo +import dev.pinkroom.marketsight.ui.core.theme.dimens + +@OptIn(ExperimentalFoundationApi::class) +@Composable +fun MainNews( + modifier: Modifier = Modifier, + newsList: List, + onNewsClick: (news: NewsInfo) -> Unit, +){ + val pagerState = rememberPagerState( + pageCount = { newsList.size } + ) + + Column( + modifier = Modifier + .fillMaxWidth(), + ) { + HorizontalPager( + state = pagerState, + key = { newsList[it].id } + ) { index -> + val news = newsList[index] + MainNewsCard( + modifier = modifier, + news = news, + onClick = onNewsClick + ) + } + Spacer(modifier = Modifier.height(dimens.smallPadding)) + IndicatorPageCarousel(pagerState = pagerState) + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNewsCard.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNewsCard.kt new file mode 100644 index 0000000..b4b438b --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNewsCard.kt @@ -0,0 +1,162 @@ +package dev.pinkroom.marketsight.ui.news_screen.components + +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.aspectRatio +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.shadow +import androidx.compose.ui.graphics.Brush +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.layout.onSizeChanged +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.IntSize +import coil.compose.SubcomposeAsyncImage +import dev.pinkroom.marketsight.R +import dev.pinkroom.marketsight.domain.model.news.ImageSize +import dev.pinkroom.marketsight.domain.model.news.ImagesNews +import dev.pinkroom.marketsight.domain.model.news.NewsInfo +import dev.pinkroom.marketsight.domain.model.news.getAspectRatio +import dev.pinkroom.marketsight.ui.core.theme.Black +import dev.pinkroom.marketsight.ui.core.theme.White +import dev.pinkroom.marketsight.ui.core.theme.dimens +import dev.pinkroom.marketsight.ui.core.theme.shimmerEffect +import java.time.LocalDateTime + +@Composable +fun MainNewsCard( + modifier: Modifier = Modifier, + news: NewsInfo, + onClick: (news: NewsInfo) -> Unit +){ + var size by remember { mutableStateOf(IntSize.Zero) } + Box( + modifier = modifier + .fillMaxWidth() + .shadow( + elevation = dimens.normalElevation, + shape = RoundedCornerShape(size = dimens.normalShape) + ) + .aspectRatio(ratio = dimens.imageSizeMainNews.getAspectRatio()) + .onSizeChanged { + size = it + } + .clickable( + onClick = { onClick(news) } + ), + ) { + SubcomposeAsyncImage( + model = news.getImageUrl(imageSize = dimens.imageSizeMainNews), + contentDescription = null, + error = { + val imageToLoad = when (dimens.imageSizeMainNews) { + ImageSize.Large -> R.drawable.default_news_large + ImageSize.Small -> R.drawable.default_news_small + ImageSize.Thumb -> R.drawable.default_news_thumb + } + Image( + painter = painterResource(id = imageToLoad), + contentDescription = null, + modifier = Modifier + .fillMaxSize() + ) + }, + loading = { + Box( + modifier = Modifier + .fillMaxSize() + .shimmerEffect() + ) + }, + contentScale = ContentScale.Crop, + modifier = Modifier + .fillMaxSize() + ) + Box( + modifier = Modifier + .fillMaxSize() + .background( + Brush.verticalGradient( + colors = listOf( + Color.Transparent, + Black, + ), + startY = 0f, + endY = size.height.toFloat() / 1.35f + ) + ) + ){ + Column( + modifier = Modifier + .align(Alignment.BottomCenter) + .padding(horizontal = dimens.normalPadding) + .padding(bottom = dimens.normalPadding), + verticalArrangement = Arrangement.spacedBy(dimens.xSmallPadding) + ) { + Text( + text = news.headline, + style = MaterialTheme.typography.headlineSmall, + fontWeight = FontWeight.Medium, + color = White, + maxLines = 2, + overflow = TextOverflow.Ellipsis, + ) + Text( + modifier = Modifier.fillMaxWidth(), + text = news.getUpdatedDateFormatted(), + fontWeight = FontWeight.Bold, + color = White, + textAlign = TextAlign.Start, + ) + } + } + } +} + +@Preview( + showBackground = true, + showSystemUi = true, +) +@Composable +fun MainNewsCardPreview(){ + MainNewsCard( + news = NewsInfo( + id = 1L, + symbols = listOf("TSLA","AAPL","BTC"), + images = listOf( + ImagesNews( + size = ImageSize.Small, + url = "https://cdn.benzinga.com/files/imagecache/1024x768xUP/market-clubhouse-morning-memo_201.png", + ) + ), + source = "Bezinga", + url = "https://www.benzinga.com/", + updatedAt = LocalDateTime.now(), + createdAt = LocalDateTime.now(), + author = "RIPS", + summary = "Good Morning Traders! In today's Market Clubhouse Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, and TSLA.", + headline = "Market Clubhouse Morning Memo - April 11th, 2024 (Trade Strategy For SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", + ), + onClick = {} + ) +} \ No newline at end of file diff --git a/app/src/main/res/drawable/default_news_large.jpeg b/app/src/main/res/drawable/default_news_large.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..7955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*#iA)VJ zTvY~M7kihqqoeBKK8#%_x4@jOIMrLNaZm6)P4B4%(?u)B@Z5A)W$#4u2d$4yCdNb= zb{AgZ-3P}!v5oHj5xJnNBcszP5Z-FdPjY0>HnMP1LoM<q|>QwMiR9m5nWSHhU7 zj_T(#s43if&XTU+_r|?;PiA8=d-*9@q1U7lCH)*}DK$?cLr#@#t2VAG71vXQ&C=Yx zkS_m$JdE|6nuRhmf?H&iJHi3gz`)KH3TJ<^{5Yq9{AR$SRxCa1fj2u-TK=stvVb{`SOpD$*-y`B6Y Df62mr literal 0 HcmV?d00001 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9f7d112..156f73b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -20,12 +20,14 @@ mockkVersion = "1.13.10" coroutineVersion = "1.8.0" assertkVersion = "0.28.0" fakerVersion = "1.0.2" +coilVersion = "2.6.0" [libraries] # CORE androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" } +androidx-lifecycle-runtime-compose = { group = "androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "lifecycleRuntimeKtx" } androidx-ui = { group = "androidx.compose.ui", name = "ui" } androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" } androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview"} @@ -63,6 +65,9 @@ hilt-compiler = { group = "com.google.dagger", name = "hilt-compiler", version.r # SPLASH splash = { group = "androidx.core", name = "core-splashscreen", version.ref = "splashVersion" } +# COIL +coil = { group = "io.coil-kt", name = "coil-compose", version.ref = "coilVersion" } + # UNIT TEST junit = { group = "junit", name = "junit", version.ref = "junit4" } coroutine-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "coroutineVersion" } From 84360dddc2cbfeff8959039eb823e94fa634326a Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Thu, 18 Apr 2024 15:39:10 +0100 Subject: [PATCH 16/33] - main carousel news add anim - empty screen when news are empty - loading shimmer effect while loading main news --- .../common/ConnectivityObserver.kt | 12 ++ .../pinkroom/marketsight/common/Constants.kt | 5 + .../common/NetworkConnectivityObserver.kt | 49 ++++++++ .../pinkroom/marketsight/common/Resource.kt | 1 - .../data/repository/NewsRepositoryImp.kt | 1 - .../dev/pinkroom/marketsight/di/AppModule.kt | 9 +- .../marketsight/domain/model/news/NewsInfo.kt | 6 +- .../domain/use_case/news/ChangeFilterNews.kt | 1 - .../ui/core/navigation/NavigationAppHost.kt | 4 + .../marketsight/ui/core/theme/Dimensions.kt | 2 +- .../marketsight/ui/core/theme/Theme.kt | 10 +- .../marketsight/ui/news_screen/NewsEvent.kt | 5 + .../marketsight/ui/news_screen/NewsScreen.kt | 52 +++++--- .../marketsight/ui/news_screen/NewsUiState.kt | 45 +------ .../ui/news_screen/NewsViewModel.kt | 59 +++++++++ .../news_screen/components/EmptyNewsList.kt | 53 ++++++++ .../components/IndicatorPageCarousel.kt | 14 ++- .../ui/news_screen/components/MainNews.kt | 113 +++++++++++++++--- .../ui/news_screen/components/MainNewsCard.kt | 28 +++-- app/src/main/res/drawable/icon_error.xml | 5 + app/src/main/res/values/strings.xml | 2 + 21 files changed, 383 insertions(+), 93 deletions(-) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/common/ConnectivityObserver.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/common/Constants.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/common/NetworkConnectivityObserver.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsEvent.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/EmptyNewsList.kt create mode 100644 app/src/main/res/drawable/icon_error.xml diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/ConnectivityObserver.kt b/app/src/main/java/dev/pinkroom/marketsight/common/ConnectivityObserver.kt new file mode 100644 index 0000000..e0be426 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/common/ConnectivityObserver.kt @@ -0,0 +1,12 @@ +package dev.pinkroom.marketsight.common + +import kotlinx.coroutines.flow.Flow + +interface ConnectivityObserver { + + fun observe(): Flow + + enum class Status { + Available, Unavailable, Losing, Lost + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/Constants.kt b/app/src/main/java/dev/pinkroom/marketsight/common/Constants.kt new file mode 100644 index 0000000..67d61ca --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/common/Constants.kt @@ -0,0 +1,5 @@ +package dev.pinkroom.marketsight.common + +object Constants { + val ANIM_TIME_CAROUSEL = 700 +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/NetworkConnectivityObserver.kt b/app/src/main/java/dev/pinkroom/marketsight/common/NetworkConnectivityObserver.kt new file mode 100644 index 0000000..a1b9a35 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/common/NetworkConnectivityObserver.kt @@ -0,0 +1,49 @@ +package dev.pinkroom.marketsight.common + +import android.content.Context +import android.net.ConnectivityManager +import android.net.Network +import kotlinx.coroutines.channels.awaitClose +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.callbackFlow +import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.launch + +class NetworkConnectivityObserver( + context: Context +): ConnectivityObserver { + + private val connectivityManager = + context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager + + override fun observe(): Flow { + return callbackFlow { + val callback = object : ConnectivityManager.NetworkCallback() { + override fun onAvailable(network: Network) { + super.onAvailable(network) + launch { send(ConnectivityObserver.Status.Available) } + } + + override fun onLosing(network: Network, maxMsToLive: Int) { + super.onLosing(network, maxMsToLive) + launch { send(ConnectivityObserver.Status.Losing) } + } + + override fun onLost(network: Network) { + super.onLost(network) + launch { send(ConnectivityObserver.Status.Lost) } + } + + override fun onUnavailable() { + super.onUnavailable() + launch { send(ConnectivityObserver.Status.Unavailable) } + } + } + + connectivityManager.registerDefaultNetworkCallback(callback) + awaitClose { + connectivityManager.unregisterNetworkCallback(callback) + } + }.distinctUntilChanged() + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/Resource.kt b/app/src/main/java/dev/pinkroom/marketsight/common/Resource.kt index 610ce0c..ce46c8c 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/common/Resource.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/common/Resource.kt @@ -9,5 +9,4 @@ sealed class Resource{ val errorInfo: ErrorMessage? = null, val data: T? = null ): Resource() - data class Loading(val isLoading: Boolean=true): Resource() } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt b/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt index db23693..176ed11 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt @@ -40,7 +40,6 @@ class NewsRepositoryImp @Inject constructor( when(response){ is Resource.Error -> emit(Resource.Error(data = symbols)) is Resource.Success -> emit(Resource.Success(data = response.data.news ?: symbols)) - else -> Unit } } }.flowOn(dispatchers.IO).single() diff --git a/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt b/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt index 2896c7d..e5f2399 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt @@ -14,9 +14,11 @@ import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent import dev.pinkroom.marketsight.BuildConfig import dev.pinkroom.marketsight.MarketSightApp +import dev.pinkroom.marketsight.common.ConnectivityObserver import dev.pinkroom.marketsight.common.DefaultDispatchers import dev.pinkroom.marketsight.common.DispatcherProvider import dev.pinkroom.marketsight.common.FlowStreamAdapterFactory +import dev.pinkroom.marketsight.common.NetworkConnectivityObserver import dev.pinkroom.marketsight.common.addAuthenticationInterceptor import dev.pinkroom.marketsight.common.addLoggingInterceptor import dev.pinkroom.marketsight.data.data_source.NewsRemoteDataSource @@ -83,7 +85,7 @@ object AppModule { @Provides @Singleton - fun provideDispatchers(): DispatcherProvider{ + fun provideDispatchers(): DispatcherProvider { return DefaultDispatchers() } @@ -92,4 +94,9 @@ object AppModule { fun provideNewsRepository(newsRemoteDataSource: NewsRemoteDataSource, dispatcherProvider: DispatcherProvider): NewsRepository { return NewsRepositoryImp(newsRemoteDataSource = newsRemoteDataSource, dispatchers = dispatcherProvider) } + + @Provides + @Singleton + fun provideConnectivityObserver(@ApplicationContext context: Context): ConnectivityObserver = + NetworkConnectivityObserver(context = context) } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/NewsInfo.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/NewsInfo.kt index cd40d36..b0192b5 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/NewsInfo.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/NewsInfo.kt @@ -21,7 +21,7 @@ data class NewsInfo( ){ fun getImageUrl(imageSize: ImageSize) = images?.find { it.size == imageSize }?.url - fun getUpdatedDateFormatted(): String{ + fun getUpdatedDateFormatted(): String { val formatter = DateTimeFormatter .ofLocalizedDateTime(FormatStyle.LONG, FormatStyle.SHORT) .withLocale(Locale.getDefault()) @@ -29,4 +29,8 @@ data class NewsInfo( return updatedAt.format(formatter) } + + fun getAllSymbols(): String { + return symbols.joinToString(separator = ", ") + } } diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/ChangeFilterNews.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/ChangeFilterNews.kt index d34b755..cc0ec2e 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/ChangeFilterNews.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/ChangeFilterNews.kt @@ -34,7 +34,6 @@ class ChangeFilterNews @Inject constructor( is Resource.Error -> { symbolsToRevert.addAll(subscribeSymbols) } - else -> Unit } } diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt index 68a7d28..5b832b7 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt @@ -41,8 +41,12 @@ fun NavigationAppHost( NewsScreen( news = uiState.news, + mainNews = uiState.mainNews, realTimeNews = uiState.realTimeNews, symbols = uiState.symbols, + isLoading = uiState.isLoading, + errorMessage = uiState.errorMessage, + onEvent = viewModel::onEvent ) } composable( diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt index 3b44de8..dcaa520 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt @@ -17,7 +17,7 @@ class Dimensions( val headlineMedium: TextUnit = 28.sp, val headlineSmall: TextUnit = 24.sp, val titleLarge: TextUnit = 22.sp, - val titleMedium: TextUnit = 16.sp, + val titleMedium: TextUnit = 19.sp, val titleSmall: TextUnit = 14.sp, val bodyLarge: TextUnit = 16.sp, val bodyMedium: TextUnit = 14.sp, diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Theme.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Theme.kt index eb8cf37..f4c80b1 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Theme.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Theme.kt @@ -16,23 +16,25 @@ import androidx.compose.ui.platform.LocalView import androidx.core.view.WindowCompat private val DarkColorScheme = darkColorScheme( - primary = WoodSmoke, + primary = Gray, onPrimary = White, surfaceVariant = Gray, surface = WoodSmoke, onSurfaceVariant = White, background = WoodSmoke, onBackground = White, + tertiaryContainer = Gray, ) private val LightColorScheme = lightColorScheme( - primary = GrayAthens, + primary = White, onPrimary = Black, surfaceVariant = White, surface = GrayAthens, onSurfaceVariant = Black, background = GrayAthens, onBackground = Black, + tertiaryContainer = Black, ) @Composable @@ -53,8 +55,8 @@ fun MarketSightTheme( if (!view.isInEditMode) { SideEffect { val window = (view.context as Activity).window - window.statusBarColor = colorScheme.primary.toArgb() - window.navigationBarColor = colorScheme.primary.toArgb() + window.statusBarColor = colorScheme.background.toArgb() + window.navigationBarColor = colorScheme.background.toArgb() WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = !darkTheme } } diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsEvent.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsEvent.kt new file mode 100644 index 0000000..d407f0b --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsEvent.kt @@ -0,0 +1,5 @@ +package dev.pinkroom.marketsight.ui.news_screen + +sealed class NewsEvent { + data object RetryNews: NewsEvent() +} diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt index e326004..2e45b1f 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt @@ -5,29 +5,34 @@ import android.net.Uri import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.tooling.preview.Preview +import dev.pinkroom.marketsight.R import dev.pinkroom.marketsight.domain.model.common.SubInfoSymbols import dev.pinkroom.marketsight.domain.model.news.ImageSize import dev.pinkroom.marketsight.domain.model.news.ImagesNews import dev.pinkroom.marketsight.domain.model.news.NewsInfo import dev.pinkroom.marketsight.ui.core.theme.dimens +import dev.pinkroom.marketsight.ui.news_screen.components.EmptyNewsList import dev.pinkroom.marketsight.ui.news_screen.components.MainNews import java.time.LocalDateTime @Composable fun NewsScreen( modifier: Modifier = Modifier, + mainNews: List, news: List, realTimeNews: List, symbols: List, + isLoading: Boolean, + errorMessage: Int? = null, + onEvent: (event: NewsEvent) -> Unit, ){ val context = LocalContext.current - + LazyColumn( modifier = modifier .fillMaxSize(), @@ -36,19 +41,28 @@ fun NewsScreen( bottom = dimens.contentBottomPadding, ) ) { - item { - MainNews( - modifier = Modifier - .fillMaxWidth() - .padding( - horizontal = dimens.horizontalPadding, - ), - newsList = news, - onNewsClick = { - val intent = Intent(Intent.ACTION_VIEW, Uri.parse(it.url)) - context.startActivity(intent) - } - ) + if (!isLoading && news.isEmpty()){ + item { + EmptyNewsList( + modifier = Modifier + .fillParentMaxSize(), + errorMessage = errorMessage ?: R.string.get_news_error_message, + onEvent = onEvent, + ) + } + } else { + item { + MainNews( + modifier = Modifier + .fillMaxWidth(), + newsList = mainNews, + isLoading = isLoading, + onNewsClick = { + val intent = Intent(Intent.ACTION_VIEW, Uri.parse(it.url)) + context.startActivity(intent) + } + ) + } } } } @@ -60,7 +74,8 @@ fun NewsScreen( @Composable fun NewsScreenPreview(){ NewsScreen( - news = listOf( + news = listOf(), + mainNews = listOf( NewsInfo( id = 1L, symbols = listOf("TSLA","AAPL","BTC"), @@ -79,7 +94,7 @@ fun NewsScreenPreview(){ headline = "Market Clubhouse Morning Memo - April 11th, 2024 (Trade Strategy For SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", ), NewsInfo( - id = 1L, + id = 2L, symbols = listOf("TSLA","AAPL","BTC"), images = listOf( ImagesNews( @@ -118,5 +133,8 @@ fun NewsScreenPreview(){ name = "APPLE", symbol = "AAPL", ), ), + isLoading = true, + errorMessage = R.string.get_news_error_message, + onEvent = {}, ) } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt index 4ecb74c..43348b4 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt @@ -1,49 +1,14 @@ package dev.pinkroom.marketsight.ui.news_screen +import androidx.annotation.DrawableRes import dev.pinkroom.marketsight.domain.model.common.SubInfoSymbols -import dev.pinkroom.marketsight.domain.model.news.ImageSize -import dev.pinkroom.marketsight.domain.model.news.ImagesNews import dev.pinkroom.marketsight.domain.model.news.NewsInfo -import java.time.LocalDateTime data class NewsUiState( - val isLoading: Boolean = false, - val news: List = listOf( - NewsInfo( - id = 1L, - symbols = listOf("TSLA","AAPL","BTC"), - images = listOf( - ImagesNews( - size = ImageSize.Small, - url = "https://cdn.benzinga.com/files/imagecache/1024x768xUP/market-clubhouse-morning-memo_201.png", - ) - ), - source = "Bezinga", - url = "https://www.benzinga.com/", - updatedAt = LocalDateTime.now(), - createdAt = LocalDateTime.now(), - author = "RIPS", - summary = "Good Morning Traders! In today's Market Clubhouse Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, and TSLA.", - headline = "Market Clubhouse Morning Memo - April 11th, 2024 (Trade Strategy For SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", - ), - NewsInfo( - id = 2L, - symbols = listOf("TSLA","AAPL","BTC"), - images = listOf( - ImagesNews( - size = ImageSize.Small, - url = "https://cdn.benzinga.com/files/imagecache/1024x768xUP/market-clubhouse-morning-memo_201.p", - ) - ), - source = "Bezinga", - url = "https://www.benzinga.com/", - updatedAt = LocalDateTime.now(), - createdAt = LocalDateTime.now(), - author = "RIPS", - summary = "Good Morning Traders! In today's Market Clubhouse Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, and TSLA.", - headline = "Market Clubhouse Morning Memo - April 11th, 2024 (Trade Strategy For SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", - ), - ), + val isLoading: Boolean = true, + @DrawableRes val errorMessage: Int? = null, + val mainNews: List = listOf(), + val news: List = listOf(), val realTimeNews: List = listOf(), val symbols: List = listOf(), ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt index 4cec0a4..bef78e1 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt @@ -1,13 +1,23 @@ package dev.pinkroom.marketsight.ui.news_screen import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel +import dev.pinkroom.marketsight.R +import dev.pinkroom.marketsight.common.ConnectivityObserver +import dev.pinkroom.marketsight.common.ConnectivityObserver.Status.Available +import dev.pinkroom.marketsight.common.DispatcherProvider +import dev.pinkroom.marketsight.common.Resource import dev.pinkroom.marketsight.domain.use_case.news.ChangeFilterNews import dev.pinkroom.marketsight.domain.use_case.news.GetNews import dev.pinkroom.marketsight.domain.use_case.news.GetRealTimeNews import dev.pinkroom.marketsight.domain.use_case.news.SubscribeNews +import kotlinx.coroutines.Job import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.update +import kotlinx.coroutines.launch import javax.inject.Inject @HiltViewModel @@ -16,11 +26,60 @@ class NewsViewModel @Inject constructor( private val getRealTimeNews: GetRealTimeNews, private val getNews: GetNews, private val changeFilterNews: ChangeFilterNews, + private val connectivityObserver: ConnectivityObserver, + private val dispatchers: DispatcherProvider, ): ViewModel() { private val _uiState = MutableStateFlow(NewsUiState()) val uiState = _uiState.asStateFlow() + private var initNewsJob: Job? = null + init { + observeNetworkStatus() + initNews() + } + + fun onEvent(event: NewsEvent){ + when(event){ + NewsEvent.RetryNews -> retryToGetNews() + } + } + + private fun observeNetworkStatus(){ + viewModelScope.launch(dispatchers.IO) { + connectivityObserver.observe().distinctUntilChanged().collect{ statusNet -> + if (statusNet == Available && uiState.value.news.isEmpty() && initNewsJob == null) + initNews() + } + } + } + + private fun initNews(){ + initNewsJob = viewModelScope.launch(dispatchers.IO) { + _uiState.update { it.copy(isLoading = true) } + when(val response = getNews()){ + is Resource.Success -> { + val allNews = response.data.news + val maxNumberNews = if (allNews.size >= 5) 5 else allNews.size + val mainNews = allNews.subList(fromIndex = 0, toIndex = maxNumberNews) + _uiState.update { + it.copy( + news = response.data.news, mainNews = mainNews, + isLoading = false, errorMessage = null, + ) + } + } + is Resource.Error -> { + _uiState.update { + it.copy(isLoading = false, errorMessage = R.string.get_news_error_message) + } + } + } + initNewsJob = null + } + } + private fun retryToGetNews() { + if (initNewsJob == null) initNews() } } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/EmptyNewsList.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/EmptyNewsList.kt new file mode 100644 index 0000000..b455a58 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/EmptyNewsList.kt @@ -0,0 +1,53 @@ +package dev.pinkroom.marketsight.ui.news_screen.components + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.material3.Button +import androidx.compose.material3.Icon +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign +import dev.pinkroom.marketsight.R +import dev.pinkroom.marketsight.ui.core.theme.dimens +import dev.pinkroom.marketsight.ui.news_screen.NewsEvent + +@Composable +fun EmptyNewsList( + modifier: Modifier = Modifier, + errorMessage: Int, + onEvent: (event: NewsEvent) -> Unit, +){ + Column( + modifier = modifier + .padding(horizontal = dimens.horizontalPadding), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally, + ) { + Icon( + modifier = Modifier.size(dimens.largeIconSize), + painter = painterResource(id = R.drawable.icon_error), + contentDescription = null, + ) + Spacer(modifier = Modifier.height(dimens.smallPadding)) + Text( + text = stringResource(id = errorMessage), + textAlign = TextAlign.Center + ) + Spacer(modifier = Modifier.height(dimens.normalPadding)) + Button( + onClick = { onEvent(NewsEvent.RetryNews) } + ) { + Text( + text = stringResource(id = R.string.retry) + ) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/IndicatorPageCarousel.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/IndicatorPageCarousel.kt index 85e96cb..25c9640 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/IndicatorPageCarousel.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/IndicatorPageCarousel.kt @@ -1,5 +1,6 @@ package dev.pinkroom.marketsight.ui.news_screen.components +import androidx.compose.animation.core.tween import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -18,6 +19,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip +import dev.pinkroom.marketsight.common.Constants import dev.pinkroom.marketsight.ui.core.theme.PhilippineGray import dev.pinkroom.marketsight.ui.core.theme.PhilippineSilver import dev.pinkroom.marketsight.ui.core.theme.dimens @@ -27,6 +29,7 @@ import kotlinx.coroutines.launch @Composable fun IndicatorPageCarousel( pagerState: PagerState, + changePage: (currentPage: Int) -> Unit, ){ val scope = rememberCoroutineScope() val interactionSource = remember { MutableInteractionSource() } @@ -50,10 +53,17 @@ fun IndicatorPageCarousel( indication = null, interactionSource = interactionSource, onClick = { - if (pagerState.currentPage != iteration) + if (pagerState.currentPage != iteration) { scope.launch { - pagerState.animateScrollToPage(page = iteration) + pagerState.animateScrollToPage( + page = iteration, + animationSpec = tween( + durationMillis = Constants.ANIM_TIME_CAROUSEL + ) + ) } + changePage(iteration) + } } ), ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNews.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNews.kt index cdbff8a..da9e171 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNews.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNews.kt @@ -1,44 +1,125 @@ package dev.pinkroom.marketsight.ui.news_screen.components +import androidx.compose.animation.core.tween import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.foundation.interaction.collectIsDraggedAsState +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.pager.HorizontalPager +import androidx.compose.foundation.pager.PagerState import androidx.compose.foundation.pager.rememberPagerState +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.shadow +import androidx.compose.ui.graphics.graphicsLayer +import androidx.compose.ui.util.lerp +import dev.pinkroom.marketsight.common.Constants import dev.pinkroom.marketsight.domain.model.news.NewsInfo +import dev.pinkroom.marketsight.domain.model.news.getAspectRatio import dev.pinkroom.marketsight.ui.core.theme.dimens +import dev.pinkroom.marketsight.ui.core.theme.shimmerEffect +import kotlinx.coroutines.delay +import kotlinx.coroutines.launch +import kotlin.math.absoluteValue @OptIn(ExperimentalFoundationApi::class) @Composable fun MainNews( modifier: Modifier = Modifier, newsList: List, + isLoading: Boolean, onNewsClick: (news: NewsInfo) -> Unit, + autoScrollDuration: Long = 5000L, ){ val pagerState = rememberPagerState( pageCount = { newsList.size } ) - Column( - modifier = Modifier - .fillMaxWidth(), - ) { - HorizontalPager( - state = pagerState, - key = { newsList[it].id } - ) { index -> - val news = newsList[index] - MainNewsCard( - modifier = modifier, - news = news, - onClick = onNewsClick + val isDragged by pagerState.interactionSource.collectIsDraggedAsState() + var currentPageKey by remember { mutableIntStateOf(pagerState.currentPage) } + if (isDragged.not() && newsList.isNotEmpty()) { + with(pagerState) { + LaunchedEffect(key1 = currentPageKey) { + launch { + delay(timeMillis = autoScrollDuration) + val nextPage = (currentPage + 1).mod(pageCount) + animateScrollToPage( + page = nextPage, + animationSpec = tween( + durationMillis = Constants.ANIM_TIME_CAROUSEL + ) + ) + currentPageKey = nextPage + } + } + } + } + + if (isLoading) { + Box( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = dimens.horizontalPadding) + .shadow( + elevation = dimens.normalElevation, + shape = RoundedCornerShape(size = dimens.normalShape) + ) + .aspectRatio(dimens.imageSizeMainNews.getAspectRatio()) + .shimmerEffect() + ) + } else { + Column( + modifier = Modifier + .fillMaxWidth(), + ) { + HorizontalPager( + state = pagerState, + key = { newsList[it].id }, + contentPadding = PaddingValues(horizontal = dimens.horizontalPadding), + pageSpacing = dimens.normalPadding + ) { index -> + val news = newsList[index] + MainNewsCard( + modifier = modifier + .carouselTransition(index, pagerState), + news = news, + onClick = onNewsClick + ) + } + Spacer(modifier = Modifier.height(dimens.smallPadding)) + IndicatorPageCarousel( + pagerState = pagerState, + changePage = { + currentPageKey = it + } ) } - Spacer(modifier = Modifier.height(dimens.smallPadding)) - IndicatorPageCarousel(pagerState = pagerState) } -} \ No newline at end of file +} + +@OptIn(ExperimentalFoundationApi::class) +fun Modifier.carouselTransition(page: Int, pagerState: PagerState) = + graphicsLayer { + val pageOffset = + ((pagerState.currentPage - page) + pagerState.currentPageOffsetFraction).absoluteValue + + val transformation = lerp( + start = 0.7f, + stop = 1f, + fraction = 1f - pageOffset.coerceIn(0f, 1f) + ) + alpha = transformation + scaleY = transformation + } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNewsCard.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNewsCard.kt index b4b438b..e7ca306 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNewsCard.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNewsCard.kt @@ -6,6 +6,7 @@ import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth @@ -115,19 +116,30 @@ fun MainNewsCard( ) { Text( text = news.headline, - style = MaterialTheme.typography.headlineSmall, + style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.Medium, color = White, maxLines = 2, overflow = TextOverflow.Ellipsis, ) - Text( - modifier = Modifier.fillMaxWidth(), - text = news.getUpdatedDateFormatted(), - fontWeight = FontWeight.Bold, - color = White, - textAlign = TextAlign.Start, - ) + Row { + Text( + modifier = Modifier.weight(1f), + text = news.getUpdatedDateFormatted(), + color = White, + fontWeight = FontWeight.Bold, + textAlign = TextAlign.Start, + ) + Text( + modifier = Modifier.weight(0.8f), + textAlign = TextAlign.End, + text = news.getAllSymbols(), + fontWeight = FontWeight.Bold, + color = White, + maxLines = 1, + overflow = TextOverflow.Ellipsis, + ) + } } } } diff --git a/app/src/main/res/drawable/icon_error.xml b/app/src/main/res/drawable/icon_error.xml new file mode 100644 index 0000000..ee34fd7 --- /dev/null +++ b/app/src/main/res/drawable/icon_error.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 32fce48..7ce213a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -3,4 +3,6 @@ News Home icon bottom bar + Something went wrong, check your internet connection. + Retry \ No newline at end of file From aac9174b335ed594d191ace4ff0f7563e1c2f1b4 Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Fri, 19 Apr 2024 11:56:55 +0100 Subject: [PATCH 17/33] - show all news - refresh news - show snackbar error - refactor code --- .../pinkroom/marketsight/common/Constants.kt | 3 +- .../dev/pinkroom/marketsight/di/AppModule.kt | 33 ++++- .../pinkroom/marketsight/ui/MainActivity.kt | 21 ++- .../ui/core/components/ObserveAsEvents.kt | 18 +++ .../components/PullToRefreshLazyColumn.kt | 69 ++++++++++ .../ui/core/navigation/NavigationAppHost.kt | 15 +++ .../ui/core/navigation/NavigationBottomBar.kt | 16 ++- .../marketsight/ui/core/theme/Dimensions.kt | 5 + .../marketsight/ui/news_screen/NewsAction.kt | 11 ++ .../marketsight/ui/news_screen/NewsEvent.kt | 1 + .../marketsight/ui/news_screen/NewsScreen.kt | 79 ++++++++++-- .../marketsight/ui/news_screen/NewsUiState.kt | 1 + .../ui/news_screen/NewsViewModel.kt | 38 +++++- .../ui/news_screen/components/AllNews.kt | 67 ++++++++++ .../ui/news_screen/components/AllNewsCard.kt | 121 ++++++++++++++++++ .../news_screen/components/EmptyNewsList.kt | 5 +- .../ui/news_screen/components/ImageNews.kt | 41 ++++++ .../ui/news_screen/components/MainNews.kt | 2 +- .../ui/news_screen/components/MainNewsCard.kt | 34 +---- app/src/main/res/values/strings.xml | 2 +- 20 files changed, 518 insertions(+), 64 deletions(-) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/core/components/ObserveAsEvents.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/core/components/PullToRefreshLazyColumn.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsAction.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/AllNews.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/AllNewsCard.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/ImageNews.kt diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/Constants.kt b/app/src/main/java/dev/pinkroom/marketsight/common/Constants.kt index 67d61ca..529f4d0 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/common/Constants.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/common/Constants.kt @@ -1,5 +1,6 @@ package dev.pinkroom.marketsight.common object Constants { - val ANIM_TIME_CAROUSEL = 700 + const val ANIM_TIME_CAROUSEL = 700 + const val MAX_ITEMS_CAROUSEL = 5 } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt b/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt index e5f2399..8f6881b 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt @@ -31,6 +31,7 @@ import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory import retrofit2.create import java.util.concurrent.TimeUnit +import javax.inject.Named import javax.inject.Singleton @Module @@ -38,13 +39,29 @@ import javax.inject.Singleton object AppModule { private const val ALPACA_STREAM_URL_NEWS = BuildConfig.ALPACA_STREAM_URL + "v1beta1/news" - private const val API_TIMEOUT = 60L + private const val API_TIMEOUT_WS = 30L + private const val API_TIMEOUT_API = 10L + private const val OK_HTTP_WS = "okHttpWS" + private const val OK_HTTP_API = "okHttpAPI" + + @Provides + @Singleton + @Named(OK_HTTP_WS) + fun provideOkHttpClientWS() = OkHttpClient.Builder() + .connectTimeout(API_TIMEOUT_WS, TimeUnit.SECONDS) + .readTimeout(API_TIMEOUT_WS, TimeUnit.SECONDS) + .writeTimeout(API_TIMEOUT_WS, TimeUnit.SECONDS) + .addAuthenticationInterceptor() + .addLoggingInterceptor() + .build() + @Provides @Singleton - fun provideOkHttpClient() = OkHttpClient.Builder() - .connectTimeout(API_TIMEOUT, TimeUnit.SECONDS) - .readTimeout(API_TIMEOUT, TimeUnit.SECONDS) - .writeTimeout(API_TIMEOUT, TimeUnit.SECONDS) + @Named(OK_HTTP_API) + fun provideOkHttpClientAPI() = OkHttpClient.Builder() + .connectTimeout(API_TIMEOUT_API, TimeUnit.SECONDS) + .readTimeout(API_TIMEOUT_API, TimeUnit.SECONDS) + .writeTimeout(API_TIMEOUT_API, TimeUnit.SECONDS) .addAuthenticationInterceptor() .addLoggingInterceptor() .build() @@ -57,7 +74,9 @@ object AppModule { @Provides @Singleton - fun provideAlpacaNewsService(okHttpClient: OkHttpClient, lifecycle: Lifecycle): AlpacaNewsService { + fun provideAlpacaNewsService( + @Named(OK_HTTP_WS) okHttpClient: OkHttpClient, lifecycle: Lifecycle + ): AlpacaNewsService { val scarlet = Scarlet.Builder() .webSocketFactory(okHttpClient.newWebSocketFactory(ALPACA_STREAM_URL_NEWS)) .addMessageAdapterFactory(GsonMessageAdapter.Factory()) @@ -70,7 +89,7 @@ object AppModule { @Provides @Singleton - fun provideAlpacaNewsApi(okHttpClient: OkHttpClient): AlpacaNewsApi { + fun provideAlpacaNewsApi(@Named(OK_HTTP_API) okHttpClient: OkHttpClient): AlpacaNewsApi { return Retrofit.Builder() .baseUrl(BuildConfig.ALPACA_DATA_URL) .addConverterFactory(GsonConverterFactory.create()) diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt index 6bd6322..61c58e5 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt @@ -6,7 +6,11 @@ import androidx.activity.compose.setContent import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.material3.Scaffold +import androidx.compose.material3.SnackbarHost +import androidx.compose.material3.SnackbarHostState import androidx.compose.material3.Surface +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import androidx.navigation.compose.rememberNavController @@ -15,6 +19,7 @@ import dev.pinkroom.marketsight.ui.core.navigation.NavigationAppHost import dev.pinkroom.marketsight.ui.core.navigation.NavigationBottomBar import dev.pinkroom.marketsight.ui.core.navigation.Route import dev.pinkroom.marketsight.ui.core.theme.MarketSightTheme +import kotlinx.coroutines.launch @AndroidEntryPoint class MainActivity : ComponentActivity() { @@ -25,13 +30,17 @@ class MainActivity : ComponentActivity() { setContent { val navController = rememberNavController() val startDestination = Route.NewsScreen - + val snackBarHostState = remember { SnackbarHostState() } + val scope = rememberCoroutineScope() MarketSightTheme { Surface( modifier = Modifier.fillMaxSize(), ) { Scaffold( modifier = Modifier.fillMaxSize(), + snackbarHost = { + SnackbarHost(hostState = snackBarHostState) + }, bottomBar = { NavigationBottomBar( navController = navController, @@ -43,6 +52,16 @@ class MainActivity : ComponentActivity() { modifier = Modifier.padding(padding), navController = navController, startDestination = startDestination, + onShowSnackBar = { message, duration -> + scope.launch { + snackBarHostState.currentSnackbarData?.dismiss() + snackBarHostState.showSnackbar( + message = message, + duration = duration, + withDismissAction = true, + ) + } + } ) } } diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/ObserveAsEvents.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/ObserveAsEvents.kt new file mode 100644 index 0000000..a8e9d5e --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/ObserveAsEvents.kt @@ -0,0 +1,18 @@ +package dev.pinkroom.marketsight.ui.core.components + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.ui.platform.LocalLifecycleOwner +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.repeatOnLifecycle +import kotlinx.coroutines.flow.Flow + +@Composable +fun ObserveAsEvents(flow: Flow, onEvent: (T) -> Unit) { + val lifecycleOwner = LocalLifecycleOwner.current + LaunchedEffect(flow, lifecycleOwner.lifecycle) { + lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) { + flow.collect(onEvent) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/PullToRefreshLazyColumn.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/PullToRefreshLazyColumn.kt new file mode 100644 index 0000000..9f36a0e --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/PullToRefreshLazyColumn.kt @@ -0,0 +1,69 @@ +package dev.pinkroom.marketsight.ui.core.components + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.LazyListScope +import androidx.compose.foundation.lazy.LazyListState +import androidx.compose.foundation.lazy.rememberLazyListState +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.pulltorefresh.PullToRefreshContainer +import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.input.nestedscroll.nestedScroll +import androidx.compose.ui.unit.dp + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun PullToRefreshLazyColumn( + modifier: Modifier = Modifier, + isRefreshing: Boolean, + enabledPullToRefresh: (() -> Boolean)? = null, + onRefresh: () -> Unit, + contentPadding: PaddingValues = PaddingValues(), + lazyListState: LazyListState = rememberLazyListState(), + content: (LazyListScope.() -> Unit), +) { + val pullToRefreshState = rememberPullToRefreshState( + enabled = enabledPullToRefresh ?: { true } + ) + Box( + modifier = modifier + .nestedScroll(pullToRefreshState.nestedScrollConnection), + ) { + LazyColumn( + state = lazyListState, + contentPadding = contentPadding, + modifier = Modifier + .fillMaxSize(), + verticalArrangement = Arrangement.spacedBy(8.dp) + ){ + content() + } + + if(pullToRefreshState.isRefreshing) { + LaunchedEffect(true) { + onRefresh() + } + } + + LaunchedEffect(isRefreshing) { + if(isRefreshing) { + pullToRefreshState.startRefresh() + } else { + pullToRefreshState.endRefresh() + } + } + + PullToRefreshContainer( + state = pullToRefreshState, + modifier = Modifier + .align(Alignment.TopCenter), + ) + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt index 5b832b7..d19468e 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt @@ -1,7 +1,9 @@ package dev.pinkroom.marketsight.ui.core.navigation +import androidx.compose.material3.SnackbarDuration import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.navigation.NavHostController @@ -9,10 +11,12 @@ import androidx.navigation.NavType import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.navArgument +import dev.pinkroom.marketsight.ui.core.components.ObserveAsEvents import dev.pinkroom.marketsight.ui.core.navigation.Args.SYMBOL_ID import dev.pinkroom.marketsight.ui.detail_screen.DetailScreen import dev.pinkroom.marketsight.ui.home_screen.HomeScreen import dev.pinkroom.marketsight.ui.home_screen.HomeViewModel +import dev.pinkroom.marketsight.ui.news_screen.NewsAction import dev.pinkroom.marketsight.ui.news_screen.NewsScreen import dev.pinkroom.marketsight.ui.news_screen.NewsViewModel @@ -21,7 +25,9 @@ fun NavigationAppHost( modifier: Modifier = Modifier, navController: NavHostController, startDestination: Route, + onShowSnackBar: (message: String, duration: SnackbarDuration) -> Unit, ){ + val context = LocalContext.current NavHost( navController = navController, startDestination = startDestination.route, @@ -39,12 +45,21 @@ fun NavigationAppHost( val viewModel = hiltViewModel() val uiState = viewModel.uiState.collectAsStateWithLifecycle().value + ObserveAsEvents(viewModel.action){ action -> + when(action){ + is NewsAction.ShowSnackBar -> { + onShowSnackBar(context.getString(action.message), action.duration) + } + } + } + NewsScreen( news = uiState.news, mainNews = uiState.mainNews, realTimeNews = uiState.realTimeNews, symbols = uiState.symbols, isLoading = uiState.isLoading, + isRefreshing = uiState.isRefreshing, errorMessage = uiState.errorMessage, onEvent = viewModel::onEvent ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationBottomBar.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationBottomBar.kt index e73dc8d..1dedf4b 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationBottomBar.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationBottomBar.kt @@ -5,8 +5,12 @@ import androidx.compose.animation.core.animateDpAsState import androidx.compose.animation.core.tween import androidx.compose.animation.slideInVertically import androidx.compose.animation.slideOutVertically +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.RowScope import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.RoundedCornerShape @@ -14,7 +18,6 @@ import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.NavigationBar import androidx.compose.material3.NavigationBarItem import androidx.compose.material3.NavigationBarItemDefaults import androidx.compose.runtime.Composable @@ -22,6 +25,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource @@ -59,7 +63,9 @@ fun NavigationBottomBar( content = { Card( modifier = Modifier + .background(color = Color.Transparent) .fillMaxWidth() + .height(dimens.menuHeight) .padding(horizontal = dimens.horizontalPadding) .padding(bottom = dimens.menuBottomPadding), shape = RoundedCornerShape(dimens.smallShape), @@ -67,8 +73,12 @@ fun NavigationBottomBar( defaultElevation = dimens.lowElevation, ), ) { - NavigationBar( - containerColor = Color.Transparent + Row( + modifier = Modifier + .background(Color.Transparent) + .fillMaxWidth(), + horizontalArrangement = Arrangement.SpaceEvenly, + verticalAlignment = Alignment.CenterVertically ) { items.forEach { bottomBarItem -> AddItem( diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt index dcaa520..8367c8b 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt @@ -57,6 +57,8 @@ class Dimensions( val imageSizeMainNews: ImageSize = ImageSize.Small, val circlePageIndicatorSize: Dp = 9.dp, val spaceBetweenPageIndicator: Dp = 2.dp, + val newsCard: Dp = 120.dp, + val menuHeight: Dp = 100.dp ) val dimens: Dimensions @@ -71,6 +73,9 @@ val dimens: Dimensions // Here you will override the dimensions needed depending on the screen size private val smallDimensions = Dimensions( + largeIconSize = 24.dp, + normalIconSize = 15.dp, + menuHeight = 70.dp, imageSizeMainNews = ImageSize.Small, ) private val normalDimensions = Dimensions( diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsAction.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsAction.kt new file mode 100644 index 0000000..46aae29 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsAction.kt @@ -0,0 +1,11 @@ +package dev.pinkroom.marketsight.ui.news_screen + +import androidx.annotation.StringRes +import androidx.compose.material3.SnackbarDuration + +sealed class NewsAction{ + data class ShowSnackBar( + @StringRes val message: Int, + val duration: SnackbarDuration = SnackbarDuration.Short, + ): NewsAction() +} diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsEvent.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsEvent.kt index d407f0b..0f66a54 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsEvent.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsEvent.kt @@ -2,4 +2,5 @@ package dev.pinkroom.marketsight.ui.news_screen sealed class NewsEvent { data object RetryNews: NewsEvent() + data object RefreshNews: NewsEvent() } diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt index 2e45b1f..dbce9d0 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt @@ -1,11 +1,11 @@ package dev.pinkroom.marketsight.ui.news_screen +import android.content.Context import android.content.Intent import android.net.Uri import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext @@ -15,7 +15,9 @@ import dev.pinkroom.marketsight.domain.model.common.SubInfoSymbols import dev.pinkroom.marketsight.domain.model.news.ImageSize import dev.pinkroom.marketsight.domain.model.news.ImagesNews import dev.pinkroom.marketsight.domain.model.news.NewsInfo +import dev.pinkroom.marketsight.ui.core.components.PullToRefreshLazyColumn import dev.pinkroom.marketsight.ui.core.theme.dimens +import dev.pinkroom.marketsight.ui.news_screen.components.AllNews import dev.pinkroom.marketsight.ui.news_screen.components.EmptyNewsList import dev.pinkroom.marketsight.ui.news_screen.components.MainNews import java.time.LocalDateTime @@ -28,26 +30,36 @@ fun NewsScreen( realTimeNews: List, symbols: List, isLoading: Boolean, + isRefreshing: Boolean, errorMessage: Int? = null, onEvent: (event: NewsEvent) -> Unit, ){ val context = LocalContext.current - LazyColumn( + PullToRefreshLazyColumn( modifier = modifier .fillMaxSize(), contentPadding = PaddingValues( top = dimens.contentTopPadding, bottom = dimens.contentBottomPadding, - ) + ), + isRefreshing = isRefreshing, + enabledPullToRefresh = { + !((!isLoading && errorMessage != null && news.isEmpty()) || isLoading) + }, + onRefresh = { + onEvent(NewsEvent.RefreshNews) + }, ) { - if (!isLoading && news.isEmpty()){ + if (!isLoading && errorMessage != null && news.isEmpty()){ item { EmptyNewsList( modifier = Modifier .fillParentMaxSize(), - errorMessage = errorMessage ?: R.string.get_news_error_message, - onEvent = onEvent, + errorMessage = errorMessage, + onRetry = { + onEvent(NewsEvent.RetryNews) + }, ) } } else { @@ -58,15 +70,26 @@ fun NewsScreen( newsList = mainNews, isLoading = isLoading, onNewsClick = { - val intent = Intent(Intent.ACTION_VIEW, Uri.parse(it.url)) - context.startActivity(intent) + context.navigateToNews(newsInfo = it) } ) } + AllNews( + news = news, + isLoading = isLoading, + navigateToNews = { + context.navigateToNews(newsInfo = it) + } + ) } } } +fun Context.navigateToNews(newsInfo: NewsInfo){ + val intent = Intent(Intent.ACTION_VIEW, Uri.parse(newsInfo.url)) + startActivity(intent) +} + @Preview( showBackground = true, showSystemUi = true, @@ -74,7 +97,42 @@ fun NewsScreen( @Composable fun NewsScreenPreview(){ NewsScreen( - news = listOf(), + news = listOf( + NewsInfo( + id = 1L, + symbols = listOf("TSLA","AAPL","BTC"), + images = listOf( + ImagesNews( + size = ImageSize.Small, + url = "https://cdn.benzinga.com/files/imagecache/1024x768xUP/market-clubhouse-morning-memo_201.png", + ) + ), + source = "Bezinga", + url = "https://www.benzinga.com/", + updatedAt = LocalDateTime.now(), + createdAt = LocalDateTime.now(), + author = "RIPS", + summary = "Good Morning Traders! In today's Market Clubhouse Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, and TSLA.", + headline = "Market Clubhouse Morning Memo - April 11th, 2024 (Trade Strategy For SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", + ), + NewsInfo( + id = 2L, + symbols = listOf("TSLA","AAPL","BTC"), + images = listOf( + ImagesNews( + size = ImageSize.Small, + url = "https://cdn.benzinga.com/files/imagecache/1024x768xUP/market-clubhouse-morning-memo_201.png", + ) + ), + source = "Bezinga", + url = "https://www.benzinga.com/", + updatedAt = LocalDateTime.now(), + createdAt = LocalDateTime.now(), + author = "RIPS", + summary = "Good Morning Traders! In today's Market Clubhouse Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, and TSLA.", + headline = "Market Clubhouse Morning Memo - April 11th, 2024 (Trade Strategy For SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", + ), + ), mainNews = listOf( NewsInfo( id = 1L, @@ -133,8 +191,9 @@ fun NewsScreenPreview(){ name = "APPLE", symbol = "AAPL", ), ), - isLoading = true, + isLoading = false, errorMessage = R.string.get_news_error_message, + isRefreshing = false, onEvent = {}, ) } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt index 43348b4..638ceb3 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt @@ -6,6 +6,7 @@ import dev.pinkroom.marketsight.domain.model.news.NewsInfo data class NewsUiState( val isLoading: Boolean = true, + val isRefreshing: Boolean = false, @DrawableRes val errorMessage: Int? = null, val mainNews: List = listOf(), val news: List = listOf(), diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt index bef78e1..65b4fc8 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt @@ -6,6 +6,8 @@ import dagger.hilt.android.lifecycle.HiltViewModel import dev.pinkroom.marketsight.R import dev.pinkroom.marketsight.common.ConnectivityObserver import dev.pinkroom.marketsight.common.ConnectivityObserver.Status.Available +import dev.pinkroom.marketsight.common.ConnectivityObserver.Status.Unavailable +import dev.pinkroom.marketsight.common.Constants.MAX_ITEMS_CAROUSEL import dev.pinkroom.marketsight.common.DispatcherProvider import dev.pinkroom.marketsight.common.Resource import dev.pinkroom.marketsight.domain.use_case.news.ChangeFilterNews @@ -13,9 +15,11 @@ import dev.pinkroom.marketsight.domain.use_case.news.GetNews import dev.pinkroom.marketsight.domain.use_case.news.GetRealTimeNews import dev.pinkroom.marketsight.domain.use_case.news.SubscribeNews import kotlinx.coroutines.Job +import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.receiveAsFlow import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch import javax.inject.Inject @@ -32,7 +36,11 @@ class NewsViewModel @Inject constructor( private val _uiState = MutableStateFlow(NewsUiState()) val uiState = _uiState.asStateFlow() + private val _action = Channel() + val action = _action.receiveAsFlow() + private var initNewsJob: Job? = null + private var connectionStatus = Unavailable init { observeNetworkStatus() @@ -42,12 +50,14 @@ class NewsViewModel @Inject constructor( fun onEvent(event: NewsEvent){ when(event){ NewsEvent.RetryNews -> retryToGetNews() + NewsEvent.RefreshNews -> refreshNews() } } private fun observeNetworkStatus(){ viewModelScope.launch(dispatchers.IO) { connectivityObserver.observe().distinctUntilChanged().collect{ statusNet -> + connectionStatus = statusNet if (statusNet == Available && uiState.value.news.isEmpty() && initNewsJob == null) initNews() } @@ -60,19 +70,28 @@ class NewsViewModel @Inject constructor( when(val response = getNews()){ is Resource.Success -> { val allNews = response.data.news - val maxNumberNews = if (allNews.size >= 5) 5 else allNews.size - val mainNews = allNews.subList(fromIndex = 0, toIndex = maxNumberNews) + val maxNumberNews = if (allNews.size >= MAX_ITEMS_CAROUSEL) MAX_ITEMS_CAROUSEL else allNews.size + val mainNews = allNews.take(maxNumberNews) + val remainingNews = if (maxNumberNews == allNews.size) mainNews + else allNews.drop(maxNumberNews) _uiState.update { it.copy( - news = response.data.news, mainNews = mainNews, - isLoading = false, errorMessage = null, + news = remainingNews, mainNews = mainNews, + isLoading = false, errorMessage = null, isRefreshing = false, ) } } is Resource.Error -> { _uiState.update { - it.copy(isLoading = false, errorMessage = R.string.get_news_error_message) + it.copy( + isLoading = false, isRefreshing = false, + errorMessage = R.string.get_news_error_message + ) } + if (uiState.value.news.isNotEmpty()) + _action.send( + NewsAction.ShowSnackBar(message = R.string.get_news_error_message) + ) } } initNewsJob = null @@ -80,6 +99,13 @@ class NewsViewModel @Inject constructor( } private fun retryToGetNews() { - if (initNewsJob == null) initNews() + if (initNewsJob == null && connectionStatus == Available) initNews() + } + + private fun refreshNews() { + if (initNewsJob == null){ + _uiState.update { it.copy(isRefreshing = true) } + initNews() + } } } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/AllNews.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/AllNews.kt new file mode 100644 index 0000000..a63c4c0 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/AllNews.kt @@ -0,0 +1,67 @@ +package dev.pinkroom.marketsight.ui.news_screen.components + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyListScope +import androidx.compose.foundation.lazy.items +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.shadow +import dev.pinkroom.marketsight.domain.model.news.NewsInfo +import dev.pinkroom.marketsight.ui.core.theme.dimens +import dev.pinkroom.marketsight.ui.core.theme.shimmerEffect + +fun LazyListScope.AllNews( + modifier: Modifier = Modifier, + isLoading: Boolean, + news: List, + navigateToNews: (newsInfo: NewsInfo) -> Unit, +){ + if (isLoading) + items(3){ + Row( + modifier = modifier + .fillMaxWidth() + .height(dimens.newsCard) + .padding(horizontal = dimens.horizontalPadding, vertical = dimens.smallPadding), + horizontalArrangement = Arrangement.SpaceBetween, + verticalAlignment = Alignment.CenterVertically, + ) { + Box( + modifier = Modifier + .shadow( + elevation = dimens.normalElevation, + shape = RoundedCornerShape(size = dimens.normalShape) + ) + .weight(0.5f) + .fillMaxSize() + .shimmerEffect() + ) + Box( + modifier = Modifier + .weight(1f) + .padding(start = dimens.smallPadding) + .fillMaxHeight() + .shimmerEffect() + ) + } + } + else + items(news){ item -> + AllNewsCard( + modifier = modifier + .fillMaxWidth() + .height(dimens.newsCard) + .padding(horizontal = dimens.horizontalPadding, vertical = dimens.smallPadding), + news = item, + onNewsClick = navigateToNews + ) + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/AllNewsCard.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/AllNewsCard.kt new file mode 100644 index 0000000..015a721 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/AllNewsCard.kt @@ -0,0 +1,121 @@ +package dev.pinkroom.marketsight.ui.news_screen.components + +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.shadow +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.tooling.preview.Preview +import dev.pinkroom.marketsight.domain.model.news.ImageSize +import dev.pinkroom.marketsight.domain.model.news.ImagesNews +import dev.pinkroom.marketsight.domain.model.news.NewsInfo +import dev.pinkroom.marketsight.ui.core.theme.dimens +import java.time.LocalDateTime + +@Composable +fun AllNewsCard( + modifier: Modifier = Modifier, + news: NewsInfo, + onNewsClick: (news: NewsInfo) -> Unit, +){ + Row( + modifier = modifier + .clickable { + onNewsClick(news) + }, + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween, + ) { + ImageNews( + modifier = Modifier + .shadow( + elevation = dimens.normalElevation, + shape = RoundedCornerShape(size = dimens.normalShape) + ) + .weight(0.5f) + .fillMaxSize(), + url = news.getImageUrl(imageSize = ImageSize.Thumb), + ) + Column( + modifier = Modifier + .weight(1f) + .padding(start = dimens.smallPadding) + .fillMaxHeight(), + verticalArrangement = Arrangement.SpaceEvenly, + ) { + if (news.symbols.isNotEmpty()) + Text( + text = news.getAllSymbols(), + fontWeight = FontWeight.Bold, + style = MaterialTheme.typography.bodySmall, + maxLines = 1, + overflow = TextOverflow.Ellipsis, + ) + Text( + text = news.headline, + style = MaterialTheme.typography.titleSmall, + maxLines = 3, + overflow = TextOverflow.Ellipsis, + ) + Row( + modifier = Modifier + .fillMaxWidth(), + horizontalArrangement = Arrangement.SpaceBetween, + ) { + Text( + text = news.source, + style = MaterialTheme.typography.labelMedium, + ) + Text( + text = news.getUpdatedDateFormatted(), + style = MaterialTheme.typography.labelMedium, + ) + } + } + } +} + +@Preview( + showBackground = true, + showSystemUi = true, +) +@Composable +fun PreviewAllNewsCard(){ + AllNewsCard( + modifier = Modifier + .height(dimens.newsCard) + .fillMaxWidth() + .padding(horizontal = dimens.horizontalPadding), + news = NewsInfo( + id = 1L, + symbols = listOf("TSLA","AAPL","BTC"), + images = listOf( + ImagesNews( + size = ImageSize.Small, + url = "https://cdn.benzinga.com/files/imagecache/1024x768xUP/market-clubhouse-morning-memo_201.png", + ) + ), + source = "Bezinga", + url = "https://www.benzinga.com/", + updatedAt = LocalDateTime.now(), + createdAt = LocalDateTime.now(), + author = "RIPS", + summary = "Good Morning Traders! In today's Market Clubhouse Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, and TSLA.", + headline = "rning Traders! In today's Market Clubhouse Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, Nrning Traders! In today's Market Clubhouse Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, Nrning Traders! In today's Market Clubhouse Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, NMarket Clubhouse Morning Memo - April 11th, 2024 (Trade Strategy For SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", + ), + onNewsClick = {}, + ) +} diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/EmptyNewsList.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/EmptyNewsList.kt index b455a58..a6b0c72 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/EmptyNewsList.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/EmptyNewsList.kt @@ -17,13 +17,12 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import dev.pinkroom.marketsight.R import dev.pinkroom.marketsight.ui.core.theme.dimens -import dev.pinkroom.marketsight.ui.news_screen.NewsEvent @Composable fun EmptyNewsList( modifier: Modifier = Modifier, errorMessage: Int, - onEvent: (event: NewsEvent) -> Unit, + onRetry: () -> Unit, ){ Column( modifier = modifier @@ -43,7 +42,7 @@ fun EmptyNewsList( ) Spacer(modifier = Modifier.height(dimens.normalPadding)) Button( - onClick = { onEvent(NewsEvent.RetryNews) } + onClick = onRetry ) { Text( text = stringResource(id = R.string.retry) diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/ImageNews.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/ImageNews.kt new file mode 100644 index 0000000..7e86464 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/ImageNews.kt @@ -0,0 +1,41 @@ +package dev.pinkroom.marketsight.ui.news_screen.components + +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.res.painterResource +import coil.compose.SubcomposeAsyncImage +import dev.pinkroom.marketsight.R +import dev.pinkroom.marketsight.ui.core.theme.shimmerEffect + +@Composable +fun ImageNews( + modifier: Modifier = Modifier, + url: String? = null, +){ + SubcomposeAsyncImage( + model = url, + contentDescription = null, + error = { + Image( + painter = painterResource(id = R.drawable.default_news_thumb), + contentDescription = null, + contentScale = ContentScale.Crop, + modifier = Modifier + .fillMaxSize() + ) + }, + loading = { + Box( + modifier = Modifier + .fillMaxSize() + .shimmerEffect() + ) + }, + contentScale = ContentScale.Crop, + modifier = modifier + ) +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNews.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNews.kt index da9e171..837bcd0 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNews.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNews.kt @@ -49,7 +49,7 @@ fun MainNews( val isDragged by pagerState.interactionSource.collectIsDraggedAsState() var currentPageKey by remember { mutableIntStateOf(pagerState.currentPage) } - if (isDragged.not() && newsList.isNotEmpty()) { + if (isDragged.not() && newsList.isNotEmpty() && !isLoading) { with(pagerState) { LaunchedEffect(key1 = currentPageKey) { launch { diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNewsCard.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNewsCard.kt index e7ca306..ceed469 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNewsCard.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNewsCard.kt @@ -1,6 +1,5 @@ package dev.pinkroom.marketsight.ui.news_screen.components -import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement @@ -24,16 +23,12 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.shadow import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color -import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.layout.onSizeChanged -import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.IntSize -import coil.compose.SubcomposeAsyncImage -import dev.pinkroom.marketsight.R import dev.pinkroom.marketsight.domain.model.news.ImageSize import dev.pinkroom.marketsight.domain.model.news.ImagesNews import dev.pinkroom.marketsight.domain.model.news.NewsInfo @@ -41,7 +36,6 @@ import dev.pinkroom.marketsight.domain.model.news.getAspectRatio import dev.pinkroom.marketsight.ui.core.theme.Black import dev.pinkroom.marketsight.ui.core.theme.White import dev.pinkroom.marketsight.ui.core.theme.dimens -import dev.pinkroom.marketsight.ui.core.theme.shimmerEffect import java.time.LocalDateTime @Composable @@ -66,32 +60,10 @@ fun MainNewsCard( onClick = { onClick(news) } ), ) { - SubcomposeAsyncImage( - model = news.getImageUrl(imageSize = dimens.imageSizeMainNews), - contentDescription = null, - error = { - val imageToLoad = when (dimens.imageSizeMainNews) { - ImageSize.Large -> R.drawable.default_news_large - ImageSize.Small -> R.drawable.default_news_small - ImageSize.Thumb -> R.drawable.default_news_thumb - } - Image( - painter = painterResource(id = imageToLoad), - contentDescription = null, - modifier = Modifier - .fillMaxSize() - ) - }, - loading = { - Box( - modifier = Modifier - .fillMaxSize() - .shimmerEffect() - ) - }, - contentScale = ContentScale.Crop, + ImageNews( modifier = Modifier - .fillMaxSize() + .fillMaxSize(), + url = news.getImageUrl(imageSize = dimens.imageSizeMainNews), ) Box( modifier = Modifier diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7ce213a..84a9cb9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -3,6 +3,6 @@ News Home icon bottom bar - Something went wrong, check your internet connection. + Something went wrong when fetching the news. Check your Internet connection. Retry \ No newline at end of file From 0b8c08507292220345ffc152e8f73a6744fe6ae8 Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Mon, 22 Apr 2024 09:56:14 +0100 Subject: [PATCH 18/33] - real time news - refactor news repository and news remote source --- app/build.gradle.kts | 4 + .../pinkroom/marketsight/common/Constants.kt | 1 + .../ConnectivityObserver.kt | 2 +- .../NetworkConnectivityObserver.kt | 2 +- .../data/data_source/NewsRemoteDataSource.kt | 49 +++----- .../data/repository/NewsRepositoryImp.kt | 5 - .../dev/pinkroom/marketsight/di/AppModule.kt | 4 +- .../domain/repository/NewsRepository.kt | 7 +- .../domain/use_case/news/SubscribeNews.kt | 13 -- .../marketsight/ui/core/theme/Dimensions.kt | 4 +- .../marketsight/ui/news_screen/NewsScreen.kt | 24 ++++ .../ui/news_screen/NewsViewModel.kt | 17 ++- .../ui/news_screen/components/AllNews.kt | 19 ++- .../ui/news_screen/components/RealTimeNews.kt | 73 ++++++++++++ .../components/RealTimeNewsCard.kt | 112 ++++++++++++++++++ app/src/main/res/values/strings.xml | 2 + gradle/libs.versions.toml | 5 + 17 files changed, 277 insertions(+), 66 deletions(-) rename app/src/main/java/dev/pinkroom/marketsight/common/{ => connection_network}/ConnectivityObserver.kt (75%) rename app/src/main/java/dev/pinkroom/marketsight/common/{ => connection_network}/NetworkConnectivityObserver.kt (96%) delete mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/SubscribeNews.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/RealTimeNews.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/RealTimeNewsCard.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index a2d2aa1..6e9cf7e 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -109,6 +109,10 @@ dependencies { // SPLASH implementation(libs.splash) + // PAGING + implementation(libs.paging.runtime) + implementation(libs.paging.compose) + // COIL implementation(libs.coil) diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/Constants.kt b/app/src/main/java/dev/pinkroom/marketsight/common/Constants.kt index 529f4d0..30da4a2 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/common/Constants.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/common/Constants.kt @@ -3,4 +3,5 @@ package dev.pinkroom.marketsight.common object Constants { const val ANIM_TIME_CAROUSEL = 700 const val MAX_ITEMS_CAROUSEL = 5 + const val LIMIT_NEWS = 20 } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/ConnectivityObserver.kt b/app/src/main/java/dev/pinkroom/marketsight/common/connection_network/ConnectivityObserver.kt similarity index 75% rename from app/src/main/java/dev/pinkroom/marketsight/common/ConnectivityObserver.kt rename to app/src/main/java/dev/pinkroom/marketsight/common/connection_network/ConnectivityObserver.kt index e0be426..08aae22 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/common/ConnectivityObserver.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/common/connection_network/ConnectivityObserver.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.common +package dev.pinkroom.marketsight.common.connection_network import kotlinx.coroutines.flow.Flow diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/NetworkConnectivityObserver.kt b/app/src/main/java/dev/pinkroom/marketsight/common/connection_network/NetworkConnectivityObserver.kt similarity index 96% rename from app/src/main/java/dev/pinkroom/marketsight/common/NetworkConnectivityObserver.kt rename to app/src/main/java/dev/pinkroom/marketsight/common/connection_network/NetworkConnectivityObserver.kt index a1b9a35..781fe26 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/common/NetworkConnectivityObserver.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/common/connection_network/NetworkConnectivityObserver.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.common +package dev.pinkroom.marketsight.common.connection_network import android.content.Context import android.net.ConnectivityManager diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt index b76e9fd..e87d7e6 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt @@ -1,23 +1,21 @@ package dev.pinkroom.marketsight.data.data_source -import android.util.Log import com.google.gson.Gson -import com.tinder.scarlet.Message import com.tinder.scarlet.WebSocket import dev.pinkroom.marketsight.common.ActionAlpaca +import dev.pinkroom.marketsight.common.Constants import dev.pinkroom.marketsight.common.DispatcherProvider import dev.pinkroom.marketsight.common.HelperIdentifierMessagesAlpacaService import dev.pinkroom.marketsight.common.Resource import dev.pinkroom.marketsight.common.SortType import dev.pinkroom.marketsight.common.toObject -import dev.pinkroom.marketsight.common.verifyIfIsError -import dev.pinkroom.marketsight.data.mapper.toErrorMessage import dev.pinkroom.marketsight.data.remote.AlpacaNewsApi import dev.pinkroom.marketsight.data.remote.AlpacaNewsService import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.NewsResponseDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.NewsMessageDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.SubscriptionMessageDto import dev.pinkroom.marketsight.data.remote.model.request.MessageAlpacaService +import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.take @@ -29,31 +27,24 @@ class NewsRemoteDataSource @Inject constructor( private val alpacaNewsApi: AlpacaNewsApi, private val dispatchers: DispatcherProvider, ) { - fun subscribeNews(symbols: List = listOf("*")) = flow> { - alpacaNewsService.observeOnConnectionEvent().collect{ - when(it){ - is WebSocket.Event.OnConnectionOpened<*> -> { - alpacaNewsService.sendMessage(message = MessageAlpacaService(action = ActionAlpaca.Subscribe.action, news = symbols)) - } - is WebSocket.Event.OnMessageReceived -> { - Log.d(TAG,"Received: ${it.message}") - if (it.message is Message.Text){ - gson.verifyIfIsError(jsonValue = (it.message as Message.Text).value)?.let { errorMessage -> - emit(Resource.Error(message = errorMessage.msg, errorInfo = errorMessage.toErrorMessage())) - } ?: run { - emit(Resource.Success(it)) - } - } - } - is WebSocket.Event.OnConnectionFailed -> { - emit(Resource.Error(message = it.throwable.message, data = it)) - } - else -> Log.d(TAG,it.toString()) + private var isNewsSubscribed: Boolean = false + + private suspend fun subscribeNews(symbols: List = listOf("*")){ + alpacaNewsService.observeOnConnectionEvent() + .filter { it is WebSocket.Event.OnConnectionOpened<*> } + .take(1) + .collect{ + isNewsSubscribed = true + alpacaNewsService.sendMessage( + message = MessageAlpacaService( + action = ActionAlpaca.Subscribe.action, news = symbols, + ) + ) } - } - }.flowOn(dispatchers.IO) + } fun getRealTimeNews() = flow { + if (!isNewsSubscribed) subscribeNews() alpacaNewsService.observeResponse().collect{ data -> val listNews = mutableListOf() data.forEach { @@ -80,7 +71,7 @@ class NewsRemoteDataSource @Inject constructor( suspend fun getNews( symbols: List?, - limit: Int?, + limit: Int? = Constants.LIMIT_NEWS, pageToken: String?, sort: SortType? ): NewsResponseDto { @@ -91,8 +82,4 @@ class NewsRemoteDataSource @Inject constructor( sort = sort?.type, ) } - - companion object { - const val TAG = "AlpacaRemote" - } } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt b/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt index 176ed11..50a5efb 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt @@ -19,11 +19,6 @@ class NewsRepositoryImp @Inject constructor( private val newsRemoteDataSource: NewsRemoteDataSource, private val dispatchers: DispatcherProvider, ): NewsRepository { - override fun subscribeNews(symbols: List) = flow { - newsRemoteDataSource.subscribeNews(symbols = symbols).collect{ - emit(it) - } - }.flowOn(dispatchers.IO) override fun getRealTimeNews() = flow { newsRemoteDataSource.getRealTimeNews().collect{ diff --git a/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt b/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt index 8f6881b..3d48ad5 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt @@ -14,13 +14,13 @@ import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent import dev.pinkroom.marketsight.BuildConfig import dev.pinkroom.marketsight.MarketSightApp -import dev.pinkroom.marketsight.common.ConnectivityObserver import dev.pinkroom.marketsight.common.DefaultDispatchers import dev.pinkroom.marketsight.common.DispatcherProvider import dev.pinkroom.marketsight.common.FlowStreamAdapterFactory -import dev.pinkroom.marketsight.common.NetworkConnectivityObserver import dev.pinkroom.marketsight.common.addAuthenticationInterceptor import dev.pinkroom.marketsight.common.addLoggingInterceptor +import dev.pinkroom.marketsight.common.connection_network.ConnectivityObserver +import dev.pinkroom.marketsight.common.connection_network.NetworkConnectivityObserver import dev.pinkroom.marketsight.data.data_source.NewsRemoteDataSource import dev.pinkroom.marketsight.data.remote.AlpacaNewsApi import dev.pinkroom.marketsight.data.remote.AlpacaNewsService diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt index dd2f56c..dfb6354 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt @@ -1,7 +1,7 @@ package dev.pinkroom.marketsight.domain.repository -import com.tinder.scarlet.WebSocket import dev.pinkroom.marketsight.common.ActionAlpaca +import dev.pinkroom.marketsight.common.Constants.LIMIT_NEWS import dev.pinkroom.marketsight.common.Resource import dev.pinkroom.marketsight.common.SortType import dev.pinkroom.marketsight.domain.model.news.NewsInfo @@ -9,9 +9,6 @@ import dev.pinkroom.marketsight.domain.model.news.NewsResponse import kotlinx.coroutines.flow.Flow interface NewsRepository { - fun subscribeNews( - symbols: List = listOf("*"), - ): Flow> fun getRealTimeNews(): Flow> suspend fun changeFilterNews( symbols: List, @@ -20,7 +17,7 @@ interface NewsRepository { suspend fun getNews( symbols: List? = null, - limit: Int? = null, + limit: Int? = LIMIT_NEWS, pageToken: String? = null, sort: SortType? = SortType.DESC, ): Resource diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/SubscribeNews.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/SubscribeNews.kt deleted file mode 100644 index 68b70b4..0000000 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/SubscribeNews.kt +++ /dev/null @@ -1,13 +0,0 @@ -package dev.pinkroom.marketsight.domain.use_case.news - -import dev.pinkroom.marketsight.common.DispatcherProvider -import dev.pinkroom.marketsight.domain.repository.NewsRepository -import kotlinx.coroutines.flow.flowOn -import javax.inject.Inject - -class SubscribeNews @Inject constructor( - private val newsRepository: NewsRepository, - private val dispatchers: DispatcherProvider, -){ - operator fun invoke() = newsRepository.subscribeNews().flowOn(dispatchers.IO) -} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt index 8367c8b..356f185 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt @@ -58,7 +58,9 @@ class Dimensions( val circlePageIndicatorSize: Dp = 9.dp, val spaceBetweenPageIndicator: Dp = 2.dp, val newsCard: Dp = 120.dp, - val menuHeight: Dp = 100.dp + val menuHeight: Dp = 100.dp, + val liveNewsCardWidth: Dp = 270.dp, + val liveNewsCardHeight: Dp = 100.dp, ) val dimens: Dimensions diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt index dbce9d0..2529791 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt @@ -20,6 +20,7 @@ import dev.pinkroom.marketsight.ui.core.theme.dimens import dev.pinkroom.marketsight.ui.news_screen.components.AllNews import dev.pinkroom.marketsight.ui.news_screen.components.EmptyNewsList import dev.pinkroom.marketsight.ui.news_screen.components.MainNews +import dev.pinkroom.marketsight.ui.news_screen.components.RealTimeNews import java.time.LocalDateTime @Composable @@ -74,6 +75,17 @@ fun NewsScreen( } ) } + item { + RealTimeNews( + modifier = Modifier + .fillMaxWidth(), + news = realTimeNews, + isLoading = isLoading, + onNewsClick = { + context.navigateToNews(newsInfo = it) + } + ) + } AllNews( news = news, isLoading = isLoading, @@ -182,6 +194,18 @@ fun NewsScreenPreview(){ summary = "Good Morning Traders! In today's Market Clubhouse Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, and TSLA.", headline = "Market Clubhouse Morning Memo - April 11th, 2024 (Trade Strategy For SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", ), + NewsInfo( + id = 2L, + symbols = listOf("TSLA","AAPL","BTC"), + images = null, + source = "Bezinga", + url = "https://www.benzinga.com/", + updatedAt = LocalDateTime.now(), + createdAt = LocalDateTime.now(), + author = "RIPS", + summary = "Good Morning Traders! In today's Market Clubhouse Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, and TSLA.", + headline = "Market Clubhouse Morning Memo - April 11th, 2024 (Trade Strategy For SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", + ), ), symbols = listOf( SubInfoSymbols( diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt index 65b4fc8..c0c4cbf 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt @@ -4,16 +4,15 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel import dev.pinkroom.marketsight.R -import dev.pinkroom.marketsight.common.ConnectivityObserver -import dev.pinkroom.marketsight.common.ConnectivityObserver.Status.Available -import dev.pinkroom.marketsight.common.ConnectivityObserver.Status.Unavailable import dev.pinkroom.marketsight.common.Constants.MAX_ITEMS_CAROUSEL import dev.pinkroom.marketsight.common.DispatcherProvider import dev.pinkroom.marketsight.common.Resource +import dev.pinkroom.marketsight.common.connection_network.ConnectivityObserver +import dev.pinkroom.marketsight.common.connection_network.ConnectivityObserver.Status.Available +import dev.pinkroom.marketsight.common.connection_network.ConnectivityObserver.Status.Unavailable import dev.pinkroom.marketsight.domain.use_case.news.ChangeFilterNews import dev.pinkroom.marketsight.domain.use_case.news.GetNews import dev.pinkroom.marketsight.domain.use_case.news.GetRealTimeNews -import dev.pinkroom.marketsight.domain.use_case.news.SubscribeNews import kotlinx.coroutines.Job import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.MutableStateFlow @@ -26,7 +25,6 @@ import javax.inject.Inject @HiltViewModel class NewsViewModel @Inject constructor( - private val subscribeNews: SubscribeNews, private val getRealTimeNews: GetRealTimeNews, private val getNews: GetNews, private val changeFilterNews: ChangeFilterNews, @@ -45,6 +43,7 @@ class NewsViewModel @Inject constructor( init { observeNetworkStatus() initNews() + fetchRealTimeNews() } fun onEvent(event: NewsEvent){ @@ -108,4 +107,12 @@ class NewsViewModel @Inject constructor( initNews() } } + + private fun fetchRealTimeNews() { + viewModelScope.launch(dispatchers.IO) { + getRealTimeNews().collect{ news -> + _uiState.update { it.copy(realTimeNews = it.realTimeNews + news) } + } + } + } } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/AllNews.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/AllNews.kt index a63c4c0..90b327a 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/AllNews.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/AllNews.kt @@ -11,9 +11,14 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyListScope import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.shadow +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontWeight +import dev.pinkroom.marketsight.R import dev.pinkroom.marketsight.domain.model.news.NewsInfo import dev.pinkroom.marketsight.ui.core.theme.dimens import dev.pinkroom.marketsight.ui.core.theme.shimmerEffect @@ -53,8 +58,17 @@ fun LazyListScope.AllNews( ) } } - else - items(news){ item -> + else { + item { + Text( + modifier = Modifier + .padding(horizontal = dimens.horizontalPadding), + text = stringResource(id = R.string.latest_news), + style = MaterialTheme.typography.titleLarge, + fontWeight = FontWeight.Bold, + ) + } + items(news) { item -> AllNewsCard( modifier = modifier .fillMaxWidth() @@ -64,4 +78,5 @@ fun LazyListScope.AllNews( onNewsClick = navigateToNews ) } + } } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/RealTimeNews.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/RealTimeNews.kt new file mode 100644 index 0000000..3ad3e42 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/RealTimeNews.kt @@ -0,0 +1,73 @@ +package dev.pinkroom.marketsight.ui.news_screen.components + +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.ExperimentalAnimationApi +import androidx.compose.animation.fadeIn +import androidx.compose.animation.slideInHorizontally +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.lazy.LazyRow +import androidx.compose.foundation.lazy.items +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontWeight +import dev.pinkroom.marketsight.R +import dev.pinkroom.marketsight.domain.model.news.NewsInfo +import dev.pinkroom.marketsight.ui.core.theme.dimens + +@OptIn(ExperimentalAnimationApi::class) +@Composable +fun RealTimeNews( + modifier: Modifier = Modifier, + news: List, + isLoading: Boolean, + onNewsClick: (news: NewsInfo) -> Unit, +){ + AnimatedVisibility( + visible = news.isNotEmpty() && !isLoading, + enter = slideInHorizontally() + fadeIn() + ) { + Column( + modifier = modifier, + verticalArrangement = Arrangement.spacedBy(dimens.smallPadding) + ) { + Text( + modifier = Modifier + .padding(horizontal = dimens.horizontalPadding), + text = stringResource(id = R.string.real_time), + style = MaterialTheme.typography.titleLarge, + fontWeight = FontWeight.Bold, + ) + LazyRow( + modifier = Modifier + .fillMaxWidth(), + contentPadding = PaddingValues( + horizontal = dimens.horizontalPadding, + ), + ) { + items( + items = news, + ){ + RealTimeNewsCard( + modifier = Modifier + .width(dimens.liveNewsCardWidth) + .height(dimens.liveNewsCardHeight) + .padding(vertical = dimens.smallPadding) + .padding(end = dimens.normalPadding), + news = it, + onClick = onNewsClick + ) + } + } + } + } + +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/RealTimeNewsCard.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/RealTimeNewsCard.kt new file mode 100644 index 0000000..99b87e0 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/RealTimeNewsCard.kt @@ -0,0 +1,112 @@ +package dev.pinkroom.marketsight.ui.news_screen.components + +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.requiredWidthIn +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Card +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.shadow +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.tooling.preview.Preview +import dev.pinkroom.marketsight.domain.model.news.ImageSize +import dev.pinkroom.marketsight.domain.model.news.ImagesNews +import dev.pinkroom.marketsight.domain.model.news.NewsInfo +import dev.pinkroom.marketsight.ui.core.theme.dimens +import java.time.LocalDateTime + +@Composable +fun RealTimeNewsCard( + modifier: Modifier = Modifier, + news: NewsInfo, + onClick: (news: NewsInfo) -> Unit +){ + Card( + modifier = modifier + .clickable { onClick(news) } + .shadow( + elevation = dimens.lowElevation, + shape = RoundedCornerShape(size = dimens.normalShape) + ) + ) { + Column( + modifier = Modifier + .fillMaxSize() + .padding(vertical = dimens.xSmallPadding, horizontal = dimens.smallPadding), + verticalArrangement = Arrangement.SpaceAround, + horizontalAlignment = Alignment.Start + ) { + if (news.symbols.isNotEmpty()) + Text( + text = news.getAllSymbols(), + fontWeight = FontWeight.Bold, + style = MaterialTheme.typography.bodySmall, + maxLines = 1, + overflow = TextOverflow.Ellipsis, + ) + Text( + text = news.headline, + style = MaterialTheme.typography.bodySmall, + maxLines = 2, + overflow = TextOverflow.Ellipsis, + ) + Row( + modifier = Modifier + .fillMaxWidth(), + horizontalArrangement = Arrangement.SpaceBetween, + ) { + Text( + text = news.source, + style = MaterialTheme.typography.labelSmall, + ) + Text( + text = news.getUpdatedDateFormatted(), + style = MaterialTheme.typography.labelSmall, + ) + } + } + } +} + + +@Preview( + showBackground = true, + showSystemUi = true, +) +@Composable +fun RealTimeNewsCardPreview(){ + RealTimeNewsCard( + modifier = Modifier + .requiredWidthIn(max = dimens.liveNewsCardWidth) + .height(dimens.liveNewsCardHeight), + news = NewsInfo( + id = 1L, + symbols = listOf("TSLA","AAPL","BTC"), + images = listOf( + ImagesNews( + size = ImageSize.Small, + url = "https://cdn.benzinga.com/files/imagecache/1024x768xUP/market-clubhouse-morning-memo_201.png", + ) + ), + source = "Bezinga", + url = "https://www.benzinga.com/", + updatedAt = LocalDateTime.now(), + createdAt = LocalDateTime.now(), + author = "RIPS", + summary = "Good Morning Traders! In today's Market Clubhouse Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, and TSLA.", + headline = "Market Clubhouse Morning Memo - April 11th, 2024 (Trade Strategy For SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", + ), + onClick = {} + ) +} diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 84a9cb9..00afeed 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -5,4 +5,6 @@ icon bottom bar Something went wrong when fetching the news. Check your Internet connection. Retry + Live News + Latest News \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 156f73b..c820512 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -21,6 +21,7 @@ coroutineVersion = "1.8.0" assertkVersion = "0.28.0" fakerVersion = "1.0.2" coilVersion = "2.6.0" +pagingVersion = "3.2.1" [libraries] @@ -65,6 +66,10 @@ hilt-compiler = { group = "com.google.dagger", name = "hilt-compiler", version.r # SPLASH splash = { group = "androidx.core", name = "core-splashscreen", version.ref = "splashVersion" } +# PAGING +paging-runtime = { group = "androidx.paging", name = "paging-runtime", version.ref = "pagingVersion" } +paging-compose = { group = "androidx.paging", name = "paging-compose", version.ref = "pagingVersion" } + # COIL coil = { group = "io.coil-kt", name = "coil-compose", version.ref = "coilVersion" } From 80c43b2dd149c5667bd27f8054520dd9c87bce8e Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Mon, 22 Apr 2024 14:48:10 +0100 Subject: [PATCH 19/33] - pagination news - empty content ui --- .../pinkroom/marketsight/common/Constants.kt | 1 + .../common/paginator/DefaultPagination.kt | 43 ++++++++++ .../common/paginator/Pagination.kt | 6 ++ .../data/data_source/NewsRemoteDataSource.kt | 4 +- .../domain/model/common/PaginationInfo.kt | 7 ++ .../domain/use_case/news/GetNews.kt | 9 ++- .../ui/core/components/ReachedBottom.kt | 8 ++ .../ui/core/navigation/NavigationAppHost.kt | 1 + .../marketsight/ui/core/theme/Dimensions.kt | 1 + .../marketsight/ui/news_screen/NewsEvent.kt | 1 + .../marketsight/ui/news_screen/NewsScreen.kt | 30 ++++++- .../marketsight/ui/news_screen/NewsUiState.kt | 1 + .../ui/news_screen/NewsViewModel.kt | 37 +++++++++ .../ui/news_screen/components/AllNews.kt | 80 +++++++++++-------- .../news_screen/components/EmptyNewsList.kt | 20 ++--- .../ui/news_screen/components/MainNews.kt | 2 +- .../ui/news_screen/components/RealTimeNews.kt | 2 - app/src/main/res/values/strings.xml | 1 + 18 files changed, 203 insertions(+), 51 deletions(-) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/common/paginator/DefaultPagination.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/common/paginator/Pagination.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/model/common/PaginationInfo.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/core/components/ReachedBottom.kt diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/Constants.kt b/app/src/main/java/dev/pinkroom/marketsight/common/Constants.kt index 30da4a2..70a51db 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/common/Constants.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/common/Constants.kt @@ -4,4 +4,5 @@ object Constants { const val ANIM_TIME_CAROUSEL = 700 const val MAX_ITEMS_CAROUSEL = 5 const val LIMIT_NEWS = 20 + const val BUFFER_LIST = 5 } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/paginator/DefaultPagination.kt b/app/src/main/java/dev/pinkroom/marketsight/common/paginator/DefaultPagination.kt new file mode 100644 index 0000000..01d78e0 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/common/paginator/DefaultPagination.kt @@ -0,0 +1,43 @@ +package dev.pinkroom.marketsight.common.paginator + +import dev.pinkroom.marketsight.common.Resource + +class DefaultPagination( + private val initialKey: Key?, + private inline val onLoadUpdated: (Boolean) -> Unit, + private inline val onRequest: suspend (nextKey: Key?) -> Resource, + private inline val getNextKey: suspend (T) -> Key, + private inline val onError: suspend (message: String?) -> Unit, + private inline val onSuccess: suspend (data: T, newKey: Key?) -> Unit +): Pagination { + + private var currentKey = initialKey + private var isMakingRequest = false + + override suspend fun loadNextItems() { + if(isMakingRequest) { + return + } + setLoading(isLoading = true) + when(val response = onRequest(currentKey)){ + is Resource.Error -> { + onError(response.message) + setLoading(isLoading = false) + } + is Resource.Success -> { + currentKey = getNextKey(response.data) + onSuccess(response.data, currentKey) + setLoading(isLoading = false) + } + } + } + + private fun setLoading(isLoading: Boolean){ + onLoadUpdated(isLoading) + isMakingRequest = isLoading + } + + override fun reset(key: Key?) { + currentKey = key ?: initialKey + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/paginator/Pagination.kt b/app/src/main/java/dev/pinkroom/marketsight/common/paginator/Pagination.kt new file mode 100644 index 0000000..0bc0eba --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/common/paginator/Pagination.kt @@ -0,0 +1,6 @@ +package dev.pinkroom.marketsight.common.paginator + +interface Pagination { + suspend fun loadNextItems() + fun reset(key: Key?) +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt index e87d7e6..c323c5d 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt @@ -70,10 +70,10 @@ class NewsRemoteDataSource @Inject constructor( }.flowOn(dispatchers.IO).take(1) suspend fun getNews( - symbols: List?, + symbols: List? = null, limit: Int? = Constants.LIMIT_NEWS, pageToken: String?, - sort: SortType? + sort: SortType? = null ): NewsResponseDto { return alpacaNewsApi.getNews( symbols = symbols?.joinToString(","), diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/common/PaginationInfo.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/common/PaginationInfo.kt new file mode 100644 index 0000000..11e105c --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/common/PaginationInfo.kt @@ -0,0 +1,7 @@ +package dev.pinkroom.marketsight.domain.model.common + +data class PaginationInfo( + val isLoading: Boolean = false, + val endReached: Boolean = false, + val page: String? = null +) \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/GetNews.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/GetNews.kt index 852c9aa..431d008 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/GetNews.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/GetNews.kt @@ -1,10 +1,17 @@ package dev.pinkroom.marketsight.domain.use_case.news +import dev.pinkroom.marketsight.common.Constants.LIMIT_NEWS import dev.pinkroom.marketsight.domain.repository.NewsRepository import javax.inject.Inject class GetNews @Inject constructor( private val newsRepository: NewsRepository, ){ - suspend operator fun invoke() = newsRepository.getNews() + suspend operator fun invoke( + pageToken: String? = null, + limitPerPage: Int? = LIMIT_NEWS, + ) = newsRepository.getNews( + pageToken = pageToken, + limit = limitPerPage, + ) } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/ReachedBottom.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/ReachedBottom.kt new file mode 100644 index 0000000..c26adad --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/ReachedBottom.kt @@ -0,0 +1,8 @@ +package dev.pinkroom.marketsight.ui.core.components + +import androidx.compose.foundation.lazy.LazyListState + +internal fun LazyListState.reachedBottom(buffer: Int = 1): Boolean { + val lastVisibleItem = this.layoutInfo.visibleItemsInfo.lastOrNull() + return lastVisibleItem?.index != 0 && lastVisibleItem?.index == this.layoutInfo.totalItemsCount - buffer +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt index d19468e..13574aa 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt @@ -59,6 +59,7 @@ fun NavigationAppHost( realTimeNews = uiState.realTimeNews, symbols = uiState.symbols, isLoading = uiState.isLoading, + isLoadingMoreNews = uiState.isLoadingMoreItems, isRefreshing = uiState.isRefreshing, errorMessage = uiState.errorMessage, onEvent = viewModel::onEvent diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt index 356f185..688f839 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt @@ -61,6 +61,7 @@ class Dimensions( val menuHeight: Dp = 100.dp, val liveNewsCardWidth: Dp = 270.dp, val liveNewsCardHeight: Dp = 100.dp, + val emptyContentMaxHeight: Float = 0.95f ) val dimens: Dimensions diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsEvent.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsEvent.kt index 0f66a54..44d545a 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsEvent.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsEvent.kt @@ -3,4 +3,5 @@ package dev.pinkroom.marketsight.ui.news_screen sealed class NewsEvent { data object RetryNews: NewsEvent() data object RefreshNews: NewsEvent() + data object LoadMoreNews: NewsEvent() } diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt index 2529791..0476867 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt @@ -6,16 +6,23 @@ import android.net.Uri import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.derivedStateOf +import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.tooling.preview.Preview import dev.pinkroom.marketsight.R +import dev.pinkroom.marketsight.common.Constants.BUFFER_LIST import dev.pinkroom.marketsight.domain.model.common.SubInfoSymbols import dev.pinkroom.marketsight.domain.model.news.ImageSize import dev.pinkroom.marketsight.domain.model.news.ImagesNews import dev.pinkroom.marketsight.domain.model.news.NewsInfo import dev.pinkroom.marketsight.ui.core.components.PullToRefreshLazyColumn +import dev.pinkroom.marketsight.ui.core.components.reachedBottom import dev.pinkroom.marketsight.ui.core.theme.dimens import dev.pinkroom.marketsight.ui.news_screen.components.AllNews import dev.pinkroom.marketsight.ui.news_screen.components.EmptyNewsList @@ -31,12 +38,21 @@ fun NewsScreen( realTimeNews: List, symbols: List, isLoading: Boolean, + isLoadingMoreNews: Boolean, isRefreshing: Boolean, errorMessage: Int? = null, onEvent: (event: NewsEvent) -> Unit, ){ val context = LocalContext.current + val listState = rememberLazyListState() + val reachedBottom: Boolean by remember { + derivedStateOf { listState.reachedBottom(buffer = BUFFER_LIST) } + } + LaunchedEffect(reachedBottom) { + if (reachedBottom && !isLoading && !isLoadingMoreNews) onEvent(NewsEvent.LoadMoreNews) + } + PullToRefreshLazyColumn( modifier = modifier .fillMaxSize(), @@ -51,13 +67,14 @@ fun NewsScreen( onRefresh = { onEvent(NewsEvent.RefreshNews) }, + lazyListState = listState, ) { if (!isLoading && errorMessage != null && news.isEmpty()){ item { EmptyNewsList( modifier = Modifier .fillParentMaxSize(), - errorMessage = errorMessage, + message = errorMessage, onRetry = { onEvent(NewsEvent.RetryNews) }, @@ -86,9 +103,19 @@ fun NewsScreen( } ) } + if (news.isEmpty() && !isLoading) + item { + EmptyNewsList( + modifier = Modifier + .fillMaxWidth() + .fillParentMaxHeight(dimens.emptyContentMaxHeight), + message = R.string.empty_news, + ) + } AllNews( news = news, isLoading = isLoading, + isLoadingMoreNews = isLoadingMoreNews, navigateToNews = { context.navigateToNews(newsInfo = it) } @@ -216,6 +243,7 @@ fun NewsScreenPreview(){ ), ), isLoading = false, + isLoadingMoreNews = false, errorMessage = R.string.get_news_error_message, isRefreshing = false, onEvent = {}, diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt index 638ceb3..36f2c2c 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt @@ -6,6 +6,7 @@ import dev.pinkroom.marketsight.domain.model.news.NewsInfo data class NewsUiState( val isLoading: Boolean = true, + val isLoadingMoreItems: Boolean = false, val isRefreshing: Boolean = false, @DrawableRes val errorMessage: Int? = null, val mainNews: List = listOf(), diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt index c0c4cbf..532d3ee 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt @@ -10,6 +10,9 @@ import dev.pinkroom.marketsight.common.Resource import dev.pinkroom.marketsight.common.connection_network.ConnectivityObserver import dev.pinkroom.marketsight.common.connection_network.ConnectivityObserver.Status.Available import dev.pinkroom.marketsight.common.connection_network.ConnectivityObserver.Status.Unavailable +import dev.pinkroom.marketsight.common.paginator.DefaultPagination +import dev.pinkroom.marketsight.domain.model.common.PaginationInfo +import dev.pinkroom.marketsight.domain.model.news.NewsResponse import dev.pinkroom.marketsight.domain.use_case.news.ChangeFilterNews import dev.pinkroom.marketsight.domain.use_case.news.GetNews import dev.pinkroom.marketsight.domain.use_case.news.GetRealTimeNews @@ -37,6 +40,31 @@ class NewsViewModel @Inject constructor( private val _action = Channel() val action = _action.receiveAsFlow() + private var paginationInfo = PaginationInfo() + private val pagination = DefaultPagination( + initialKey = null, + onLoadUpdated = { isLoading -> + paginationInfo = paginationInfo.copy(isLoading = isLoading) + _uiState.update { it.copy(isLoadingMoreItems = isLoading) } + }, + onRequest = { nextPage -> + getNews(pageToken = nextPage) + }, + getNextKey = { + it.nextPageToken + }, + onError = { + _action.send(NewsAction.ShowSnackBar(message = R.string.get_news_error_message)) + }, + onSuccess = { data, newKey -> + paginationInfo = paginationInfo.copy( + endReached = newKey == null, + page = newKey + ) + _uiState.update { it.copy(news = it.news + data.news) } + } + ) + private var initNewsJob: Job? = null private var connectionStatus = Unavailable @@ -50,6 +78,7 @@ class NewsViewModel @Inject constructor( when(event){ NewsEvent.RetryNews -> retryToGetNews() NewsEvent.RefreshNews -> refreshNews() + NewsEvent.LoadMoreNews -> loadMoreNews() } } @@ -73,6 +102,8 @@ class NewsViewModel @Inject constructor( val mainNews = allNews.take(maxNumberNews) val remainingNews = if (maxNumberNews == allNews.size) mainNews else allNews.drop(maxNumberNews) + + pagination.reset(key = response.data.nextPageToken) _uiState.update { it.copy( news = remainingNews, mainNews = mainNews, @@ -108,6 +139,12 @@ class NewsViewModel @Inject constructor( } } + private fun loadMoreNews(){ + viewModelScope.launch(dispatchers.IO) { + if (!paginationInfo.isLoading) pagination.loadNextItems() + } + } + private fun fetchRealTimeNews() { viewModelScope.launch(dispatchers.IO) { getRealTimeNews().collect{ news -> diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/AllNews.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/AllNews.kt index 90b327a..a83a464 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/AllNews.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/AllNews.kt @@ -26,47 +26,22 @@ import dev.pinkroom.marketsight.ui.core.theme.shimmerEffect fun LazyListScope.AllNews( modifier: Modifier = Modifier, isLoading: Boolean, + isLoadingMoreNews: Boolean, news: List, navigateToNews: (newsInfo: NewsInfo) -> Unit, ){ if (isLoading) - items(3){ - Row( - modifier = modifier - .fillMaxWidth() - .height(dimens.newsCard) - .padding(horizontal = dimens.horizontalPadding, vertical = dimens.smallPadding), - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically, - ) { - Box( - modifier = Modifier - .shadow( - elevation = dimens.normalElevation, - shape = RoundedCornerShape(size = dimens.normalShape) - ) - .weight(0.5f) - .fillMaxSize() - .shimmerEffect() - ) - Box( - modifier = Modifier - .weight(1f) - .padding(start = dimens.smallPadding) - .fillMaxHeight() - .shimmerEffect() - ) - } - } + LoadingNews() else { item { - Text( - modifier = Modifier - .padding(horizontal = dimens.horizontalPadding), - text = stringResource(id = R.string.latest_news), - style = MaterialTheme.typography.titleLarge, - fontWeight = FontWeight.Bold, - ) + if (news.isNotEmpty()) + Text( + modifier = Modifier + .padding(horizontal = dimens.horizontalPadding), + text = stringResource(id = R.string.latest_news), + style = MaterialTheme.typography.titleLarge, + fontWeight = FontWeight.Bold, + ) } items(news) { item -> AllNewsCard( @@ -78,5 +53,40 @@ fun LazyListScope.AllNews( onNewsClick = navigateToNews ) } + if (isLoadingMoreNews) + LoadingNews() + } +} + +fun LazyListScope.LoadingNews( + modifier: Modifier = Modifier, +){ + items(3){ + Row( + modifier = modifier + .fillMaxWidth() + .height(dimens.newsCard) + .padding(horizontal = dimens.horizontalPadding, vertical = dimens.smallPadding), + horizontalArrangement = Arrangement.SpaceBetween, + verticalAlignment = Alignment.CenterVertically, + ) { + Box( + modifier = Modifier + .shadow( + elevation = dimens.normalElevation, + shape = RoundedCornerShape(size = dimens.normalShape) + ) + .weight(0.5f) + .fillMaxSize() + .shimmerEffect() + ) + Box( + modifier = Modifier + .weight(1f) + .padding(start = dimens.smallPadding) + .fillMaxHeight() + .shimmerEffect() + ) + } } } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/EmptyNewsList.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/EmptyNewsList.kt index a6b0c72..9910814 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/EmptyNewsList.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/EmptyNewsList.kt @@ -21,8 +21,8 @@ import dev.pinkroom.marketsight.ui.core.theme.dimens @Composable fun EmptyNewsList( modifier: Modifier = Modifier, - errorMessage: Int, - onRetry: () -> Unit, + message: Int, + onRetry: (() -> Unit)? = null, ){ Column( modifier = modifier @@ -37,16 +37,18 @@ fun EmptyNewsList( ) Spacer(modifier = Modifier.height(dimens.smallPadding)) Text( - text = stringResource(id = errorMessage), + text = stringResource(id = message), textAlign = TextAlign.Center ) Spacer(modifier = Modifier.height(dimens.normalPadding)) - Button( - onClick = onRetry - ) { - Text( - text = stringResource(id = R.string.retry) - ) + if (onRetry != null) { + Button( + onClick = onRetry + ) { + Text( + text = stringResource(id = R.string.retry) + ) + } } } } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNews.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNews.kt index 837bcd0..01953ab 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNews.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNews.kt @@ -79,7 +79,7 @@ fun MainNews( .aspectRatio(dimens.imageSizeMainNews.getAspectRatio()) .shimmerEffect() ) - } else { + } else if (newsList.isNotEmpty()) { Column( modifier = Modifier .fillMaxWidth(), diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/RealTimeNews.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/RealTimeNews.kt index 3ad3e42..da6bebc 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/RealTimeNews.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/RealTimeNews.kt @@ -1,7 +1,6 @@ package dev.pinkroom.marketsight.ui.news_screen.components import androidx.compose.animation.AnimatedVisibility -import androidx.compose.animation.ExperimentalAnimationApi import androidx.compose.animation.fadeIn import androidx.compose.animation.slideInHorizontally import androidx.compose.foundation.layout.Arrangement @@ -23,7 +22,6 @@ import dev.pinkroom.marketsight.R import dev.pinkroom.marketsight.domain.model.news.NewsInfo import dev.pinkroom.marketsight.ui.core.theme.dimens -@OptIn(ExperimentalAnimationApi::class) @Composable fun RealTimeNews( modifier: Modifier = Modifier, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 00afeed..49f03f9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -7,4 +7,5 @@ Retry Live News Latest News + Unable to find news for selected filters. \ No newline at end of file From dd409caf6e782cefacf4aadb511ad1dca6ea263b Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Wed, 24 Apr 2024 17:29:43 +0100 Subject: [PATCH 20/33] - date picker ui - desc/asc ui - symbols subscribed ui --- .../pinkroom/marketsight/common/Constants.kt | 6 + .../dev/pinkroom/marketsight/common/Utils.kt | 102 +++++++- .../domain/model/common/SubInfoSymbols.kt | 3 + .../ui/core/components/ButtonFilter.kt | 64 +++++ .../ui/core/components/DatePickerComponent.kt | 115 +++++++++ .../core/components/DefaultSectionFilter.kt | 35 +++ .../ui/core/navigation/NavigationAppHost.kt | 11 +- .../marketsight/ui/core/theme/Color.kt | 4 +- .../marketsight/ui/core/theme/Dimensions.kt | 9 +- .../marketsight/ui/core/theme/Theme.kt | 2 + .../{components => util}/ObserveAsEvents.kt | 2 +- .../{components => util}/ReachedBottom.kt | 2 +- .../ui/core/util/SelectableDatesImp.kt | 28 ++ .../marketsight/ui/news_screen/NewsEvent.kt | 8 + .../marketsight/ui/news_screen/NewsScreen.kt | 102 ++++++-- .../marketsight/ui/news_screen/NewsUiState.kt | 16 +- .../ui/news_screen/NewsViewModel.kt | 72 +++++- .../components/BottomSheetFilters.kt | 241 ++++++++++++++++++ .../news_screen/components/HeaderListNews.kt | 53 ++++ .../ui/news_screen/components/RealTimeNews.kt | 61 ++++- app/src/main/res/drawable/icon_check.xml | 5 + .../main/res/drawable/icon_filter_list.xml | 5 + app/src/main/res/values/strings.xml | 13 + 23 files changed, 915 insertions(+), 44 deletions(-) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/core/components/ButtonFilter.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/core/components/DatePickerComponent.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/core/components/DefaultSectionFilter.kt rename app/src/main/java/dev/pinkroom/marketsight/ui/core/{components => util}/ObserveAsEvents.kt (91%) rename app/src/main/java/dev/pinkroom/marketsight/ui/core/{components => util}/ReachedBottom.kt (85%) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/core/util/SelectableDatesImp.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/BottomSheetFilters.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/HeaderListNews.kt create mode 100644 app/src/main/res/drawable/icon_check.xml create mode 100644 app/src/main/res/drawable/icon_filter_list.xml diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/Constants.kt b/app/src/main/java/dev/pinkroom/marketsight/common/Constants.kt index 70a51db..953892c 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/common/Constants.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/common/Constants.kt @@ -1,8 +1,14 @@ package dev.pinkroom.marketsight.common object Constants { + // ANIM TIME const val ANIM_TIME_CAROUSEL = 700 + + // LIMIT const val MAX_ITEMS_CAROUSEL = 5 const val LIMIT_NEWS = 20 const val BUFFER_LIST = 5 + + // TEXT + const val ALL_SYMBOLS = "All" } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt b/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt index e93c9db..797697d 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt @@ -1,8 +1,17 @@ package dev.pinkroom.marketsight.common +import androidx.annotation.StringRes import dev.pinkroom.marketsight.BuildConfig +import dev.pinkroom.marketsight.R +import dev.pinkroom.marketsight.common.Constants.ALL_SYMBOLS +import dev.pinkroom.marketsight.domain.model.common.SubInfoSymbols import okhttp3.OkHttpClient import okhttp3.logging.HttpLoggingInterceptor +import java.time.LocalDate +import java.time.ZoneOffset +import java.time.format.DateTimeFormatter +import java.time.format.FormatStyle +import java.util.Locale fun OkHttpClient.Builder.addAuthenticationInterceptor(): OkHttpClient.Builder { addInterceptor { chain -> @@ -26,12 +35,97 @@ fun OkHttpClient.Builder.addLoggingInterceptor(): OkHttpClient.Builder { return this } +fun LocalDate.toEpochMillis(zoneOffset: ZoneOffset = ZoneOffset.UTC, endOfTheDay: Boolean = false): Long{ + val time = if (endOfTheDay) atTime(23,59) else atStartOfDay() + return time.atOffset(zoneOffset).toInstant().toEpochMilli() +} +fun LocalDate.toReadableDate(): String { + val formatter = DateTimeFormatter + .ofLocalizedDate(FormatStyle.SHORT) + .withLocale(Locale.getDefault()) + return format(formatter) +} + sealed class ActionAlpaca(val action: String) { data object Subscribe: ActionAlpaca(action = "subscribe") data object Unsubscribe: ActionAlpaca(action = "unsubscribe") } -sealed class SortType(val type: String){ - data object DESC: SortType(type = "desc") - data object ASC: SortType(type = "asc") -} \ No newline at end of file +sealed class SortType(val type: String, @StringRes val stringId: Int){ + data object DESC: SortType(type = "desc", stringId = R.string.descending) + data object ASC: SortType(type = "asc", stringId = R.string.ascending) +} + +sealed interface DateMomentType{ + data object Start: DateMomentType + data object End: DateMomentType +} + +val popularSymbols = listOf( + SubInfoSymbols( + stringResource = R.string.all, + name = ALL_SYMBOLS, + symbol = "*", + isSubscribed = true, + ), + SubInfoSymbols( + name = "Tesla", + symbol = "TSLA", + isSubscribed = false, + ), + SubInfoSymbols( + name = "Apple", + symbol = "AAPL", + isSubscribed = false, + ), + SubInfoSymbols( + name = "Microsoft", + symbol = "MSFT", + isSubscribed = false, + ), + SubInfoSymbols( + name = "NVIDIA", + symbol = "NVDA", + isSubscribed = false, + ), + SubInfoSymbols( + name = "Alphabet", + symbol = "GOOG", + isSubscribed = false, + ), + SubInfoSymbols( + name = "Amazon", + symbol = "AMZN", + isSubscribed = false, + ), + SubInfoSymbols( + name = "Meta", + symbol = "META", + isSubscribed = false, + ), + SubInfoSymbols( + name = "Visa", + symbol = "V", + isSubscribed = false, + ), + SubInfoSymbols( + name = "Coca-Cola", + symbol = "KO", + isSubscribed = false, + ), + SubInfoSymbols( + name = "Bitcoin", + symbol = "BTC/USD", + isSubscribed = false, + ), + SubInfoSymbols( + name = "Ethereum", + symbol = "ETH/USD", + isSubscribed = false, + ), + SubInfoSymbols( + name = "Shiba", + symbol = "SHIB/USD", + isSubscribed = false, + ), +) \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/common/SubInfoSymbols.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/common/SubInfoSymbols.kt index a97d12e..04f8cb6 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/model/common/SubInfoSymbols.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/common/SubInfoSymbols.kt @@ -1,6 +1,9 @@ package dev.pinkroom.marketsight.domain.model.common +import androidx.annotation.StringRes + data class SubInfoSymbols( + @StringRes val stringResource: Int? = null, val name: String, val symbol: String, val isSubscribed: Boolean = false, diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/ButtonFilter.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/ButtonFilter.kt new file mode 100644 index 0000000..1da14ea --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/ButtonFilter.kt @@ -0,0 +1,64 @@ +package dev.pinkroom.marketsight.ui.core.components + +import androidx.compose.animation.animateContentSize +import androidx.compose.foundation.BorderStroke +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.res.painterResource +import dev.pinkroom.marketsight.R +import dev.pinkroom.marketsight.ui.core.theme.BabyBlue +import dev.pinkroom.marketsight.ui.core.theme.Blue +import dev.pinkroom.marketsight.ui.core.theme.dimens + +@Composable +fun ButtonFilter( + isSelected: Boolean, + text: String, + onClick: () -> Unit, +){ + val colorBackground = if (isSelected) BabyBlue.copy(alpha = 0.4f) else Color.Transparent + val colorContent = if (isSelected) Blue else MaterialTheme.colorScheme.onBackground + val colorBorder = if (isSelected) Color.Transparent else MaterialTheme.colorScheme.onBackground + Button( + shape = RoundedCornerShape(dimens.smallShape), + border = BorderStroke( + width = dimens.smallWidth, color = colorBorder, + ), + colors = ButtonDefaults.buttonColors( + containerColor = colorBackground, + contentColor = colorContent, + ), + onClick = onClick, + ) { + Row( + modifier = Modifier + .animateContentSize(), + horizontalArrangement = Arrangement.spacedBy(dimens.xSmallPadding), + verticalAlignment = Alignment.CenterVertically, + ) { + if (isSelected) + Icon( + modifier = Modifier + .size(dimens.smallIconSize), + painter = painterResource(id = R.drawable.icon_check), + contentDescription = null, + ) + + Text( + text = text, + style = MaterialTheme.typography.bodySmall, + ) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/DatePickerComponent.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/DatePickerComponent.kt new file mode 100644 index 0000000..90af288 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/DatePickerComponent.kt @@ -0,0 +1,115 @@ +package dev.pinkroom.marketsight.ui.core.components + +import android.annotation.SuppressLint +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.text.selection.TextSelectionColors +import androidx.compose.material3.Button +import androidx.compose.material3.DatePicker +import androidx.compose.material3.DatePickerDefaults +import androidx.compose.material3.DatePickerDialog +import androidx.compose.material3.DatePickerState +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextFieldDefaults +import androidx.compose.material3.SelectableDates +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalConfiguration +import androidx.compose.ui.res.stringResource +import dev.pinkroom.marketsight.R +import dev.pinkroom.marketsight.common.toEpochMillis +import dev.pinkroom.marketsight.ui.core.theme.BabyBlue +import dev.pinkroom.marketsight.ui.core.theme.Blue +import dev.pinkroom.marketsight.ui.core.theme.dimens +import java.time.LocalDate + +@SuppressLint("UnrememberedMutableState") +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun DatePickerComponent( + modifier: Modifier = Modifier, + initialDate: LocalDate? = null, + isToShowDatePicker: Boolean, + saveNewDate: (date: Long?) -> Unit, + dismissDatePicker: () -> Unit, + selectableDates: SelectableDates, +){ + val locale = LocalConfiguration.current.locales[0] + + val state = DatePickerState( + locale = locale, + initialSelectedDateMillis = initialDate?.toEpochMillis(), + selectableDates = selectableDates, + ) + + val colorCurrentDay = if (selectableDates.isSelectableDate(System.currentTimeMillis())) + MaterialTheme.colorScheme.onBackground + else MaterialTheme.colorScheme.onBackground.copy(alpha = 0.4f) + + if (isToShowDatePicker) + DatePickerDialog( + modifier = modifier, + onDismissRequest = { + state.selectedDateMillis = initialDate?.toEpochMillis() + dismissDatePicker() + }, + confirmButton = { + Row( + horizontalArrangement = Arrangement.spacedBy(dimens.smallPadding), + ) { + AnimatedVisibility(visible = state.selectedDateMillis != null) { + Button( + onClick = { + state.selectedDateMillis = null + saveNewDate(null) + dismissDatePicker() + }, + ) { + Text(text = stringResource(id = R.string.clear_date)) + } + } + Button( + onClick = { + state.selectedDateMillis?.let { saveNewDate(it) } + dismissDatePicker() + }, + ) { + Text(text = stringResource(id = R.string.select)) + } + } + }, + dismissButton = { + Button( + onClick = { + state.selectedDateMillis = initialDate?.toEpochMillis() + dismissDatePicker() + }, + ) { + Text(text = stringResource(id = R.string.cancel)) + } + }, + ) { + DatePicker( + state = state, + colors = DatePickerDefaults.colors( + selectedDayContainerColor = BabyBlue.copy(alpha = 0.3f), + selectedDayContentColor = Blue, + todayContentColor = colorCurrentDay, + todayDateBorderColor = MaterialTheme.colorScheme.onBackground, + currentYearContentColor = MaterialTheme.colorScheme.onBackground, + dateTextFieldColors = OutlinedTextFieldDefaults.colors( + focusedBorderColor = MaterialTheme.colorScheme.onBackground, + focusedLabelColor = MaterialTheme.colorScheme.onBackground, + cursorColor = MaterialTheme.colorScheme.onBackground, + selectionColors = TextSelectionColors( + handleColor = MaterialTheme.colorScheme.onBackground, + backgroundColor = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.4f) + ) + ) + ) + ) + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/DefaultSectionFilter.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/DefaultSectionFilter.kt new file mode 100644 index 0000000..5005aed --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/DefaultSectionFilter.kt @@ -0,0 +1,35 @@ +package dev.pinkroom.marketsight.ui.core.components + +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.HorizontalDivider +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextAlign +import dev.pinkroom.marketsight.ui.core.theme.dimens + +@Composable +fun DefaultSectionFilter( + modifier: Modifier = Modifier, + title: String, + showBottomDivider: Boolean = false, + content: @Composable () -> Unit, +){ + HorizontalDivider(modifier = modifier.padding(horizontal = dimens.smallPadding)) + Text( + modifier = Modifier + .padding(horizontal = dimens.horizontalPadding) + .padding(top = dimens.smallPadding), + text = title, + style = MaterialTheme.typography.titleSmall, + fontWeight = FontWeight.Medium, + textAlign = TextAlign.Center, + ) + content() + if (showBottomDivider) + HorizontalDivider(modifier = modifier + .padding(horizontal = dimens.smallPadding, vertical = dimens.smallPadding) + ) +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt index 13574aa..0663688 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt @@ -1,5 +1,6 @@ package dev.pinkroom.marketsight.ui.core.navigation +import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.SnackbarDuration import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier @@ -11,8 +12,8 @@ import androidx.navigation.NavType import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.navArgument -import dev.pinkroom.marketsight.ui.core.components.ObserveAsEvents import dev.pinkroom.marketsight.ui.core.navigation.Args.SYMBOL_ID +import dev.pinkroom.marketsight.ui.core.util.ObserveAsEvents import dev.pinkroom.marketsight.ui.detail_screen.DetailScreen import dev.pinkroom.marketsight.ui.home_screen.HomeScreen import dev.pinkroom.marketsight.ui.home_screen.HomeViewModel @@ -20,6 +21,7 @@ import dev.pinkroom.marketsight.ui.news_screen.NewsAction import dev.pinkroom.marketsight.ui.news_screen.NewsScreen import dev.pinkroom.marketsight.ui.news_screen.NewsViewModel +@OptIn(ExperimentalMaterial3Api::class) @Composable fun NavigationAppHost( modifier: Modifier = Modifier, @@ -58,9 +60,16 @@ fun NavigationAppHost( mainNews = uiState.mainNews, realTimeNews = uiState.realTimeNews, symbols = uiState.symbols, + sortBy = uiState.sortBy, + sortItems = uiState.sort, + endDate = uiState.endDateSort, + startDate = uiState.startDateSort, + startSelectableDates = uiState.startSelectableDates, + endSelectableDates = uiState.endSelectableDates, isLoading = uiState.isLoading, isLoadingMoreNews = uiState.isLoadingMoreItems, isRefreshing = uiState.isRefreshing, + isToShowFilters = uiState.isToShowFilters, errorMessage = uiState.errorMessage, onEvent = viewModel::onEvent ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Color.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Color.kt index 5d3b9c0..ae88b88 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Color.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Color.kt @@ -12,4 +12,6 @@ val Green = Color(0xFF3DD787) val Purple = Color(0xFF7F55E7) val Red = Color(0xFFE94237) val PhilippineSilver = Color(0xFFB8B5B5) -val PhilippineGray = Color(0xFF8F8B8B) \ No newline at end of file +val PhilippineGray = Color(0xFF8F8B8B) +val BabyBlue = Color(0xFF89CFF0) +val Blue = Color(0xFF318CE7) \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt index 688f839..9e56965 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt @@ -18,7 +18,7 @@ class Dimensions( val headlineSmall: TextUnit = 24.sp, val titleLarge: TextUnit = 22.sp, val titleMedium: TextUnit = 19.sp, - val titleSmall: TextUnit = 14.sp, + val titleSmall: TextUnit = 16.sp, val bodyLarge: TextUnit = 16.sp, val bodyMedium: TextUnit = 14.sp, val bodySmall: TextUnit = 12.sp, @@ -34,6 +34,7 @@ class Dimensions( val xLargePadding: Dp = 32.dp, // Icon + val smallIconSize: Dp = 16.dp, val normalIconSize: Dp = 24.dp, val largeIconSize: Dp = 38.dp, @@ -42,6 +43,9 @@ class Dimensions( val normalElevation: Dp = 9.dp, val largeElevation: Dp = 12.dp, + // Border Width + val smallWidth: Dp = 1.5.dp, + // Shape val smallShape: Dp = 10.dp, val normalShape: Dp = 15.dp, @@ -61,7 +65,8 @@ class Dimensions( val menuHeight: Dp = 100.dp, val liveNewsCardWidth: Dp = 270.dp, val liveNewsCardHeight: Dp = 100.dp, - val emptyContentMaxHeight: Float = 0.95f + val emptyContentMaxHeight: Float = 0.95f, + val bottomSheetHeight: Float = 0.45f, ) val dimens: Dimensions diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Theme.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Theme.kt index f4c80b1..78e4467 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Theme.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Theme.kt @@ -24,6 +24,7 @@ private val DarkColorScheme = darkColorScheme( background = WoodSmoke, onBackground = White, tertiaryContainer = Gray, + outline = GrayAthens, ) private val LightColorScheme = lightColorScheme( @@ -35,6 +36,7 @@ private val LightColorScheme = lightColorScheme( background = GrayAthens, onBackground = Black, tertiaryContainer = Black, + outline = Manatee, ) @Composable diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/ObserveAsEvents.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/util/ObserveAsEvents.kt similarity index 91% rename from app/src/main/java/dev/pinkroom/marketsight/ui/core/components/ObserveAsEvents.kt rename to app/src/main/java/dev/pinkroom/marketsight/ui/core/util/ObserveAsEvents.kt index a8e9d5e..d181753 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/ObserveAsEvents.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/util/ObserveAsEvents.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.core.components +package dev.pinkroom.marketsight.ui.core.util import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/ReachedBottom.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/util/ReachedBottom.kt similarity index 85% rename from app/src/main/java/dev/pinkroom/marketsight/ui/core/components/ReachedBottom.kt rename to app/src/main/java/dev/pinkroom/marketsight/ui/core/util/ReachedBottom.kt index c26adad..c7305f1 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/ReachedBottom.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/util/ReachedBottom.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.core.components +package dev.pinkroom.marketsight.ui.core.util import androidx.compose.foundation.lazy.LazyListState diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/util/SelectableDatesImp.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/util/SelectableDatesImp.kt new file mode 100644 index 0000000..17a8e3d --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/util/SelectableDatesImp.kt @@ -0,0 +1,28 @@ +package dev.pinkroom.marketsight.ui.core.util + +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.SelectableDates +import dev.pinkroom.marketsight.common.DateMomentType +import dev.pinkroom.marketsight.common.toEpochMillis +import java.time.LocalDate + +@OptIn(ExperimentalMaterial3Api::class) +class SelectableDatesImp( + private val limitDate: LocalDate? = null, + private val dateMomentType: DateMomentType, +): SelectableDates { + override fun isSelectableDate(utcTimeMillis: Long): Boolean { + val currentTimeInMillis = System.currentTimeMillis() + val limitInMillis = when(dateMomentType){ + DateMomentType.End -> limitDate?.toEpochMillis(endOfTheDay = true) ?: utcTimeMillis + DateMomentType.Start -> limitDate?.toEpochMillis(endOfTheDay = true) ?: currentTimeInMillis + } + return if (dateMomentType == DateMomentType.Start) utcTimeMillis <= limitInMillis + else utcTimeMillis in limitInMillis..currentTimeInMillis + } + + override fun isSelectableYear(year: Int): Boolean { + val limitYear = limitDate?.year ?: LocalDate.now().year + return year <= limitYear + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsEvent.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsEvent.kt index 44d545a..511c068 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsEvent.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsEvent.kt @@ -1,7 +1,15 @@ package dev.pinkroom.marketsight.ui.news_screen +import dev.pinkroom.marketsight.common.DateMomentType +import dev.pinkroom.marketsight.common.SortType +import dev.pinkroom.marketsight.domain.model.common.SubInfoSymbols + sealed class NewsEvent { data object RetryNews: NewsEvent() data object RefreshNews: NewsEvent() data object LoadMoreNews: NewsEvent() + data class ShowOrHideFilters(val isToShow: Boolean? = null): NewsEvent() + data class ChangeSort(val sort: SortType): NewsEvent() + data class ChangeSymbol(val symbolToChange: SubInfoSymbols): NewsEvent() + data class ChangeDate(val newDateInMillis: Long?, val dateMomentType: DateMomentType): NewsEvent() } diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt index 0476867..59f12a5 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt @@ -3,10 +3,15 @@ package dev.pinkroom.marketsight.ui.news_screen import android.content.Context import android.content.Intent import android.net.Uri +import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.lazy.rememberLazyListState +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.SelectableDates +import androidx.compose.material3.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.derivedStateOf @@ -17,19 +22,26 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.tooling.preview.Preview import dev.pinkroom.marketsight.R import dev.pinkroom.marketsight.common.Constants.BUFFER_LIST +import dev.pinkroom.marketsight.common.DateMomentType +import dev.pinkroom.marketsight.common.SortType import dev.pinkroom.marketsight.domain.model.common.SubInfoSymbols import dev.pinkroom.marketsight.domain.model.news.ImageSize import dev.pinkroom.marketsight.domain.model.news.ImagesNews import dev.pinkroom.marketsight.domain.model.news.NewsInfo import dev.pinkroom.marketsight.ui.core.components.PullToRefreshLazyColumn -import dev.pinkroom.marketsight.ui.core.components.reachedBottom import dev.pinkroom.marketsight.ui.core.theme.dimens +import dev.pinkroom.marketsight.ui.core.util.SelectableDatesImp +import dev.pinkroom.marketsight.ui.core.util.reachedBottom import dev.pinkroom.marketsight.ui.news_screen.components.AllNews +import dev.pinkroom.marketsight.ui.news_screen.components.BottomSheetFilters import dev.pinkroom.marketsight.ui.news_screen.components.EmptyNewsList +import dev.pinkroom.marketsight.ui.news_screen.components.HeaderListNews import dev.pinkroom.marketsight.ui.news_screen.components.MainNews import dev.pinkroom.marketsight.ui.news_screen.components.RealTimeNews +import java.time.LocalDate import java.time.LocalDateTime +@OptIn(ExperimentalFoundationApi::class, ExperimentalMaterial3Api::class) @Composable fun NewsScreen( modifier: Modifier = Modifier, @@ -37,14 +49,23 @@ fun NewsScreen( news: List, realTimeNews: List, symbols: List, + sortBy: SortType, + sortItems: List, + startDate: LocalDate? = null, + endDate: LocalDate? = null, + startSelectableDates: SelectableDates, + endSelectableDates: SelectableDates, isLoading: Boolean, isLoadingMoreNews: Boolean, isRefreshing: Boolean, + isToShowFilters: Boolean, errorMessage: Int? = null, onEvent: (event: NewsEvent) -> Unit, ){ val context = LocalContext.current + val sheetState = rememberModalBottomSheetState() + val listState = rememberLazyListState() val reachedBottom: Boolean by remember { derivedStateOf { listState.reachedBottom(buffer = BUFFER_LIST) } @@ -69,6 +90,16 @@ fun NewsScreen( }, lazyListState = listState, ) { + stickyHeader { + HeaderListNews( + modifier = Modifier + .fillParentMaxWidth(), + isFilterBtnEnabled = !isLoading, + onFilterClick = { + onEvent(NewsEvent.ShowOrHideFilters()) + } + ) + } if (!isLoading && errorMessage != null && news.isEmpty()){ item { EmptyNewsList( @@ -122,6 +153,31 @@ fun NewsScreen( ) } } + BottomSheetFilters( + modifier = Modifier + .fillMaxHeight(dimens.bottomSheetHeight), + isVisible = isToShowFilters, + onDismiss = { + onEvent(NewsEvent.ShowOrHideFilters(isToShow = false)) + }, + sheetState = sheetState, + sortFilters = sortItems, + selectedSort = sortBy, + onSortClick = { + onEvent(NewsEvent.ChangeSort(sort = it)) + }, + symbols = symbols, + onSymbolClick = { + onEvent(NewsEvent.ChangeSymbol(symbolToChange = it)) + }, + startDate = startDate, + endDate = endDate, + changeDate = { dateInMillis, dateMomentType -> + onEvent(NewsEvent.ChangeDate(newDateInMillis = dateInMillis, dateMomentType = dateMomentType)) + }, + startSelectableDates = startSelectableDates, + endSelectableDates = endSelectableDates, + ) } fun Context.navigateToNews(newsInfo: NewsInfo){ @@ -129,6 +185,7 @@ fun Context.navigateToNews(newsInfo: NewsInfo){ startActivity(intent) } +@OptIn(ExperimentalMaterial3Api::class) @Preview( showBackground = true, showSystemUi = true, @@ -143,16 +200,16 @@ fun NewsScreenPreview(){ images = listOf( ImagesNews( size = ImageSize.Small, - url = "https://cdn.benzinga.com/files/imagecache/1024x768xUP/market-clubhouse-morning-memo_201.png", + url = "https://cdn.benzinga.com/files/imagecache/1024x768xUP/market-clubhouse-morning-memo_203.png", ) ), source = "Bezinga", - url = "https://www.benzinga.com/", + url = "https://www.benzinga.pt/", updatedAt = LocalDateTime.now(), createdAt = LocalDateTime.now(), author = "RIPS", - summary = "Good Morning Traders! In today's Market Clubhouse Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, and TSLA.", - headline = "Market Clubhouse Morning Memo - April 11th, 2024 (Trade Strategy For SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", + summary = "Good Morning Traders! In today's Market house Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, and TSLA.", + headline = "Market Clubhouse Morning Memo - April 11th, 2024 (Trade Strategy For SPY, QQQ,PL, MSFT, NVDA, GOOGL, META, And TSLA)", ), NewsInfo( id = 2L, @@ -160,7 +217,7 @@ fun NewsScreenPreview(){ images = listOf( ImagesNews( size = ImageSize.Small, - url = "https://cdn.benzinga.com/files/imagecache/1024x768xUP/market-clubhouse-morning-memo_201.png", + url = "https://cdn.benzinga.com/files/imagecache/1024x768xUP/market-clubhouse-morning-memo_202.png", ) ), source = "Bezinga", @@ -168,8 +225,8 @@ fun NewsScreenPreview(){ updatedAt = LocalDateTime.now(), createdAt = LocalDateTime.now(), author = "RIPS", - summary = "Good Morning Traders! In today's Market Clubhouse Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, and TSLA.", - headline = "Market Clubhouse Morning Memo - April 11th, 2024 (Trade Strategy For SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", + summary = "Good Morning Traders! In today's Market Clubhouse Morning Memo, we wiscuss SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, and TSLA.", + headline = "Market Clubhouse Morning Memo - April 11th, 2024 (Trade Strategy For QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", ), ), mainNews = listOf( @@ -179,16 +236,16 @@ fun NewsScreenPreview(){ images = listOf( ImagesNews( size = ImageSize.Small, - url = "https://cdn.benzinga.com/files/imagecache/1024x768xUP/market-clubhouse-morning-memo_201.png", + url = "https://cdn.benzinga.com/files/imagecache/1024x768xUP/market-clubhouse-morning-memo_208.png", ) ), source = "Bezinga", - url = "https://www.benzinga.com/", + url = "https://www.benzinga.c/", updatedAt = LocalDateTime.now(), createdAt = LocalDateTime.now(), author = "RIPS", - summary = "Good Morning Traders! In today's Market Clubhouse Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, and TSLA.", - headline = "Market Clubhouse Morning Memo - April 11th, 2024 (Trade Strategy For SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", + summary = "Good Morning Traders! In today's Market Clubhouse Memo, we will discuss SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, and TSLA.", + headline = "Market Clubhouse Morning Memo - April 11th, 2024 (Trade Stregy For SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", ), NewsInfo( id = 2L, @@ -196,16 +253,16 @@ fun NewsScreenPreview(){ images = listOf( ImagesNews( size = ImageSize.Small, - url = "https://cdn.benzinga.com/files/imagecache/1024x768xUP/market-clubhouse-morning-memo_201.png", + url = "https://cdn.benzinga.com/files/imagecache/1024x768xUP/market-clubhouse-morning-memo_200.png", ) ), source = "Bezinga", - url = "https://www.benzinga.com/", + url = "https://www.benzinga.fr/", updatedAt = LocalDateTime.now(), createdAt = LocalDateTime.now(), author = "RIPS", - summary = "Good Morning Traders! In today's Market Clubhouse Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, and TSLA.", - headline = "Market Clubhouse Morning Memo - April 11th, 2024 (Trade Strategy For SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", + summary = "Good Morning Traders! In today's Market Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, and TSLA.", + headline = "Market Clubhouse Morning Memo - April 2024 (Trade Strategy For SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", ), ), realTimeNews = listOf( @@ -214,19 +271,19 @@ fun NewsScreenPreview(){ symbols = listOf("TSLA","AAPL","BTC"), images = null, source = "Bezinga", - url = "https://www.benzinga.com/", + url = "https://www.benzinga.de/", updatedAt = LocalDateTime.now(), createdAt = LocalDateTime.now(), author = "RIPS", - summary = "Good Morning Traders! In today's Market Clubhouse Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, and TSLA.", - headline = "Market Clubhouse Morning Memo - April 11th, 2024 (Trade Strategy For SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", + summary = "Good Morning Traders! In today's Market Couse Morning Memo, we will discuss SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, and TSLA.", + headline = "Market Clubhouse Morning Memo - April 11th, 24 (Trade Strategy For SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", ), NewsInfo( id = 2L, symbols = listOf("TSLA","AAPL","BTC"), images = null, source = "Bezinga", - url = "https://www.benzinga.com/", + url = "https://www.benzinga.coo/", updatedAt = LocalDateTime.now(), createdAt = LocalDateTime.now(), author = "RIPS", @@ -246,6 +303,11 @@ fun NewsScreenPreview(){ isLoadingMoreNews = false, errorMessage = R.string.get_news_error_message, isRefreshing = false, + isToShowFilters = false, + sortItems = listOf(), + sortBy = SortType.DESC, onEvent = {}, + startSelectableDates = SelectableDatesImp(dateMomentType = DateMomentType.Start), + endSelectableDates = SelectableDatesImp(dateMomentType = DateMomentType.End), ) } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt index 36f2c2c..5f46aa5 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt @@ -1,16 +1,30 @@ package dev.pinkroom.marketsight.ui.news_screen import androidx.annotation.DrawableRes +import dev.pinkroom.marketsight.common.DateMomentType +import dev.pinkroom.marketsight.common.SortType +import dev.pinkroom.marketsight.common.popularSymbols import dev.pinkroom.marketsight.domain.model.common.SubInfoSymbols import dev.pinkroom.marketsight.domain.model.news.NewsInfo +import dev.pinkroom.marketsight.ui.core.util.SelectableDatesImp +import java.time.LocalDate data class NewsUiState( val isLoading: Boolean = true, val isLoadingMoreItems: Boolean = false, val isRefreshing: Boolean = false, + val isToShowFilters: Boolean = false, @DrawableRes val errorMessage: Int? = null, val mainNews: List = listOf(), val news: List = listOf(), val realTimeNews: List = listOf(), - val symbols: List = listOf(), + val symbols: List = popularSymbols, + val sort: List = listOf(SortType.DESC, SortType.ASC), + val sortBy: SortType = SortType.DESC, + val startDateSort: LocalDate? = null, + val endDateSort: LocalDate? = null, + val startSelectableDates: SelectableDatesImp = SelectableDatesImp(dateMomentType = DateMomentType.Start), + val endSelectableDates: SelectableDatesImp = SelectableDatesImp(dateMomentType = DateMomentType.End) ) + + diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt index 532d3ee..682d4d6 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt @@ -4,18 +4,23 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel import dev.pinkroom.marketsight.R +import dev.pinkroom.marketsight.common.Constants.ALL_SYMBOLS import dev.pinkroom.marketsight.common.Constants.MAX_ITEMS_CAROUSEL +import dev.pinkroom.marketsight.common.DateMomentType import dev.pinkroom.marketsight.common.DispatcherProvider import dev.pinkroom.marketsight.common.Resource +import dev.pinkroom.marketsight.common.SortType import dev.pinkroom.marketsight.common.connection_network.ConnectivityObserver import dev.pinkroom.marketsight.common.connection_network.ConnectivityObserver.Status.Available import dev.pinkroom.marketsight.common.connection_network.ConnectivityObserver.Status.Unavailable import dev.pinkroom.marketsight.common.paginator.DefaultPagination import dev.pinkroom.marketsight.domain.model.common.PaginationInfo +import dev.pinkroom.marketsight.domain.model.common.SubInfoSymbols import dev.pinkroom.marketsight.domain.model.news.NewsResponse import dev.pinkroom.marketsight.domain.use_case.news.ChangeFilterNews import dev.pinkroom.marketsight.domain.use_case.news.GetNews import dev.pinkroom.marketsight.domain.use_case.news.GetRealTimeNews +import dev.pinkroom.marketsight.ui.core.util.SelectableDatesImp import kotlinx.coroutines.Job import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.MutableStateFlow @@ -24,6 +29,8 @@ import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.receiveAsFlow import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch +import java.time.Instant +import java.time.ZoneOffset import javax.inject.Inject @HiltViewModel @@ -74,15 +81,19 @@ class NewsViewModel @Inject constructor( fetchRealTimeNews() } - fun onEvent(event: NewsEvent){ - when(event){ + fun onEvent(event: NewsEvent) { + when(event) { NewsEvent.RetryNews -> retryToGetNews() NewsEvent.RefreshNews -> refreshNews() NewsEvent.LoadMoreNews -> loadMoreNews() + is NewsEvent.ShowOrHideFilters -> showOrHideFilters(isToShow = event.isToShow) + is NewsEvent.ChangeSort -> changeSort(newSort = event.sort) + is NewsEvent.ChangeSymbol -> changeSymbols(symbolToChange = event.symbolToChange) + is NewsEvent.ChangeDate -> changeDate(dateInMillis = event.newDateInMillis, dateMomentType = event.dateMomentType) } } - private fun observeNetworkStatus(){ + private fun observeNetworkStatus() { viewModelScope.launch(dispatchers.IO) { connectivityObserver.observe().distinctUntilChanged().collect{ statusNet -> connectionStatus = statusNet @@ -92,7 +103,7 @@ class NewsViewModel @Inject constructor( } } - private fun initNews(){ + private fun initNews() { initNewsJob = viewModelScope.launch(dispatchers.IO) { _uiState.update { it.copy(isLoading = true) } when(val response = getNews()){ @@ -139,7 +150,7 @@ class NewsViewModel @Inject constructor( } } - private fun loadMoreNews(){ + private fun loadMoreNews() { viewModelScope.launch(dispatchers.IO) { if (!paginationInfo.isLoading) pagination.loadNextItems() } @@ -152,4 +163,55 @@ class NewsViewModel @Inject constructor( } } } + + private fun showOrHideFilters(isToShow: Boolean? = null) { + if (uiState.value.isLoading) return + _uiState.update { it.copy(isToShowFilters = isToShow ?: !it.isToShowFilters) } + } + + private fun changeSort(newSort: SortType) { + if (uiState.value.sortBy == newSort) return + _uiState.update { it.copy(sortBy = newSort) } + } + + private fun changeSymbols(symbolToChange: SubInfoSymbols) { + val symbolsSubscribed = uiState.value.symbols.filter { it.isSubscribed } + val totalSizeSubscribed = if (symbolsSubscribed.contains(symbolToChange)) + symbolsSubscribed.size - 1 + else symbolsSubscribed.size + + val needToSubscribeAll = totalSizeSubscribed == 0 || symbolToChange.name == ALL_SYMBOLS + + val newListSymbols = uiState.value.symbols.map { item -> + when { + item.name == ALL_SYMBOLS -> item.copy(isSubscribed = needToSubscribeAll) + item.symbol == symbolToChange.symbol -> item.copy(isSubscribed = !item.isSubscribed) + needToSubscribeAll -> item.copy(isSubscribed = false) + else -> item.copy() + } + } + _uiState.update { it.copy(symbols = newListSymbols) } + } + + private fun changeDate(dateInMillis: Long?, dateMomentType: DateMomentType){ + val date = dateInMillis?.let { Instant.ofEpochMilli(it).atZone(ZoneOffset.UTC).toLocalDate() } + when(dateMomentType){ + DateMomentType.End -> { + _uiState.update { + it.copy( + endDateSort = date, + startSelectableDates = SelectableDatesImp(limitDate = date, dateMomentType = DateMomentType.Start), + ) + } + } + DateMomentType.Start -> { + _uiState.update { + it.copy( + startDateSort = date, + endSelectableDates = SelectableDatesImp(limitDate = date, dateMomentType = DateMomentType.End), + ) + } + } + } + } } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/BottomSheetFilters.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/BottomSheetFilters.kt new file mode 100644 index 0000000..3fc8193 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/BottomSheetFilters.kt @@ -0,0 +1,241 @@ +package dev.pinkroom.marketsight.ui.news_screen.components + +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.ExperimentalLayoutApi +import androidx.compose.foundation.layout.FlowRow +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.ModalBottomSheet +import androidx.compose.material3.SelectableDates +import androidx.compose.material3.SheetState +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontWeight +import dev.pinkroom.marketsight.R +import dev.pinkroom.marketsight.common.DateMomentType +import dev.pinkroom.marketsight.common.SortType +import dev.pinkroom.marketsight.common.toReadableDate +import dev.pinkroom.marketsight.domain.model.common.SubInfoSymbols +import dev.pinkroom.marketsight.ui.core.components.ButtonFilter +import dev.pinkroom.marketsight.ui.core.components.DatePickerComponent +import dev.pinkroom.marketsight.ui.core.components.DefaultSectionFilter +import dev.pinkroom.marketsight.ui.core.theme.dimens +import java.time.LocalDate + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun BottomSheetFilters( + modifier: Modifier = Modifier, + sortFilters: List, + selectedSort: SortType, + symbols: List, + startDate: LocalDate? = null, + endDate: LocalDate? = null, + isVisible: Boolean, + onDismiss: () -> Unit, + onSortClick: (sort: SortType) -> Unit, + onSymbolClick: (symbol: SubInfoSymbols) -> Unit, + changeDate: (dateInMillis: Long?, dateMomentType: DateMomentType) -> Unit, + startSelectableDates: SelectableDates, + endSelectableDates: SelectableDates, + sheetState: SheetState, +){ + AnimatedVisibility(visible = isVisible) { + ModalBottomSheet( + modifier = modifier, + onDismissRequest = onDismiss, + sheetState = sheetState, + ) { + LazyColumn( + modifier = Modifier.fillMaxSize(), + verticalArrangement = Arrangement.spacedBy(dimens.smallPadding), + contentPadding = PaddingValues( + bottom = dimens.normalPadding, + ) + ) { + item { + Text( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = dimens.horizontalPadding), + text = stringResource(id = R.string.filters_news), + style = MaterialTheme.typography.titleLarge, + fontWeight = FontWeight.Bold, + ) + } + item { + DateRangePickerSection( + startDate = startDate, + endDate = endDate, + changeDate = changeDate, + startSelectableDates = startSelectableDates, + endSelectableDates = endSelectableDates, + ) + } + item { + SortSection( + modifier = Modifier + .fillMaxWidth(), + itemsSort = sortFilters, + selectedSort = selectedSort, + onSortClick = onSortClick, + ) + } + item { + SymbolsSubscribedSection( + modifier = Modifier + .fillMaxWidth(), + symbols = symbols, + onSymbolClick = onSymbolClick, + ) + } + } + } + } +} + +@OptIn(ExperimentalLayoutApi::class) +@Composable +fun SortSection( + modifier: Modifier, + itemsSort: List, + selectedSort: SortType, + onSortClick: (sort: SortType) -> Unit, +){ + DefaultSectionFilter( + title = stringResource(id = R.string.filter_sort), + ){ + FlowRow( + modifier = modifier + .fillMaxWidth() + .padding(horizontal = dimens.horizontalPadding, vertical = dimens.xSmallPadding), + horizontalArrangement = Arrangement.spacedBy(dimens.smallPadding), + ) { + itemsSort.forEach { sort -> + ButtonFilter( + isSelected = sort == selectedSort, + text = stringResource(id = sort.stringId), + onClick = { + onSortClick(sort) + } + ) + } + } + } +} + +@OptIn(ExperimentalLayoutApi::class) +@Composable +fun SymbolsSubscribedSection( + modifier: Modifier, + symbols: List, + onSymbolClick: (symbol: SubInfoSymbols) -> Unit, +){ + DefaultSectionFilter( + title = stringResource(id = R.string.filter_symbols), + showBottomDivider = true, + ){ + FlowRow( + modifier = modifier + .fillMaxWidth() + .padding(horizontal = dimens.horizontalPadding, vertical = dimens.xSmallPadding), + horizontalArrangement = Arrangement.spacedBy(dimens.smallPadding), + ) { + symbols.forEach { symbol -> + ButtonFilter( + isSelected = symbol.isSubscribed, + text = symbol.name, + onClick = { + onSymbolClick(symbol) + } + ) + } + } + } +} + +@OptIn(ExperimentalLayoutApi::class, ExperimentalMaterial3Api::class) +@Composable +fun DateRangePickerSection( + modifier: Modifier = Modifier, + startDate: LocalDate? = null, + endDate: LocalDate? = null, + startSelectableDates: SelectableDates, + endSelectableDates: SelectableDates, + changeDate: (dateInMillis: Long?, dateMomentType: DateMomentType) -> Unit, +){ + var isToShowStartDatePicker by rememberSaveable { + mutableStateOf(false) + } + var isToShowEndDatePicker by rememberSaveable { + mutableStateOf(false) + } + + val startDateText = if (startDate != null) stringResource(id = R.string.start_date) + ": ${startDate.toReadableDate()}" + else stringResource(id = R.string.start_date) + + val endDateText = if (endDate != null) stringResource(id = R.string.end_date) + ": ${endDate.toReadableDate()}" + else stringResource(id = R.string.end_date) + + DefaultSectionFilter( + title = stringResource(id = R.string.date_range), + ){ + FlowRow( + modifier = modifier + .fillMaxWidth() + .padding(horizontal = dimens.horizontalPadding, vertical = dimens.xSmallPadding), + horizontalArrangement = Arrangement.spacedBy(dimens.smallPadding), + ) { + ButtonFilter( + isSelected = false, + text = startDateText, + onClick = { + isToShowStartDatePicker = true + } + ) + ButtonFilter( + isSelected = false, + text = endDateText, + onClick = { + isToShowEndDatePicker = true + } + ) + } + } + + DatePickerComponent( + initialDate = startDate, + isToShowDatePicker = isToShowStartDatePicker, + saveNewDate = { + changeDate(it,DateMomentType.Start) + }, + dismissDatePicker = { + isToShowStartDatePicker = false + }, + selectableDates = startSelectableDates, + ) + DatePickerComponent( + initialDate = endDate, + isToShowDatePicker = isToShowEndDatePicker, + saveNewDate = { + changeDate(it,DateMomentType.End) + }, + dismissDatePicker = { + isToShowEndDatePicker = false + }, + selectableDates = endSelectableDates, + ) +} + diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/HeaderListNews.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/HeaderListNews.kt new file mode 100644 index 0000000..abad84a --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/HeaderListNews.kt @@ -0,0 +1,53 @@ +package dev.pinkroom.marketsight.ui.news_screen.components + +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontWeight +import dev.pinkroom.marketsight.R +import dev.pinkroom.marketsight.ui.core.theme.dimens + +@Composable +fun HeaderListNews( + modifier: Modifier = Modifier, + isFilterBtnEnabled: Boolean, + onFilterClick: () -> Unit, +){ + Row( + modifier = modifier + .background( + color = MaterialTheme.colorScheme.background, + ), + horizontalArrangement = Arrangement.SpaceBetween + ) { + Text( + modifier = Modifier + .padding(horizontal = dimens.horizontalPadding) + .padding(bottom = dimens.contentTopPadding), + text = stringResource(id = R.string.news), + style = MaterialTheme.typography.titleLarge, + fontWeight = FontWeight.Bold, + ) + Icon( + modifier = Modifier + .padding(horizontal = dimens.horizontalPadding) + .size(dimens.normalIconSize) + .clickable( + enabled = isFilterBtnEnabled, + onClick = onFilterClick, + ), + painter = painterResource(id = R.drawable.icon_filter_list), + contentDescription = stringResource(id = R.string.filter_list_news_btn), + ) + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/RealTimeNews.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/RealTimeNews.kt index da6bebc..f583189 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/RealTimeNews.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/RealTimeNews.kt @@ -1,25 +1,41 @@ package dev.pinkroom.marketsight.ui.news_screen.components import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.core.Spring +import androidx.compose.animation.core.animateFloatAsState +import androidx.compose.animation.core.spring import androidx.compose.animation.fadeIn import androidx.compose.animation.slideInHorizontally +import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.lazy.items +import androidx.compose.foundation.shape.CircleShape import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.scale import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import dev.pinkroom.marketsight.R import dev.pinkroom.marketsight.domain.model.news.NewsInfo +import dev.pinkroom.marketsight.ui.core.theme.Red import dev.pinkroom.marketsight.ui.core.theme.dimens @Composable @@ -29,21 +45,50 @@ fun RealTimeNews( isLoading: Boolean, onNewsClick: (news: NewsInfo) -> Unit, ){ + var liveUpdate by rememberSaveable { + mutableStateOf(false) + } + val sizeLiveIcon by animateFloatAsState( + targetValue = if (liveUpdate) 1.3f else 1f, + animationSpec = spring( + stiffness = Spring.StiffnessMedium, + dampingRatio = Spring.DampingRatioHighBouncy, + ), + finishedListener = { + liveUpdate = false + }, + label = "Animation Live Circle" + ) + LaunchedEffect(news.size) { + liveUpdate = true + } + AnimatedVisibility( visible = news.isNotEmpty() && !isLoading, enter = slideInHorizontally() + fadeIn() ) { Column( modifier = modifier, - verticalArrangement = Arrangement.spacedBy(dimens.smallPadding) + verticalArrangement = Arrangement.spacedBy(dimens.smallPadding), ) { - Text( - modifier = Modifier - .padding(horizontal = dimens.horizontalPadding), - text = stringResource(id = R.string.real_time), - style = MaterialTheme.typography.titleLarge, - fontWeight = FontWeight.Bold, - ) + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(dimens.smallPadding), + ) { + Text( + modifier = Modifier + .padding(start = dimens.horizontalPadding), + text = stringResource(id = R.string.real_time), + style = MaterialTheme.typography.titleLarge, + fontWeight = FontWeight.Bold, + ) + Box( + modifier = Modifier + .size(dimens.smallIconSize) + .scale(sizeLiveIcon) + .background(color = Red, shape = CircleShape) + ) + } LazyRow( modifier = Modifier .fillMaxWidth(), diff --git a/app/src/main/res/drawable/icon_check.xml b/app/src/main/res/drawable/icon_check.xml new file mode 100644 index 0000000..ce50926 --- /dev/null +++ b/app/src/main/res/drawable/icon_check.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/icon_filter_list.xml b/app/src/main/res/drawable/icon_filter_list.xml new file mode 100644 index 0000000..ce0e502 --- /dev/null +++ b/app/src/main/res/drawable/icon_filter_list.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 49f03f9..f089291 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -8,4 +8,17 @@ Live News Latest News Unable to find news for selected filters. + Filter list news button + Filters News + Sort + Ascending + Descending + Symbols + All + Select + Cancel + Date Range + Start Date + End Date + Clear Date \ No newline at end of file From 3f639fa6be334ab3126819835a50615bfff2ac11 Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Fri, 26 Apr 2024 16:43:40 +0200 Subject: [PATCH 21/33] - logic to apply filters on VM --- .../dev/pinkroom/marketsight/common/Utils.kt | 12 ++- .../common/paginator/DefaultPagination.kt | 2 +- .../data/data_source/NewsRemoteDataSource.kt | 8 +- .../marketsight/data/remote/AlpacaNewsApi.kt | 2 + .../data/repository/NewsRepositoryImp.kt | 15 ++- .../domain/model/news/NewsFilters.kt | 20 ++++ .../domain/model/news/NewsResponse.kt | 2 +- .../domain/repository/NewsRepository.kt | 3 + .../domain/use_case/news/GetNews.kt | 10 ++ .../pinkroom/marketsight/ui/MainActivity.kt | 22 ++--- .../ui/core/navigation/NavigationAppHost.kt | 28 +++--- .../ui/core/util/SelectableDatesImp.kt | 2 +- .../marketsight/ui/news_screen/NewsAction.kt | 1 + .../marketsight/ui/news_screen/NewsEvent.kt | 4 + .../marketsight/ui/news_screen/NewsScreen.kt | 62 ++++++------ .../marketsight/ui/news_screen/NewsUiState.kt | 15 +-- .../ui/news_screen/NewsViewModel.kt | 97 +++++++++++++++---- .../components/BottomSheetFilters.kt | 67 ++++++++++--- app/src/main/res/values/strings.xml | 3 + 19 files changed, 267 insertions(+), 108 deletions(-) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/model/news/NewsFilters.kt diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt b/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt index 797697d..9ecd060 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt @@ -8,6 +8,7 @@ import dev.pinkroom.marketsight.domain.model.common.SubInfoSymbols import okhttp3.OkHttpClient import okhttp3.logging.HttpLoggingInterceptor import java.time.LocalDate +import java.time.LocalDateTime import java.time.ZoneOffset import java.time.format.DateTimeFormatter import java.time.format.FormatStyle @@ -39,6 +40,7 @@ fun LocalDate.toEpochMillis(zoneOffset: ZoneOffset = ZoneOffset.UTC, endOfTheDay val time = if (endOfTheDay) atTime(23,59) else atStartOfDay() return time.atOffset(zoneOffset).toInstant().toEpochMilli() } + fun LocalDate.toReadableDate(): String { val formatter = DateTimeFormatter .ofLocalizedDate(FormatStyle.SHORT) @@ -46,6 +48,10 @@ fun LocalDate.toReadableDate(): String { return format(formatter) } +fun LocalDateTime.formatToStandardIso(): String = format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")) + +fun LocalDate.atEndOfTheDay() = atTime(23,59,59).atOffset(ZoneOffset.UTC).toLocalDateTime() + sealed class ActionAlpaca(val action: String) { data object Subscribe: ActionAlpaca(action = "subscribe") data object Unsubscribe: ActionAlpaca(action = "unsubscribe") @@ -115,17 +121,17 @@ val popularSymbols = listOf( ), SubInfoSymbols( name = "Bitcoin", - symbol = "BTC/USD", + symbol = "BTC", isSubscribed = false, ), SubInfoSymbols( name = "Ethereum", - symbol = "ETH/USD", + symbol = "ETH", isSubscribed = false, ), SubInfoSymbols( name = "Shiba", - symbol = "SHIB/USD", + symbol = "SHIB", isSubscribed = false, ), ) \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/paginator/DefaultPagination.kt b/app/src/main/java/dev/pinkroom/marketsight/common/paginator/DefaultPagination.kt index 01d78e0..3e70c06 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/common/paginator/DefaultPagination.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/common/paginator/DefaultPagination.kt @@ -6,7 +6,7 @@ class DefaultPagination( private val initialKey: Key?, private inline val onLoadUpdated: (Boolean) -> Unit, private inline val onRequest: suspend (nextKey: Key?) -> Resource, - private inline val getNextKey: suspend (T) -> Key, + private inline val getNextKey: suspend (T) -> Key?, private inline val onError: suspend (message: String?) -> Unit, private inline val onSuccess: suspend (data: T, newKey: Key?) -> Unit ): Pagination { diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt index c323c5d..d999cd3 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt @@ -8,6 +8,7 @@ import dev.pinkroom.marketsight.common.DispatcherProvider import dev.pinkroom.marketsight.common.HelperIdentifierMessagesAlpacaService import dev.pinkroom.marketsight.common.Resource import dev.pinkroom.marketsight.common.SortType +import dev.pinkroom.marketsight.common.formatToStandardIso import dev.pinkroom.marketsight.common.toObject import dev.pinkroom.marketsight.data.remote.AlpacaNewsApi import dev.pinkroom.marketsight.data.remote.AlpacaNewsService @@ -19,6 +20,7 @@ import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.take +import java.time.LocalDateTime import javax.inject.Inject class NewsRemoteDataSource @Inject constructor( @@ -73,13 +75,17 @@ class NewsRemoteDataSource @Inject constructor( symbols: List? = null, limit: Int? = Constants.LIMIT_NEWS, pageToken: String?, - sort: SortType? = null + sort: SortType? = null, + startDate: LocalDateTime? = null, + endDate: LocalDateTime? = null, ): NewsResponseDto { return alpacaNewsApi.getNews( symbols = symbols?.joinToString(","), perPage = limit, pageToken = pageToken, sort = sort?.type, + startDate = startDate?.formatToStandardIso(), + endDate = endDate?.formatToStandardIso(), ) } } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaNewsApi.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaNewsApi.kt index 2bbf17f..b33846d 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaNewsApi.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaNewsApi.kt @@ -11,5 +11,7 @@ interface AlpacaNewsApi { @Query("limit") perPage: Int? = null, @Query("page_token") pageToken: String? = null, @Query("sort") sort: String? = null, + @Query("start") startDate: String? = null, + @Query("end") endDate: String? = null, ): NewsResponseDto } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt b/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt index 50a5efb..f91001c 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt @@ -12,7 +12,8 @@ import dev.pinkroom.marketsight.domain.model.news.NewsResponse import dev.pinkroom.marketsight.domain.repository.NewsRepository import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOn -import kotlinx.coroutines.flow.single +import kotlinx.coroutines.flow.last +import java.time.LocalDateTime import javax.inject.Inject class NewsRepositoryImp @Inject constructor( @@ -33,17 +34,21 @@ class NewsRepositoryImp @Inject constructor( val message = MessageAlpacaService(action = actionAlpaca.action, news = symbols) newsRemoteDataSource.sendSubscribeMessageToAlpacaService(message = message).collect{ response -> when(response){ - is Resource.Error -> emit(Resource.Error(data = symbols)) + is Resource.Error -> { + emit(Resource.Error(data = symbols)) + } is Resource.Success -> emit(Resource.Success(data = response.data.news ?: symbols)) } } - }.flowOn(dispatchers.IO).single() + }.flowOn(dispatchers.IO).last() override suspend fun getNews( symbols: List?, limit: Int?, pageToken: String?, - sort: SortType? + sort: SortType?, + startDate: LocalDateTime?, + endDate: LocalDateTime?, ): Resource { return try { val response = newsRemoteDataSource.getNews( @@ -51,6 +56,8 @@ class NewsRepositoryImp @Inject constructor( limit = limit, pageToken = pageToken, sort = sort, + startDate = startDate, + endDate = endDate, ) Resource.Success(data = response.toNewsResponse()) } catch (e: Exception){ diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/NewsFilters.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/NewsFilters.kt new file mode 100644 index 0000000..01f8453 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/NewsFilters.kt @@ -0,0 +1,20 @@ +package dev.pinkroom.marketsight.domain.model.news + +import dev.pinkroom.marketsight.common.Constants.ALL_SYMBOLS +import dev.pinkroom.marketsight.common.SortType +import dev.pinkroom.marketsight.common.popularSymbols +import dev.pinkroom.marketsight.domain.model.common.SubInfoSymbols +import java.time.LocalDate + +data class NewsFilters( + val symbols: List = popularSymbols, + val sort: List = listOf(SortType.DESC, SortType.ASC), + val sortBy: SortType = SortType.DESC, + val startDateSort: LocalDate? = null, + val endDateSort: LocalDate? = null, +){ + fun getSubscribedSymbols() = symbols + .filter { it.isSubscribed && it.name != ALL_SYMBOLS } + .map { it.symbol } + .ifEmpty { null } +} diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/NewsResponse.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/NewsResponse.kt index e8f6933..74aa163 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/NewsResponse.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/news/NewsResponse.kt @@ -2,5 +2,5 @@ package dev.pinkroom.marketsight.domain.model.news data class NewsResponse( val news: List, - val nextPageToken: String, + val nextPageToken: String? = null, ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt index dfb6354..c0d39de 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt @@ -7,6 +7,7 @@ import dev.pinkroom.marketsight.common.SortType import dev.pinkroom.marketsight.domain.model.news.NewsInfo import dev.pinkroom.marketsight.domain.model.news.NewsResponse import kotlinx.coroutines.flow.Flow +import java.time.LocalDateTime interface NewsRepository { fun getRealTimeNews(): Flow> @@ -20,5 +21,7 @@ interface NewsRepository { limit: Int? = LIMIT_NEWS, pageToken: String? = null, sort: SortType? = SortType.DESC, + startDate: LocalDateTime? = null, + endDate: LocalDateTime? = null, ): Resource } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/GetNews.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/GetNews.kt index 431d008..75c7506 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/GetNews.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/GetNews.kt @@ -1,7 +1,9 @@ package dev.pinkroom.marketsight.domain.use_case.news import dev.pinkroom.marketsight.common.Constants.LIMIT_NEWS +import dev.pinkroom.marketsight.common.SortType import dev.pinkroom.marketsight.domain.repository.NewsRepository +import java.time.LocalDateTime import javax.inject.Inject class GetNews @Inject constructor( @@ -10,8 +12,16 @@ class GetNews @Inject constructor( suspend operator fun invoke( pageToken: String? = null, limitPerPage: Int? = LIMIT_NEWS, + sortType: SortType? = SortType.DESC, + symbols: List? = null, + startDate: LocalDateTime? = null, + endDate: LocalDateTime? = null, ) = newsRepository.getNews( pageToken = pageToken, limit = limitPerPage, + sort = sortType, + symbols = symbols, + startDate = startDate, + endDate = endDate, ) } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt index 61c58e5..e1b8b4f 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt @@ -8,9 +8,9 @@ import androidx.compose.foundation.layout.padding import androidx.compose.material3.Scaffold import androidx.compose.material3.SnackbarHost import androidx.compose.material3.SnackbarHostState +import androidx.compose.material3.SnackbarResult import androidx.compose.material3.Surface import androidx.compose.runtime.remember -import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import androidx.navigation.compose.rememberNavController @@ -19,7 +19,6 @@ import dev.pinkroom.marketsight.ui.core.navigation.NavigationAppHost import dev.pinkroom.marketsight.ui.core.navigation.NavigationBottomBar import dev.pinkroom.marketsight.ui.core.navigation.Route import dev.pinkroom.marketsight.ui.core.theme.MarketSightTheme -import kotlinx.coroutines.launch @AndroidEntryPoint class MainActivity : ComponentActivity() { @@ -31,7 +30,7 @@ class MainActivity : ComponentActivity() { val navController = rememberNavController() val startDestination = Route.NewsScreen val snackBarHostState = remember { SnackbarHostState() } - val scope = rememberCoroutineScope() + MarketSightTheme { Surface( modifier = Modifier.fillMaxSize(), @@ -52,15 +51,14 @@ class MainActivity : ComponentActivity() { modifier = Modifier.padding(padding), navController = navController, startDestination = startDestination, - onShowSnackBar = { message, duration -> - scope.launch { - snackBarHostState.currentSnackbarData?.dismiss() - snackBarHostState.showSnackbar( - message = message, - duration = duration, - withDismissAction = true, - ) - } + onShowSnackBar = { message, duration, actionMessage -> + snackBarHostState.currentSnackbarData?.dismiss() + snackBarHostState.showSnackbar( + message = message, + duration = duration, + withDismissAction = true, + actionLabel = actionMessage, + ) == SnackbarResult.ActionPerformed } ) } diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt index 0663688..72b9330 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt @@ -1,8 +1,8 @@ package dev.pinkroom.marketsight.ui.core.navigation -import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.SnackbarDuration import androidx.compose.runtime.Composable +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.hilt.navigation.compose.hiltViewModel @@ -18,18 +18,21 @@ import dev.pinkroom.marketsight.ui.detail_screen.DetailScreen import dev.pinkroom.marketsight.ui.home_screen.HomeScreen import dev.pinkroom.marketsight.ui.home_screen.HomeViewModel import dev.pinkroom.marketsight.ui.news_screen.NewsAction +import dev.pinkroom.marketsight.ui.news_screen.NewsEvent import dev.pinkroom.marketsight.ui.news_screen.NewsScreen import dev.pinkroom.marketsight.ui.news_screen.NewsViewModel +import kotlinx.coroutines.launch -@OptIn(ExperimentalMaterial3Api::class) @Composable fun NavigationAppHost( modifier: Modifier = Modifier, navController: NavHostController, startDestination: Route, - onShowSnackBar: (message: String, duration: SnackbarDuration) -> Unit, + onShowSnackBar: suspend (message: String, duration: SnackbarDuration, action: String?) -> Boolean, ){ val context = LocalContext.current + val scope = rememberCoroutineScope() + NavHost( navController = navController, startDestination = startDestination.route, @@ -50,7 +53,16 @@ fun NavigationAppHost( ObserveAsEvents(viewModel.action){ action -> when(action){ is NewsAction.ShowSnackBar -> { - onShowSnackBar(context.getString(action.message), action.duration) + scope.launch { + val result = onShowSnackBar( + context.getString(action.message), + action.duration, + action.actionMessage?.let { msg -> context.getString(msg) }, + ) + if (result && action.actionMessage != null){ + viewModel.onEvent(NewsEvent.RetryRealTimeNewsSubscribe) + } + } } } } @@ -59,13 +71,7 @@ fun NavigationAppHost( news = uiState.news, mainNews = uiState.mainNews, realTimeNews = uiState.realTimeNews, - symbols = uiState.symbols, - sortBy = uiState.sortBy, - sortItems = uiState.sort, - endDate = uiState.endDateSort, - startDate = uiState.startDateSort, - startSelectableDates = uiState.startSelectableDates, - endSelectableDates = uiState.endSelectableDates, + filters = uiState.filters, isLoading = uiState.isLoading, isLoadingMoreNews = uiState.isLoadingMoreItems, isRefreshing = uiState.isRefreshing, diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/util/SelectableDatesImp.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/core/util/SelectableDatesImp.kt index 17a8e3d..83ec5c3 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/util/SelectableDatesImp.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/core/util/SelectableDatesImp.kt @@ -14,7 +14,7 @@ class SelectableDatesImp( override fun isSelectableDate(utcTimeMillis: Long): Boolean { val currentTimeInMillis = System.currentTimeMillis() val limitInMillis = when(dateMomentType){ - DateMomentType.End -> limitDate?.toEpochMillis(endOfTheDay = true) ?: utcTimeMillis + DateMomentType.End -> limitDate?.toEpochMillis(endOfTheDay = false) ?: utcTimeMillis DateMomentType.Start -> limitDate?.toEpochMillis(endOfTheDay = true) ?: currentTimeInMillis } return if (dateMomentType == DateMomentType.Start) utcTimeMillis <= limitInMillis diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsAction.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsAction.kt index 46aae29..05fb0be 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsAction.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsAction.kt @@ -7,5 +7,6 @@ sealed class NewsAction{ data class ShowSnackBar( @StringRes val message: Int, val duration: SnackbarDuration = SnackbarDuration.Short, + @StringRes val actionMessage: Int? = null, ): NewsAction() } diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsEvent.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsEvent.kt index 511c068..e43aa23 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsEvent.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsEvent.kt @@ -6,8 +6,12 @@ import dev.pinkroom.marketsight.domain.model.common.SubInfoSymbols sealed class NewsEvent { data object RetryNews: NewsEvent() + data object RetryRealTimeNewsSubscribe: NewsEvent() data object RefreshNews: NewsEvent() data object LoadMoreNews: NewsEvent() + data object ClearAllFilters: NewsEvent() + data object RevertFilters: NewsEvent() + data object ApplyFilters: NewsEvent() data class ShowOrHideFilters(val isToShow: Boolean? = null): NewsEvent() data class ChangeSort(val sort: SortType): NewsEvent() data class ChangeSymbol(val symbolToChange: SubInfoSymbols): NewsEvent() diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt index 59f12a5..3ea08bf 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt @@ -10,27 +10,27 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.SelectableDates +import androidx.compose.material3.SheetState import androidx.compose.material3.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.tooling.preview.Preview import dev.pinkroom.marketsight.R import dev.pinkroom.marketsight.common.Constants.BUFFER_LIST -import dev.pinkroom.marketsight.common.DateMomentType import dev.pinkroom.marketsight.common.SortType import dev.pinkroom.marketsight.domain.model.common.SubInfoSymbols import dev.pinkroom.marketsight.domain.model.news.ImageSize import dev.pinkroom.marketsight.domain.model.news.ImagesNews +import dev.pinkroom.marketsight.domain.model.news.NewsFilters import dev.pinkroom.marketsight.domain.model.news.NewsInfo import dev.pinkroom.marketsight.ui.core.components.PullToRefreshLazyColumn import dev.pinkroom.marketsight.ui.core.theme.dimens -import dev.pinkroom.marketsight.ui.core.util.SelectableDatesImp import dev.pinkroom.marketsight.ui.core.util.reachedBottom import dev.pinkroom.marketsight.ui.news_screen.components.AllNews import dev.pinkroom.marketsight.ui.news_screen.components.BottomSheetFilters @@ -38,7 +38,8 @@ import dev.pinkroom.marketsight.ui.news_screen.components.EmptyNewsList import dev.pinkroom.marketsight.ui.news_screen.components.HeaderListNews import dev.pinkroom.marketsight.ui.news_screen.components.MainNews import dev.pinkroom.marketsight.ui.news_screen.components.RealTimeNews -import java.time.LocalDate +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.launch import java.time.LocalDateTime @OptIn(ExperimentalFoundationApi::class, ExperimentalMaterial3Api::class) @@ -48,13 +49,7 @@ fun NewsScreen( mainNews: List, news: List, realTimeNews: List, - symbols: List, - sortBy: SortType, - sortItems: List, - startDate: LocalDate? = null, - endDate: LocalDate? = null, - startSelectableDates: SelectableDates, - endSelectableDates: SelectableDates, + filters: NewsFilters, isLoading: Boolean, isLoadingMoreNews: Boolean, isRefreshing: Boolean, @@ -63,6 +58,7 @@ fun NewsScreen( onEvent: (event: NewsEvent) -> Unit, ){ val context = LocalContext.current + val scope = rememberCoroutineScope() val sheetState = rememberModalBottomSheetState() @@ -158,25 +154,31 @@ fun NewsScreen( .fillMaxHeight(dimens.bottomSheetHeight), isVisible = isToShowFilters, onDismiss = { - onEvent(NewsEvent.ShowOrHideFilters(isToShow = false)) + onEvent(NewsEvent.RevertFilters) }, sheetState = sheetState, - sortFilters = sortItems, - selectedSort = sortBy, + sortFilters = filters.sort, + selectedSort = filters.sortBy, onSortClick = { onEvent(NewsEvent.ChangeSort(sort = it)) }, - symbols = symbols, + symbols = filters.symbols, onSymbolClick = { onEvent(NewsEvent.ChangeSymbol(symbolToChange = it)) }, - startDate = startDate, - endDate = endDate, + startDate = filters.startDateSort, + endDate = filters.endDateSort, changeDate = { dateInMillis, dateMomentType -> onEvent(NewsEvent.ChangeDate(newDateInMillis = dateInMillis, dateMomentType = dateMomentType)) }, - startSelectableDates = startSelectableDates, - endSelectableDates = endSelectableDates, + onClearAll = { + sheetState.close(scope) + onEvent(NewsEvent.ClearAllFilters) + }, + onApply = { + sheetState.close(scope) + onEvent(NewsEvent.ApplyFilters) + }, ) } @@ -186,6 +188,8 @@ fun Context.navigateToNews(newsInfo: NewsInfo){ } @OptIn(ExperimentalMaterial3Api::class) +fun SheetState.close(scope: CoroutineScope) = scope.launch { hide() } + @Preview( showBackground = true, showSystemUi = true, @@ -291,23 +295,23 @@ fun NewsScreenPreview(){ headline = "Market Clubhouse Morning Memo - April 11th, 2024 (Trade Strategy For SPY, QQQ, AAPL, MSFT, NVDA, GOOGL, META, And TSLA)", ), ), - symbols = listOf( - SubInfoSymbols( - name = "TESLA", symbol = "TSLA", - ), - SubInfoSymbols( - name = "APPLE", symbol = "AAPL", + filters = NewsFilters( + symbols = listOf( + SubInfoSymbols( + name = "TESLA", symbol = "TSLA", + ), + SubInfoSymbols( + name = "APPLE", symbol = "AAPL", + ), ), + sort = listOf(), + sortBy = SortType.DESC, ), isLoading = false, isLoadingMoreNews = false, errorMessage = R.string.get_news_error_message, isRefreshing = false, isToShowFilters = false, - sortItems = listOf(), - sortBy = SortType.DESC, onEvent = {}, - startSelectableDates = SelectableDatesImp(dateMomentType = DateMomentType.Start), - endSelectableDates = SelectableDatesImp(dateMomentType = DateMomentType.End), ) } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt index 5f46aa5..0198c3c 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt @@ -1,13 +1,8 @@ package dev.pinkroom.marketsight.ui.news_screen import androidx.annotation.DrawableRes -import dev.pinkroom.marketsight.common.DateMomentType -import dev.pinkroom.marketsight.common.SortType -import dev.pinkroom.marketsight.common.popularSymbols -import dev.pinkroom.marketsight.domain.model.common.SubInfoSymbols +import dev.pinkroom.marketsight.domain.model.news.NewsFilters import dev.pinkroom.marketsight.domain.model.news.NewsInfo -import dev.pinkroom.marketsight.ui.core.util.SelectableDatesImp -import java.time.LocalDate data class NewsUiState( val isLoading: Boolean = true, @@ -18,13 +13,7 @@ data class NewsUiState( val mainNews: List = listOf(), val news: List = listOf(), val realTimeNews: List = listOf(), - val symbols: List = popularSymbols, - val sort: List = listOf(SortType.DESC, SortType.ASC), - val sortBy: SortType = SortType.DESC, - val startDateSort: LocalDate? = null, - val endDateSort: LocalDate? = null, - val startSelectableDates: SelectableDatesImp = SelectableDatesImp(dateMomentType = DateMomentType.Start), - val endSelectableDates: SelectableDatesImp = SelectableDatesImp(dateMomentType = DateMomentType.End) + val filters: NewsFilters = NewsFilters(), ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt index 682d4d6..1bd8b49 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt @@ -1,5 +1,6 @@ package dev.pinkroom.marketsight.ui.news_screen +import androidx.compose.material3.SnackbarDuration import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel @@ -10,17 +11,18 @@ import dev.pinkroom.marketsight.common.DateMomentType import dev.pinkroom.marketsight.common.DispatcherProvider import dev.pinkroom.marketsight.common.Resource import dev.pinkroom.marketsight.common.SortType +import dev.pinkroom.marketsight.common.atEndOfTheDay import dev.pinkroom.marketsight.common.connection_network.ConnectivityObserver import dev.pinkroom.marketsight.common.connection_network.ConnectivityObserver.Status.Available import dev.pinkroom.marketsight.common.connection_network.ConnectivityObserver.Status.Unavailable import dev.pinkroom.marketsight.common.paginator.DefaultPagination import dev.pinkroom.marketsight.domain.model.common.PaginationInfo import dev.pinkroom.marketsight.domain.model.common.SubInfoSymbols +import dev.pinkroom.marketsight.domain.model.news.NewsFilters import dev.pinkroom.marketsight.domain.model.news.NewsResponse import dev.pinkroom.marketsight.domain.use_case.news.ChangeFilterNews import dev.pinkroom.marketsight.domain.use_case.news.GetNews import dev.pinkroom.marketsight.domain.use_case.news.GetRealTimeNews -import dev.pinkroom.marketsight.ui.core.util.SelectableDatesImp import kotlinx.coroutines.Job import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.MutableStateFlow @@ -55,7 +57,14 @@ class NewsViewModel @Inject constructor( _uiState.update { it.copy(isLoadingMoreItems = isLoading) } }, onRequest = { nextPage -> - getNews(pageToken = nextPage) + val filters = uiState.value.filters + getNews( + pageToken = nextPage, + sortType = filters.sortBy, + symbols = filters.getSubscribedSymbols(), + startDate = filters.startDateSort?.atStartOfDay(), + endDate = filters.endDateSort?.atEndOfTheDay(), + ) }, getNextKey = { it.nextPageToken @@ -74,6 +83,7 @@ class NewsViewModel @Inject constructor( private var initNewsJob: Job? = null private var connectionStatus = Unavailable + private var previousFilters: NewsFilters = uiState.value.filters init { observeNetworkStatus() @@ -84,8 +94,12 @@ class NewsViewModel @Inject constructor( fun onEvent(event: NewsEvent) { when(event) { NewsEvent.RetryNews -> retryToGetNews() + NewsEvent.RetryRealTimeNewsSubscribe -> updateFiltersRealTimeNews(newFilters = previousFilters) NewsEvent.RefreshNews -> refreshNews() NewsEvent.LoadMoreNews -> loadMoreNews() + NewsEvent.ApplyFilters -> applyFilters() + NewsEvent.ClearAllFilters -> clearAllFilters() + NewsEvent.RevertFilters -> revertFilters() is NewsEvent.ShowOrHideFilters -> showOrHideFilters(isToShow = event.isToShow) is NewsEvent.ChangeSort -> changeSort(newSort = event.sort) is NewsEvent.ChangeSymbol -> changeSymbols(symbolToChange = event.symbolToChange) @@ -106,7 +120,15 @@ class NewsViewModel @Inject constructor( private fun initNews() { initNewsJob = viewModelScope.launch(dispatchers.IO) { _uiState.update { it.copy(isLoading = true) } - when(val response = getNews()){ + paginationInfo = paginationInfo.copy(endReached = false) + val filters = uiState.value.filters + val response = getNews( + sortType = filters.sortBy, + symbols = filters.getSubscribedSymbols(), + startDate = filters.startDateSort?.atStartOfDay(), + endDate = filters.endDateSort?.atEndOfTheDay(), + ) + when(response){ is Resource.Success -> { val allNews = response.data.news val maxNumberNews = if (allNews.size >= MAX_ITEMS_CAROUSEL) MAX_ITEMS_CAROUSEL else allNews.size @@ -152,7 +174,7 @@ class NewsViewModel @Inject constructor( private fun loadMoreNews() { viewModelScope.launch(dispatchers.IO) { - if (!paginationInfo.isLoading) pagination.loadNextItems() + if (!paginationInfo.isLoading && !paginationInfo.endReached) pagination.loadNextItems() } } @@ -170,19 +192,19 @@ class NewsViewModel @Inject constructor( } private fun changeSort(newSort: SortType) { - if (uiState.value.sortBy == newSort) return - _uiState.update { it.copy(sortBy = newSort) } + if (uiState.value.filters.sortBy == newSort) return + _uiState.update { it.copy(filters = it.filters.copy(sortBy = newSort)) } } private fun changeSymbols(symbolToChange: SubInfoSymbols) { - val symbolsSubscribed = uiState.value.symbols.filter { it.isSubscribed } + val symbolsSubscribed = uiState.value.filters.symbols.filter { it.isSubscribed } val totalSizeSubscribed = if (symbolsSubscribed.contains(symbolToChange)) symbolsSubscribed.size - 1 else symbolsSubscribed.size val needToSubscribeAll = totalSizeSubscribed == 0 || symbolToChange.name == ALL_SYMBOLS - val newListSymbols = uiState.value.symbols.map { item -> + val newListSymbols = uiState.value.filters.symbols.map { item -> when { item.name == ALL_SYMBOLS -> item.copy(isSubscribed = needToSubscribeAll) item.symbol == symbolToChange.symbol -> item.copy(isSubscribed = !item.isSubscribed) @@ -190,26 +212,59 @@ class NewsViewModel @Inject constructor( else -> item.copy() } } - _uiState.update { it.copy(symbols = newListSymbols) } + _uiState.update { it.copy(filters = it.filters.copy(symbols = newListSymbols)) } } - private fun changeDate(dateInMillis: Long?, dateMomentType: DateMomentType){ + private fun changeDate(dateInMillis: Long?, dateMomentType: DateMomentType) { val date = dateInMillis?.let { Instant.ofEpochMilli(it).atZone(ZoneOffset.UTC).toLocalDate() } when(dateMomentType){ DateMomentType.End -> { - _uiState.update { - it.copy( - endDateSort = date, - startSelectableDates = SelectableDatesImp(limitDate = date, dateMomentType = DateMomentType.Start), - ) - } + _uiState.update { it.copy(filters = it.filters.copy(endDateSort = date)) } } DateMomentType.Start -> { - _uiState.update { - it.copy( - startDateSort = date, - endSelectableDates = SelectableDatesImp(limitDate = date, dateMomentType = DateMomentType.End), - ) + _uiState.update { it.copy(filters = it.filters.copy(startDateSort = date)) } + } + } + } + + private fun applyFilters() { + _uiState.update { it.copy(isToShowFilters = false) } + if (previousFilters != uiState.value.filters) + updateNewsWithNewFilters(newFilters = uiState.value.filters) + } + + private fun clearAllFilters() { + val baseFilters = NewsFilters() + if (previousFilters != baseFilters) updateNewsWithNewFilters(newFilters = baseFilters) + _uiState.update { it.copy(filters = baseFilters, isToShowFilters = false) } + } + + private fun revertFilters() = _uiState.update { it.copy(filters = previousFilters, isToShowFilters = false) } + + private fun updateNewsWithNewFilters(newFilters: NewsFilters){ + initNews() + if (previousFilters.symbols != newFilters.symbols) updateFiltersRealTimeNews(newFilters) + previousFilters = newFilters + } + + private fun updateFiltersRealTimeNews(newFilters: NewsFilters){ + viewModelScope.launch(dispatchers.IO) { + _uiState.update { it.copy(realTimeNews = emptyList()) } + changeFilterNews( + subscribeSymbols = newFilters.symbols.filter { it.isSubscribed }.map { it.symbol }, + unsubscribeSymbols = newFilters.symbols.filter { !it.isSubscribed }.map { it.symbol } + ).collect{ response -> + when(response){ + is Resource.Success -> Unit + is Resource.Error -> { + _action.send( + NewsAction.ShowSnackBar( + message = R.string.error_subscription_real_time_news, + duration = SnackbarDuration.Indefinite, + actionMessage = R.string.retry, + ) + ) + } } } } diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/BottomSheetFilters.kt b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/BottomSheetFilters.kt index 3fc8193..0d218d7 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/BottomSheetFilters.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/BottomSheetFilters.kt @@ -1,10 +1,14 @@ package dev.pinkroom.marketsight.ui.news_screen.components import androidx.compose.animation.AnimatedVisibility +import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.ExperimentalLayoutApi import androidx.compose.foundation.layout.FlowRow import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding @@ -20,9 +24,11 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextAlign import dev.pinkroom.marketsight.R import dev.pinkroom.marketsight.common.DateMomentType import dev.pinkroom.marketsight.common.SortType @@ -31,10 +37,12 @@ import dev.pinkroom.marketsight.domain.model.common.SubInfoSymbols import dev.pinkroom.marketsight.ui.core.components.ButtonFilter import dev.pinkroom.marketsight.ui.core.components.DatePickerComponent import dev.pinkroom.marketsight.ui.core.components.DefaultSectionFilter +import dev.pinkroom.marketsight.ui.core.theme.Blue import dev.pinkroom.marketsight.ui.core.theme.dimens +import dev.pinkroom.marketsight.ui.core.util.SelectableDatesImp import java.time.LocalDate -@OptIn(ExperimentalMaterial3Api::class) +@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class) @Composable fun BottomSheetFilters( modifier: Modifier = Modifier, @@ -48,8 +56,8 @@ fun BottomSheetFilters( onSortClick: (sort: SortType) -> Unit, onSymbolClick: (symbol: SubInfoSymbols) -> Unit, changeDate: (dateInMillis: Long?, dateMomentType: DateMomentType) -> Unit, - startSelectableDates: SelectableDates, - endSelectableDates: SelectableDates, + onClearAll: () -> Unit, + onApply: () -> Unit, sheetState: SheetState, ){ AnimatedVisibility(visible = isVisible) { @@ -65,14 +73,15 @@ fun BottomSheetFilters( bottom = dimens.normalPadding, ) ) { - item { - Text( + stickyHeader { + HeaderBottomSheetFilters( modifier = Modifier + .background(color = MaterialTheme.colorScheme.background) .fillMaxWidth() - .padding(horizontal = dimens.horizontalPadding), - text = stringResource(id = R.string.filters_news), - style = MaterialTheme.typography.titleLarge, - fontWeight = FontWeight.Bold, + .padding(horizontal = dimens.horizontalPadding) + .padding(bottom = dimens.smallPadding), + onApply = onApply, + onClearAll = onClearAll, ) } item { @@ -80,8 +89,8 @@ fun BottomSheetFilters( startDate = startDate, endDate = endDate, changeDate = changeDate, - startSelectableDates = startSelectableDates, - endSelectableDates = endSelectableDates, + startSelectableDates = SelectableDatesImp(dateMomentType = DateMomentType.Start, limitDate = endDate), + endSelectableDates = SelectableDatesImp(dateMomentType = DateMomentType.End, limitDate = startDate), ) } item { @@ -106,6 +115,42 @@ fun BottomSheetFilters( } } +@Composable +fun HeaderBottomSheetFilters( + modifier: Modifier = Modifier, + onClearAll: () -> Unit, + onApply: () -> Unit, +){ + Row( + modifier = modifier, + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.Absolute.SpaceBetween, + ) { + Text( + modifier = Modifier + .clickable( + onClick = onClearAll, + ), + text = stringResource(id = R.string.clear_all) + ) + Text( + text = stringResource(id = R.string.filters_news), + style = MaterialTheme.typography.titleLarge, + fontWeight = FontWeight.Bold, + textAlign = TextAlign.Center, + ) + Text( + modifier = Modifier + .clickable( + onClick = onApply, + ), + text = stringResource(id = R.string.apply), + textAlign = TextAlign.End, + color = Blue, + ) + } +} + @OptIn(ExperimentalLayoutApi::class) @Composable fun SortSection( diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f089291..8900f77 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -21,4 +21,7 @@ Start Date End Date Clear Date + Clear All + Apply + An error occurred when trying to get news in real time. \ No newline at end of file From 9a765df1c4f02d82d12ff497767301257cdcb765 Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Mon, 29 Apr 2024 16:54:59 +0100 Subject: [PATCH 22/33] - unit test --- app/build.gradle.kts | 1 + app/src/main/AndroidManifest.xml | 2 +- .../data/repository/NewsRepositoryImp.kt | 2 +- .../domain/repository/NewsRepository.kt | 2 +- ...terNews.kt => ChangeFilterRealTimeNews.kt} | 6 +- .../{ui => presentation}/MainActivity.kt | 10 +- .../core/components/ButtonFilter.kt | 8 +- .../core/components/DatePickerComponent.kt | 8 +- .../core/components/DefaultSectionFilter.kt | 4 +- .../components/PullToRefreshLazyColumn.kt | 2 +- .../core/navigation/BottomBarItem.kt | 2 +- .../core/navigation/NavigationAppHost.kt | 20 +- .../core/navigation/NavigationBottomBar.kt | 4 +- .../core/navigation/Route.kt | 4 +- .../{ui => presentation}/core/theme/Color.kt | 2 +- .../core/theme/Dimensions.kt | 2 +- .../core/theme/ShimmerEffect.kt | 2 +- .../{ui => presentation}/core/theme/Theme.kt | 2 +- .../{ui => presentation}/core/theme/Type.kt | 2 +- .../core/util/ObserveAsEvents.kt | 2 +- .../core/util/ReachedBottom.kt | 2 +- .../core/util/SelectableDatesImp.kt | 2 +- .../detail_screen/DetailScreen.kt | 2 +- .../home_screen/HomeScreen.kt | 2 +- .../home_screen/HomeViewModel.kt | 2 +- .../news_screen/NewsAction.kt | 2 +- .../news_screen/NewsEvent.kt | 2 +- .../news_screen/NewsScreen.kt | 20 +- .../news_screen/NewsUiState.kt | 2 +- .../news_screen/NewsViewModel.kt | 15 +- .../news_screen/components/AllNews.kt | 6 +- .../news_screen/components/AllNewsCard.kt | 4 +- .../components/BottomSheetFilters.kt | 14 +- .../news_screen/components/EmptyNewsList.kt | 4 +- .../news_screen/components/HeaderListNews.kt | 4 +- .../news_screen/components/ImageNews.kt | 4 +- .../components/IndicatorPageCarousel.kt | 8 +- .../news_screen/components/MainNews.kt | 6 +- .../news_screen/components/MainNewsCard.kt | 8 +- .../news_screen/components/RealTimeNews.kt | 6 +- .../components/RealTimeNewsCard.kt | 4 +- .../data_source/NewsRemoteDataSourceTest.kt | 34 +- .../data/repository/NewsRepositoryTest.kt | 25 +- ...est.kt => ChangeFilterRealTimeNewsTest.kt} | 20 +- .../news_screen/NewsViewModelTest.kt | 678 ++++++++++++++++++ gradle/libs.versions.toml | 4 + 46 files changed, 816 insertions(+), 151 deletions(-) rename app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/{ChangeFilterNews.kt => ChangeFilterRealTimeNews.kt} (81%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/MainActivity.kt (88%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/core/components/ButtonFilter.kt (89%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/core/components/DatePickerComponent.kt (94%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/core/components/DefaultSectionFilter.kt (89%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/core/components/PullToRefreshLazyColumn.kt (97%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/core/navigation/BottomBarItem.kt (92%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/core/navigation/NavigationAppHost.kt (81%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/core/navigation/NavigationBottomBar.kt (97%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/core/navigation/Route.kt (75%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/core/theme/Color.kt (89%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/core/theme/Dimensions.kt (98%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/core/theme/ShimmerEffect.kt (96%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/core/theme/Theme.kt (97%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/core/theme/Type.kt (98%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/core/util/ObserveAsEvents.kt (90%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/core/util/ReachedBottom.kt (84%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/core/util/SelectableDatesImp.kt (95%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/detail_screen/DetailScreen.kt (91%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/home_screen/HomeScreen.kt (91%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/home_screen/HomeViewModel.kt (76%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/news_screen/NewsAction.kt (84%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/news_screen/NewsEvent.kt (93%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/news_screen/NewsScreen.kt (94%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/news_screen/NewsUiState.kt (90%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/news_screen/NewsViewModel.kt (98%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/news_screen/components/AllNews.kt (93%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/news_screen/components/AllNewsCard.kt (97%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/news_screen/components/BottomSheetFilters.kt (95%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/news_screen/components/EmptyNewsList.kt (92%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/news_screen/components/HeaderListNews.kt (93%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/news_screen/components/ImageNews.kt (88%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/news_screen/components/IndicatorPageCarousel.kt (91%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/news_screen/components/MainNews.kt (95%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/news_screen/components/MainNewsCard.kt (95%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/news_screen/components/RealTimeNews.kt (95%) rename app/src/main/java/dev/pinkroom/marketsight/{ui => presentation}/news_screen/components/RealTimeNewsCard.kt (96%) rename app/src/test/java/dev/pinkroom/marketsight/domain/use_case/news/{ChangeFilterNewsTest.kt => ChangeFilterRealTimeNewsTest.kt} (86%) create mode 100644 app/src/test/java/dev/pinkroom/marketsight/presentation/news_screen/NewsViewModelTest.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 6e9cf7e..38a162b 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -126,6 +126,7 @@ dependencies { testImplementation(libs.coroutine.test) testImplementation(libs.assertk) testImplementation(libs.faker) + testImplementation(libs.turbine) // END-TO-END TEST androidTestImplementation(libs.androidx.junit) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6396822..6d0f573 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -17,7 +17,7 @@ tools:targetApi="34" android:name=".MarketSightApp"> diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt b/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt index f91001c..f51832c 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryImp.kt @@ -27,7 +27,7 @@ class NewsRepositoryImp @Inject constructor( } }.flowOn(dispatchers.IO) - override suspend fun changeFilterNews( + override suspend fun changeFilterRealTimeNews( symbols: List, actionAlpaca: ActionAlpaca, ): Resource> = flow { diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt index c0d39de..bb64922 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/NewsRepository.kt @@ -11,7 +11,7 @@ import java.time.LocalDateTime interface NewsRepository { fun getRealTimeNews(): Flow> - suspend fun changeFilterNews( + suspend fun changeFilterRealTimeNews( symbols: List, actionAlpaca: ActionAlpaca, ): Resource> diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/ChangeFilterNews.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/ChangeFilterRealTimeNews.kt similarity index 81% rename from app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/ChangeFilterNews.kt rename to app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/ChangeFilterRealTimeNews.kt index cc0ec2e..6655c89 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/ChangeFilterNews.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/news/ChangeFilterRealTimeNews.kt @@ -8,7 +8,7 @@ import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOn import javax.inject.Inject -class ChangeFilterNews @Inject constructor( +class ChangeFilterRealTimeNews @Inject constructor( private val newsRepository: NewsRepository, private val dispatchers: DispatcherProvider, ){ @@ -18,7 +18,7 @@ class ChangeFilterNews @Inject constructor( ) = flow>> { val symbolsToRevert = mutableListOf() unsubscribeSymbols?.let { symbols -> - val response = newsRepository.changeFilterNews(symbols = symbols, actionAlpaca = ActionAlpaca.Unsubscribe) + val response = newsRepository.changeFilterRealTimeNews(symbols = symbols, actionAlpaca = ActionAlpaca.Unsubscribe) when(response){ is Resource.Error -> { symbolsToRevert.addAll(unsubscribeSymbols) @@ -28,7 +28,7 @@ class ChangeFilterNews @Inject constructor( } subscribeSymbols?.let { symbols -> - val response = newsRepository.changeFilterNews(symbols = symbols, actionAlpaca = ActionAlpaca.Subscribe) + val response = newsRepository.changeFilterRealTimeNews(symbols = symbols, actionAlpaca = ActionAlpaca.Subscribe) when(response){ is Resource.Success -> emit(Resource.Success(data = response.data)) is Resource.Error -> { diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/MainActivity.kt similarity index 88% rename from app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/MainActivity.kt index e1b8b4f..d9d66a3 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/MainActivity.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/MainActivity.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui +package dev.pinkroom.marketsight.presentation import android.os.Bundle import androidx.activity.ComponentActivity @@ -15,10 +15,10 @@ import androidx.compose.ui.Modifier import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import androidx.navigation.compose.rememberNavController import dagger.hilt.android.AndroidEntryPoint -import dev.pinkroom.marketsight.ui.core.navigation.NavigationAppHost -import dev.pinkroom.marketsight.ui.core.navigation.NavigationBottomBar -import dev.pinkroom.marketsight.ui.core.navigation.Route -import dev.pinkroom.marketsight.ui.core.theme.MarketSightTheme +import dev.pinkroom.marketsight.presentation.core.navigation.NavigationAppHost +import dev.pinkroom.marketsight.presentation.core.navigation.NavigationBottomBar +import dev.pinkroom.marketsight.presentation.core.navigation.Route +import dev.pinkroom.marketsight.presentation.core.theme.MarketSightTheme @AndroidEntryPoint class MainActivity : ComponentActivity() { diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/ButtonFilter.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/components/ButtonFilter.kt similarity index 89% rename from app/src/main/java/dev/pinkroom/marketsight/ui/core/components/ButtonFilter.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/core/components/ButtonFilter.kt index 1da14ea..3f7bcd4 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/ButtonFilter.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/components/ButtonFilter.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.core.components +package dev.pinkroom.marketsight.presentation.core.components import androidx.compose.animation.animateContentSize import androidx.compose.foundation.BorderStroke @@ -17,9 +17,9 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource import dev.pinkroom.marketsight.R -import dev.pinkroom.marketsight.ui.core.theme.BabyBlue -import dev.pinkroom.marketsight.ui.core.theme.Blue -import dev.pinkroom.marketsight.ui.core.theme.dimens +import dev.pinkroom.marketsight.presentation.core.theme.BabyBlue +import dev.pinkroom.marketsight.presentation.core.theme.Blue +import dev.pinkroom.marketsight.presentation.core.theme.dimens @Composable fun ButtonFilter( diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/DatePickerComponent.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/components/DatePickerComponent.kt similarity index 94% rename from app/src/main/java/dev/pinkroom/marketsight/ui/core/components/DatePickerComponent.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/core/components/DatePickerComponent.kt index 90af288..84d011b 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/DatePickerComponent.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/components/DatePickerComponent.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.core.components +package dev.pinkroom.marketsight.presentation.core.components import android.annotation.SuppressLint import androidx.compose.animation.AnimatedVisibility @@ -21,9 +21,9 @@ import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.res.stringResource import dev.pinkroom.marketsight.R import dev.pinkroom.marketsight.common.toEpochMillis -import dev.pinkroom.marketsight.ui.core.theme.BabyBlue -import dev.pinkroom.marketsight.ui.core.theme.Blue -import dev.pinkroom.marketsight.ui.core.theme.dimens +import dev.pinkroom.marketsight.presentation.core.theme.BabyBlue +import dev.pinkroom.marketsight.presentation.core.theme.Blue +import dev.pinkroom.marketsight.presentation.core.theme.dimens import java.time.LocalDate @SuppressLint("UnrememberedMutableState") diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/DefaultSectionFilter.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/components/DefaultSectionFilter.kt similarity index 89% rename from app/src/main/java/dev/pinkroom/marketsight/ui/core/components/DefaultSectionFilter.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/core/components/DefaultSectionFilter.kt index 5005aed..ddafd69 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/DefaultSectionFilter.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/components/DefaultSectionFilter.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.core.components +package dev.pinkroom.marketsight.presentation.core.components import androidx.compose.foundation.layout.padding import androidx.compose.material3.HorizontalDivider @@ -8,7 +8,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign -import dev.pinkroom.marketsight.ui.core.theme.dimens +import dev.pinkroom.marketsight.presentation.core.theme.dimens @Composable fun DefaultSectionFilter( diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/PullToRefreshLazyColumn.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/components/PullToRefreshLazyColumn.kt similarity index 97% rename from app/src/main/java/dev/pinkroom/marketsight/ui/core/components/PullToRefreshLazyColumn.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/core/components/PullToRefreshLazyColumn.kt index 9f36a0e..a7054de 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/components/PullToRefreshLazyColumn.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/components/PullToRefreshLazyColumn.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.core.components +package dev.pinkroom.marketsight.presentation.core.components import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/BottomBarItem.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/navigation/BottomBarItem.kt similarity index 92% rename from app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/BottomBarItem.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/core/navigation/BottomBarItem.kt index 8968ef9..ea06914 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/BottomBarItem.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/navigation/BottomBarItem.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.core.navigation +package dev.pinkroom.marketsight.presentation.core.navigation import androidx.annotation.DrawableRes import androidx.annotation.StringRes diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/navigation/NavigationAppHost.kt similarity index 81% rename from app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/core/navigation/NavigationAppHost.kt index 72b9330..804e920 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationAppHost.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/navigation/NavigationAppHost.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.core.navigation +package dev.pinkroom.marketsight.presentation.core.navigation import androidx.compose.material3.SnackbarDuration import androidx.compose.runtime.Composable @@ -12,15 +12,15 @@ import androidx.navigation.NavType import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.navArgument -import dev.pinkroom.marketsight.ui.core.navigation.Args.SYMBOL_ID -import dev.pinkroom.marketsight.ui.core.util.ObserveAsEvents -import dev.pinkroom.marketsight.ui.detail_screen.DetailScreen -import dev.pinkroom.marketsight.ui.home_screen.HomeScreen -import dev.pinkroom.marketsight.ui.home_screen.HomeViewModel -import dev.pinkroom.marketsight.ui.news_screen.NewsAction -import dev.pinkroom.marketsight.ui.news_screen.NewsEvent -import dev.pinkroom.marketsight.ui.news_screen.NewsScreen -import dev.pinkroom.marketsight.ui.news_screen.NewsViewModel +import dev.pinkroom.marketsight.presentation.core.navigation.Args.SYMBOL_ID +import dev.pinkroom.marketsight.presentation.core.util.ObserveAsEvents +import dev.pinkroom.marketsight.presentation.detail_screen.DetailScreen +import dev.pinkroom.marketsight.presentation.home_screen.HomeScreen +import dev.pinkroom.marketsight.presentation.home_screen.HomeViewModel +import dev.pinkroom.marketsight.presentation.news_screen.NewsAction +import dev.pinkroom.marketsight.presentation.news_screen.NewsEvent +import dev.pinkroom.marketsight.presentation.news_screen.NewsScreen +import dev.pinkroom.marketsight.presentation.news_screen.NewsViewModel import kotlinx.coroutines.launch @Composable diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationBottomBar.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/navigation/NavigationBottomBar.kt similarity index 97% rename from app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationBottomBar.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/core/navigation/NavigationBottomBar.kt index 1dedf4b..2d89961 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/NavigationBottomBar.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/navigation/NavigationBottomBar.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.core.navigation +package dev.pinkroom.marketsight.presentation.core.navigation import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.core.animateDpAsState @@ -33,7 +33,7 @@ import androidx.compose.ui.res.stringResource import androidx.navigation.NavHostController import androidx.navigation.compose.currentBackStackEntryAsState import dev.pinkroom.marketsight.R -import dev.pinkroom.marketsight.ui.core.theme.dimens +import dev.pinkroom.marketsight.presentation.core.theme.dimens @Composable fun NavigationBottomBar( diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/Route.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/navigation/Route.kt similarity index 75% rename from app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/Route.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/core/navigation/Route.kt index a21306a..32cd4d7 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/navigation/Route.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/navigation/Route.kt @@ -1,6 +1,6 @@ -package dev.pinkroom.marketsight.ui.core.navigation +package dev.pinkroom.marketsight.presentation.core.navigation -import dev.pinkroom.marketsight.ui.core.navigation.Args.SYMBOL_ID +import dev.pinkroom.marketsight.presentation.core.navigation.Args.SYMBOL_ID sealed class Route(val route: String){ data object HomeScreen: Route("home-screen") diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Color.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/Color.kt similarity index 89% rename from app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Color.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/Color.kt index ae88b88..4f1069f 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Color.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/Color.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.core.theme +package dev.pinkroom.marketsight.presentation.core.theme import androidx.compose.ui.graphics.Color diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/Dimensions.kt similarity index 98% rename from app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/Dimensions.kt index 9e56965..129a7e5 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Dimensions.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/Dimensions.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.core.theme +package dev.pinkroom.marketsight.presentation.core.theme import androidx.compose.runtime.Composable import androidx.compose.ui.platform.LocalConfiguration diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/ShimmerEffect.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/ShimmerEffect.kt similarity index 96% rename from app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/ShimmerEffect.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/ShimmerEffect.kt index 7ca4efc..29a1be4 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/ShimmerEffect.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/ShimmerEffect.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.core.theme +package dev.pinkroom.marketsight.presentation.core.theme import androidx.compose.animation.core.animateFloat import androidx.compose.animation.core.infiniteRepeatable diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Theme.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/Theme.kt similarity index 97% rename from app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Theme.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/Theme.kt index 78e4467..4779b42 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Theme.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/Theme.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.core.theme +package dev.pinkroom.marketsight.presentation.core.theme import android.app.Activity import android.os.Build diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Type.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/Type.kt similarity index 98% rename from app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Type.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/Type.kt index ba9b22c..1cacbfd 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/theme/Type.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/Type.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.core.theme +package dev.pinkroom.marketsight.presentation.core.theme import androidx.compose.material3.Typography import androidx.compose.runtime.Composable diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/util/ObserveAsEvents.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/util/ObserveAsEvents.kt similarity index 90% rename from app/src/main/java/dev/pinkroom/marketsight/ui/core/util/ObserveAsEvents.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/core/util/ObserveAsEvents.kt index d181753..4e5b90f 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/util/ObserveAsEvents.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/util/ObserveAsEvents.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.core.util +package dev.pinkroom.marketsight.presentation.core.util import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/util/ReachedBottom.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/util/ReachedBottom.kt similarity index 84% rename from app/src/main/java/dev/pinkroom/marketsight/ui/core/util/ReachedBottom.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/core/util/ReachedBottom.kt index c7305f1..d2df462 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/util/ReachedBottom.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/util/ReachedBottom.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.core.util +package dev.pinkroom.marketsight.presentation.core.util import androidx.compose.foundation.lazy.LazyListState diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/core/util/SelectableDatesImp.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/util/SelectableDatesImp.kt similarity index 95% rename from app/src/main/java/dev/pinkroom/marketsight/ui/core/util/SelectableDatesImp.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/core/util/SelectableDatesImp.kt index 83ec5c3..41ed8be 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/core/util/SelectableDatesImp.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/util/SelectableDatesImp.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.core.util +package dev.pinkroom.marketsight.presentation.core.util import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.SelectableDates diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/detail_screen/DetailScreen.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/detail_screen/DetailScreen.kt similarity index 91% rename from app/src/main/java/dev/pinkroom/marketsight/ui/detail_screen/DetailScreen.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/detail_screen/DetailScreen.kt index 4ff4581..07cfbc5 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/detail_screen/DetailScreen.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/detail_screen/DetailScreen.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.detail_screen +package dev.pinkroom.marketsight.presentation.detail_screen import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/home_screen/HomeScreen.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeScreen.kt similarity index 91% rename from app/src/main/java/dev/pinkroom/marketsight/ui/home_screen/HomeScreen.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeScreen.kt index 87058cf..81b69f3 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/home_screen/HomeScreen.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeScreen.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.home_screen +package dev.pinkroom.marketsight.presentation.home_screen import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/home_screen/HomeViewModel.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeViewModel.kt similarity index 76% rename from app/src/main/java/dev/pinkroom/marketsight/ui/home_screen/HomeViewModel.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeViewModel.kt index 5421ff5..abad681 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/home_screen/HomeViewModel.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeViewModel.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.home_screen +package dev.pinkroom.marketsight.presentation.home_screen import androidx.lifecycle.ViewModel import dagger.hilt.android.lifecycle.HiltViewModel diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsAction.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/NewsAction.kt similarity index 84% rename from app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsAction.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/NewsAction.kt index 05fb0be..2070c92 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsAction.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/NewsAction.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.news_screen +package dev.pinkroom.marketsight.presentation.news_screen import androidx.annotation.StringRes import androidx.compose.material3.SnackbarDuration diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsEvent.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/NewsEvent.kt similarity index 93% rename from app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsEvent.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/NewsEvent.kt index e43aa23..216b378 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsEvent.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/NewsEvent.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.news_screen +package dev.pinkroom.marketsight.presentation.news_screen import dev.pinkroom.marketsight.common.DateMomentType import dev.pinkroom.marketsight.common.SortType diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/NewsScreen.kt similarity index 94% rename from app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/NewsScreen.kt index 3ea08bf..5318115 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsScreen.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/NewsScreen.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.news_screen +package dev.pinkroom.marketsight.presentation.news_screen import android.content.Context import android.content.Intent @@ -29,15 +29,15 @@ import dev.pinkroom.marketsight.domain.model.news.ImageSize import dev.pinkroom.marketsight.domain.model.news.ImagesNews import dev.pinkroom.marketsight.domain.model.news.NewsFilters import dev.pinkroom.marketsight.domain.model.news.NewsInfo -import dev.pinkroom.marketsight.ui.core.components.PullToRefreshLazyColumn -import dev.pinkroom.marketsight.ui.core.theme.dimens -import dev.pinkroom.marketsight.ui.core.util.reachedBottom -import dev.pinkroom.marketsight.ui.news_screen.components.AllNews -import dev.pinkroom.marketsight.ui.news_screen.components.BottomSheetFilters -import dev.pinkroom.marketsight.ui.news_screen.components.EmptyNewsList -import dev.pinkroom.marketsight.ui.news_screen.components.HeaderListNews -import dev.pinkroom.marketsight.ui.news_screen.components.MainNews -import dev.pinkroom.marketsight.ui.news_screen.components.RealTimeNews +import dev.pinkroom.marketsight.presentation.core.components.PullToRefreshLazyColumn +import dev.pinkroom.marketsight.presentation.core.theme.dimens +import dev.pinkroom.marketsight.presentation.core.util.reachedBottom +import dev.pinkroom.marketsight.presentation.news_screen.components.AllNews +import dev.pinkroom.marketsight.presentation.news_screen.components.BottomSheetFilters +import dev.pinkroom.marketsight.presentation.news_screen.components.EmptyNewsList +import dev.pinkroom.marketsight.presentation.news_screen.components.HeaderListNews +import dev.pinkroom.marketsight.presentation.news_screen.components.MainNews +import dev.pinkroom.marketsight.presentation.news_screen.components.RealTimeNews import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch import java.time.LocalDateTime diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/NewsUiState.kt similarity index 90% rename from app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/NewsUiState.kt index 0198c3c..10a0453 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsUiState.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/NewsUiState.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.news_screen +package dev.pinkroom.marketsight.presentation.news_screen import androidx.annotation.DrawableRes import dev.pinkroom.marketsight.domain.model.news.NewsFilters diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/NewsViewModel.kt similarity index 98% rename from app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/NewsViewModel.kt index 1bd8b49..44f0127 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/NewsViewModel.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/NewsViewModel.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.news_screen +package dev.pinkroom.marketsight.presentation.news_screen import androidx.compose.material3.SnackbarDuration import androidx.lifecycle.ViewModel @@ -20,7 +20,7 @@ import dev.pinkroom.marketsight.domain.model.common.PaginationInfo import dev.pinkroom.marketsight.domain.model.common.SubInfoSymbols import dev.pinkroom.marketsight.domain.model.news.NewsFilters import dev.pinkroom.marketsight.domain.model.news.NewsResponse -import dev.pinkroom.marketsight.domain.use_case.news.ChangeFilterNews +import dev.pinkroom.marketsight.domain.use_case.news.ChangeFilterRealTimeNews import dev.pinkroom.marketsight.domain.use_case.news.GetNews import dev.pinkroom.marketsight.domain.use_case.news.GetRealTimeNews import kotlinx.coroutines.Job @@ -39,7 +39,7 @@ import javax.inject.Inject class NewsViewModel @Inject constructor( private val getRealTimeNews: GetRealTimeNews, private val getNews: GetNews, - private val changeFilterNews: ChangeFilterNews, + private val changeFilterRealTimeNews: ChangeFilterRealTimeNews, private val connectivityObserver: ConnectivityObserver, private val dispatchers: DispatcherProvider, ): ViewModel() { @@ -86,9 +86,9 @@ class NewsViewModel @Inject constructor( private var previousFilters: NewsFilters = uiState.value.filters init { - observeNetworkStatus() initNews() fetchRealTimeNews() + observeNetworkStatus() } fun onEvent(event: NewsEvent) { @@ -121,6 +121,7 @@ class NewsViewModel @Inject constructor( initNewsJob = viewModelScope.launch(dispatchers.IO) { _uiState.update { it.copy(isLoading = true) } paginationInfo = paginationInfo.copy(endReached = false) + val filters = uiState.value.filters val response = getNews( sortType = filters.sortBy, @@ -241,16 +242,16 @@ class NewsViewModel @Inject constructor( private fun revertFilters() = _uiState.update { it.copy(filters = previousFilters, isToShowFilters = false) } - private fun updateNewsWithNewFilters(newFilters: NewsFilters){ + private fun updateNewsWithNewFilters(newFilters: NewsFilters) { initNews() if (previousFilters.symbols != newFilters.symbols) updateFiltersRealTimeNews(newFilters) previousFilters = newFilters } - private fun updateFiltersRealTimeNews(newFilters: NewsFilters){ + private fun updateFiltersRealTimeNews(newFilters: NewsFilters) { viewModelScope.launch(dispatchers.IO) { _uiState.update { it.copy(realTimeNews = emptyList()) } - changeFilterNews( + changeFilterRealTimeNews( subscribeSymbols = newFilters.symbols.filter { it.isSubscribed }.map { it.symbol }, unsubscribeSymbols = newFilters.symbols.filter { !it.isSubscribed }.map { it.symbol } ).collect{ response -> diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/AllNews.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/AllNews.kt similarity index 93% rename from app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/AllNews.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/AllNews.kt index a83a464..edc0b16 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/AllNews.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/AllNews.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.news_screen.components +package dev.pinkroom.marketsight.presentation.news_screen.components import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box @@ -20,8 +20,8 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import dev.pinkroom.marketsight.R import dev.pinkroom.marketsight.domain.model.news.NewsInfo -import dev.pinkroom.marketsight.ui.core.theme.dimens -import dev.pinkroom.marketsight.ui.core.theme.shimmerEffect +import dev.pinkroom.marketsight.presentation.core.theme.dimens +import dev.pinkroom.marketsight.presentation.core.theme.shimmerEffect fun LazyListScope.AllNews( modifier: Modifier = Modifier, diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/AllNewsCard.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/AllNewsCard.kt similarity index 97% rename from app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/AllNewsCard.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/AllNewsCard.kt index 015a721..5ec0d5b 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/AllNewsCard.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/AllNewsCard.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.news_screen.components +package dev.pinkroom.marketsight.presentation.news_screen.components import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement @@ -22,7 +22,7 @@ import androidx.compose.ui.tooling.preview.Preview import dev.pinkroom.marketsight.domain.model.news.ImageSize import dev.pinkroom.marketsight.domain.model.news.ImagesNews import dev.pinkroom.marketsight.domain.model.news.NewsInfo -import dev.pinkroom.marketsight.ui.core.theme.dimens +import dev.pinkroom.marketsight.presentation.core.theme.dimens import java.time.LocalDateTime @Composable diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/BottomSheetFilters.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/BottomSheetFilters.kt similarity index 95% rename from app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/BottomSheetFilters.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/BottomSheetFilters.kt index 0d218d7..08c7403 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/BottomSheetFilters.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/BottomSheetFilters.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.news_screen.components +package dev.pinkroom.marketsight.presentation.news_screen.components import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.ExperimentalFoundationApi @@ -34,12 +34,12 @@ import dev.pinkroom.marketsight.common.DateMomentType import dev.pinkroom.marketsight.common.SortType import dev.pinkroom.marketsight.common.toReadableDate import dev.pinkroom.marketsight.domain.model.common.SubInfoSymbols -import dev.pinkroom.marketsight.ui.core.components.ButtonFilter -import dev.pinkroom.marketsight.ui.core.components.DatePickerComponent -import dev.pinkroom.marketsight.ui.core.components.DefaultSectionFilter -import dev.pinkroom.marketsight.ui.core.theme.Blue -import dev.pinkroom.marketsight.ui.core.theme.dimens -import dev.pinkroom.marketsight.ui.core.util.SelectableDatesImp +import dev.pinkroom.marketsight.presentation.core.components.ButtonFilter +import dev.pinkroom.marketsight.presentation.core.components.DatePickerComponent +import dev.pinkroom.marketsight.presentation.core.components.DefaultSectionFilter +import dev.pinkroom.marketsight.presentation.core.theme.Blue +import dev.pinkroom.marketsight.presentation.core.theme.dimens +import dev.pinkroom.marketsight.presentation.core.util.SelectableDatesImp import java.time.LocalDate @OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class) diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/EmptyNewsList.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/EmptyNewsList.kt similarity index 92% rename from app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/EmptyNewsList.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/EmptyNewsList.kt index 9910814..100c988 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/EmptyNewsList.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/EmptyNewsList.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.news_screen.components +package dev.pinkroom.marketsight.presentation.news_screen.components import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -16,7 +16,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import dev.pinkroom.marketsight.R -import dev.pinkroom.marketsight.ui.core.theme.dimens +import dev.pinkroom.marketsight.presentation.core.theme.dimens @Composable fun EmptyNewsList( diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/HeaderListNews.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/HeaderListNews.kt similarity index 93% rename from app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/HeaderListNews.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/HeaderListNews.kt index abad84a..f24fde7 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/HeaderListNews.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/HeaderListNews.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.news_screen.components +package dev.pinkroom.marketsight.presentation.news_screen.components import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -15,7 +15,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import dev.pinkroom.marketsight.R -import dev.pinkroom.marketsight.ui.core.theme.dimens +import dev.pinkroom.marketsight.presentation.core.theme.dimens @Composable fun HeaderListNews( diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/ImageNews.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/ImageNews.kt similarity index 88% rename from app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/ImageNews.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/ImageNews.kt index 7e86464..1bc3b1b 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/ImageNews.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/ImageNews.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.news_screen.components +package dev.pinkroom.marketsight.presentation.news_screen.components import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Box @@ -9,7 +9,7 @@ import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.res.painterResource import coil.compose.SubcomposeAsyncImage import dev.pinkroom.marketsight.R -import dev.pinkroom.marketsight.ui.core.theme.shimmerEffect +import dev.pinkroom.marketsight.presentation.core.theme.shimmerEffect @Composable fun ImageNews( diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/IndicatorPageCarousel.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/IndicatorPageCarousel.kt similarity index 91% rename from app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/IndicatorPageCarousel.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/IndicatorPageCarousel.kt index 25c9640..2fcb23e 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/IndicatorPageCarousel.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/IndicatorPageCarousel.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.news_screen.components +package dev.pinkroom.marketsight.presentation.news_screen.components import androidx.compose.animation.core.tween import androidx.compose.foundation.ExperimentalFoundationApi @@ -20,9 +20,9 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import dev.pinkroom.marketsight.common.Constants -import dev.pinkroom.marketsight.ui.core.theme.PhilippineGray -import dev.pinkroom.marketsight.ui.core.theme.PhilippineSilver -import dev.pinkroom.marketsight.ui.core.theme.dimens +import dev.pinkroom.marketsight.presentation.core.theme.PhilippineGray +import dev.pinkroom.marketsight.presentation.core.theme.PhilippineSilver +import dev.pinkroom.marketsight.presentation.core.theme.dimens import kotlinx.coroutines.launch @OptIn(ExperimentalFoundationApi::class) diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNews.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/MainNews.kt similarity index 95% rename from app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNews.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/MainNews.kt index 01953ab..86f3dc1 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNews.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/MainNews.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.news_screen.components +package dev.pinkroom.marketsight.presentation.news_screen.components import androidx.compose.animation.core.tween import androidx.compose.foundation.ExperimentalFoundationApi @@ -28,8 +28,8 @@ import androidx.compose.ui.util.lerp import dev.pinkroom.marketsight.common.Constants import dev.pinkroom.marketsight.domain.model.news.NewsInfo import dev.pinkroom.marketsight.domain.model.news.getAspectRatio -import dev.pinkroom.marketsight.ui.core.theme.dimens -import dev.pinkroom.marketsight.ui.core.theme.shimmerEffect +import dev.pinkroom.marketsight.presentation.core.theme.dimens +import dev.pinkroom.marketsight.presentation.core.theme.shimmerEffect import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlin.math.absoluteValue diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNewsCard.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/MainNewsCard.kt similarity index 95% rename from app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNewsCard.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/MainNewsCard.kt index ceed469..a29bcc2 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/MainNewsCard.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/MainNewsCard.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.news_screen.components +package dev.pinkroom.marketsight.presentation.news_screen.components import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -33,9 +33,9 @@ import dev.pinkroom.marketsight.domain.model.news.ImageSize import dev.pinkroom.marketsight.domain.model.news.ImagesNews import dev.pinkroom.marketsight.domain.model.news.NewsInfo import dev.pinkroom.marketsight.domain.model.news.getAspectRatio -import dev.pinkroom.marketsight.ui.core.theme.Black -import dev.pinkroom.marketsight.ui.core.theme.White -import dev.pinkroom.marketsight.ui.core.theme.dimens +import dev.pinkroom.marketsight.presentation.core.theme.Black +import dev.pinkroom.marketsight.presentation.core.theme.White +import dev.pinkroom.marketsight.presentation.core.theme.dimens import java.time.LocalDateTime @Composable diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/RealTimeNews.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/RealTimeNews.kt similarity index 95% rename from app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/RealTimeNews.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/RealTimeNews.kt index f583189..495b73f 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/RealTimeNews.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/RealTimeNews.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.news_screen.components +package dev.pinkroom.marketsight.presentation.news_screen.components import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.core.Spring @@ -35,8 +35,8 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import dev.pinkroom.marketsight.R import dev.pinkroom.marketsight.domain.model.news.NewsInfo -import dev.pinkroom.marketsight.ui.core.theme.Red -import dev.pinkroom.marketsight.ui.core.theme.dimens +import dev.pinkroom.marketsight.presentation.core.theme.Red +import dev.pinkroom.marketsight.presentation.core.theme.dimens @Composable fun RealTimeNews( diff --git a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/RealTimeNewsCard.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/RealTimeNewsCard.kt similarity index 96% rename from app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/RealTimeNewsCard.kt rename to app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/RealTimeNewsCard.kt index 99b87e0..49e11e2 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/ui/news_screen/components/RealTimeNewsCard.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/news_screen/components/RealTimeNewsCard.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.ui.news_screen.components +package dev.pinkroom.marketsight.presentation.news_screen.components import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement @@ -23,7 +23,7 @@ import androidx.compose.ui.tooling.preview.Preview import dev.pinkroom.marketsight.domain.model.news.ImageSize import dev.pinkroom.marketsight.domain.model.news.ImagesNews import dev.pinkroom.marketsight.domain.model.news.NewsInfo -import dev.pinkroom.marketsight.ui.core.theme.dimens +import dev.pinkroom.marketsight.presentation.core.theme.dimens import java.time.LocalDateTime @Composable diff --git a/app/src/test/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSourceTest.kt b/app/src/test/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSourceTest.kt index 4ff5fd8..eefb259 100644 --- a/app/src/test/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSourceTest.kt +++ b/app/src/test/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSourceTest.kt @@ -59,17 +59,23 @@ class NewsRemoteDataSourceTest { ) @Test - fun `Given params, when init subscribe news with all topics, then sendMessage is called with correct params`() = runTest { + fun `When call on getRealTimeNews twice, then in just in 1 time need to subscribe symbols`() = runTest { // GIVEN - mockStartAlpacaServiceWithSuccess() - val symbols = listOf("*") + val listNews = newsFactory.buildList() + mockNewsServiceWithOpenConnection() + mockNewsServiceWithSuccess(newsList = listNews) // WHEN - alpacaRemoteDataSource.subscribeNews(symbols = symbols).firstOrNull() + var response = alpacaRemoteDataSource.getRealTimeNews().first() + assertThat(response).isNotEmpty() + response = alpacaRemoteDataSource.getRealTimeNews().first() + assertThat(response).isNotEmpty() // THEN - val expectedMessageArgs = MessageAlpacaService(action = ActionAlpaca.Subscribe.action, news = symbols) - verify { alpacaNewsService.sendMessage(message = expectedMessageArgs) } + val expectedMessageToSubscribe = MessageAlpacaService( + action = ActionAlpaca.Subscribe.action, news = listOf("*"), + ) + verify(exactly = 1) { alpacaNewsService.sendMessage(expectedMessageToSubscribe) } } @Test @@ -181,6 +187,12 @@ class NewsRemoteDataSourceTest { ) } + private fun mockNewsServiceWithOpenConnection(){ + every { alpacaNewsService.observeOnConnectionEvent() }.returns( + flow { emit(WebSocket.Event.OnConnectionOpened(webSocket = Any())) } + ) + } + private fun mockNewsServiceWithSuccess(newsList: List) { every { alpacaNewsService.observeResponse() }.returns( flow { @@ -208,16 +220,6 @@ class NewsRemoteDataSourceTest { ) } - private fun mockStartAlpacaServiceWithSuccess() { - every { alpacaNewsService.sendMessage(any()) }.returns(Unit) - - every { alpacaNewsService.observeOnConnectionEvent() }.returns( - flow { - emit(WebSocket.Event.OnConnectionOpened(webSocket = Any())) - } - ) - } - private fun mockMessageSubscriptionServiceWithSuccess(messageAlpacaService: MessageAlpacaService) { val returnedMessageService = SubscriptionMessageDto( type = "subscription", diff --git a/app/src/test/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryTest.kt b/app/src/test/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryTest.kt index 7f743ad..4032aaf 100644 --- a/app/src/test/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryTest.kt +++ b/app/src/test/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryTest.kt @@ -5,7 +5,6 @@ import assertk.assertions.isEqualTo import assertk.assertions.isNotEmpty import assertk.assertions.isTrue import com.github.javafaker.Faker -import com.tinder.scarlet.WebSocket import dev.pinkroom.marketsight.common.ActionAlpaca import dev.pinkroom.marketsight.common.Resource import dev.pinkroom.marketsight.common.SortType @@ -47,18 +46,6 @@ class NewsRepositoryTest{ dispatchers = dispatchers, ) - @Test - fun `Given params, when init subscribe news, then subscribeNews is called with correct params and emit values`() = runTest { - // GIVEN - mockSubscribeNewsWithSuccess() - - // WHEN - val response = newsRepository.subscribeNews().first() - - // THEN - assertThat(response is Resource.Success).isTrue() - } - @Test fun `When receive message on getRealTimeNews, then emit NewsInfo class`() = runTest { // GIVEN @@ -138,7 +125,7 @@ class NewsRepositoryTest{ mockMessageSubscriptionServiceWithSuccess(messageToSend) // WHEN - val response = newsRepository.changeFilterNews(symbols = messageToSend.news!!, actionAlpaca = ActionAlpaca.Subscribe) + val response = newsRepository.changeFilterRealTimeNews(symbols = messageToSend.news!!, actionAlpaca = ActionAlpaca.Subscribe) // THEN verify { newsRemoteDataSource.sendSubscribeMessageToAlpacaService(message = messageToSend) } @@ -154,7 +141,7 @@ class NewsRepositoryTest{ mockMessageSubscriptionServiceWithError() // WHEN - val response = newsRepository.changeFilterNews(symbols = messageToSend.news!!, actionAlpaca = ActionAlpaca.Subscribe) + val response = newsRepository.changeFilterRealTimeNews(symbols = messageToSend.news!!, actionAlpaca = ActionAlpaca.Subscribe) // THEN verify { newsRemoteDataSource.sendSubscribeMessageToAlpacaService(message = messageToSend) } @@ -201,14 +188,6 @@ class NewsRepositoryTest{ ) } - private fun mockSubscribeNewsWithSuccess(){ - every { newsRemoteDataSource.subscribeNews(any()) }.returns( - flow { - emit(Resource.Success(data = WebSocket.Event.OnConnectionOpened(webSocket = Any()))) - } - ) - } - private fun mockMessageSubscriptionServiceWithSuccess(messageAlpacaService: MessageAlpacaService) { val returnedMessageService = SubscriptionMessageDto( type = "subscription", diff --git a/app/src/test/java/dev/pinkroom/marketsight/domain/use_case/news/ChangeFilterNewsTest.kt b/app/src/test/java/dev/pinkroom/marketsight/domain/use_case/news/ChangeFilterRealTimeNewsTest.kt similarity index 86% rename from app/src/test/java/dev/pinkroom/marketsight/domain/use_case/news/ChangeFilterNewsTest.kt rename to app/src/test/java/dev/pinkroom/marketsight/domain/use_case/news/ChangeFilterRealTimeNewsTest.kt index 0ab95d6..19d1fd9 100644 --- a/app/src/test/java/dev/pinkroom/marketsight/domain/use_case/news/ChangeFilterNewsTest.kt +++ b/app/src/test/java/dev/pinkroom/marketsight/domain/use_case/news/ChangeFilterRealTimeNewsTest.kt @@ -20,14 +20,14 @@ import org.junit.Rule import org.junit.Test @ExperimentalCoroutinesApi -class ChangeFilterNewsTest{ +class ChangeFilterRealTimeNewsTest{ @get:Rule val coroutineRule = MainCoroutineRule() private val dispatchers = TestDispatcherProvider() private val newsRepository = mockk(relaxed = true, relaxUnitFun = true) - private val changeFilterNews = ChangeFilterNews( + private val changeFilterRealTimeNews = ChangeFilterRealTimeNews( newsRepository = newsRepository, dispatchers = dispatchers, ) @@ -40,20 +40,20 @@ class ChangeFilterNewsTest{ mockChangeFilterNewsSuccess(subscribeSymbols) // WHEN - val response = changeFilterNews( + val response = changeFilterRealTimeNews( subscribeSymbols = subscribeSymbols, unsubscribeSymbols = unsubscribeSymbols ).toList() // THEN coVerify { - newsRepository.changeFilterNews( + newsRepository.changeFilterRealTimeNews( symbols = unsubscribeSymbols, actionAlpaca = ActionAlpaca.Unsubscribe, ) } coVerify { - newsRepository.changeFilterNews( + newsRepository.changeFilterRealTimeNews( symbols = subscribeSymbols, actionAlpaca = ActionAlpaca.Subscribe, ) @@ -79,20 +79,20 @@ class ChangeFilterNewsTest{ ) // WHEN - val response = changeFilterNews( + val response = changeFilterRealTimeNews( subscribeSymbols = subscribeSymbols, unsubscribeSymbols = unsubscribeSymbols ).last() // THEN coVerify { - newsRepository.changeFilterNews( + newsRepository.changeFilterRealTimeNews( symbols = unsubscribeSymbols, actionAlpaca = ActionAlpaca.Unsubscribe, ) } coVerify { - newsRepository.changeFilterNews( + newsRepository.changeFilterRealTimeNews( symbols = subscribeSymbols, actionAlpaca = ActionAlpaca.Subscribe, ) @@ -106,7 +106,7 @@ class ChangeFilterNewsTest{ private fun mockChangeFilterNewsSuccess( subscribedSymbols: List, ){ - coEvery { newsRepository.changeFilterNews(any(),any()) }.returnsMany( + coEvery { newsRepository.changeFilterRealTimeNews(any(),any()) }.returnsMany( Resource.Success(data = emptyList()), Resource.Success(data = subscribedSymbols) ) } @@ -115,7 +115,7 @@ class ChangeFilterNewsTest{ subscribedSymbols: List, unsubscribedSymbols: List, ){ - coEvery { newsRepository.changeFilterNews(any(),any()) }.returns( + coEvery { newsRepository.changeFilterRealTimeNews(any(),any()) }.returns( Resource.Error(data = subscribedSymbols + unsubscribedSymbols) ) } diff --git a/app/src/test/java/dev/pinkroom/marketsight/presentation/news_screen/NewsViewModelTest.kt b/app/src/test/java/dev/pinkroom/marketsight/presentation/news_screen/NewsViewModelTest.kt new file mode 100644 index 0000000..69816b2 --- /dev/null +++ b/app/src/test/java/dev/pinkroom/marketsight/presentation/news_screen/NewsViewModelTest.kt @@ -0,0 +1,678 @@ +package dev.pinkroom.marketsight.presentation.news_screen + +import app.cash.turbine.test +import assertk.assertThat +import assertk.assertions.isEmpty +import assertk.assertions.isEqualTo +import assertk.assertions.isFalse +import assertk.assertions.isGreaterThan +import assertk.assertions.isInstanceOf +import assertk.assertions.isNotEmpty +import assertk.assertions.isNotEqualTo +import assertk.assertions.isNotNull +import assertk.assertions.isTrue +import dev.pinkroom.marketsight.common.Constants.ALL_SYMBOLS +import dev.pinkroom.marketsight.common.Constants.LIMIT_NEWS +import dev.pinkroom.marketsight.common.Constants.MAX_ITEMS_CAROUSEL +import dev.pinkroom.marketsight.common.DateMomentType +import dev.pinkroom.marketsight.common.Resource +import dev.pinkroom.marketsight.common.SortType +import dev.pinkroom.marketsight.common.atEndOfTheDay +import dev.pinkroom.marketsight.common.connection_network.ConnectivityObserver +import dev.pinkroom.marketsight.data.mapper.toNewsInfo +import dev.pinkroom.marketsight.domain.model.news.NewsFilters +import dev.pinkroom.marketsight.domain.model.news.NewsInfo +import dev.pinkroom.marketsight.domain.model.news.NewsResponse +import dev.pinkroom.marketsight.domain.use_case.news.ChangeFilterRealTimeNews +import dev.pinkroom.marketsight.domain.use_case.news.GetNews +import dev.pinkroom.marketsight.domain.use_case.news.GetRealTimeNews +import dev.pinkroom.marketsight.factories.NewsDtoFactory +import dev.pinkroom.marketsight.util.MainCoroutineRule +import dev.pinkroom.marketsight.util.TestDispatcherProvider +import io.mockk.coEvery +import io.mockk.coVerify +import io.mockk.mockk +import io.mockk.verify +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.delay +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.test.advanceUntilIdle +import kotlinx.coroutines.test.runTest +import org.junit.Rule +import org.junit.Test +import java.time.Instant +import java.time.ZoneOffset + +@ExperimentalCoroutinesApi +class NewsViewModelTest{ + + @get:Rule + val coroutineRule = MainCoroutineRule() + + private val dispatchers = TestDispatcherProvider() + private val getNews = mockk(relaxed = true, relaxUnitFun = true) + private val getRealTimeNews = mockk(relaxed = true, relaxUnitFun = true) + private val changeFilterRealTimeNews = mockk(relaxed = true, relaxUnitFun = true) + private val connectivityObserver = mockk(relaxed = true, relaxUnitFun = true) + private lateinit var newsViewModel: NewsViewModel + + private fun initViewModel() { + newsViewModel = NewsViewModel( + getNews = getNews, + getRealTimeNews = getRealTimeNews, + changeFilterRealTimeNews = changeFilterRealTimeNews, + connectivityObserver = connectivityObserver, + dispatchers = dispatchers, + ) + } + + @Test + fun `Given access to Net, When init VM, Then Success on Get News and RealTime News`() = runTest { + // GIVEN + val news = NewsDtoFactory().buildList(number = LIMIT_NEWS).map { it.toNewsInfo() } + mockResponseGetNewsSuccess(news) + mockGetRealTimeNews(news) + + // WHEN + initViewModel() + advanceUntilIdle() + + // THEN + val uiState = newsViewModel.uiState.value + val filters = uiState.filters + + coVerify { + getNews.invoke( + pageToken = any(), limitPerPage = any(), sortType = filters.sortBy, + symbols = filters.getSubscribedSymbols(), + startDate = filters.startDateSort?.atStartOfDay(), + endDate = filters.endDateSort?.atEndOfTheDay(), + ) + } + assertThat(uiState.news).isNotEmpty() + assertThat(uiState.mainNews).isNotEmpty() + assertThat(uiState.isLoading).isFalse() + assertThat(uiState.mainNews).isEqualTo(news.take(MAX_ITEMS_CAROUSEL)) + assertThat(uiState.news).isEqualTo(news.drop(MAX_ITEMS_CAROUSEL)) + + coVerify { getRealTimeNews.invoke() } + assertThat(uiState.realTimeNews).isNotEmpty() + } + + @Test + fun `Start Without Net, When init VM, Then Error on Get News`() = runTest { + // GIVEN + mockResponseGetNewsError() + + // WHEN + initViewModel() + advanceUntilIdle() + + // THEN + val uiState = newsViewModel.uiState.value + + coVerify { + getNews.invoke( + pageToken = any(), limitPerPage = any(), sortType = any(), + symbols = any(), startDate = any(), endDate = any(), + ) + } + assertThat(uiState.news).isEmpty() + assertThat(uiState.mainNews).isEmpty() + assertThat(uiState.isLoading).isFalse() + assertThat(uiState.mainNews).isEmpty() + assertThat(uiState.news).isEmpty() + assertThat(uiState.errorMessage).isNotNull() + } + + @Test + fun `Given without Net, When init VM, Then it gets net and automatically calls GetNews`() = runTest { + // GIVEN + val news = NewsDtoFactory().buildList(number = LIMIT_NEWS).map { it.toNewsInfo() } + mockNetwork() + mockResponseGetNewsErrorThenSuccess(news) + + // WHEN + initViewModel() + + // THEN + newsViewModel.uiState.test { + var item = awaitItem() + assertThat(item.isLoading).isTrue() + item = awaitItem() + assertThat(item.isLoading).isFalse() + assertThat(item.news).isEmpty() + assertThat(item.errorMessage).isNotNull() + } + advanceUntilIdle() + val uiState = newsViewModel.uiState.value + + coVerify(exactly = 2) { + getNews.invoke() + } + assertThat(uiState.news).isNotEmpty() + assertThat(uiState.mainNews).isNotEmpty() + assertThat(uiState.isLoading).isFalse() + assertThat(uiState.mainNews).isEqualTo(news.take(MAX_ITEMS_CAROUSEL)) + assertThat(uiState.news).isEqualTo(news.drop(MAX_ITEMS_CAROUSEL)) + } + + @Test + fun `When RetryNews event, then init news`() = runTest { + // GIVEN + initViewModel() + val news = NewsDtoFactory().buildList(number = LIMIT_NEWS).map { it.toNewsInfo() } + mockResponseGetNewsSuccess(news) + + // WHEN + newsViewModel.onEvent(event = NewsEvent.RetryNews) + + // THEN + advanceUntilIdle() + val uiState = newsViewModel.uiState.value + + coVerify { + getNews.invoke( + pageToken = any(), limitPerPage = any(), sortType = any(), + symbols = any(), startDate = any(), endDate = any(), + ) + } + assertThat(uiState.news).isNotEmpty() + assertThat(uiState.mainNews).isNotEmpty() + assertThat(uiState.isLoading).isFalse() + assertThat(uiState.mainNews).isEqualTo(news.take(MAX_ITEMS_CAROUSEL)) + assertThat(uiState.news).isEqualTo(news.drop(MAX_ITEMS_CAROUSEL)) + } + + @Test + fun `When request for news is running, Then if the call is made again it is ignored`() = runTest { + // GIVEN + initViewModel() + + // WHEN + newsViewModel.onEvent(event = NewsEvent.RetryNews) + newsViewModel.onEvent(event = NewsEvent.RetryNews) + + // THEN + advanceUntilIdle() + + coVerify(exactly = 1) { + getNews.invoke( + pageToken = any(), limitPerPage = any(), sortType = any(), + symbols = any(), startDate = any(), endDate = any(), + ) + } + } + + @Test + fun `When RetryRealTimeNewsSubscribe event is called, then send request to service`() = runTest { + // GIVEN + initViewModel() + val filters = newsViewModel.uiState.value.filters + + // WHEN + newsViewModel.onEvent(event = NewsEvent.RetryRealTimeNewsSubscribe) + + // THEN + advanceUntilIdle() + + coVerify { + changeFilterRealTimeNews.invoke( + subscribeSymbols = filters.symbols.filter { it.isSubscribed }.map { it.symbol }, + unsubscribeSymbols = filters.symbols.filter { !it.isSubscribed }.map { it.symbol }, + ) + } + } + + @Test + fun `When RetryRealTimeNewsSubscribe event is called, then receive Error from service and send Action to show SnackBar`() = runTest { + // GIVEN + initViewModel() + val filters = newsViewModel.uiState.value.filters + mockChangeFilterRealTimeNewsError() + + // WHEN + newsViewModel.onEvent(event = NewsEvent.RetryRealTimeNewsSubscribe) + + // THEN + advanceUntilIdle() + + coVerify { + changeFilterRealTimeNews.invoke( + subscribeSymbols = filters.symbols.filter { it.isSubscribed }.map { it.symbol }, + unsubscribeSymbols = filters.symbols.filter { !it.isSubscribed }.map { it.symbol }, + ) + } + val action = newsViewModel.action.first() + assertThat(action).isInstanceOf(NewsAction.ShowSnackBar::class.java) + } + + @Test + fun `When RefreshNews event is called, then call init news`() = runTest { + // GIVEN + initViewModel() + advanceUntilIdle() + + // WHEN + newsViewModel.onEvent(event = NewsEvent.RefreshNews) + + // THEN + newsViewModel.uiState.test { + val uiState = awaitItem() + assertThat(uiState.isRefreshing).isTrue() + } + + coVerify { + getNews.invoke( + pageToken = any(), limitPerPage = any(), sortType = any(), + symbols = any(), startDate = any(), endDate = any(), + ) + } + } + + @Test + fun `When LoadMoreNews event is called, then get news`() = runTest { + // GIVEN + val news = NewsDtoFactory().buildList(number = LIMIT_NEWS).map { it.toNewsInfo() } + val nextToken = "RandomStringToken" + mockResponseGetNewsSuccess(news = news, nextPageToken = nextToken) + initViewModel() + advanceUntilIdle() + + // WHEN + newsViewModel.onEvent(event = NewsEvent.LoadMoreNews) + advanceUntilIdle() + + // THEN + val uiState = newsViewModel.uiState.value + + coVerify(exactly = 2) { + getNews.invoke( + pageToken = any(), limitPerPage = any(), sortType = any(), + symbols = any(), startDate = any(), endDate = any(), + ) + } + assertThat(uiState.news.size).isGreaterThan(news.size) + } + + @Test + fun `When LoadMoreNews event is called twice, then just one call to get news`() = runTest { + // GIVEN + val news = NewsDtoFactory().buildList(number = LIMIT_NEWS).map { it.toNewsInfo() } + val nextToken = "RandomStringToken" + mockResponseGetNewsSuccess(news = news, nextPageToken = nextToken) + initViewModel() + advanceUntilIdle() + + // WHEN + newsViewModel.onEvent(event = NewsEvent.LoadMoreNews) + newsViewModel.onEvent(event = NewsEvent.LoadMoreNews) + advanceUntilIdle() + + // THEN + coVerify(exactly = 2) { // IS 2 BECAUSE ON INIT VIEWMODEL IS CALLED GET NEWS + getNews.invoke( + pageToken = any(), limitPerPage = any(), sortType = any(), + symbols = any(), startDate = any(), endDate = any(), + ) + } + } + + @Test + fun `When LoadMoreNews event is called but end is reached, then just ignore`() = runTest { + // GIVEN + val news = NewsDtoFactory().buildList(number = LIMIT_NEWS).map { it.toNewsInfo() } + mockResponseGetNewsSuccess(news = news, nextPageToken = null) + initViewModel() + advanceUntilIdle() + + // WHEN + newsViewModel.onEvent(event = NewsEvent.LoadMoreNews) + + // THEN + coVerify(exactly = 1) { // IS 1 BECAUSE ON INIT VIEWMODEL IS CALLED GET NEWS + getNews.invoke( + pageToken = any(), limitPerPage = any(), sortType = any(), + symbols = any(), startDate = any(), endDate = any(), + ) + } + } + + @Test + fun `When ShowOrHideFilters event is called, Then change isToShowFilters`() = runTest { + // GIVEN + initViewModel() + advanceUntilIdle() + val isToShow = true + + // WHEN + newsViewModel.onEvent(event = NewsEvent.ShowOrHideFilters(isToShow = isToShow)) + + // THEN + val uiState = newsViewModel.uiState.value + assertThat(uiState.isToShowFilters).isEqualTo(isToShow) + } + + @Test + fun `When ShowOrHideFilters event is called but is loading, Then show filters is false`() = runTest { + // GIVEN + val news = NewsDtoFactory().buildList(number = LIMIT_NEWS).map { it.toNewsInfo() } + mockResponseGetNewsSuccess(news = news, nextPageToken = null) + val isToShow = true + + // WHEN + initViewModel() + newsViewModel.onEvent(event = NewsEvent.ShowOrHideFilters(isToShow = isToShow)) + advanceUntilIdle() + + // THEN + val uiState = newsViewModel.uiState.value + assertThat(uiState.isToShowFilters).isEqualTo(!isToShow) + } + + @Test + fun `When ChangeSort event is called, Then update filters in uiState`() = runTest { + // GIVEN + initViewModel() + val newSort = SortType.ASC + + // WHEN + newsViewModel.onEvent(event = NewsEvent.ChangeSort(sort = newSort)) + advanceUntilIdle() + + // THEN + val filters = newsViewModel.uiState.value.filters + assertThat(filters.sortBy).isEqualTo(newSort) + } + + @Test + fun `When ChangeSymbol event is called, Then update filters in uiState`() = runTest { + // GIVEN + initViewModel() + val allSymbols = newsViewModel.uiState.value.filters.symbols + val newSymbolToChange = allSymbols.last() + + // WHEN + newsViewModel.onEvent(event = NewsEvent.ChangeSymbol(symbolToChange = newSymbolToChange)) + advanceUntilIdle() + + // THEN + val symbols = newsViewModel.uiState.value.filters.symbols + val lastSymbol = symbols.last() + val all = symbols.find { it.name == ALL_SYMBOLS } + assertThat(lastSymbol.isSubscribed).isNotEqualTo(newSymbolToChange.isSubscribed) + assertThat(all!!.isSubscribed).isFalse() + } + + @Test + fun `When ChangeSymbol event is called to unsubscribe last subscribed symbol, Then all symbol is subscribed`() = runTest { + // GIVEN + initViewModel() + newsViewModel.onEvent(event = NewsEvent.ChangeSymbol(symbolToChange = newsViewModel.uiState.value.filters.symbols.last())) // SUBSCRIBE LAST + advanceUntilIdle() + + // WHEN + newsViewModel.onEvent(event = NewsEvent.ChangeSymbol(symbolToChange = newsViewModel.uiState.value.filters.symbols.last())) // UNSUBSCRIBE LAST + advanceUntilIdle() + + // THEN + val symbols = newsViewModel.uiState.value.filters.symbols + val lastSymbol = symbols.last() + val all = symbols.find { it.name == ALL_SYMBOLS } + assertThat(lastSymbol.isSubscribed).isFalse() + assertThat(all!!.isSubscribed).isTrue() + } + + @Test + fun `When ChangeSymbol event is called to subscribe ALL, Then all symbol is subscribed and other items are unsubscribed`() = runTest { + // GIVEN + initViewModel() + val symbolToChange = newsViewModel.uiState.value.filters.symbols.size - 1 + newsViewModel.onEvent(event = NewsEvent.ChangeSymbol(symbolToChange = newsViewModel.uiState.value.filters.symbols.elementAt(symbolToChange))) + newsViewModel.onEvent(event = NewsEvent.ChangeSymbol(symbolToChange = newsViewModel.uiState.value.filters.symbols.last())) + advanceUntilIdle() + + // WHEN + var symbols = newsViewModel.uiState.value.filters.symbols + var all = symbols.find { it.name == ALL_SYMBOLS } + newsViewModel.onEvent(event = NewsEvent.ChangeSymbol(symbolToChange = all!!)) // SUBSCRIBE ALL + advanceUntilIdle() + + // THEN + symbols = newsViewModel.uiState.value.filters.symbols + all = symbols.find { it.name == ALL_SYMBOLS } + assertThat(all!!.isSubscribed).isTrue() + assertThat(symbols.count { it.isSubscribed }).isEqualTo(1) + } + + @Test + fun `When ChangeDate event is called, Then update date`() = runTest { + // GIVEN + initViewModel() + val dateInMillis = 1714399712434L + + // WHEN + newsViewModel.onEvent(event = NewsEvent.ChangeDate(newDateInMillis = dateInMillis, dateMomentType = DateMomentType.Start)) + newsViewModel.onEvent(event = NewsEvent.ChangeDate(newDateInMillis = dateInMillis, dateMomentType = DateMomentType.End)) + advanceUntilIdle() + + // THEN + val expectedDate = Instant.ofEpochMilli(dateInMillis).atZone(ZoneOffset.UTC).toLocalDate() + val filters = newsViewModel.uiState.value.filters + assertThat(filters.startDateSort).isEqualTo(expectedDate) + assertThat(filters.endDateSort).isEqualTo(expectedDate) + } + + @Test + fun `When ApplyFilters event is called, Then update news with new filters`() = runTest { + // GIVEN + initViewModel() + val dateInMillis = 1714399712434L + + // WHEN + newsViewModel.onEvent(event = NewsEvent.ChangeDate(newDateInMillis = dateInMillis, dateMomentType = DateMomentType.Start)) + newsViewModel.onEvent(event = NewsEvent.ChangeSymbol(symbolToChange = newsViewModel.uiState.value.filters.symbols.last())) + advanceUntilIdle() + newsViewModel.onEvent(event = NewsEvent.ApplyFilters) + advanceUntilIdle() + + // THEN + val expectedDate = Instant.ofEpochMilli(dateInMillis).atZone(ZoneOffset.UTC).toLocalDate() + coVerify(exactly = 2) { + getNews.invoke( + startDate = expectedDate.atStartOfDay(), + symbols = listOf(newsViewModel.uiState.value.filters.symbols.last().symbol), + pageToken = any(), endDate = any(), sortType = any() + ) + } + verify { + changeFilterRealTimeNews.invoke( + subscribeSymbols = any(), + unsubscribeSymbols = any(), + ) + } + } + + @Test + fun `When ApplyFilters event is called and filters are the same, Then just ignore`() = runTest { + // GIVEN + initViewModel() + + // WHEN + newsViewModel.onEvent(event = NewsEvent.ApplyFilters) + advanceUntilIdle() + + // THEN + coVerify(exactly = 1) { // 1 is because GetNews is called in INIT + getNews.invoke() + } + verify(exactly = 0) { + changeFilterRealTimeNews.invoke() + } + } + + @Test + fun `When ApplyFilters event is called and filters don't change in symbols, Then real time changeFilterRealTimeNews is not called`() = runTest { + // GIVEN + initViewModel() + val dateInMillis = 1714399712434L + + // WHEN + newsViewModel.onEvent(event = NewsEvent.ChangeDate(newDateInMillis = dateInMillis, dateMomentType = DateMomentType.Start)) + newsViewModel.onEvent(event = NewsEvent.ApplyFilters) + advanceUntilIdle() + + // THEN + coVerify(exactly = 2) { + getNews.invoke( + startDate = any() + ) + } + verify(exactly = 0) { + changeFilterRealTimeNews.invoke() + } + } + + @Test + fun `When ClearAllFilters event is called, Then update news related to base filters`() = runTest { + // GIVEN + initViewModel() + val dateInMillis = 1714399712434L + + // WHEN + newsViewModel.onEvent(event = NewsEvent.ChangeDate(newDateInMillis = dateInMillis, dateMomentType = DateMomentType.Start)) + newsViewModel.onEvent(event = NewsEvent.ApplyFilters) + newsViewModel.onEvent(event = NewsEvent.ClearAllFilters) + advanceUntilIdle() + + // THEN + val uiState = newsViewModel.uiState.value + assertThat(uiState.isToShowFilters).isFalse() + assertThat(uiState.filters).isEqualTo(NewsFilters()) + coVerify(exactly = 3) { + getNews.invoke( + startDate = any() + ) + } + } + + @Test + fun `When ClearAllFilters event is called but the filters applied are the base filters, Then just close the bottom sheet`() = runTest { + // GIVEN + initViewModel() + val dateInMillis = 1714399712434L + + // WHEN + newsViewModel.onEvent(event = NewsEvent.ChangeDate(newDateInMillis = dateInMillis, dateMomentType = DateMomentType.Start)) + newsViewModel.onEvent(event = NewsEvent.ClearAllFilters) + advanceUntilIdle() + + // THEN + val uiState = newsViewModel.uiState.value + assertThat(uiState.isToShowFilters).isFalse() + assertThat(uiState.filters).isEqualTo(NewsFilters()) + coVerify(exactly = 1) { + getNews.invoke() + } + } + + @Test + fun `When RevertFilters event is called, Then just revert filters to last filters`() = runTest { + // GIVEN + initViewModel() + val dateInMillis = 1714399712434L + + // WHEN + newsViewModel.onEvent(event = NewsEvent.ChangeDate(newDateInMillis = dateInMillis, dateMomentType = DateMomentType.Start)) + newsViewModel.onEvent(event = NewsEvent.ApplyFilters) + advanceUntilIdle() + val lastFilters = newsViewModel.uiState.value.filters + + newsViewModel.onEvent(event = NewsEvent.ChangeDate(newDateInMillis = null, dateMomentType = DateMomentType.Start)) + newsViewModel.onEvent(event = NewsEvent.RevertFilters) + advanceUntilIdle() + + // THEN + val uiState = newsViewModel.uiState.value + assertThat(uiState.isToShowFilters).isFalse() + assertThat(uiState.filters).isEqualTo(lastFilters) + } + + private fun mockChangeFilterRealTimeNewsError() { + coEvery { + changeFilterRealTimeNews.invoke( + subscribeSymbols = any(), + unsubscribeSymbols = any(), + ) + }.returns( + flow { + emit(Resource.Error(message = "Error")) + } + ) + } + + private fun mockResponseGetNewsSuccess( + news: List, + nextPageToken: String? = null, + ) { + coEvery { + getNews.invoke( + pageToken = any(), limitPerPage = any(), sortType = any(), + symbols = any(), startDate = any(), endDate = any(), + ) + }.coAnswers { + delay(1000) + Resource.Success(data = NewsResponse(news = news, nextPageToken = nextPageToken)) + } + } + + private fun mockResponseGetNewsError() { + coEvery { + getNews.invoke( + pageToken = any(), limitPerPage = any(), sortType = any(), + symbols = any(), startDate = any(), endDate = any(), + ) + }.returns( + Resource.Error(message = "Error on GetNews") + ) + } + + private fun mockResponseGetNewsErrorThenSuccess( + news: List, + ) { + coEvery { + getNews.invoke( + pageToken = any(), limitPerPage = any(), sortType = any(), + symbols = any(), startDate = any(), endDate = any(), + ) + }.returnsMany( + Resource.Error(message = "Error on GetNews"), + Resource.Success(data = NewsResponse(news = news, nextPageToken = null)) + ) + } + + private fun mockNetwork() { + coEvery { + connectivityObserver.observe() + }.returns( + flow { + emit(ConnectivityObserver.Status.Lost) + delay(1000) + emit(ConnectivityObserver.Status.Available) + } + ) + } + + private fun mockGetRealTimeNews( + news: List, + ) { + coEvery { + getRealTimeNews.invoke() + }.returns( + flow { + emit(news) + } + ) + } +} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c820512..8097808 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -20,6 +20,7 @@ mockkVersion = "1.13.10" coroutineVersion = "1.8.0" assertkVersion = "0.28.0" fakerVersion = "1.0.2" +turbineVersion = "1.1.0" coilVersion = "2.6.0" pagingVersion = "3.2.1" @@ -87,6 +88,9 @@ assertk = { group = "com.willowtreeapps.assertk", name = "assertk", version.ref mockk-android = { group = "io.mockk", name = "mockk-android", version.ref = "mockkVersion" } mockk-agent = { group = "io.mockk", name = "mockk-agent", version.ref = "mockkVersion" } +# TURBINE +turbine = { group = "app.cash.turbine", name = "turbine", version.ref = "turbineVersion"} + # END-TO-END TEST androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" } From fa5c993d5da53dbfd724b50acb45c8a57cdc6fef Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Mon, 29 Apr 2024 16:59:22 +0100 Subject: [PATCH 23/33] - update libs --- app/build.gradle.kts | 2 +- gradle/libs.versions.toml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 38a162b..e1f7448 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -61,7 +61,7 @@ android { buildConfig = true } composeOptions { - kotlinCompilerExtensionVersion = "1.5.10" + kotlinCompilerExtensionVersion = "1.5.12" } packaging { resources { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8097808..e298319 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,12 +1,12 @@ [versions] -agp = "8.3.1" -kotlin = "1.9.22" -coreKtx = "1.12.0" +agp = "8.3.2" +kotlin = "1.9.23" +coreKtx = "1.13.0" junitVersion = "1.1.5" espressoCore = "3.5.1" lifecycleRuntimeKtx = "2.7.0" -activityCompose = "1.8.2" -composeBom = "2024.04.00" +activityCompose = "1.9.0" +composeBom = "2024.04.01" retrofitVersion = "2.11.0" okHttpVersion = "4.12.0" scarletVersion = "0.1.12" From 232d958a0739b3890d24fb5bc328c5709ee7fb2a Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Mon, 29 Apr 2024 17:23:47 +0100 Subject: [PATCH 24/33] - update symbol crypto --- app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt b/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt index 9ecd060..4aad853 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt @@ -121,17 +121,17 @@ val popularSymbols = listOf( ), SubInfoSymbols( name = "Bitcoin", - symbol = "BTC", + symbol = "BTCUSD", isSubscribed = false, ), SubInfoSymbols( name = "Ethereum", - symbol = "ETH", + symbol = "ETHUSD", isSubscribed = false, ), SubInfoSymbols( name = "Shiba", - symbol = "SHIB", + symbol = "SHIBUSD", isSubscribed = false, ), ) \ No newline at end of file From 660586ca2904b32aad5d7d9c5b235dbb945de492 Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Thu, 2 May 2024 11:31:13 +0100 Subject: [PATCH 25/33] - assets API - assets Remote Data Source, Repository and Use Case - setup paper API, stock service, crypto service - refactor alpaca data api --- app/build.gradle.kts | 2 + .../data_source/AssetsRemoteDataSource.kt | 14 ++ .../data/data_source/NewsRemoteDataSource.kt | 22 +-- .../marketsight/data/mapper/RemoteMapper.kt | 140 ++++++++++-------- .../marketsight/data/remote/AlpacaDataApi.kt | 42 ++++++ .../marketsight/data/remote/AlpacaNewsApi.kt | 17 --- .../marketsight/data/remote/AlpacaPaperApi.kt | 13 ++ ...{AlpacaNewsService.kt => AlpacaService.kt} | 2 +- .../model/dto/alpaca_data_api/BarAssetDto.kt | 14 ++ .../alpaca_data_api/BarsCryptoResponseDto.kt | 6 + .../alpaca_data_api/BarsStockResponseDto.kt | 9 ++ .../ImagesNewsDto.kt | 2 +- .../NewsDto.kt | 2 +- .../NewsResponseDto.kt | 2 +- .../model/dto/alpaca_paper_api/AssetDto.kt | 11 ++ .../data/repository/AssetsRepositoryImp.kt | 25 ++++ .../dev/pinkroom/marketsight/di/AppModule.kt | 71 ++++++++- .../marketsight/domain/model/assets/Asset.kt | 9 ++ .../domain/model/assets/TypeAsset.kt | 6 + .../domain/model/historical_bars/BarAsset.kt | 14 ++ .../domain/model/historical_bars/TimeFrame.kt | 22 +++ .../domain/repository/AssetsRepository.kt | 11 ++ .../domain/repository/CryptoRepository.kt | 4 + .../domain/repository/StockRepository.kt | 17 +++ .../domain/use_case/assets/GetAllAssets.kt | 13 ++ .../data_source/NewsRemoteDataSourceTest.kt | 42 +++--- .../data/repository/NewsRepositoryTest.kt | 2 +- .../marketsight/factories/ImagesFactory.kt | 2 +- .../marketsight/factories/NewsDtoFactory.kt | 2 +- 29 files changed, 416 insertions(+), 122 deletions(-) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/data_source/AssetsRemoteDataSource.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaDataApi.kt delete mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaNewsApi.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaPaperApi.kt rename app/src/main/java/dev/pinkroom/marketsight/data/remote/{AlpacaNewsService.kt => AlpacaService.kt} (93%) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/BarAssetDto.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/BarsCryptoResponseDto.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/BarsStockResponseDto.kt rename app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/{alpaca_news_api => alpaca_data_api}/ImagesNewsDto.kt (50%) rename app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/{alpaca_news_api => alpaca_data_api}/NewsDto.kt (85%) rename app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/{alpaca_news_api => alpaca_data_api}/NewsResponseDto.kt (71%) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_paper_api/AssetDto.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/repository/AssetsRepositoryImp.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/model/assets/Asset.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/model/assets/TypeAsset.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/model/historical_bars/BarAsset.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/model/historical_bars/TimeFrame.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/repository/AssetsRepository.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/repository/CryptoRepository.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/repository/StockRepository.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetAllAssets.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index e1f7448..0fbebae 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -30,11 +30,13 @@ android { val alpacaStreamUrl = properties.getProperty("ALPACA_STREAM_URL") ?: "" val alpacaDataUrl = properties.getProperty("ALPACA_DATA_URL") ?: "" + val alpacaPaperUrl = properties.getProperty("ALPACA_PAPER_URL") ?: "" val alpacaApiId = properties.getProperty("ALPACA_API_ID") ?: "" val alpacaApiSecret = properties.getProperty("ALPACA_API_SECRET") ?: "" buildConfigField(type = "String", name = "ALPACA_STREAM_URL", value = alpacaStreamUrl) buildConfigField(type = "String", name = "ALPACA_DATA_URL", value = alpacaDataUrl) + buildConfigField(type = "String", name = "ALPACA_PAPER_URL", value = alpacaPaperUrl) buildConfigField(type = "String", name = "ALPACA_API_ID", value = alpacaApiId) buildConfigField(type = "String", name = "ALPACA_API_SECRET", value = alpacaApiSecret) } diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/AssetsRemoteDataSource.kt b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/AssetsRemoteDataSource.kt new file mode 100644 index 0000000..3db7889 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/AssetsRemoteDataSource.kt @@ -0,0 +1,14 @@ +package dev.pinkroom.marketsight.data.data_source + +import dev.pinkroom.marketsight.data.remote.AlpacaPaperApi +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_paper_api.AssetDto +import dev.pinkroom.marketsight.domain.model.assets.TypeAsset +import javax.inject.Inject + +class AssetsRemoteDataSource @Inject constructor( + private val alpacaPaperApi: AlpacaPaperApi, +) { + suspend fun getAllAssets(typeAsset: TypeAsset): List { + return alpacaPaperApi.getAssets(typeAsset = typeAsset.value) + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt index d999cd3..1027a00 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt @@ -10,9 +10,9 @@ import dev.pinkroom.marketsight.common.Resource import dev.pinkroom.marketsight.common.SortType import dev.pinkroom.marketsight.common.formatToStandardIso import dev.pinkroom.marketsight.common.toObject -import dev.pinkroom.marketsight.data.remote.AlpacaNewsApi -import dev.pinkroom.marketsight.data.remote.AlpacaNewsService -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.NewsResponseDto +import dev.pinkroom.marketsight.data.remote.AlpacaDataApi +import dev.pinkroom.marketsight.data.remote.AlpacaService +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.NewsResponseDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.NewsMessageDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.SubscriptionMessageDto import dev.pinkroom.marketsight.data.remote.model.request.MessageAlpacaService @@ -25,19 +25,19 @@ import javax.inject.Inject class NewsRemoteDataSource @Inject constructor( private val gson: Gson, - private val alpacaNewsService: AlpacaNewsService, - private val alpacaNewsApi: AlpacaNewsApi, + private val alpacaService: AlpacaService, + private val alpacaDataApi: AlpacaDataApi, private val dispatchers: DispatcherProvider, ) { private var isNewsSubscribed: Boolean = false private suspend fun subscribeNews(symbols: List = listOf("*")){ - alpacaNewsService.observeOnConnectionEvent() + alpacaService.observeOnConnectionEvent() .filter { it is WebSocket.Event.OnConnectionOpened<*> } .take(1) .collect{ isNewsSubscribed = true - alpacaNewsService.sendMessage( + alpacaService.sendMessage( message = MessageAlpacaService( action = ActionAlpaca.Subscribe.action, news = symbols, ) @@ -47,7 +47,7 @@ class NewsRemoteDataSource @Inject constructor( fun getRealTimeNews() = flow { if (!isNewsSubscribed) subscribeNews() - alpacaNewsService.observeResponse().collect{ data -> + alpacaService.observeResponse().collect{ data -> val listNews = mutableListOf() data.forEach { gson.toObject(value = it, helperIdentifier = HelperIdentifierMessagesAlpacaService.News)?.let { news -> @@ -59,8 +59,8 @@ class NewsRemoteDataSource @Inject constructor( }.flowOn(dispatchers.IO) fun sendSubscribeMessageToAlpacaService(message: MessageAlpacaService) = flow> { - alpacaNewsService.sendMessage(message = message) - alpacaNewsService.observeResponse().collect { data -> + alpacaService.sendMessage(message = message) + alpacaService.observeResponse().collect { data -> data.forEach { gson.toObject(value = it, helperIdentifier = HelperIdentifierMessagesAlpacaService.Subscription)?.let { sub -> emit(Resource.Success(sub)) @@ -79,7 +79,7 @@ class NewsRemoteDataSource @Inject constructor( startDate: LocalDateTime? = null, endDate: LocalDateTime? = null, ): NewsResponseDto { - return alpacaNewsApi.getNews( + return alpacaDataApi.getNews( symbols = symbols?.joinToString(","), perPage = limit, pageToken = pageToken, diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt b/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt index 8f7552a..1b1ce5f 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt @@ -1,13 +1,19 @@ package dev.pinkroom.marketsight.data.mapper -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.ImagesNewsDto -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.NewsDto -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.NewsResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.BarAssetDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.BarsCryptoResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.BarsStockResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.ImagesNewsDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.NewsDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.NewsResponseDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.ErrorMessageDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.NewsMessageDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.SubscriptionMessageDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_paper_api.AssetDto +import dev.pinkroom.marketsight.domain.model.assets.Asset import dev.pinkroom.marketsight.domain.model.common.ErrorMessage import dev.pinkroom.marketsight.domain.model.common.SubscriptionMessage +import dev.pinkroom.marketsight.domain.model.historical_bars.BarAsset import dev.pinkroom.marketsight.domain.model.news.ImageSize import dev.pinkroom.marketsight.domain.model.news.ImagesNews import dev.pinkroom.marketsight.domain.model.news.NewsInfo @@ -18,34 +24,29 @@ import java.time.ZoneOffset import java.time.format.DateTimeFormatter import java.util.Locale -fun NewsMessageDto.toNewsInfo(): NewsInfo { - return NewsInfo( - author = this.author, - createdAt = this.createdAt.toLocalDateTime(), - headline = this.headline, - id = this.id, - source = this.source, - summary = this.summary, - symbols = this.symbols, - updatedAt = this.updatedAt.toLocalDateTime(), - url = this.url, - ) -} +fun NewsMessageDto.toNewsInfo() = NewsInfo( + author = this.author, + createdAt = this.createdAt.toLocalDateTime(), + headline = this.headline, + id = this.id, + source = this.source, + summary = this.summary, + symbols = this.symbols, + updatedAt = this.updatedAt.toLocalDateTime(), + url = this.url, +) -fun ErrorMessageDto.toErrorMessage(): ErrorMessage { - return ErrorMessage( - code = this.code, - msg = this.msg, - ) -} +fun ErrorMessageDto.toErrorMessage() = ErrorMessage( + code = this.code, + msg = this.msg, +) + +fun SubscriptionMessageDto.toSubscriptionMessage() = SubscriptionMessage( + news = this.news, + quotes = this.quotes, + trades = this.trades, +) -fun SubscriptionMessageDto.toSubscriptionMessage(): SubscriptionMessage { - return SubscriptionMessage( - news = this.news, - quotes = this.quotes, - trades = this.trades, - ) -} fun String.toLocalDateTime(): LocalDateTime { val parser = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.getDefault()) @@ -53,39 +54,56 @@ fun String.toLocalDateTime(): LocalDateTime { return date.atZone(ZoneOffset.UTC).withZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime() } -fun NewsResponseDto.toNewsResponse(): NewsResponse { - return NewsResponse( - news = this.news.map { it.toNewsInfo() }, - nextPageToken = this.nextPageToken, - ) -} +fun NewsResponseDto.toNewsResponse() = NewsResponse( + news = this.news.map { it.toNewsInfo() }, + nextPageToken = this.nextPageToken, +) -fun NewsDto.toNewsInfo(): NewsInfo { - return NewsInfo( - author = this.author, - createdAt = this.createdAt.toLocalDateTime(), - headline = this.headline, - id = this.id, - source = this.source, - summary = this.summary, - symbols = this.symbols, - updatedAt = this.updatedAt.toLocalDateTime(), - url = this.url, - images = this.images.map { it.toImagesNews() } - ) -} +fun NewsDto.toNewsInfo() = NewsInfo( + author = this.author, + createdAt = this.createdAt.toLocalDateTime(), + headline = this.headline, + id = this.id, + source = this.source, + summary = this.summary, + symbols = this.symbols, + updatedAt = this.updatedAt.toLocalDateTime(), + url = this.url, + images = this.images.map { it.toImagesNews() } +) -fun ImagesNewsDto.toImagesNews(): ImagesNews { - return ImagesNews( - url = this.url, - size = this.size.toImageSize(), - ) +fun ImagesNewsDto.toImagesNews() = ImagesNews( + url = this.url, + size = this.size.toImageSize(), +) + + +fun String.toImageSize() = when(this) { + "large" -> ImageSize.Large + "small" -> ImageSize.Small + else -> ImageSize.Thumb } -fun String.toImageSize(): ImageSize { - return when(this){ - "large" -> ImageSize.Large - "small" -> ImageSize.Small - else -> ImageSize.Thumb - } -} \ No newline at end of file + +fun AssetDto.toAsset() = Asset( + id = id, + name = name, + symbol = symbol, + exchange = exchange, + isStock = type != "crypto", +) + +fun BarAssetDto.toBarAsset() = BarAsset( + openingPrice = openingPrice, + closingPrice = closingPrice, + highPrice = highPrice, + barVolume = barVolume, + lowPrice = lowPrice, + tradeCountInBar = tradeCountInBar, + timestamp = timestamp.toLocalDateTime(), + volumeWeightedAvgPrice = volumeWeightedAvgPrice, +) + +fun BarsStockResponseDto.toListBarAsset() = bars.map { it.toBarAsset() } + +fun BarsCryptoResponseDto.toListBarAsset() = bars.entries.first().value.map { it.toBarAsset() } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaDataApi.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaDataApi.kt new file mode 100644 index 0000000..edcbe7d --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaDataApi.kt @@ -0,0 +1,42 @@ +package dev.pinkroom.marketsight.data.remote + +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.BarsCryptoResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.BarsStockResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.NewsResponseDto +import dev.pinkroom.marketsight.domain.model.historical_bars.TimeFrame +import retrofit2.http.GET +import retrofit2.http.Path +import retrofit2.http.Query + +interface AlpacaDataApi { + @GET("v1beta1/news") + suspend fun getNews( + @Query("symbols") symbols: String? = null, + @Query("limit") perPage: Int? = null, + @Query("page_token") pageToken: String? = null, + @Query("sort") sort: String? = null, + @Query("start") startDate: String? = null, + @Query("end") endDate: String? = null, + ): NewsResponseDto + + @GET("v2/stocks/{symbol}/bars") + suspend fun getHistoricalBarsStock( + @Path("symbol") symbol: String, + @Query("timeframe") timeFrame: String? = TimeFrame.Day.frameValue, + @Query("limit") limit: Int? = 1000, + @Query("start") startDate: String? = null, + @Query("end") endDate: String? = null, + @Query("feed") feed: String? = "iex", + @Query("sort") sort: String? = null, + ): BarsStockResponseDto + + @GET("v1beta3/crypto/us/bars") + suspend fun getHistoricalBarsCrypto( + @Query("symbols") symbol: String, + @Query("timeframe") timeFrame: String? = TimeFrame.Day.frameValue, + @Query("limit") limit: Int? = 1000, + @Query("start") startDate: String? = null, + @Query("end") endDate: String? = null, + @Query("sort") sort: String? = null, + ): BarsCryptoResponseDto +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaNewsApi.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaNewsApi.kt deleted file mode 100644 index b33846d..0000000 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaNewsApi.kt +++ /dev/null @@ -1,17 +0,0 @@ -package dev.pinkroom.marketsight.data.remote - -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.NewsResponseDto -import retrofit2.http.GET -import retrofit2.http.Query - -interface AlpacaNewsApi { - @GET("news") - suspend fun getNews( - @Query("symbols") symbols: String? = null, - @Query("limit") perPage: Int? = null, - @Query("page_token") pageToken: String? = null, - @Query("sort") sort: String? = null, - @Query("start") startDate: String? = null, - @Query("end") endDate: String? = null, - ): NewsResponseDto -} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaPaperApi.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaPaperApi.kt new file mode 100644 index 0000000..442f007 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaPaperApi.kt @@ -0,0 +1,13 @@ +package dev.pinkroom.marketsight.data.remote + +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_paper_api.AssetDto +import retrofit2.http.GET +import retrofit2.http.Query + +interface AlpacaPaperApi { + @GET("assets") + suspend fun getAssets( + @Query("asset_class") typeAsset: String? = null, + @Query("status") status: String? = "active", + ): List +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaNewsService.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaService.kt similarity index 93% rename from app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaNewsService.kt rename to app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaService.kt index 543c05e..bf44654 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaNewsService.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaService.kt @@ -6,7 +6,7 @@ import com.tinder.scarlet.ws.Send import dev.pinkroom.marketsight.data.remote.model.request.MessageAlpacaService import kotlinx.coroutines.flow.Flow -interface AlpacaNewsService { +interface AlpacaService { @Receive fun observeOnConnectionEvent(): Flow diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/BarAssetDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/BarAssetDto.kt new file mode 100644 index 0000000..fbaa01e --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/BarAssetDto.kt @@ -0,0 +1,14 @@ +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api + +import com.google.gson.annotations.SerializedName + +data class BarAssetDto( + @SerializedName("c") val closingPrice: Double, + @SerializedName("h") val highPrice: Double, + @SerializedName("l") val lowPrice: Double, + @SerializedName("n") val tradeCountInBar: Int, + @SerializedName("o") val openingPrice: Double, + @SerializedName("t") val timestamp: String, + @SerializedName("v") val barVolume: Double, + @SerializedName("vw") val volumeWeightedAvgPrice: Double, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/BarsCryptoResponseDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/BarsCryptoResponseDto.kt new file mode 100644 index 0000000..1bf072b --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/BarsCryptoResponseDto.kt @@ -0,0 +1,6 @@ +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api + +data class BarsCryptoResponseDto( + val bars: Map>, + val nextPageToken: String? = null, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/BarsStockResponseDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/BarsStockResponseDto.kt new file mode 100644 index 0000000..5c005dd --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/BarsStockResponseDto.kt @@ -0,0 +1,9 @@ +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api + +import com.google.gson.annotations.SerializedName + +data class BarsStockResponseDto( + val bars: List, + @SerializedName("next_page_token") val nextPageToken: String? = null, + val symbol: String, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/ImagesNewsDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/ImagesNewsDto.kt similarity index 50% rename from app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/ImagesNewsDto.kt rename to app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/ImagesNewsDto.kt index c9aa082..3aa7f96 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/ImagesNewsDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/ImagesNewsDto.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api data class ImagesNewsDto( val size: String, diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/NewsDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/NewsDto.kt similarity index 85% rename from app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/NewsDto.kt rename to app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/NewsDto.kt index 236fb7f..a585465 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/NewsDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/NewsDto.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api import com.google.gson.annotations.SerializedName diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/NewsResponseDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/NewsResponseDto.kt similarity index 71% rename from app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/NewsResponseDto.kt rename to app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/NewsResponseDto.kt index e6a1998..85fddc7 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/NewsResponseDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/NewsResponseDto.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api import com.google.gson.annotations.SerializedName diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_paper_api/AssetDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_paper_api/AssetDto.kt new file mode 100644 index 0000000..f642635 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_paper_api/AssetDto.kt @@ -0,0 +1,11 @@ +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_paper_api + +import com.google.gson.annotations.SerializedName + +data class AssetDto( + val id: String, + @SerializedName("class") val type: String, + val symbol: String, + val name: String, + val exchange: String, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/repository/AssetsRepositoryImp.kt b/app/src/main/java/dev/pinkroom/marketsight/data/repository/AssetsRepositoryImp.kt new file mode 100644 index 0000000..8a00b3b --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/repository/AssetsRepositoryImp.kt @@ -0,0 +1,25 @@ +package dev.pinkroom.marketsight.data.repository + +import dev.pinkroom.marketsight.common.Resource +import dev.pinkroom.marketsight.data.data_source.AssetsRemoteDataSource +import dev.pinkroom.marketsight.data.mapper.toAsset +import dev.pinkroom.marketsight.domain.model.assets.Asset +import dev.pinkroom.marketsight.domain.model.assets.TypeAsset +import dev.pinkroom.marketsight.domain.repository.AssetsRepository +import javax.inject.Inject + +class AssetsRepositoryImp @Inject constructor( + private val assetsRemoteDataSource: AssetsRemoteDataSource, +): AssetsRepository { + override suspend fun getAllAssets(typeAsset: TypeAsset): Resource> { + return try { + val response = assetsRemoteDataSource.getAllAssets( + typeAsset = typeAsset, + ) + Resource.Success(data = response.map { it.toAsset() }) + } catch (e: Exception){ + e.printStackTrace() + Resource.Error(message = e.message ?: "Something Went Wrong") + } + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt b/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt index 3d48ad5..c38b055 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt @@ -22,8 +22,9 @@ import dev.pinkroom.marketsight.common.addLoggingInterceptor import dev.pinkroom.marketsight.common.connection_network.ConnectivityObserver import dev.pinkroom.marketsight.common.connection_network.NetworkConnectivityObserver import dev.pinkroom.marketsight.data.data_source.NewsRemoteDataSource -import dev.pinkroom.marketsight.data.remote.AlpacaNewsApi -import dev.pinkroom.marketsight.data.remote.AlpacaNewsService +import dev.pinkroom.marketsight.data.remote.AlpacaDataApi +import dev.pinkroom.marketsight.data.remote.AlpacaPaperApi +import dev.pinkroom.marketsight.data.remote.AlpacaService import dev.pinkroom.marketsight.data.repository.NewsRepositoryImp import dev.pinkroom.marketsight.domain.repository.NewsRepository import okhttp3.OkHttpClient @@ -39,10 +40,15 @@ import javax.inject.Singleton object AppModule { private const val ALPACA_STREAM_URL_NEWS = BuildConfig.ALPACA_STREAM_URL + "v1beta1/news" + private const val ALPACA_STREAM_URL_STOCK = BuildConfig.ALPACA_STREAM_URL + "v2/iex" + private const val ALPACA_STREAM_URL_CRYPTO = BuildConfig.ALPACA_STREAM_URL + "v1beta3/crypto/us" private const val API_TIMEOUT_WS = 30L private const val API_TIMEOUT_API = 10L private const val OK_HTTP_WS = "okHttpWS" private const val OK_HTTP_API = "okHttpAPI" + private const val ALPACA_NEWS_SERVICE = "alpacaNewsService" + private const val ALPACA_STOCK_SERVICE = "alpacaStockService" + private const val ALPACA_CRYPTO_SERVICE = "alpacaCryptoService" @Provides @Singleton @@ -74,9 +80,10 @@ object AppModule { @Provides @Singleton + @Named(ALPACA_NEWS_SERVICE) fun provideAlpacaNewsService( @Named(OK_HTTP_WS) okHttpClient: OkHttpClient, lifecycle: Lifecycle - ): AlpacaNewsService { + ): AlpacaService { val scarlet = Scarlet.Builder() .webSocketFactory(okHttpClient.newWebSocketFactory(ALPACA_STREAM_URL_NEWS)) .addMessageAdapterFactory(GsonMessageAdapter.Factory()) @@ -84,12 +91,12 @@ object AppModule { //.lifecycle(lifecycle) .build() - return scarlet.create(AlpacaNewsService::class.java) + return scarlet.create(AlpacaService::class.java) } @Provides @Singleton - fun provideAlpacaNewsApi(@Named(OK_HTTP_API) okHttpClient: OkHttpClient): AlpacaNewsApi { + fun provideAlpacaNewsApi(@Named(OK_HTTP_API) okHttpClient: OkHttpClient): AlpacaDataApi { return Retrofit.Builder() .baseUrl(BuildConfig.ALPACA_DATA_URL) .addConverterFactory(GsonConverterFactory.create()) @@ -98,6 +105,49 @@ object AppModule { .create() } + @Provides + @Singleton + @Named(ALPACA_STOCK_SERVICE) + fun provideAlpacaStockService( + @Named(OK_HTTP_WS) okHttpClient: OkHttpClient, lifecycle: Lifecycle + ): AlpacaService { + val scarlet = Scarlet.Builder() + .webSocketFactory(okHttpClient.newWebSocketFactory(ALPACA_STREAM_URL_STOCK)) + .addMessageAdapterFactory(GsonMessageAdapter.Factory()) + .addStreamAdapterFactory(FlowStreamAdapterFactory()) + //.lifecycle(lifecycle) + .build() + + return scarlet.create(AlpacaService::class.java) + } + + @Provides + @Singleton + @Named(ALPACA_CRYPTO_SERVICE) + fun provideAlpacaCryptoService( + @Named(OK_HTTP_WS) okHttpClient: OkHttpClient, lifecycle: Lifecycle + ): AlpacaService { + val scarlet = Scarlet.Builder() + .webSocketFactory(okHttpClient.newWebSocketFactory(ALPACA_STREAM_URL_CRYPTO)) + .addMessageAdapterFactory(GsonMessageAdapter.Factory()) + .addStreamAdapterFactory(FlowStreamAdapterFactory()) + //.lifecycle(lifecycle) + .build() + + return scarlet.create(AlpacaService::class.java) + } + + @Provides + @Singleton + fun provideAlpacaPaperApi(@Named(OK_HTTP_API) okHttpClient: OkHttpClient): AlpacaPaperApi { + return Retrofit.Builder() + .baseUrl(BuildConfig.ALPACA_PAPER_URL) + .addConverterFactory(GsonConverterFactory.create()) + .client(okHttpClient) + .build() + .create() + } + @Provides @Singleton fun provideGson(): Gson = Gson() @@ -108,6 +158,17 @@ object AppModule { return DefaultDispatchers() } + @Provides + @Singleton + fun provideNewsRemoteDataSource( + gson: Gson, + dispatcherProvider: DispatcherProvider, + alpacaDataApi: AlpacaDataApi, + @Named(ALPACA_NEWS_SERVICE) alpacaService: AlpacaService, + ): NewsRemoteDataSource { + return NewsRemoteDataSource(gson = gson, alpacaService = alpacaService, alpacaDataApi = alpacaDataApi, dispatchers = dispatcherProvider) + } + @Provides @Singleton fun provideNewsRepository(newsRemoteDataSource: NewsRemoteDataSource, dispatcherProvider: DispatcherProvider): NewsRepository { diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/assets/Asset.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/assets/Asset.kt new file mode 100644 index 0000000..7e1e1cc --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/assets/Asset.kt @@ -0,0 +1,9 @@ +package dev.pinkroom.marketsight.domain.model.assets + +data class Asset( + val id: String, + val name: String, + val symbol: String, + val isStock: Boolean, + val exchange: String, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/assets/TypeAsset.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/assets/TypeAsset.kt new file mode 100644 index 0000000..da657ea --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/assets/TypeAsset.kt @@ -0,0 +1,6 @@ +package dev.pinkroom.marketsight.domain.model.assets + +sealed class TypeAsset(val value: String) { + data object Crypto: TypeAsset(value = "crypto") + data object Stock: TypeAsset(value = "us_equity") +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/historical_bars/BarAsset.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/historical_bars/BarAsset.kt new file mode 100644 index 0000000..ca18a02 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/historical_bars/BarAsset.kt @@ -0,0 +1,14 @@ +package dev.pinkroom.marketsight.domain.model.historical_bars + +import java.time.LocalDateTime + +data class BarAsset( + val closingPrice: Double, + val highPrice: Double, + val lowPrice: Double, + val tradeCountInBar: Int, + val openingPrice: Double, + val timestamp: LocalDateTime, + val barVolume: Double, + val volumeWeightedAvgPrice: Double, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/historical_bars/TimeFrame.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/historical_bars/TimeFrame.kt new file mode 100644 index 0000000..06ec69a --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/historical_bars/TimeFrame.kt @@ -0,0 +1,22 @@ +package dev.pinkroom.marketsight.domain.model.historical_bars + +sealed class TimeFrame(val frameValue: String){ + data class Minutes(val value: Int): TimeFrame(frameValue = "${value}T"){ + init { + require(value in 1..59) { "Vale need to be between 1 and 59." } + } + } + data class Hour(val value: Int): TimeFrame(frameValue = "${value}H"){ + init { + require(value in 1..23) { "Value need to be between 1 and 23." } + } + } + data object Day: TimeFrame(frameValue = "1D") + data object Week: TimeFrame(frameValue = "1W") + data class Month(val value: Int): TimeFrame(frameValue = "${value}M"){ + init { + val specificValues = listOf(1,2,3,6,12) + require(value in specificValues) { "Value need to be one of: ${specificValues.joinToString(separator = ", ")}." } + } + } +} diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/AssetsRepository.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/AssetsRepository.kt new file mode 100644 index 0000000..e926ac2 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/AssetsRepository.kt @@ -0,0 +1,11 @@ +package dev.pinkroom.marketsight.domain.repository + +import dev.pinkroom.marketsight.common.Resource +import dev.pinkroom.marketsight.domain.model.assets.Asset +import dev.pinkroom.marketsight.domain.model.assets.TypeAsset + +interface AssetsRepository { + suspend fun getAllAssets( + typeAsset: TypeAsset + ): Resource> +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/CryptoRepository.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/CryptoRepository.kt new file mode 100644 index 0000000..98d6d75 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/CryptoRepository.kt @@ -0,0 +1,4 @@ +package dev.pinkroom.marketsight.domain.repository + +interface CryptoRepository { +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/StockRepository.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/StockRepository.kt new file mode 100644 index 0000000..b0b8de9 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/StockRepository.kt @@ -0,0 +1,17 @@ +package dev.pinkroom.marketsight.domain.repository + +import dev.pinkroom.marketsight.common.Resource +import dev.pinkroom.marketsight.common.SortType +import dev.pinkroom.marketsight.domain.model.historical_bars.BarAsset +import dev.pinkroom.marketsight.domain.model.historical_bars.TimeFrame + +interface StockRepository { + suspend fun getHistoricalBars( + symbol: String, + timeFrame: TimeFrame? = TimeFrame.Day, + limit: Int? = 1000, + startDate: String, + endDate: String, + sort: SortType? = SortType.ASC, + ): Resource> +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetAllAssets.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetAllAssets.kt new file mode 100644 index 0000000..d208c2e --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetAllAssets.kt @@ -0,0 +1,13 @@ +package dev.pinkroom.marketsight.domain.use_case.assets + +import dev.pinkroom.marketsight.domain.model.assets.TypeAsset +import dev.pinkroom.marketsight.domain.repository.AssetsRepository +import javax.inject.Inject + +class GetAllAssets @Inject constructor( + private val assetsRepository: AssetsRepository, +){ + suspend operator fun invoke( + typeAsset: TypeAsset, + ) = assetsRepository.getAllAssets(typeAsset = typeAsset) +} \ No newline at end of file diff --git a/app/src/test/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSourceTest.kt b/app/src/test/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSourceTest.kt index eefb259..448b5b9 100644 --- a/app/src/test/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSourceTest.kt +++ b/app/src/test/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSourceTest.kt @@ -12,9 +12,9 @@ import com.tinder.scarlet.WebSocket import dev.pinkroom.marketsight.common.ActionAlpaca import dev.pinkroom.marketsight.common.Resource import dev.pinkroom.marketsight.common.SortType -import dev.pinkroom.marketsight.data.remote.AlpacaNewsApi -import dev.pinkroom.marketsight.data.remote.AlpacaNewsService -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.NewsResponseDto +import dev.pinkroom.marketsight.data.remote.AlpacaDataApi +import dev.pinkroom.marketsight.data.remote.AlpacaService +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.NewsResponseDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.ErrorMessageDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.NewsMessageDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.SubscriptionMessageDto @@ -48,13 +48,13 @@ class NewsRemoteDataSourceTest { private val faker = Faker() private val newsFactory = NewsFactory() private val newsDtoFactory = NewsDtoFactory() - private val alpacaNewsService = mockk(relaxed = true, relaxUnitFun = true) - private val alpacaNewsApi = mockk() + private val alpacaService = mockk(relaxed = true, relaxUnitFun = true) + private val alpacaDataApi = mockk() private val dispatchers = TestDispatcherProvider() private val alpacaRemoteDataSource = NewsRemoteDataSource( gson = gson, - alpacaNewsService = alpacaNewsService, - alpacaNewsApi = alpacaNewsApi, + alpacaService = alpacaService, + alpacaDataApi = alpacaDataApi, dispatchers = dispatchers, ) @@ -75,7 +75,7 @@ class NewsRemoteDataSourceTest { val expectedMessageToSubscribe = MessageAlpacaService( action = ActionAlpaca.Subscribe.action, news = listOf("*"), ) - verify(exactly = 1) { alpacaNewsService.sendMessage(expectedMessageToSubscribe) } + verify(exactly = 1) { alpacaService.sendMessage(expectedMessageToSubscribe) } } @Test @@ -88,7 +88,7 @@ class NewsRemoteDataSourceTest { val response = alpacaRemoteDataSource.sendSubscribeMessageToAlpacaService(message = messageToSend).first() // THEN - verify { alpacaNewsService.sendMessage(message = messageToSend) } + verify { alpacaService.sendMessage(message = messageToSend) } assertThat(response is Resource.Success).isTrue() val data = response as Resource.Success assertThat(data.data.news).isEqualTo(messageToSend.news) @@ -106,7 +106,7 @@ class NewsRemoteDataSourceTest { val response = alpacaRemoteDataSource.getRealTimeNews().toList() // THEN - verify { alpacaNewsService.observeResponse() } + verify { alpacaService.observeResponse() } val allIdsSent = listNews.map { it.id } assertThat(response).isNotEmpty() response.forEach { newsReturned -> @@ -136,7 +136,7 @@ class NewsRemoteDataSourceTest { // THEN coVerify { - alpacaNewsApi.getNews( + alpacaDataApi.getNews( symbols = symbols.joinToString(","), perPage = limit, pageToken = pageToken, @@ -155,7 +155,7 @@ class NewsRemoteDataSourceTest { val response = alpacaRemoteDataSource.getRealTimeNews().firstOrNull() // THEN - verify { alpacaNewsService.observeResponse() } + verify { alpacaService.observeResponse() } assertThat(response).isNull() } @@ -169,12 +169,12 @@ class NewsRemoteDataSourceTest { val response = alpacaRemoteDataSource.sendSubscribeMessageToAlpacaService(messageToSend).first() // THEN - verify { alpacaNewsService.observeResponse() } + verify { alpacaService.observeResponse() } assertThat(response is Resource.Error).isTrue() } private fun mockNewsResponseApiWithSuccess(limit: Int) { - coEvery { alpacaNewsApi.getNews( + coEvery { alpacaDataApi.getNews( symbols = any(), perPage = any(), pageToken = any(), @@ -188,13 +188,13 @@ class NewsRemoteDataSourceTest { } private fun mockNewsServiceWithOpenConnection(){ - every { alpacaNewsService.observeOnConnectionEvent() }.returns( + every { alpacaService.observeOnConnectionEvent() }.returns( flow { emit(WebSocket.Event.OnConnectionOpened(webSocket = Any())) } ) } private fun mockNewsServiceWithSuccess(newsList: List) { - every { alpacaNewsService.observeResponse() }.returns( + every { alpacaService.observeResponse() }.returns( flow { emit(listOf(gson.toJsonTree(newsList.first()))) delay(3000) // Simulate WS API @@ -207,7 +207,7 @@ class NewsRemoteDataSourceTest { } private fun mockNewsServiceWithMessageNotExpected() { - every { alpacaNewsService.observeResponse() }.returns( + every { alpacaService.observeResponse() }.returns( flow { emit(listOf(gson.toJsonTree( ErrorMessageDto( @@ -228,8 +228,8 @@ class NewsRemoteDataSourceTest { trades = messageAlpacaService.trades, ) - every { alpacaNewsService.sendMessage(any()) } returns(Unit) - every { alpacaNewsService.observeResponse() }.returns( + every { alpacaService.sendMessage(any()) } returns(Unit) + every { alpacaService.observeResponse() }.returns( flow { emit(listOf(gson.toJsonTree(returnedMessageService))) } @@ -242,8 +242,8 @@ class NewsRemoteDataSourceTest { msg = "Not Found", code = 404, ) - every { alpacaNewsService.sendMessage(any()) } returns(Unit) - every { alpacaNewsService.observeResponse() }.returns( + every { alpacaService.sendMessage(any()) } returns(Unit) + every { alpacaService.observeResponse() }.returns( flow { emit(listOf(gson.toJsonTree(errorMessage))) } diff --git a/app/src/test/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryTest.kt b/app/src/test/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryTest.kt index 4032aaf..72e0df4 100644 --- a/app/src/test/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryTest.kt +++ b/app/src/test/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryTest.kt @@ -10,7 +10,7 @@ import dev.pinkroom.marketsight.common.Resource import dev.pinkroom.marketsight.common.SortType import dev.pinkroom.marketsight.data.data_source.NewsRemoteDataSource import dev.pinkroom.marketsight.data.mapper.toNewsInfo -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.NewsResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.NewsResponseDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.NewsMessageDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.SubscriptionMessageDto import dev.pinkroom.marketsight.data.remote.model.request.MessageAlpacaService diff --git a/app/src/test/java/dev/pinkroom/marketsight/factories/ImagesFactory.kt b/app/src/test/java/dev/pinkroom/marketsight/factories/ImagesFactory.kt index 97fce1d..91b8047 100644 --- a/app/src/test/java/dev/pinkroom/marketsight/factories/ImagesFactory.kt +++ b/app/src/test/java/dev/pinkroom/marketsight/factories/ImagesFactory.kt @@ -1,7 +1,7 @@ package dev.pinkroom.marketsight.factories import com.github.javafaker.Faker -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.ImagesNewsDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.ImagesNewsDto import kotlin.random.Random class ImagesFactory: BaseFactory { diff --git a/app/src/test/java/dev/pinkroom/marketsight/factories/NewsDtoFactory.kt b/app/src/test/java/dev/pinkroom/marketsight/factories/NewsDtoFactory.kt index 4d6b0ae..a3fd5e1 100644 --- a/app/src/test/java/dev/pinkroom/marketsight/factories/NewsDtoFactory.kt +++ b/app/src/test/java/dev/pinkroom/marketsight/factories/NewsDtoFactory.kt @@ -1,7 +1,7 @@ package dev.pinkroom.marketsight.factories import com.github.javafaker.Faker -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.NewsDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.NewsDto class NewsDtoFactory: BaseFactory { From 9d0225c17b173bc2432e92e8b363ea7bb0155707 Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Thu, 2 May 2024 14:08:32 +0100 Subject: [PATCH 26/33] - refactor alpaca data API --- .../data/data_source/NewsRemoteDataSource.kt | 8 ++-- .../marketsight/data/mapper/RemoteMapper.kt | 12 +++--- .../data/remote/AlpacaCryptoApi.kt | 40 ++++++++++++++++++ .../marketsight/data/remote/AlpacaNewsApi.kt | 17 ++++++++ .../{AlpacaDataApi.kt => AlpacaStockApi.kt} | 42 ++++++++++--------- .../BarAssetDto.kt | 2 +- .../model/dto/alpaca_api/QuoteAssetDto.kt | 9 ++++ .../model/dto/alpaca_api/TradeAssetDto.kt | 8 ++++ .../BarsCryptoResponseDto.kt | 8 ++++ .../HistoricalQuotesCryptoResponseDto.kt | 9 ++++ .../HistoricalTradeCryptoResponseDto.kt | 9 ++++ .../alpaca_data_api/BarsCryptoResponseDto.kt | 6 --- .../ImagesNewsDto.kt | 2 +- .../NewsDto.kt | 2 +- .../NewsResponseDto.kt | 2 +- .../BarsStockResponseDto.kt | 3 +- .../HistoricalQuotesStockResponseDto.kt | 9 ++++ .../HistoricalTradeStockResponseDto.kt | 9 ++++ .../dev/pinkroom/marketsight/di/AppModule.kt | 37 +++++++++++++--- .../domain/repository/StockRepository.kt | 2 + .../data_source/NewsRemoteDataSourceTest.kt | 12 +++--- .../data/repository/NewsRepositoryTest.kt | 2 +- .../marketsight/factories/ImagesFactory.kt | 2 +- .../marketsight/factories/NewsDtoFactory.kt | 2 +- 24 files changed, 199 insertions(+), 55 deletions(-) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaCryptoApi.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaNewsApi.kt rename app/src/main/java/dev/pinkroom/marketsight/data/remote/{AlpacaDataApi.kt => AlpacaStockApi.kt} (54%) rename app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/{alpaca_data_api => alpaca_api}/BarAssetDto.kt (87%) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/QuoteAssetDto.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/TradeAssetDto.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/BarsCryptoResponseDto.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/HistoricalQuotesCryptoResponseDto.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/HistoricalTradeCryptoResponseDto.kt delete mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/BarsCryptoResponseDto.kt rename app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/{alpaca_data_api => alpaca_news_api}/ImagesNewsDto.kt (50%) rename app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/{alpaca_data_api => alpaca_news_api}/NewsDto.kt (85%) rename app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/{alpaca_data_api => alpaca_news_api}/NewsResponseDto.kt (71%) rename app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/{alpaca_data_api => alpaca_stock_api}/BarsStockResponseDto.kt (59%) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_stock_api/HistoricalQuotesStockResponseDto.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_stock_api/HistoricalTradeStockResponseDto.kt diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt index 1027a00..af9811d 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt @@ -10,9 +10,9 @@ import dev.pinkroom.marketsight.common.Resource import dev.pinkroom.marketsight.common.SortType import dev.pinkroom.marketsight.common.formatToStandardIso import dev.pinkroom.marketsight.common.toObject -import dev.pinkroom.marketsight.data.remote.AlpacaDataApi +import dev.pinkroom.marketsight.data.remote.AlpacaNewsApi import dev.pinkroom.marketsight.data.remote.AlpacaService -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.NewsResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.NewsResponseDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.NewsMessageDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.SubscriptionMessageDto import dev.pinkroom.marketsight.data.remote.model.request.MessageAlpacaService @@ -26,7 +26,7 @@ import javax.inject.Inject class NewsRemoteDataSource @Inject constructor( private val gson: Gson, private val alpacaService: AlpacaService, - private val alpacaDataApi: AlpacaDataApi, + private val alpacaNewsApi: AlpacaNewsApi, private val dispatchers: DispatcherProvider, ) { private var isNewsSubscribed: Boolean = false @@ -79,7 +79,7 @@ class NewsRemoteDataSource @Inject constructor( startDate: LocalDateTime? = null, endDate: LocalDateTime? = null, ): NewsResponseDto { - return alpacaDataApi.getNews( + return alpacaNewsApi.getNews( symbols = symbols?.joinToString(","), perPage = limit, pageToken = pageToken, diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt b/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt index 1b1ce5f..b49fe90 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt @@ -1,15 +1,15 @@ package dev.pinkroom.marketsight.data.mapper -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.BarAssetDto -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.BarsCryptoResponseDto -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.BarsStockResponseDto -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.ImagesNewsDto -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.NewsDto -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.NewsResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.BarAssetDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_crypto_api.BarsCryptoResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.ImagesNewsDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.NewsDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.NewsResponseDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.ErrorMessageDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.NewsMessageDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.SubscriptionMessageDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_paper_api.AssetDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_stock_api.BarsStockResponseDto import dev.pinkroom.marketsight.domain.model.assets.Asset import dev.pinkroom.marketsight.domain.model.common.ErrorMessage import dev.pinkroom.marketsight.domain.model.common.SubscriptionMessage diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaCryptoApi.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaCryptoApi.kt new file mode 100644 index 0000000..0f4b099 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaCryptoApi.kt @@ -0,0 +1,40 @@ +package dev.pinkroom.marketsight.data.remote + +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_crypto_api.BarsCryptoResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_crypto_api.HistoricalQuotesCryptoResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_crypto_api.HistoricalTradeCryptoResponseDto +import dev.pinkroom.marketsight.domain.model.historical_bars.TimeFrame +import retrofit2.http.GET +import retrofit2.http.Query + +interface AlpacaCryptoApi { + @GET("bars") + suspend fun getHistoricalBarsCrypto( + @Query("symbols") symbol: String, + @Query("timeframe") timeFrame: String? = TimeFrame.Day.frameValue, + @Query("limit") limit: Int? = 1000, + @Query("start") startDate: String? = null, + @Query("end") endDate: String? = null, + @Query("sort") sort: String? = null, + ): BarsCryptoResponseDto + + @GET("trades") + suspend fun getHistoricalTradesCrypto( + @Query("symbol") symbol: String, + @Query("limit") limit: Int? = 1000, + @Query("start") startDate: String? = null, + @Query("end") endDate: String? = null, + @Query("sort") sort: String? = null, + @Query("page_token") pageToken: String? = null, + ): HistoricalTradeCryptoResponseDto + + @GET("quotes") + suspend fun getHistoricalQuotesCrypto( + @Query("symbol") symbol: String, + @Query("limit") limit: Int? = 1000, + @Query("start") startDate: String? = null, + @Query("end") endDate: String? = null, + @Query("sort") sort: String? = null, + @Query("page_token") pageToken: String? = null, + ): HistoricalQuotesCryptoResponseDto +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaNewsApi.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaNewsApi.kt new file mode 100644 index 0000000..b33846d --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaNewsApi.kt @@ -0,0 +1,17 @@ +package dev.pinkroom.marketsight.data.remote + +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.NewsResponseDto +import retrofit2.http.GET +import retrofit2.http.Query + +interface AlpacaNewsApi { + @GET("news") + suspend fun getNews( + @Query("symbols") symbols: String? = null, + @Query("limit") perPage: Int? = null, + @Query("page_token") pageToken: String? = null, + @Query("sort") sort: String? = null, + @Query("start") startDate: String? = null, + @Query("end") endDate: String? = null, + ): NewsResponseDto +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaDataApi.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaStockApi.kt similarity index 54% rename from app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaDataApi.kt rename to app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaStockApi.kt index edcbe7d..477782c 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaDataApi.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaStockApi.kt @@ -1,25 +1,15 @@ package dev.pinkroom.marketsight.data.remote -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.BarsCryptoResponseDto -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.BarsStockResponseDto -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.NewsResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_stock_api.BarsStockResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_stock_api.HistoricalQuotesStockResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_stock_api.HistoricalTradeStockResponseDto import dev.pinkroom.marketsight.domain.model.historical_bars.TimeFrame import retrofit2.http.GET import retrofit2.http.Path import retrofit2.http.Query -interface AlpacaDataApi { - @GET("v1beta1/news") - suspend fun getNews( - @Query("symbols") symbols: String? = null, - @Query("limit") perPage: Int? = null, - @Query("page_token") pageToken: String? = null, - @Query("sort") sort: String? = null, - @Query("start") startDate: String? = null, - @Query("end") endDate: String? = null, - ): NewsResponseDto - - @GET("v2/stocks/{symbol}/bars") +interface AlpacaStockApi { + @GET("{symbol}/bars") suspend fun getHistoricalBarsStock( @Path("symbol") symbol: String, @Query("timeframe") timeFrame: String? = TimeFrame.Day.frameValue, @@ -30,13 +20,25 @@ interface AlpacaDataApi { @Query("sort") sort: String? = null, ): BarsStockResponseDto - @GET("v1beta3/crypto/us/bars") - suspend fun getHistoricalBarsCrypto( - @Query("symbols") symbol: String, - @Query("timeframe") timeFrame: String? = TimeFrame.Day.frameValue, + @GET("{symbol}/trades") + suspend fun getHistoricalTradesStock( + @Path("symbol") symbol: String, @Query("limit") limit: Int? = 1000, @Query("start") startDate: String? = null, @Query("end") endDate: String? = null, + @Query("feed") feed: String? = "iex", @Query("sort") sort: String? = null, - ): BarsCryptoResponseDto + @Query("page_token") pageToken: String? = null, + ): HistoricalTradeStockResponseDto + + @GET("{symbol}/quotes") + suspend fun getHistoricalQuotesStock( + @Path("symbol") symbol: String, + @Query("limit") limit: Int? = 1000, + @Query("start") startDate: String? = null, + @Query("end") endDate: String? = null, + @Query("feed") feed: String? = "iex", + @Query("sort") sort: String? = null, + @Query("page_token") pageToken: String? = null, + ): HistoricalQuotesStockResponseDto } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/BarAssetDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/BarAssetDto.kt similarity index 87% rename from app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/BarAssetDto.kt rename to app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/BarAssetDto.kt index fbaa01e..66e6cfe 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/BarAssetDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/BarAssetDto.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api import com.google.gson.annotations.SerializedName diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/QuoteAssetDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/QuoteAssetDto.kt new file mode 100644 index 0000000..61cee9c --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/QuoteAssetDto.kt @@ -0,0 +1,9 @@ +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api + +import com.google.gson.annotations.SerializedName + +data class QuoteAssetDto( + @SerializedName("bp") val bidPrice: Double, + @SerializedName("ap") val askPrice: Double, + @SerializedName("t") val timeStamp: String, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/TradeAssetDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/TradeAssetDto.kt new file mode 100644 index 0000000..52b4ba2 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/TradeAssetDto.kt @@ -0,0 +1,8 @@ +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api + +import com.google.gson.annotations.SerializedName + +data class TradeAssetDto( + @SerializedName("p") val tradePrice: Double, + @SerializedName("t") val timeStamp: String, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/BarsCryptoResponseDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/BarsCryptoResponseDto.kt new file mode 100644 index 0000000..337ebe1 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/BarsCryptoResponseDto.kt @@ -0,0 +1,8 @@ +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_crypto_api + +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.BarAssetDto + +data class BarsCryptoResponseDto( + val bars: Map>, + val nextPageToken: String? = null, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/HistoricalQuotesCryptoResponseDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/HistoricalQuotesCryptoResponseDto.kt new file mode 100644 index 0000000..99c60be --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/HistoricalQuotesCryptoResponseDto.kt @@ -0,0 +1,9 @@ +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_crypto_api + +import com.google.gson.annotations.SerializedName +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.QuoteAssetDto + +data class HistoricalQuotesCryptoResponseDto( + val quotes: Map>, + @SerializedName("next_page_token") val pageToken: String? = null, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/HistoricalTradeCryptoResponseDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/HistoricalTradeCryptoResponseDto.kt new file mode 100644 index 0000000..db88c61 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/HistoricalTradeCryptoResponseDto.kt @@ -0,0 +1,9 @@ +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_crypto_api + +import com.google.gson.annotations.SerializedName +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.TradeAssetDto + +data class HistoricalTradeCryptoResponseDto( + val trades: Map>, + @SerializedName("next_page_token") val pageToken: String? = null, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/BarsCryptoResponseDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/BarsCryptoResponseDto.kt deleted file mode 100644 index 1bf072b..0000000 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/BarsCryptoResponseDto.kt +++ /dev/null @@ -1,6 +0,0 @@ -package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api - -data class BarsCryptoResponseDto( - val bars: Map>, - val nextPageToken: String? = null, -) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/ImagesNewsDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/ImagesNewsDto.kt similarity index 50% rename from app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/ImagesNewsDto.kt rename to app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/ImagesNewsDto.kt index 3aa7f96..c9aa082 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/ImagesNewsDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/ImagesNewsDto.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api data class ImagesNewsDto( val size: String, diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/NewsDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/NewsDto.kt similarity index 85% rename from app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/NewsDto.kt rename to app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/NewsDto.kt index a585465..236fb7f 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/NewsDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/NewsDto.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api import com.google.gson.annotations.SerializedName diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/NewsResponseDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/NewsResponseDto.kt similarity index 71% rename from app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/NewsResponseDto.kt rename to app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/NewsResponseDto.kt index 85fddc7..e6a1998 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/NewsResponseDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_api/NewsResponseDto.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api import com.google.gson.annotations.SerializedName diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/BarsStockResponseDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_stock_api/BarsStockResponseDto.kt similarity index 59% rename from app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/BarsStockResponseDto.kt rename to app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_stock_api/BarsStockResponseDto.kt index 5c005dd..3b6a9b3 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_data_api/BarsStockResponseDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_stock_api/BarsStockResponseDto.kt @@ -1,6 +1,7 @@ -package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_stock_api import com.google.gson.annotations.SerializedName +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.BarAssetDto data class BarsStockResponseDto( val bars: List, diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_stock_api/HistoricalQuotesStockResponseDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_stock_api/HistoricalQuotesStockResponseDto.kt new file mode 100644 index 0000000..c8bd9bf --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_stock_api/HistoricalQuotesStockResponseDto.kt @@ -0,0 +1,9 @@ +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_stock_api + +import com.google.gson.annotations.SerializedName +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.QuoteAssetDto + +data class HistoricalQuotesStockResponseDto( + val quotes: List, + @SerializedName("next_page_token") val pageToken: String? = null, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_stock_api/HistoricalTradeStockResponseDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_stock_api/HistoricalTradeStockResponseDto.kt new file mode 100644 index 0000000..60361a2 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_stock_api/HistoricalTradeStockResponseDto.kt @@ -0,0 +1,9 @@ +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_stock_api + +import com.google.gson.annotations.SerializedName +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.TradeAssetDto + +data class HistoricalTradeStockResponseDto( + val trades: List, + @SerializedName("next_page_token") val pageToken: String? = null, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt b/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt index c38b055..0d1450c 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt @@ -22,9 +22,11 @@ import dev.pinkroom.marketsight.common.addLoggingInterceptor import dev.pinkroom.marketsight.common.connection_network.ConnectivityObserver import dev.pinkroom.marketsight.common.connection_network.NetworkConnectivityObserver import dev.pinkroom.marketsight.data.data_source.NewsRemoteDataSource -import dev.pinkroom.marketsight.data.remote.AlpacaDataApi +import dev.pinkroom.marketsight.data.remote.AlpacaCryptoApi +import dev.pinkroom.marketsight.data.remote.AlpacaNewsApi import dev.pinkroom.marketsight.data.remote.AlpacaPaperApi import dev.pinkroom.marketsight.data.remote.AlpacaService +import dev.pinkroom.marketsight.data.remote.AlpacaStockApi import dev.pinkroom.marketsight.data.repository.NewsRepositoryImp import dev.pinkroom.marketsight.domain.repository.NewsRepository import okhttp3.OkHttpClient @@ -42,6 +44,9 @@ object AppModule { private const val ALPACA_STREAM_URL_NEWS = BuildConfig.ALPACA_STREAM_URL + "v1beta1/news" private const val ALPACA_STREAM_URL_STOCK = BuildConfig.ALPACA_STREAM_URL + "v2/iex" private const val ALPACA_STREAM_URL_CRYPTO = BuildConfig.ALPACA_STREAM_URL + "v1beta3/crypto/us" + private const val ALPACA_API_URL_NEWS = BuildConfig.ALPACA_DATA_URL + "v1beta1/" + private const val ALPACA_API_URL_STOCK = BuildConfig.ALPACA_DATA_URL + "v2/stocks/" + private const val ALPACA_API_URL_CRYPTO = BuildConfig.ALPACA_DATA_URL + "v1beta3/crypto/us/" private const val API_TIMEOUT_WS = 30L private const val API_TIMEOUT_API = 10L private const val OK_HTTP_WS = "okHttpWS" @@ -96,9 +101,31 @@ object AppModule { @Provides @Singleton - fun provideAlpacaNewsApi(@Named(OK_HTTP_API) okHttpClient: OkHttpClient): AlpacaDataApi { + fun provideAlpacaNewsApi(@Named(OK_HTTP_API) okHttpClient: OkHttpClient): AlpacaNewsApi { return Retrofit.Builder() - .baseUrl(BuildConfig.ALPACA_DATA_URL) + .baseUrl(ALPACA_API_URL_NEWS) + .addConverterFactory(GsonConverterFactory.create()) + .client(okHttpClient) + .build() + .create() + } + + @Provides + @Singleton + fun provideAlpacaStockApi(@Named(OK_HTTP_API) okHttpClient: OkHttpClient): AlpacaStockApi { + return Retrofit.Builder() + .baseUrl(ALPACA_API_URL_STOCK) + .addConverterFactory(GsonConverterFactory.create()) + .client(okHttpClient) + .build() + .create() + } + + @Provides + @Singleton + fun provideAlpacaCryptoApi(@Named(OK_HTTP_API) okHttpClient: OkHttpClient): AlpacaCryptoApi { + return Retrofit.Builder() + .baseUrl(ALPACA_API_URL_CRYPTO) .addConverterFactory(GsonConverterFactory.create()) .client(okHttpClient) .build() @@ -163,10 +190,10 @@ object AppModule { fun provideNewsRemoteDataSource( gson: Gson, dispatcherProvider: DispatcherProvider, - alpacaDataApi: AlpacaDataApi, + alpacaNewsApi: AlpacaNewsApi, @Named(ALPACA_NEWS_SERVICE) alpacaService: AlpacaService, ): NewsRemoteDataSource { - return NewsRemoteDataSource(gson = gson, alpacaService = alpacaService, alpacaDataApi = alpacaDataApi, dispatchers = dispatcherProvider) + return NewsRemoteDataSource(gson = gson, alpacaService = alpacaService, alpacaNewsApi = alpacaNewsApi, dispatchers = dispatcherProvider) } @Provides diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/StockRepository.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/StockRepository.kt index b0b8de9..be25db5 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/StockRepository.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/StockRepository.kt @@ -14,4 +14,6 @@ interface StockRepository { endDate: String, sort: SortType? = SortType.ASC, ): Resource> + + //fun getRealTimeTrades(): Flow> } \ No newline at end of file diff --git a/app/src/test/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSourceTest.kt b/app/src/test/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSourceTest.kt index 448b5b9..8900c8f 100644 --- a/app/src/test/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSourceTest.kt +++ b/app/src/test/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSourceTest.kt @@ -12,9 +12,9 @@ import com.tinder.scarlet.WebSocket import dev.pinkroom.marketsight.common.ActionAlpaca import dev.pinkroom.marketsight.common.Resource import dev.pinkroom.marketsight.common.SortType -import dev.pinkroom.marketsight.data.remote.AlpacaDataApi +import dev.pinkroom.marketsight.data.remote.AlpacaNewsApi import dev.pinkroom.marketsight.data.remote.AlpacaService -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.NewsResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.NewsResponseDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.ErrorMessageDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.NewsMessageDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.SubscriptionMessageDto @@ -49,12 +49,12 @@ class NewsRemoteDataSourceTest { private val newsFactory = NewsFactory() private val newsDtoFactory = NewsDtoFactory() private val alpacaService = mockk(relaxed = true, relaxUnitFun = true) - private val alpacaDataApi = mockk() + private val alpacaNewsApi = mockk() private val dispatchers = TestDispatcherProvider() private val alpacaRemoteDataSource = NewsRemoteDataSource( gson = gson, alpacaService = alpacaService, - alpacaDataApi = alpacaDataApi, + alpacaNewsApi = alpacaNewsApi, dispatchers = dispatchers, ) @@ -136,7 +136,7 @@ class NewsRemoteDataSourceTest { // THEN coVerify { - alpacaDataApi.getNews( + alpacaNewsApi.getNews( symbols = symbols.joinToString(","), perPage = limit, pageToken = pageToken, @@ -174,7 +174,7 @@ class NewsRemoteDataSourceTest { } private fun mockNewsResponseApiWithSuccess(limit: Int) { - coEvery { alpacaDataApi.getNews( + coEvery { alpacaNewsApi.getNews( symbols = any(), perPage = any(), pageToken = any(), diff --git a/app/src/test/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryTest.kt b/app/src/test/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryTest.kt index 72e0df4..4032aaf 100644 --- a/app/src/test/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryTest.kt +++ b/app/src/test/java/dev/pinkroom/marketsight/data/repository/NewsRepositoryTest.kt @@ -10,7 +10,7 @@ import dev.pinkroom.marketsight.common.Resource import dev.pinkroom.marketsight.common.SortType import dev.pinkroom.marketsight.data.data_source.NewsRemoteDataSource import dev.pinkroom.marketsight.data.mapper.toNewsInfo -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.NewsResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.NewsResponseDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.NewsMessageDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.SubscriptionMessageDto import dev.pinkroom.marketsight.data.remote.model.request.MessageAlpacaService diff --git a/app/src/test/java/dev/pinkroom/marketsight/factories/ImagesFactory.kt b/app/src/test/java/dev/pinkroom/marketsight/factories/ImagesFactory.kt index 91b8047..97fce1d 100644 --- a/app/src/test/java/dev/pinkroom/marketsight/factories/ImagesFactory.kt +++ b/app/src/test/java/dev/pinkroom/marketsight/factories/ImagesFactory.kt @@ -1,7 +1,7 @@ package dev.pinkroom.marketsight.factories import com.github.javafaker.Faker -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.ImagesNewsDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.ImagesNewsDto import kotlin.random.Random class ImagesFactory: BaseFactory { diff --git a/app/src/test/java/dev/pinkroom/marketsight/factories/NewsDtoFactory.kt b/app/src/test/java/dev/pinkroom/marketsight/factories/NewsDtoFactory.kt index a3fd5e1..4d6b0ae 100644 --- a/app/src/test/java/dev/pinkroom/marketsight/factories/NewsDtoFactory.kt +++ b/app/src/test/java/dev/pinkroom/marketsight/factories/NewsDtoFactory.kt @@ -1,7 +1,7 @@ package dev.pinkroom.marketsight.factories import com.github.javafaker.Faker -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_data_api.NewsDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.NewsDto class NewsDtoFactory: BaseFactory { From 92f6b79afdd7bd86f2b48acd8a9951646f871147 Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Thu, 2 May 2024 15:41:18 +0100 Subject: [PATCH 27/33] - trades, quotes, bars info --- .../pinkroom/marketsight/common/Constants.kt | 1 + .../data_source/AssetsRemoteDataSource.kt | 101 ++++++++++++++++++ .../marketsight/data/mapper/RemoteMapper.kt | 47 +++++++- .../data/remote/AlpacaCryptoApi.kt | 17 +-- .../marketsight/data/remote/AlpacaStockApi.kt | 21 ++-- .../BarsResponseDto.kt} | 5 +- .../model/dto/alpaca_api/QuoteAssetDto.kt | 1 + .../model/dto/alpaca_api/QuotesResponseDto.kt | 8 ++ .../model/dto/alpaca_api/TradeAssetDto.kt | 1 + .../model/dto/alpaca_api/TradesResponseDto.kt | 8 ++ ...ponseDto.kt => QuotesCryptoResponseDto.kt} | 2 +- ...ponseDto.kt => TradesCryptoResponseDto.kt} | 2 +- .../HistoricalQuotesStockResponseDto.kt | 9 -- .../HistoricalTradeStockResponseDto.kt | 9 -- .../data/repository/AssetsRepositoryImp.kt | 90 +++++++++++++++- .../BarAsset.kt | 2 +- .../TimeFrame.kt | 2 +- .../domain/model/quotes_asset/QuoteAsset.kt | 10 ++ .../model/quotes_asset/QuotesResponse.kt | 6 ++ .../domain/model/trades_asset/TradeAsset.kt | 9 ++ .../model/trades_asset/TradesResponse.kt | 6 ++ .../domain/repository/AssetsRepository.kt | 37 +++++++ .../domain/repository/CryptoRepository.kt | 4 - .../domain/repository/StockRepository.kt | 19 ---- .../domain/use_case/assets/GetBarsAssets.kt | 31 ++++++ .../domain/use_case/assets/GetQuotesAssets.kt | 30 ++++++ .../domain/use_case/assets/GetTradesAssets.kt | 30 ++++++ 27 files changed, 435 insertions(+), 73 deletions(-) rename app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/{alpaca_stock_api/BarsStockResponseDto.kt => alpaca_api/BarsResponseDto.kt} (50%) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/QuotesResponseDto.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/TradesResponseDto.kt rename app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/{HistoricalQuotesCryptoResponseDto.kt => QuotesCryptoResponseDto.kt} (87%) rename app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/{HistoricalTradeCryptoResponseDto.kt => TradesCryptoResponseDto.kt} (87%) delete mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_stock_api/HistoricalQuotesStockResponseDto.kt delete mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_stock_api/HistoricalTradeStockResponseDto.kt rename app/src/main/java/dev/pinkroom/marketsight/domain/model/{historical_bars => bars_asset}/BarAsset.kt (82%) rename app/src/main/java/dev/pinkroom/marketsight/domain/model/{historical_bars => bars_asset}/TimeFrame.kt (92%) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/model/quotes_asset/QuoteAsset.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/model/quotes_asset/QuotesResponse.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/model/trades_asset/TradeAsset.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/model/trades_asset/TradesResponse.kt delete mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/repository/CryptoRepository.kt delete mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/repository/StockRepository.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetBarsAssets.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetQuotesAssets.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetTradesAssets.kt diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/Constants.kt b/app/src/main/java/dev/pinkroom/marketsight/common/Constants.kt index 953892c..12561ee 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/common/Constants.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/common/Constants.kt @@ -7,6 +7,7 @@ object Constants { // LIMIT const val MAX_ITEMS_CAROUSEL = 5 const val LIMIT_NEWS = 20 + const val DEFAULT_LIMIT_ASSET = 1000 const val BUFFER_LIST = 5 // TEXT diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/AssetsRemoteDataSource.kt b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/AssetsRemoteDataSource.kt index 3db7889..0d11bc0 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/AssetsRemoteDataSource.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/AssetsRemoteDataSource.kt @@ -1,14 +1,115 @@ package dev.pinkroom.marketsight.data.data_source +import dev.pinkroom.marketsight.common.Constants +import dev.pinkroom.marketsight.common.SortType +import dev.pinkroom.marketsight.common.formatToStandardIso +import dev.pinkroom.marketsight.data.mapper.toQuotesResponseDto +import dev.pinkroom.marketsight.data.mapper.toTradesResponseDto +import dev.pinkroom.marketsight.data.remote.AlpacaCryptoApi import dev.pinkroom.marketsight.data.remote.AlpacaPaperApi +import dev.pinkroom.marketsight.data.remote.AlpacaStockApi +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.BarAssetDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.QuotesResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.TradesResponseDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_paper_api.AssetDto import dev.pinkroom.marketsight.domain.model.assets.TypeAsset +import dev.pinkroom.marketsight.domain.model.bars_asset.TimeFrame +import java.time.LocalDateTime import javax.inject.Inject class AssetsRemoteDataSource @Inject constructor( private val alpacaPaperApi: AlpacaPaperApi, + private val alpacaStockApi: AlpacaStockApi, + private val alpacaCryptoApi: AlpacaCryptoApi, ) { suspend fun getAllAssets(typeAsset: TypeAsset): List { return alpacaPaperApi.getAssets(typeAsset = typeAsset.value) } + + suspend fun getBars( + symbol: String, + typeAsset: TypeAsset, + timeFrame: TimeFrame? = TimeFrame.Day, + limit: Int? = Constants.DEFAULT_LIMIT_ASSET, + startDate: LocalDateTime, + endDate: LocalDateTime, + sort: SortType? = SortType.ASC, + ): List { + return if (typeAsset is TypeAsset.Stock) + alpacaStockApi.getHistoricalBarsStock( + symbol = symbol, + startDate = startDate.formatToStandardIso(), + endDate = endDate.formatToStandardIso(), + sort = sort?.type, + limit = limit, + timeFrame = timeFrame?.frameValue, + ).bars + else + alpacaCryptoApi.getHistoricalBarsCrypto( + symbol = symbol, + startDate = startDate.formatToStandardIso(), + endDate = endDate.formatToStandardIso(), + sort = sort?.type, + limit = limit, + timeFrame = timeFrame?.frameValue, + ).bars.entries.first().value + } + + suspend fun getTrades( + symbol: String, + typeAsset: TypeAsset, + limit: Int? = Constants.DEFAULT_LIMIT_ASSET, + startDate: LocalDateTime? = null, + endDate: LocalDateTime? = null, + sort: SortType? = SortType.ASC, + pageToken: String? = null, + ): TradesResponseDto { + return if (typeAsset is TypeAsset.Stock) + alpacaStockApi.getHistoricalTradesStock( + symbol = symbol, + startDate = startDate?.formatToStandardIso(), + endDate = endDate?.formatToStandardIso(), + sort = sort?.type, + limit = limit, + pageToken = pageToken + ) + else + alpacaCryptoApi.getHistoricalTradesCrypto( + symbol = symbol, + startDate = startDate?.formatToStandardIso(), + endDate = endDate?.formatToStandardIso(), + sort = sort?.type, + limit = limit, + pageToken = pageToken + ).toTradesResponseDto() + } + + suspend fun getQuotes( + symbol: String, + typeAsset: TypeAsset, + limit: Int? = Constants.DEFAULT_LIMIT_ASSET, + startDate: LocalDateTime? = null, + endDate: LocalDateTime? = null, + sort: SortType? = SortType.ASC, + pageToken: String? = null, + ): QuotesResponseDto { + return if (typeAsset is TypeAsset.Stock) + alpacaStockApi.getHistoricalQuotesStock( + symbol = symbol, + startDate = startDate?.formatToStandardIso(), + endDate = endDate?.formatToStandardIso(), + sort = sort?.type, + limit = limit, + pageToken = pageToken + ) + else + alpacaCryptoApi.getHistoricalQuotesCrypto( + symbol = symbol, + startDate = startDate?.formatToStandardIso(), + endDate = endDate?.formatToStandardIso(), + sort = sort?.type, + limit = limit, + pageToken = pageToken + ).toQuotesResponseDto() + } } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt b/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt index b49fe90..21d8758 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt @@ -1,7 +1,12 @@ package dev.pinkroom.marketsight.data.mapper import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.BarAssetDto -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_crypto_api.BarsCryptoResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.QuoteAssetDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.QuotesResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.TradeAssetDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.TradesResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_crypto_api.QuotesCryptoResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_crypto_api.TradesCryptoResponseDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.ImagesNewsDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.NewsDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_api.NewsResponseDto @@ -9,15 +14,18 @@ import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.ErrorM import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.NewsMessageDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.SubscriptionMessageDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_paper_api.AssetDto -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_stock_api.BarsStockResponseDto import dev.pinkroom.marketsight.domain.model.assets.Asset +import dev.pinkroom.marketsight.domain.model.bars_asset.BarAsset import dev.pinkroom.marketsight.domain.model.common.ErrorMessage import dev.pinkroom.marketsight.domain.model.common.SubscriptionMessage -import dev.pinkroom.marketsight.domain.model.historical_bars.BarAsset import dev.pinkroom.marketsight.domain.model.news.ImageSize import dev.pinkroom.marketsight.domain.model.news.ImagesNews import dev.pinkroom.marketsight.domain.model.news.NewsInfo import dev.pinkroom.marketsight.domain.model.news.NewsResponse +import dev.pinkroom.marketsight.domain.model.quotes_asset.QuoteAsset +import dev.pinkroom.marketsight.domain.model.quotes_asset.QuotesResponse +import dev.pinkroom.marketsight.domain.model.trades_asset.TradeAsset +import dev.pinkroom.marketsight.domain.model.trades_asset.TradesResponse import java.time.LocalDateTime import java.time.ZoneId import java.time.ZoneOffset @@ -104,6 +112,35 @@ fun BarAssetDto.toBarAsset() = BarAsset( volumeWeightedAvgPrice = volumeWeightedAvgPrice, ) -fun BarsStockResponseDto.toListBarAsset() = bars.map { it.toBarAsset() } +fun QuotesResponseDto.toQuotesResponse() = QuotesResponse( + quotes = quotes.map { it.toQuoteAsset() }, + pageToken = pageToken, +) + +fun QuoteAssetDto.toQuoteAsset() = QuoteAsset( + id = tradeId, + bidPrice = bidPrice, + askPrice = askPrice, + timeStamp = timeStamp.toLocalDateTime(), +) + +fun QuotesCryptoResponseDto.toQuotesResponseDto() = QuotesResponseDto( + quotes = quotes.entries.first().value, + pageToken = pageToken, +) + +fun TradesResponseDto.toTradesResponse() = TradesResponse( + trades = trades.map { it.toTradeAsset() }, + pageToken = pageToken, +) + +fun TradeAssetDto.toTradeAsset() = TradeAsset( + id = tradeId, + tradePrice = tradePrice, + timeStamp = timeStamp.toLocalDateTime(), +) -fun BarsCryptoResponseDto.toListBarAsset() = bars.entries.first().value.map { it.toBarAsset() } \ No newline at end of file +fun TradesCryptoResponseDto.toTradesResponseDto() = TradesResponseDto( + trades = trades.entries.first().value, + pageToken = pageToken, +) \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaCryptoApi.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaCryptoApi.kt index 0f4b099..2cabb7d 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaCryptoApi.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaCryptoApi.kt @@ -1,9 +1,10 @@ package dev.pinkroom.marketsight.data.remote +import dev.pinkroom.marketsight.common.Constants.DEFAULT_LIMIT_ASSET import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_crypto_api.BarsCryptoResponseDto -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_crypto_api.HistoricalQuotesCryptoResponseDto -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_crypto_api.HistoricalTradeCryptoResponseDto -import dev.pinkroom.marketsight.domain.model.historical_bars.TimeFrame +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_crypto_api.QuotesCryptoResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_crypto_api.TradesCryptoResponseDto +import dev.pinkroom.marketsight.domain.model.bars_asset.TimeFrame import retrofit2.http.GET import retrofit2.http.Query @@ -12,7 +13,7 @@ interface AlpacaCryptoApi { suspend fun getHistoricalBarsCrypto( @Query("symbols") symbol: String, @Query("timeframe") timeFrame: String? = TimeFrame.Day.frameValue, - @Query("limit") limit: Int? = 1000, + @Query("limit") limit: Int? = DEFAULT_LIMIT_ASSET, @Query("start") startDate: String? = null, @Query("end") endDate: String? = null, @Query("sort") sort: String? = null, @@ -21,20 +22,20 @@ interface AlpacaCryptoApi { @GET("trades") suspend fun getHistoricalTradesCrypto( @Query("symbol") symbol: String, - @Query("limit") limit: Int? = 1000, + @Query("limit") limit: Int? = DEFAULT_LIMIT_ASSET, @Query("start") startDate: String? = null, @Query("end") endDate: String? = null, @Query("sort") sort: String? = null, @Query("page_token") pageToken: String? = null, - ): HistoricalTradeCryptoResponseDto + ): TradesCryptoResponseDto @GET("quotes") suspend fun getHistoricalQuotesCrypto( @Query("symbol") symbol: String, - @Query("limit") limit: Int? = 1000, + @Query("limit") limit: Int? = DEFAULT_LIMIT_ASSET, @Query("start") startDate: String? = null, @Query("end") endDate: String? = null, @Query("sort") sort: String? = null, @Query("page_token") pageToken: String? = null, - ): HistoricalQuotesCryptoResponseDto + ): QuotesCryptoResponseDto } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaStockApi.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaStockApi.kt index 477782c..5d6dc32 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaStockApi.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/AlpacaStockApi.kt @@ -1,9 +1,10 @@ package dev.pinkroom.marketsight.data.remote -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_stock_api.BarsStockResponseDto -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_stock_api.HistoricalQuotesStockResponseDto -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_stock_api.HistoricalTradeStockResponseDto -import dev.pinkroom.marketsight.domain.model.historical_bars.TimeFrame +import dev.pinkroom.marketsight.common.Constants.DEFAULT_LIMIT_ASSET +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.BarsResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.QuotesResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.TradesResponseDto +import dev.pinkroom.marketsight.domain.model.bars_asset.TimeFrame import retrofit2.http.GET import retrofit2.http.Path import retrofit2.http.Query @@ -13,32 +14,32 @@ interface AlpacaStockApi { suspend fun getHistoricalBarsStock( @Path("symbol") symbol: String, @Query("timeframe") timeFrame: String? = TimeFrame.Day.frameValue, - @Query("limit") limit: Int? = 1000, + @Query("limit") limit: Int? = DEFAULT_LIMIT_ASSET, @Query("start") startDate: String? = null, @Query("end") endDate: String? = null, @Query("feed") feed: String? = "iex", @Query("sort") sort: String? = null, - ): BarsStockResponseDto + ): BarsResponseDto @GET("{symbol}/trades") suspend fun getHistoricalTradesStock( @Path("symbol") symbol: String, - @Query("limit") limit: Int? = 1000, + @Query("limit") limit: Int? = DEFAULT_LIMIT_ASSET, @Query("start") startDate: String? = null, @Query("end") endDate: String? = null, @Query("feed") feed: String? = "iex", @Query("sort") sort: String? = null, @Query("page_token") pageToken: String? = null, - ): HistoricalTradeStockResponseDto + ): TradesResponseDto @GET("{symbol}/quotes") suspend fun getHistoricalQuotesStock( @Path("symbol") symbol: String, - @Query("limit") limit: Int? = 1000, + @Query("limit") limit: Int? = DEFAULT_LIMIT_ASSET, @Query("start") startDate: String? = null, @Query("end") endDate: String? = null, @Query("feed") feed: String? = "iex", @Query("sort") sort: String? = null, @Query("page_token") pageToken: String? = null, - ): HistoricalQuotesStockResponseDto + ): QuotesResponseDto } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_stock_api/BarsStockResponseDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/BarsResponseDto.kt similarity index 50% rename from app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_stock_api/BarsStockResponseDto.kt rename to app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/BarsResponseDto.kt index 3b6a9b3..eeb9ac5 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_stock_api/BarsStockResponseDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/BarsResponseDto.kt @@ -1,9 +1,8 @@ -package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_stock_api +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api import com.google.gson.annotations.SerializedName -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.BarAssetDto -data class BarsStockResponseDto( +data class BarsResponseDto( val bars: List, @SerializedName("next_page_token") val nextPageToken: String? = null, val symbol: String, diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/QuoteAssetDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/QuoteAssetDto.kt index 61cee9c..5ba9445 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/QuoteAssetDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/QuoteAssetDto.kt @@ -3,6 +3,7 @@ package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api import com.google.gson.annotations.SerializedName data class QuoteAssetDto( + @SerializedName("i") val tradeId: Long, @SerializedName("bp") val bidPrice: Double, @SerializedName("ap") val askPrice: Double, @SerializedName("t") val timeStamp: String, diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/QuotesResponseDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/QuotesResponseDto.kt new file mode 100644 index 0000000..3d8e267 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/QuotesResponseDto.kt @@ -0,0 +1,8 @@ +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api + +import com.google.gson.annotations.SerializedName + +data class QuotesResponseDto( + val quotes: List, + @SerializedName("next_page_token") val pageToken: String? = null, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/TradeAssetDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/TradeAssetDto.kt index 52b4ba2..427a5cd 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/TradeAssetDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/TradeAssetDto.kt @@ -3,6 +3,7 @@ package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api import com.google.gson.annotations.SerializedName data class TradeAssetDto( + @SerializedName("i") val tradeId: Long, @SerializedName("p") val tradePrice: Double, @SerializedName("t") val timeStamp: String, ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/TradesResponseDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/TradesResponseDto.kt new file mode 100644 index 0000000..aa6bed6 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/TradesResponseDto.kt @@ -0,0 +1,8 @@ +package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api + +import com.google.gson.annotations.SerializedName + +data class TradesResponseDto( + val trades: List, + @SerializedName("next_page_token") val pageToken: String? = null, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/HistoricalQuotesCryptoResponseDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/QuotesCryptoResponseDto.kt similarity index 87% rename from app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/HistoricalQuotesCryptoResponseDto.kt rename to app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/QuotesCryptoResponseDto.kt index 99c60be..c1532c8 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/HistoricalQuotesCryptoResponseDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/QuotesCryptoResponseDto.kt @@ -3,7 +3,7 @@ package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_crypto_api import com.google.gson.annotations.SerializedName import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.QuoteAssetDto -data class HistoricalQuotesCryptoResponseDto( +data class QuotesCryptoResponseDto( val quotes: Map>, @SerializedName("next_page_token") val pageToken: String? = null, ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/HistoricalTradeCryptoResponseDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/TradesCryptoResponseDto.kt similarity index 87% rename from app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/HistoricalTradeCryptoResponseDto.kt rename to app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/TradesCryptoResponseDto.kt index db88c61..2fc8115 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/HistoricalTradeCryptoResponseDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_crypto_api/TradesCryptoResponseDto.kt @@ -3,7 +3,7 @@ package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_crypto_api import com.google.gson.annotations.SerializedName import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.TradeAssetDto -data class HistoricalTradeCryptoResponseDto( +data class TradesCryptoResponseDto( val trades: Map>, @SerializedName("next_page_token") val pageToken: String? = null, ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_stock_api/HistoricalQuotesStockResponseDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_stock_api/HistoricalQuotesStockResponseDto.kt deleted file mode 100644 index c8bd9bf..0000000 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_stock_api/HistoricalQuotesStockResponseDto.kt +++ /dev/null @@ -1,9 +0,0 @@ -package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_stock_api - -import com.google.gson.annotations.SerializedName -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.QuoteAssetDto - -data class HistoricalQuotesStockResponseDto( - val quotes: List, - @SerializedName("next_page_token") val pageToken: String? = null, -) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_stock_api/HistoricalTradeStockResponseDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_stock_api/HistoricalTradeStockResponseDto.kt deleted file mode 100644 index 60361a2..0000000 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_stock_api/HistoricalTradeStockResponseDto.kt +++ /dev/null @@ -1,9 +0,0 @@ -package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_stock_api - -import com.google.gson.annotations.SerializedName -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.TradeAssetDto - -data class HistoricalTradeStockResponseDto( - val trades: List, - @SerializedName("next_page_token") val pageToken: String? = null, -) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/repository/AssetsRepositoryImp.kt b/app/src/main/java/dev/pinkroom/marketsight/data/repository/AssetsRepositoryImp.kt index 8a00b3b..cc7bfa8 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/repository/AssetsRepositoryImp.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/repository/AssetsRepositoryImp.kt @@ -1,11 +1,20 @@ package dev.pinkroom.marketsight.data.repository import dev.pinkroom.marketsight.common.Resource +import dev.pinkroom.marketsight.common.SortType import dev.pinkroom.marketsight.data.data_source.AssetsRemoteDataSource import dev.pinkroom.marketsight.data.mapper.toAsset +import dev.pinkroom.marketsight.data.mapper.toBarAsset +import dev.pinkroom.marketsight.data.mapper.toQuotesResponse +import dev.pinkroom.marketsight.data.mapper.toTradesResponse import dev.pinkroom.marketsight.domain.model.assets.Asset import dev.pinkroom.marketsight.domain.model.assets.TypeAsset +import dev.pinkroom.marketsight.domain.model.bars_asset.BarAsset +import dev.pinkroom.marketsight.domain.model.bars_asset.TimeFrame +import dev.pinkroom.marketsight.domain.model.quotes_asset.QuotesResponse +import dev.pinkroom.marketsight.domain.model.trades_asset.TradesResponse import dev.pinkroom.marketsight.domain.repository.AssetsRepository +import java.time.LocalDateTime import javax.inject.Inject class AssetsRepositoryImp @Inject constructor( @@ -17,9 +26,86 @@ class AssetsRepositoryImp @Inject constructor( typeAsset = typeAsset, ) Resource.Success(data = response.map { it.toAsset() }) - } catch (e: Exception){ + } catch (e: Exception) { e.printStackTrace() - Resource.Error(message = e.message ?: "Something Went Wrong") + Resource.Error(message = e.message ?: "Something Went Wrong on Get all assets") + } + } + + override suspend fun getBars( + symbol: String, + typeAsset: TypeAsset, + timeFrame: TimeFrame?, + limit: Int?, + startDate: LocalDateTime, + endDate: LocalDateTime, + sort: SortType? + ): Resource> { + return try { + val response = assetsRemoteDataSource.getBars( + symbol = symbol, + typeAsset = typeAsset, + timeFrame = timeFrame, + limit = limit, + startDate = startDate, + endDate = endDate, + ) + Resource.Success(data = response.map { it.toBarAsset() }) + } catch (e: Exception) { + e.printStackTrace() + Resource.Error(message = e.message ?: "Something Went Wrong on Get Historical bars") + } + } + + override suspend fun getTrades( + symbol: String, + typeAsset: TypeAsset, + limit: Int?, + startDate: LocalDateTime?, + endDate: LocalDateTime?, + sort: SortType?, + pageToken: String? + ): Resource { + return try { + val response = assetsRemoteDataSource.getTrades( + symbol = symbol, + typeAsset = typeAsset, + limit = limit, + startDate = startDate, + endDate = endDate, + sort = sort, + pageToken = pageToken, + ) + Resource.Success(data = response.toTradesResponse()) + } catch (e: Exception) { + e.printStackTrace() + Resource.Error(message = e.message ?: "Something Went Wrong on Get Historical trades") + } + } + + override suspend fun getQuotes( + symbol: String, + typeAsset: TypeAsset, + limit: Int?, + startDate: LocalDateTime?, + endDate: LocalDateTime?, + sort: SortType?, + pageToken: String? + ): Resource { + return try { + val response = assetsRemoteDataSource.getQuotes( + symbol = symbol, + typeAsset = typeAsset, + limit = limit, + startDate = startDate, + endDate = endDate, + sort = sort, + pageToken = pageToken, + ) + Resource.Success(data = response.toQuotesResponse()) + } catch (e: Exception) { + e.printStackTrace() + Resource.Error(message = e.message ?: "Something Went Wrong on Get Historical quotes") } } } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/historical_bars/BarAsset.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/bars_asset/BarAsset.kt similarity index 82% rename from app/src/main/java/dev/pinkroom/marketsight/domain/model/historical_bars/BarAsset.kt rename to app/src/main/java/dev/pinkroom/marketsight/domain/model/bars_asset/BarAsset.kt index ca18a02..06e1038 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/model/historical_bars/BarAsset.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/bars_asset/BarAsset.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.domain.model.historical_bars +package dev.pinkroom.marketsight.domain.model.bars_asset import java.time.LocalDateTime diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/historical_bars/TimeFrame.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/bars_asset/TimeFrame.kt similarity index 92% rename from app/src/main/java/dev/pinkroom/marketsight/domain/model/historical_bars/TimeFrame.kt rename to app/src/main/java/dev/pinkroom/marketsight/domain/model/bars_asset/TimeFrame.kt index 06ec69a..83165b1 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/model/historical_bars/TimeFrame.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/bars_asset/TimeFrame.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.domain.model.historical_bars +package dev.pinkroom.marketsight.domain.model.bars_asset sealed class TimeFrame(val frameValue: String){ data class Minutes(val value: Int): TimeFrame(frameValue = "${value}T"){ diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/quotes_asset/QuoteAsset.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/quotes_asset/QuoteAsset.kt new file mode 100644 index 0000000..8230530 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/quotes_asset/QuoteAsset.kt @@ -0,0 +1,10 @@ +package dev.pinkroom.marketsight.domain.model.quotes_asset + +import java.time.LocalDateTime + +data class QuoteAsset( + val id: Long, + val bidPrice: Double, + val askPrice: Double, + val timeStamp: LocalDateTime, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/quotes_asset/QuotesResponse.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/quotes_asset/QuotesResponse.kt new file mode 100644 index 0000000..5ae5f3c --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/quotes_asset/QuotesResponse.kt @@ -0,0 +1,6 @@ +package dev.pinkroom.marketsight.domain.model.quotes_asset + +data class QuotesResponse( + val quotes: List, + val pageToken: String? = null, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/trades_asset/TradeAsset.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/trades_asset/TradeAsset.kt new file mode 100644 index 0000000..6fdac40 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/trades_asset/TradeAsset.kt @@ -0,0 +1,9 @@ +package dev.pinkroom.marketsight.domain.model.trades_asset + +import java.time.LocalDateTime + +data class TradeAsset( + val id: Long, + val tradePrice: Double, + val timeStamp: LocalDateTime, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/trades_asset/TradesResponse.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/trades_asset/TradesResponse.kt new file mode 100644 index 0000000..25888de --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/trades_asset/TradesResponse.kt @@ -0,0 +1,6 @@ +package dev.pinkroom.marketsight.domain.model.trades_asset + +data class TradesResponse( + val trades: List, + val pageToken: String? = null, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/AssetsRepository.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/AssetsRepository.kt index e926ac2..293f6cf 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/AssetsRepository.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/AssetsRepository.kt @@ -1,11 +1,48 @@ package dev.pinkroom.marketsight.domain.repository +import dev.pinkroom.marketsight.common.Constants import dev.pinkroom.marketsight.common.Resource +import dev.pinkroom.marketsight.common.SortType import dev.pinkroom.marketsight.domain.model.assets.Asset import dev.pinkroom.marketsight.domain.model.assets.TypeAsset +import dev.pinkroom.marketsight.domain.model.bars_asset.BarAsset +import dev.pinkroom.marketsight.domain.model.bars_asset.TimeFrame +import dev.pinkroom.marketsight.domain.model.quotes_asset.QuotesResponse +import dev.pinkroom.marketsight.domain.model.trades_asset.TradesResponse +import java.time.LocalDateTime interface AssetsRepository { suspend fun getAllAssets( typeAsset: TypeAsset ): Resource> + + suspend fun getBars( + symbol: String, + typeAsset: TypeAsset, + timeFrame: TimeFrame? = TimeFrame.Day, + limit: Int? = Constants.DEFAULT_LIMIT_ASSET, + startDate: LocalDateTime, + endDate: LocalDateTime, + sort: SortType? = SortType.ASC, + ): Resource> + + suspend fun getTrades( + symbol: String, + typeAsset: TypeAsset, + limit: Int? = Constants.DEFAULT_LIMIT_ASSET, + startDate: LocalDateTime? = null, + endDate: LocalDateTime? = null, + sort: SortType? = SortType.ASC, + pageToken: String? = null, + ): Resource + + suspend fun getQuotes( + symbol: String, + typeAsset: TypeAsset, + limit: Int? = Constants.DEFAULT_LIMIT_ASSET, + startDate: LocalDateTime? = null, + endDate: LocalDateTime? = null, + sort: SortType? = SortType.ASC, + pageToken: String? = null, + ): Resource } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/CryptoRepository.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/CryptoRepository.kt deleted file mode 100644 index 98d6d75..0000000 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/CryptoRepository.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.pinkroom.marketsight.domain.repository - -interface CryptoRepository { -} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/StockRepository.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/StockRepository.kt deleted file mode 100644 index be25db5..0000000 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/StockRepository.kt +++ /dev/null @@ -1,19 +0,0 @@ -package dev.pinkroom.marketsight.domain.repository - -import dev.pinkroom.marketsight.common.Resource -import dev.pinkroom.marketsight.common.SortType -import dev.pinkroom.marketsight.domain.model.historical_bars.BarAsset -import dev.pinkroom.marketsight.domain.model.historical_bars.TimeFrame - -interface StockRepository { - suspend fun getHistoricalBars( - symbol: String, - timeFrame: TimeFrame? = TimeFrame.Day, - limit: Int? = 1000, - startDate: String, - endDate: String, - sort: SortType? = SortType.ASC, - ): Resource> - - //fun getRealTimeTrades(): Flow> -} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetBarsAssets.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetBarsAssets.kt new file mode 100644 index 0000000..87e5378 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetBarsAssets.kt @@ -0,0 +1,31 @@ +package dev.pinkroom.marketsight.domain.use_case.assets + +import dev.pinkroom.marketsight.common.Constants +import dev.pinkroom.marketsight.common.SortType +import dev.pinkroom.marketsight.domain.model.assets.TypeAsset +import dev.pinkroom.marketsight.domain.model.bars_asset.TimeFrame +import dev.pinkroom.marketsight.domain.repository.AssetsRepository +import java.time.LocalDateTime +import javax.inject.Inject + +class GetBarsAssets @Inject constructor( + private val assetsRepository: AssetsRepository, +){ + suspend operator fun invoke( + symbol: String, + typeAsset: TypeAsset, + timeFrame: TimeFrame? = TimeFrame.Day, + limit: Int? = Constants.DEFAULT_LIMIT_ASSET, + startDate: LocalDateTime, + endDate: LocalDateTime, + sort: SortType? = SortType.ASC, + ) = assetsRepository.getBars( + typeAsset = typeAsset, + sort = sort, + timeFrame = timeFrame, + limit = limit, + endDate = endDate, + startDate = startDate, + symbol = symbol, + ) +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetQuotesAssets.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetQuotesAssets.kt new file mode 100644 index 0000000..72a50e1 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetQuotesAssets.kt @@ -0,0 +1,30 @@ +package dev.pinkroom.marketsight.domain.use_case.assets + +import dev.pinkroom.marketsight.common.Constants +import dev.pinkroom.marketsight.common.SortType +import dev.pinkroom.marketsight.domain.model.assets.TypeAsset +import dev.pinkroom.marketsight.domain.repository.AssetsRepository +import java.time.LocalDateTime +import javax.inject.Inject + +class GetQuotesAssets @Inject constructor( + private val assetsRepository: AssetsRepository, +){ + suspend operator fun invoke( + symbol: String, + typeAsset: TypeAsset, + limit: Int? = Constants.DEFAULT_LIMIT_ASSET, + startDate: LocalDateTime, + endDate: LocalDateTime, + sort: SortType? = SortType.ASC, + pageToken: String? = null, + ) = assetsRepository.getQuotes( + typeAsset = typeAsset, + sort = sort, + limit = limit, + endDate = endDate, + startDate = startDate, + symbol = symbol, + pageToken = pageToken, + ) +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetTradesAssets.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetTradesAssets.kt new file mode 100644 index 0000000..dfd0157 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetTradesAssets.kt @@ -0,0 +1,30 @@ +package dev.pinkroom.marketsight.domain.use_case.assets + +import dev.pinkroom.marketsight.common.Constants +import dev.pinkroom.marketsight.common.SortType +import dev.pinkroom.marketsight.domain.model.assets.TypeAsset +import dev.pinkroom.marketsight.domain.repository.AssetsRepository +import java.time.LocalDateTime +import javax.inject.Inject + +class GetTradesAssets @Inject constructor( + private val assetsRepository: AssetsRepository, +){ + suspend operator fun invoke( + symbol: String, + typeAsset: TypeAsset, + limit: Int? = Constants.DEFAULT_LIMIT_ASSET, + startDate: LocalDateTime, + endDate: LocalDateTime, + sort: SortType? = SortType.ASC, + pageToken: String? = null, + ) = assetsRepository.getTrades( + typeAsset = typeAsset, + sort = sort, + limit = limit, + endDate = endDate, + startDate = startDate, + symbol = symbol, + pageToken = pageToken, + ) +} \ No newline at end of file From faaf727cc7d42170432c2b43d727ec164cd52bbe Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Mon, 6 May 2024 11:00:16 +0100 Subject: [PATCH 28/33] - use case to get realtime tardes, quotes and bar - use case subscribe/unsubscribe asset --- .../pinkroom/marketsight/common/GsonUtils.kt | 8 +- .../HelperIdentifierMessagesAlpacaService.kt | 8 +- .../marketsight/common/WebSocketLifecycle.kt | 21 ++ .../data_source/AssetsRemoteDataSource.kt | 101 --------- .../data_source/MarketRemoteDataSource.kt | 199 ++++++++++++++++++ .../data/data_source/NewsRemoteDataSource.kt | 4 +- .../marketsight/data/mapper/RemoteMapper.kt | 23 +- .../model/dto/alpaca_api/BarAssetDto.kt | 1 + .../model/dto/alpaca_api/BarsResponseDto.kt | 2 +- .../model/dto/alpaca_api/QuoteAssetDto.kt | 1 + .../model/dto/alpaca_api/TradeAssetDto.kt | 1 + .../SubscriptionMessageDto.kt | 1 + .../model/request/MessageAlpacaService.kt | 1 + .../data/repository/AssetsRepositoryImp.kt | 65 +++++- .../dev/pinkroom/marketsight/di/AppModule.kt | 37 ++++ .../domain/model/bars_asset/BarAsset.kt | 1 + .../domain/model/quotes_asset/QuoteAsset.kt | 1 + .../domain/model/trades_asset/TradeAsset.kt | 1 + .../domain/repository/AssetsRepository.kt | 31 +++ .../GetBarsAsset.kt} | 4 +- .../GetQuotesAsset.kt} | 4 +- .../use_case/market/GetRealTimeBarsAsset.kt | 20 ++ .../use_case/market/GetRealTimeQuotesAsset.kt | 20 ++ .../use_case/market/GetRealTimeTradesAsset.kt | 20 ++ .../use_case/market/GetStatusServiceAsset.kt | 18 ++ .../GetTradesAsset.kt} | 4 +- .../market/SetSubscribeRealTimeAsset.kt | 19 ++ .../market/SetUnsubscribeRealTimeAsset.kt | 19 ++ .../marketsight/presentation/MainActivity.kt | 2 +- .../presentation/home_screen/HomeViewModel.kt | 2 +- 30 files changed, 514 insertions(+), 125 deletions(-) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/common/WebSocketLifecycle.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/data/data_source/MarketRemoteDataSource.kt rename app/src/main/java/dev/pinkroom/marketsight/domain/use_case/{assets/GetBarsAssets.kt => market/GetBarsAsset.kt} (90%) rename app/src/main/java/dev/pinkroom/marketsight/domain/use_case/{assets/GetQuotesAssets.kt => market/GetQuotesAsset.kt} (89%) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetRealTimeBarsAsset.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetRealTimeQuotesAsset.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetRealTimeTradesAsset.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetStatusServiceAsset.kt rename app/src/main/java/dev/pinkroom/marketsight/domain/use_case/{assets/GetTradesAssets.kt => market/GetTradesAsset.kt} (89%) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/SetSubscribeRealTimeAsset.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/SetUnsubscribeRealTimeAsset.kt diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/GsonUtils.kt b/app/src/main/java/dev/pinkroom/marketsight/common/GsonUtils.kt index c504068..81ca816 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/common/GsonUtils.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/common/GsonUtils.kt @@ -13,12 +13,10 @@ fun Gson.toObject(value: Any, helperIdentifier: HelperIdentifierMessagesAlpa } else null } -fun Gson.verifyIfIsError(jsonValue: String): ErrorMessageDto? { +fun Gson.verifyIfIsError(value: Any): ErrorMessageDto? { val helperIdentifier = HelperIdentifierMessagesAlpacaService.Error - fromJson(jsonValue, Array::class.java).toList().forEach { data -> - toObject(value = data, helperIdentifier = helperIdentifier)?.let { - return it - } + toObject(value = value, helperIdentifier = helperIdentifier)?.let { + return it } return null } diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/HelperIdentifierMessagesAlpacaService.kt b/app/src/main/java/dev/pinkroom/marketsight/common/HelperIdentifierMessagesAlpacaService.kt index 50099b0..50a0722 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/common/HelperIdentifierMessagesAlpacaService.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/common/HelperIdentifierMessagesAlpacaService.kt @@ -1,5 +1,8 @@ package dev.pinkroom.marketsight.common +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.BarAssetDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.QuoteAssetDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.TradeAssetDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.ErrorMessageDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.NewsMessageDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.SubscriptionMessageDto @@ -9,8 +12,9 @@ sealed class HelperIdentifierMessagesAlpacaService( val classOfT: Class? = null, ){ data object News: HelperIdentifierMessagesAlpacaService(identifier = "n", classOfT = NewsMessageDto::class.java) - data object Stocks: HelperIdentifierMessagesAlpacaService(identifier = "q") - data object Crypto: HelperIdentifierMessagesAlpacaService(identifier = "t") + data object Trades: HelperIdentifierMessagesAlpacaService(identifier = "t", classOfT = TradeAssetDto::class.java) + data object Quotes: HelperIdentifierMessagesAlpacaService(identifier = "q", classOfT = QuoteAssetDto::class.java) + data object Bars: HelperIdentifierMessagesAlpacaService(identifier = "b", classOfT = BarAssetDto::class.java) data object Success: HelperIdentifierMessagesAlpacaService(identifier = "success") data object Error: HelperIdentifierMessagesAlpacaService(identifier = "error", classOfT = ErrorMessageDto::class.java) data object Subscription: HelperIdentifierMessagesAlpacaService(identifier = "subscription", classOfT = SubscriptionMessageDto::class.java) diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/WebSocketLifecycle.kt b/app/src/main/java/dev/pinkroom/marketsight/common/WebSocketLifecycle.kt new file mode 100644 index 0000000..a1167fc --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/common/WebSocketLifecycle.kt @@ -0,0 +1,21 @@ +package dev.pinkroom.marketsight.common + +import androidx.lifecycle.DefaultLifecycleObserver +import androidx.lifecycle.LifecycleOwner +import com.tinder.scarlet.Lifecycle +import com.tinder.scarlet.lifecycle.LifecycleRegistry + +class WebSocketLifecycle( + private val lifecycleRegistry: LifecycleRegistry, +) : Lifecycle by lifecycleRegistry, DefaultLifecycleObserver { + + override fun onStart(owner: LifecycleOwner) { + super.onStart(owner) + lifecycleRegistry.onNext(Lifecycle.State.Started) + } + + override fun onDestroy(owner: LifecycleOwner) { + super.onDestroy(owner) + lifecycleRegistry.onComplete() + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/AssetsRemoteDataSource.kt b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/AssetsRemoteDataSource.kt index 0d11bc0..3db7889 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/AssetsRemoteDataSource.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/AssetsRemoteDataSource.kt @@ -1,115 +1,14 @@ package dev.pinkroom.marketsight.data.data_source -import dev.pinkroom.marketsight.common.Constants -import dev.pinkroom.marketsight.common.SortType -import dev.pinkroom.marketsight.common.formatToStandardIso -import dev.pinkroom.marketsight.data.mapper.toQuotesResponseDto -import dev.pinkroom.marketsight.data.mapper.toTradesResponseDto -import dev.pinkroom.marketsight.data.remote.AlpacaCryptoApi import dev.pinkroom.marketsight.data.remote.AlpacaPaperApi -import dev.pinkroom.marketsight.data.remote.AlpacaStockApi -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.BarAssetDto -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.QuotesResponseDto -import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.TradesResponseDto import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_paper_api.AssetDto import dev.pinkroom.marketsight.domain.model.assets.TypeAsset -import dev.pinkroom.marketsight.domain.model.bars_asset.TimeFrame -import java.time.LocalDateTime import javax.inject.Inject class AssetsRemoteDataSource @Inject constructor( private val alpacaPaperApi: AlpacaPaperApi, - private val alpacaStockApi: AlpacaStockApi, - private val alpacaCryptoApi: AlpacaCryptoApi, ) { suspend fun getAllAssets(typeAsset: TypeAsset): List { return alpacaPaperApi.getAssets(typeAsset = typeAsset.value) } - - suspend fun getBars( - symbol: String, - typeAsset: TypeAsset, - timeFrame: TimeFrame? = TimeFrame.Day, - limit: Int? = Constants.DEFAULT_LIMIT_ASSET, - startDate: LocalDateTime, - endDate: LocalDateTime, - sort: SortType? = SortType.ASC, - ): List { - return if (typeAsset is TypeAsset.Stock) - alpacaStockApi.getHistoricalBarsStock( - symbol = symbol, - startDate = startDate.formatToStandardIso(), - endDate = endDate.formatToStandardIso(), - sort = sort?.type, - limit = limit, - timeFrame = timeFrame?.frameValue, - ).bars - else - alpacaCryptoApi.getHistoricalBarsCrypto( - symbol = symbol, - startDate = startDate.formatToStandardIso(), - endDate = endDate.formatToStandardIso(), - sort = sort?.type, - limit = limit, - timeFrame = timeFrame?.frameValue, - ).bars.entries.first().value - } - - suspend fun getTrades( - symbol: String, - typeAsset: TypeAsset, - limit: Int? = Constants.DEFAULT_LIMIT_ASSET, - startDate: LocalDateTime? = null, - endDate: LocalDateTime? = null, - sort: SortType? = SortType.ASC, - pageToken: String? = null, - ): TradesResponseDto { - return if (typeAsset is TypeAsset.Stock) - alpacaStockApi.getHistoricalTradesStock( - symbol = symbol, - startDate = startDate?.formatToStandardIso(), - endDate = endDate?.formatToStandardIso(), - sort = sort?.type, - limit = limit, - pageToken = pageToken - ) - else - alpacaCryptoApi.getHistoricalTradesCrypto( - symbol = symbol, - startDate = startDate?.formatToStandardIso(), - endDate = endDate?.formatToStandardIso(), - sort = sort?.type, - limit = limit, - pageToken = pageToken - ).toTradesResponseDto() - } - - suspend fun getQuotes( - symbol: String, - typeAsset: TypeAsset, - limit: Int? = Constants.DEFAULT_LIMIT_ASSET, - startDate: LocalDateTime? = null, - endDate: LocalDateTime? = null, - sort: SortType? = SortType.ASC, - pageToken: String? = null, - ): QuotesResponseDto { - return if (typeAsset is TypeAsset.Stock) - alpacaStockApi.getHistoricalQuotesStock( - symbol = symbol, - startDate = startDate?.formatToStandardIso(), - endDate = endDate?.formatToStandardIso(), - sort = sort?.type, - limit = limit, - pageToken = pageToken - ) - else - alpacaCryptoApi.getHistoricalQuotesCrypto( - symbol = symbol, - startDate = startDate?.formatToStandardIso(), - endDate = endDate?.formatToStandardIso(), - sort = sort?.type, - limit = limit, - pageToken = pageToken - ).toQuotesResponseDto() - } } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/MarketRemoteDataSource.kt b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/MarketRemoteDataSource.kt new file mode 100644 index 0000000..e7a5f69 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/MarketRemoteDataSource.kt @@ -0,0 +1,199 @@ +package dev.pinkroom.marketsight.data.data_source + +import com.google.gson.Gson +import dev.pinkroom.marketsight.common.ActionAlpaca +import dev.pinkroom.marketsight.common.Constants +import dev.pinkroom.marketsight.common.DispatcherProvider +import dev.pinkroom.marketsight.common.HelperIdentifierMessagesAlpacaService +import dev.pinkroom.marketsight.common.SortType +import dev.pinkroom.marketsight.common.formatToStandardIso +import dev.pinkroom.marketsight.common.toObject +import dev.pinkroom.marketsight.common.verifyIfIsError +import dev.pinkroom.marketsight.data.mapper.toQuotesResponseDto +import dev.pinkroom.marketsight.data.mapper.toTradesResponseDto +import dev.pinkroom.marketsight.data.remote.AlpacaCryptoApi +import dev.pinkroom.marketsight.data.remote.AlpacaService +import dev.pinkroom.marketsight.data.remote.AlpacaStockApi +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.BarAssetDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.QuotesResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.TradesResponseDto +import dev.pinkroom.marketsight.data.remote.model.request.MessageAlpacaService +import dev.pinkroom.marketsight.domain.model.assets.TypeAsset +import dev.pinkroom.marketsight.domain.model.bars_asset.TimeFrame +import kotlinx.coroutines.cancel +import kotlinx.coroutines.currentCoroutineContext +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.flowOn +import java.time.LocalDateTime +import javax.inject.Inject + +class MarketRemoteDataSource @Inject constructor( + private val alpacaStockApi: AlpacaStockApi, + private val alpacaServiceStock: AlpacaService, + private val alpacaServiceCrypto: AlpacaService, + private val alpacaCryptoApi: AlpacaCryptoApi, + private val dispatchers: DispatcherProvider, + private val gson: Gson, +) { + suspend fun getBars( + symbol: String, + typeAsset: TypeAsset, + timeFrame: TimeFrame? = TimeFrame.Day, + limit: Int? = Constants.DEFAULT_LIMIT_ASSET, + startDate: LocalDateTime, + endDate: LocalDateTime, + sort: SortType? = SortType.ASC, + ): List { + return if (typeAsset is TypeAsset.Stock) + alpacaStockApi.getHistoricalBarsStock( + symbol = symbol, + startDate = startDate.formatToStandardIso(), + endDate = endDate.formatToStandardIso(), + sort = sort?.type, + limit = limit, + timeFrame = timeFrame?.frameValue, + ).bars ?: emptyList() + else + alpacaCryptoApi.getHistoricalBarsCrypto( + symbol = symbol, + startDate = startDate.formatToStandardIso(), + endDate = endDate.formatToStandardIso(), + sort = sort?.type, + limit = limit, + timeFrame = timeFrame?.frameValue, + ).bars.entries.first().value + } + + fun getRealTimeBars( + typeAsset: TypeAsset, + ) = getRealTimeData( + typeAsset = typeAsset, + helperIdentifierMessagesAlpacaService = HelperIdentifierMessagesAlpacaService.Bars + ).flowOn(dispatchers.IO) + + suspend fun getTrades( + symbol: String, + typeAsset: TypeAsset, + limit: Int? = Constants.DEFAULT_LIMIT_ASSET, + startDate: LocalDateTime? = null, + endDate: LocalDateTime? = null, + sort: SortType? = SortType.ASC, + pageToken: String? = null, + ): TradesResponseDto { + return if (typeAsset is TypeAsset.Stock) + alpacaStockApi.getHistoricalTradesStock( + symbol = symbol, + startDate = startDate?.formatToStandardIso(), + endDate = endDate?.formatToStandardIso(), + sort = sort?.type, + limit = limit, + pageToken = pageToken + ) + else + alpacaCryptoApi.getHistoricalTradesCrypto( + symbol = symbol, + startDate = startDate?.formatToStandardIso(), + endDate = endDate?.formatToStandardIso(), + sort = sort?.type, + limit = limit, + pageToken = pageToken + ).toTradesResponseDto() + } + + fun getRealTimeTrades( + typeAsset: TypeAsset, + ) = getRealTimeData( + typeAsset = typeAsset, + helperIdentifierMessagesAlpacaService = HelperIdentifierMessagesAlpacaService.Trades + ).flowOn(dispatchers.IO) + + suspend fun getQuotes( + symbol: String, + typeAsset: TypeAsset, + limit: Int? = Constants.DEFAULT_LIMIT_ASSET, + startDate: LocalDateTime? = null, + endDate: LocalDateTime? = null, + sort: SortType? = SortType.ASC, + pageToken: String? = null, + ): QuotesResponseDto { + return if (typeAsset is TypeAsset.Stock) + alpacaStockApi.getHistoricalQuotesStock( + symbol = symbol, + startDate = startDate?.formatToStandardIso(), + endDate = endDate?.formatToStandardIso(), + sort = sort?.type, + limit = limit, + pageToken = pageToken + ) + else + alpacaCryptoApi.getHistoricalQuotesCrypto( + symbol = symbol, + startDate = startDate?.formatToStandardIso(), + endDate = endDate?.formatToStandardIso(), + sort = sort?.type, + limit = limit, + pageToken = pageToken + ).toQuotesResponseDto() + } + + fun getRealTimeQuotes( + typeAsset: TypeAsset, + ) = getRealTimeData( + typeAsset = typeAsset, + helperIdentifierMessagesAlpacaService = HelperIdentifierMessagesAlpacaService.Quotes + ).flowOn(dispatchers.IO) + + fun subscribeUnsubscribeRealTimeFinancialData( + action: ActionAlpaca, + typeAsset: TypeAsset, + symbol: String, + ) = flow { + val serviceToUse = getServiceToUse(typeAsset = typeAsset) + val symbols = listOf(symbol) + val message = MessageAlpacaService( + action = action.action, trades = symbols, + quotes = symbols, bars = symbols, + ) + serviceToUse.sendMessage(message = message) + serviceToUse.observeResponse().collect { data -> + data.forEach { + gson.toObject(value = it, helperIdentifier = HelperIdentifierMessagesAlpacaService.Subscription)?.let { sub -> + emit(sub) + currentCoroutineContext().cancel() + } ?: run { + if (gson.verifyIfIsError(it) != null){ + throw Exception("Error on Subscription") + } + } + } + } + }.flowOn(dispatchers.IO) + + fun statusService( + typeAsset: TypeAsset + ) = flow { + val serviceToUse = getServiceToUse(typeAsset = typeAsset) + serviceToUse.observeOnConnectionEvent().collect(this) + }.flowOn(dispatchers.IO) + + private fun getRealTimeData( + typeAsset: TypeAsset, + helperIdentifierMessagesAlpacaService: HelperIdentifierMessagesAlpacaService, + ) = flow { + val serviceToUse = getServiceToUse(typeAsset = typeAsset) + serviceToUse.observeResponse().collect{ data -> + val listObject = mutableListOf() + data.forEach { + gson.toObject(value = it, helperIdentifier = helperIdentifierMessagesAlpacaService)?.let { response -> + listObject.add(response) + } + } + if (listObject.isNotEmpty()){ + emit(listObject.toList()) + } + } + }.flowOn(dispatchers.IO) + + private fun getServiceToUse(typeAsset: TypeAsset) = if (typeAsset is TypeAsset.Stock) alpacaServiceStock + else alpacaServiceCrypto +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt index af9811d..02766f6 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/data_source/NewsRemoteDataSource.kt @@ -46,7 +46,9 @@ class NewsRemoteDataSource @Inject constructor( } fun getRealTimeNews() = flow { - if (!isNewsSubscribed) subscribeNews() + if (!isNewsSubscribed){ + subscribeNews() + } alpacaService.observeResponse().collect{ data -> val listNews = mutableListOf() data.forEach { diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt b/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt index 21d8758..f945415 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt @@ -58,7 +58,19 @@ fun SubscriptionMessageDto.toSubscriptionMessage() = SubscriptionMessage( fun String.toLocalDateTime(): LocalDateTime { val parser = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.getDefault()) - val date = LocalDateTime.parse(this, parser) + val date = try { + LocalDateTime.parse(this, parser) + } catch (e: Exception) { LocalDateTime.now() } + return date.atZone(ZoneOffset.UTC).withZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime() +} + +fun String.toLocalDateTimeWithNanoSecond(): LocalDateTime { + val max = this.count().coerceAtMost(22) + val formatStringDate = this.subSequence(0,max) + val parser = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SS", Locale.getDefault()) + val date = try { + LocalDateTime.parse(formatStringDate, parser) + } catch (e: Exception) { LocalDateTime.now() } return date.atZone(ZoneOffset.UTC).withZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime() } @@ -108,8 +120,9 @@ fun BarAssetDto.toBarAsset() = BarAsset( barVolume = barVolume, lowPrice = lowPrice, tradeCountInBar = tradeCountInBar, - timestamp = timestamp.toLocalDateTime(), + timestamp = timestamp.toLocalDateTimeWithNanoSecond(), volumeWeightedAvgPrice = volumeWeightedAvgPrice, + symbol = symbol, ) fun QuotesResponseDto.toQuotesResponse() = QuotesResponse( @@ -121,7 +134,8 @@ fun QuoteAssetDto.toQuoteAsset() = QuoteAsset( id = tradeId, bidPrice = bidPrice, askPrice = askPrice, - timeStamp = timeStamp.toLocalDateTime(), + timeStamp = timeStamp.toLocalDateTimeWithNanoSecond(), + symbol = symbol, ) fun QuotesCryptoResponseDto.toQuotesResponseDto() = QuotesResponseDto( @@ -137,7 +151,8 @@ fun TradesResponseDto.toTradesResponse() = TradesResponse( fun TradeAssetDto.toTradeAsset() = TradeAsset( id = tradeId, tradePrice = tradePrice, - timeStamp = timeStamp.toLocalDateTime(), + timeStamp = timeStamp.toLocalDateTimeWithNanoSecond(), + symbol = symbol, ) fun TradesCryptoResponseDto.toTradesResponseDto() = TradesResponseDto( diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/BarAssetDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/BarAssetDto.kt index 66e6cfe..c26f329 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/BarAssetDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/BarAssetDto.kt @@ -11,4 +11,5 @@ data class BarAssetDto( @SerializedName("t") val timestamp: String, @SerializedName("v") val barVolume: Double, @SerializedName("vw") val volumeWeightedAvgPrice: Double, + @SerializedName("S") val symbol: String? = null, ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/BarsResponseDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/BarsResponseDto.kt index eeb9ac5..58e2a6a 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/BarsResponseDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/BarsResponseDto.kt @@ -3,7 +3,7 @@ package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api import com.google.gson.annotations.SerializedName data class BarsResponseDto( - val bars: List, + val bars: List? = null, @SerializedName("next_page_token") val nextPageToken: String? = null, val symbol: String, ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/QuoteAssetDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/QuoteAssetDto.kt index 5ba9445..6df421a 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/QuoteAssetDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/QuoteAssetDto.kt @@ -7,4 +7,5 @@ data class QuoteAssetDto( @SerializedName("bp") val bidPrice: Double, @SerializedName("ap") val askPrice: Double, @SerializedName("t") val timeStamp: String, + @SerializedName("S") val symbol: String? = null, ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/TradeAssetDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/TradeAssetDto.kt index 427a5cd..55aa615 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/TradeAssetDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/TradeAssetDto.kt @@ -6,4 +6,5 @@ data class TradeAssetDto( @SerializedName("i") val tradeId: Long, @SerializedName("p") val tradePrice: Double, @SerializedName("t") val timeStamp: String, + @SerializedName("S") val symbol: String? = null, ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/SubscriptionMessageDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/SubscriptionMessageDto.kt index ccbd2d3..7ac48ff 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/SubscriptionMessageDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_news_service/SubscriptionMessageDto.kt @@ -7,4 +7,5 @@ data class SubscriptionMessageDto( val news: List? = null, val quotes: List? = null, val trades: List? = null, + val bars: List? = null, ) \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/request/MessageAlpacaService.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/request/MessageAlpacaService.kt index ea1a837..d2df7c5 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/request/MessageAlpacaService.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/request/MessageAlpacaService.kt @@ -4,5 +4,6 @@ data class MessageAlpacaService( val action: String, // subscribe / unsubscribe val trades: List? = null, val quotes: List? = null, + val bars: List? = null, val news: List? = null, ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/repository/AssetsRepositoryImp.kt b/app/src/main/java/dev/pinkroom/marketsight/data/repository/AssetsRepositoryImp.kt index cc7bfa8..1add206 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/repository/AssetsRepositoryImp.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/repository/AssetsRepositoryImp.kt @@ -1,24 +1,36 @@ package dev.pinkroom.marketsight.data.repository +import dev.pinkroom.marketsight.common.ActionAlpaca +import dev.pinkroom.marketsight.common.DispatcherProvider import dev.pinkroom.marketsight.common.Resource import dev.pinkroom.marketsight.common.SortType import dev.pinkroom.marketsight.data.data_source.AssetsRemoteDataSource +import dev.pinkroom.marketsight.data.data_source.MarketRemoteDataSource import dev.pinkroom.marketsight.data.mapper.toAsset import dev.pinkroom.marketsight.data.mapper.toBarAsset +import dev.pinkroom.marketsight.data.mapper.toQuoteAsset import dev.pinkroom.marketsight.data.mapper.toQuotesResponse +import dev.pinkroom.marketsight.data.mapper.toSubscriptionMessage +import dev.pinkroom.marketsight.data.mapper.toTradeAsset import dev.pinkroom.marketsight.data.mapper.toTradesResponse import dev.pinkroom.marketsight.domain.model.assets.Asset import dev.pinkroom.marketsight.domain.model.assets.TypeAsset import dev.pinkroom.marketsight.domain.model.bars_asset.BarAsset import dev.pinkroom.marketsight.domain.model.bars_asset.TimeFrame +import dev.pinkroom.marketsight.domain.model.common.SubscriptionMessage import dev.pinkroom.marketsight.domain.model.quotes_asset.QuotesResponse import dev.pinkroom.marketsight.domain.model.trades_asset.TradesResponse import dev.pinkroom.marketsight.domain.repository.AssetsRepository +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.flowOn +import kotlinx.coroutines.flow.single import java.time.LocalDateTime import javax.inject.Inject class AssetsRepositoryImp @Inject constructor( private val assetsRemoteDataSource: AssetsRemoteDataSource, + private val marketRemoteDataSource: MarketRemoteDataSource, + private val dispatchers: DispatcherProvider, ): AssetsRepository { override suspend fun getAllAssets(typeAsset: TypeAsset): Resource> { return try { @@ -42,7 +54,7 @@ class AssetsRepositoryImp @Inject constructor( sort: SortType? ): Resource> { return try { - val response = assetsRemoteDataSource.getBars( + val response = marketRemoteDataSource.getBars( symbol = symbol, typeAsset = typeAsset, timeFrame = timeFrame, @@ -67,7 +79,7 @@ class AssetsRepositoryImp @Inject constructor( pageToken: String? ): Resource { return try { - val response = assetsRemoteDataSource.getTrades( + val response = marketRemoteDataSource.getTrades( symbol = symbol, typeAsset = typeAsset, limit = limit, @@ -93,7 +105,7 @@ class AssetsRepositoryImp @Inject constructor( pageToken: String? ): Resource { return try { - val response = assetsRemoteDataSource.getQuotes( + val response = marketRemoteDataSource.getQuotes( symbol = symbol, typeAsset = typeAsset, limit = limit, @@ -108,4 +120,51 @@ class AssetsRepositoryImp @Inject constructor( Resource.Error(message = e.message ?: "Something Went Wrong on Get Historical quotes") } } + + override fun getRealTimeBars(symbol: String, typeAsset: TypeAsset) = flow { + marketRemoteDataSource.getRealTimeBars( + typeAsset = typeAsset + ).collect{ response -> + val dataRelatedToRequiredSymbol = response.filter { it.symbol == symbol }.map { it.toBarAsset() } + dataRelatedToRequiredSymbol.takeIf { it.isNotEmpty() }?.let { emit(it) } + } + }.flowOn(dispatchers.IO) + + override fun getRealTimeTrades(symbol: String, typeAsset: TypeAsset) = flow { + marketRemoteDataSource.getRealTimeTrades( + typeAsset = typeAsset + ).collect{ response -> + val dataRelatedToRequiredSymbol = response.filter { it.symbol == symbol }.map { it.toTradeAsset() } + dataRelatedToRequiredSymbol.takeIf { it.isNotEmpty() }?.let { emit(it) } + } + }.flowOn(dispatchers.IO) + + override fun getRealTimeQuotes(symbol: String, typeAsset: TypeAsset) = flow { + marketRemoteDataSource.getRealTimeQuotes( + typeAsset = typeAsset + ).collect{ response -> + val dataRelatedToRequiredSymbol = response.filter { it.symbol == symbol }.map { it.toQuoteAsset() } + dataRelatedToRequiredSymbol.takeIf { it.isNotEmpty() }?.let { emit(it) } + } + }.flowOn(dispatchers.IO) + + override suspend fun subscribeUnsubscribeRealTimeFinancialData( + action: ActionAlpaca, + typeAsset: TypeAsset, + symbol: String + ): Resource { + return try { + val response = marketRemoteDataSource.subscribeUnsubscribeRealTimeFinancialData( + action = action, typeAsset = typeAsset, symbol = symbol, + ).single() + Resource.Success(data = response.toSubscriptionMessage()) + } catch (e: Exception) { + e.printStackTrace() + Resource.Error(message = e.message ?: "Something Went Wrong on Subscription Financial Asset") + } + } + + override fun statusService(typeAsset: TypeAsset) = marketRemoteDataSource.statusService( + typeAsset = typeAsset, + ).flowOn(dispatchers.IO) } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt b/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt index 0d1450c..d9e0a6f 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/di/AppModule.kt @@ -21,13 +21,17 @@ import dev.pinkroom.marketsight.common.addAuthenticationInterceptor import dev.pinkroom.marketsight.common.addLoggingInterceptor import dev.pinkroom.marketsight.common.connection_network.ConnectivityObserver import dev.pinkroom.marketsight.common.connection_network.NetworkConnectivityObserver +import dev.pinkroom.marketsight.data.data_source.AssetsRemoteDataSource +import dev.pinkroom.marketsight.data.data_source.MarketRemoteDataSource import dev.pinkroom.marketsight.data.data_source.NewsRemoteDataSource import dev.pinkroom.marketsight.data.remote.AlpacaCryptoApi import dev.pinkroom.marketsight.data.remote.AlpacaNewsApi import dev.pinkroom.marketsight.data.remote.AlpacaPaperApi import dev.pinkroom.marketsight.data.remote.AlpacaService import dev.pinkroom.marketsight.data.remote.AlpacaStockApi +import dev.pinkroom.marketsight.data.repository.AssetsRepositoryImp import dev.pinkroom.marketsight.data.repository.NewsRepositoryImp +import dev.pinkroom.marketsight.domain.repository.AssetsRepository import dev.pinkroom.marketsight.domain.repository.NewsRepository import okhttp3.OkHttpClient import retrofit2.Retrofit @@ -196,12 +200,45 @@ object AppModule { return NewsRemoteDataSource(gson = gson, alpacaService = alpacaService, alpacaNewsApi = alpacaNewsApi, dispatchers = dispatcherProvider) } + @Provides + @Singleton + fun provideMarketRemoteDataSource( + gson: Gson, + dispatcherProvider: DispatcherProvider, + alpacaCryptoApi: AlpacaCryptoApi, + alpacaStockApi: AlpacaStockApi, + @Named(ALPACA_STOCK_SERVICE) alpacaServiceStock: AlpacaService, + @Named(ALPACA_CRYPTO_SERVICE) alpacaServiceCrypto: AlpacaService, + ): MarketRemoteDataSource { + return MarketRemoteDataSource( + alpacaServiceCrypto = alpacaServiceCrypto, + alpacaServiceStock = alpacaServiceStock, + dispatchers = dispatcherProvider, + alpacaCryptoApi = alpacaCryptoApi, + alpacaStockApi = alpacaStockApi, + gson = gson, + ) + } + @Provides @Singleton fun provideNewsRepository(newsRemoteDataSource: NewsRemoteDataSource, dispatcherProvider: DispatcherProvider): NewsRepository { return NewsRepositoryImp(newsRemoteDataSource = newsRemoteDataSource, dispatchers = dispatcherProvider) } + @Provides + @Singleton + fun provideAssetsRepository( + marketRemoteDataSource: MarketRemoteDataSource, + assetsRemoteDataSource: AssetsRemoteDataSource, + dispatcherProvider: DispatcherProvider, + ): AssetsRepository { + return AssetsRepositoryImp( + marketRemoteDataSource = marketRemoteDataSource, + assetsRemoteDataSource = assetsRemoteDataSource, dispatchers = dispatcherProvider, + ) + } + @Provides @Singleton fun provideConnectivityObserver(@ApplicationContext context: Context): ConnectivityObserver = diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/bars_asset/BarAsset.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/bars_asset/BarAsset.kt index 06e1038..ba3aca5 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/model/bars_asset/BarAsset.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/bars_asset/BarAsset.kt @@ -11,4 +11,5 @@ data class BarAsset( val timestamp: LocalDateTime, val barVolume: Double, val volumeWeightedAvgPrice: Double, + val symbol: String? = null, ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/quotes_asset/QuoteAsset.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/quotes_asset/QuoteAsset.kt index 8230530..6815093 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/model/quotes_asset/QuoteAsset.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/quotes_asset/QuoteAsset.kt @@ -7,4 +7,5 @@ data class QuoteAsset( val bidPrice: Double, val askPrice: Double, val timeStamp: LocalDateTime, + val symbol: String? = null, ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/trades_asset/TradeAsset.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/trades_asset/TradeAsset.kt index 6fdac40..baa2284 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/model/trades_asset/TradeAsset.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/trades_asset/TradeAsset.kt @@ -6,4 +6,5 @@ data class TradeAsset( val id: Long, val tradePrice: Double, val timeStamp: LocalDateTime, + val symbol: String? = null, ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/AssetsRepository.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/AssetsRepository.kt index 293f6cf..abeecd2 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/repository/AssetsRepository.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/repository/AssetsRepository.kt @@ -1,5 +1,7 @@ package dev.pinkroom.marketsight.domain.repository +import com.tinder.scarlet.WebSocket +import dev.pinkroom.marketsight.common.ActionAlpaca import dev.pinkroom.marketsight.common.Constants import dev.pinkroom.marketsight.common.Resource import dev.pinkroom.marketsight.common.SortType @@ -7,8 +9,12 @@ import dev.pinkroom.marketsight.domain.model.assets.Asset import dev.pinkroom.marketsight.domain.model.assets.TypeAsset import dev.pinkroom.marketsight.domain.model.bars_asset.BarAsset import dev.pinkroom.marketsight.domain.model.bars_asset.TimeFrame +import dev.pinkroom.marketsight.domain.model.common.SubscriptionMessage +import dev.pinkroom.marketsight.domain.model.quotes_asset.QuoteAsset import dev.pinkroom.marketsight.domain.model.quotes_asset.QuotesResponse +import dev.pinkroom.marketsight.domain.model.trades_asset.TradeAsset import dev.pinkroom.marketsight.domain.model.trades_asset.TradesResponse +import kotlinx.coroutines.flow.Flow import java.time.LocalDateTime interface AssetsRepository { @@ -45,4 +51,29 @@ interface AssetsRepository { sort: SortType? = SortType.ASC, pageToken: String? = null, ): Resource + + fun getRealTimeBars( + symbol: String, + typeAsset: TypeAsset, + ): Flow> + + fun getRealTimeTrades( + symbol: String, + typeAsset: TypeAsset, + ): Flow> + + fun getRealTimeQuotes( + symbol: String, + typeAsset: TypeAsset, + ): Flow> + + suspend fun subscribeUnsubscribeRealTimeFinancialData( + action: ActionAlpaca, + typeAsset: TypeAsset, + symbol: String, + ): Resource + + fun statusService( + typeAsset: TypeAsset + ): Flow } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetBarsAssets.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetBarsAsset.kt similarity index 90% rename from app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetBarsAssets.kt rename to app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetBarsAsset.kt index 87e5378..979331f 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetBarsAssets.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetBarsAsset.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.domain.use_case.assets +package dev.pinkroom.marketsight.domain.use_case.market import dev.pinkroom.marketsight.common.Constants import dev.pinkroom.marketsight.common.SortType @@ -8,7 +8,7 @@ import dev.pinkroom.marketsight.domain.repository.AssetsRepository import java.time.LocalDateTime import javax.inject.Inject -class GetBarsAssets @Inject constructor( +class GetBarsAsset @Inject constructor( private val assetsRepository: AssetsRepository, ){ suspend operator fun invoke( diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetQuotesAssets.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetQuotesAsset.kt similarity index 89% rename from app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetQuotesAssets.kt rename to app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetQuotesAsset.kt index 72a50e1..795e17d 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetQuotesAssets.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetQuotesAsset.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.domain.use_case.assets +package dev.pinkroom.marketsight.domain.use_case.market import dev.pinkroom.marketsight.common.Constants import dev.pinkroom.marketsight.common.SortType @@ -7,7 +7,7 @@ import dev.pinkroom.marketsight.domain.repository.AssetsRepository import java.time.LocalDateTime import javax.inject.Inject -class GetQuotesAssets @Inject constructor( +class GetQuotesAsset @Inject constructor( private val assetsRepository: AssetsRepository, ){ suspend operator fun invoke( diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetRealTimeBarsAsset.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetRealTimeBarsAsset.kt new file mode 100644 index 0000000..8ecbada --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetRealTimeBarsAsset.kt @@ -0,0 +1,20 @@ +package dev.pinkroom.marketsight.domain.use_case.market + +import dev.pinkroom.marketsight.common.DispatcherProvider +import dev.pinkroom.marketsight.domain.model.assets.TypeAsset +import dev.pinkroom.marketsight.domain.repository.AssetsRepository +import kotlinx.coroutines.flow.flowOn +import javax.inject.Inject + +class GetRealTimeBarsAsset @Inject constructor( + private val assetsRepository: AssetsRepository, + private val dispatchers: DispatcherProvider, +) { + operator fun invoke( + symbol: String, + typeAsset: TypeAsset, + ) = assetsRepository.getRealTimeBars( + symbol = symbol, + typeAsset = typeAsset, + ).flowOn(dispatchers.IO) +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetRealTimeQuotesAsset.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetRealTimeQuotesAsset.kt new file mode 100644 index 0000000..476807c --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetRealTimeQuotesAsset.kt @@ -0,0 +1,20 @@ +package dev.pinkroom.marketsight.domain.use_case.market + +import dev.pinkroom.marketsight.common.DispatcherProvider +import dev.pinkroom.marketsight.domain.model.assets.TypeAsset +import dev.pinkroom.marketsight.domain.repository.AssetsRepository +import kotlinx.coroutines.flow.flowOn +import javax.inject.Inject + +class GetRealTimeQuotesAsset @Inject constructor( + private val assetsRepository: AssetsRepository, + private val dispatchers: DispatcherProvider, +) { + operator fun invoke( + symbol: String, + typeAsset: TypeAsset, + ) = assetsRepository.getRealTimeQuotes( + symbol = symbol, + typeAsset = typeAsset, + ).flowOn(dispatchers.IO) +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetRealTimeTradesAsset.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetRealTimeTradesAsset.kt new file mode 100644 index 0000000..ab68d0c --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetRealTimeTradesAsset.kt @@ -0,0 +1,20 @@ +package dev.pinkroom.marketsight.domain.use_case.market + +import dev.pinkroom.marketsight.common.DispatcherProvider +import dev.pinkroom.marketsight.domain.model.assets.TypeAsset +import dev.pinkroom.marketsight.domain.repository.AssetsRepository +import kotlinx.coroutines.flow.flowOn +import javax.inject.Inject + +class GetRealTimeTradesAsset @Inject constructor( + private val assetsRepository: AssetsRepository, + private val dispatchers: DispatcherProvider, +) { + operator fun invoke( + symbol: String, + typeAsset: TypeAsset, + ) = assetsRepository.getRealTimeTrades( + symbol = symbol, + typeAsset = typeAsset, + ).flowOn(dispatchers.IO) +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetStatusServiceAsset.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetStatusServiceAsset.kt new file mode 100644 index 0000000..6bd56fb --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetStatusServiceAsset.kt @@ -0,0 +1,18 @@ +package dev.pinkroom.marketsight.domain.use_case.market + +import dev.pinkroom.marketsight.common.DispatcherProvider +import dev.pinkroom.marketsight.domain.model.assets.TypeAsset +import dev.pinkroom.marketsight.domain.repository.AssetsRepository +import kotlinx.coroutines.flow.flowOn +import javax.inject.Inject + +class GetStatusServiceAsset @Inject constructor( + private val assetsRepository: AssetsRepository, + private val dispatcher: DispatcherProvider, +) { + operator fun invoke( + typeAsset: TypeAsset, + ) = assetsRepository.statusService( + typeAsset = typeAsset, + ).flowOn(dispatcher.IO) +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetTradesAssets.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetTradesAsset.kt similarity index 89% rename from app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetTradesAssets.kt rename to app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetTradesAsset.kt index dfd0157..cf07b4b 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/assets/GetTradesAssets.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/GetTradesAsset.kt @@ -1,4 +1,4 @@ -package dev.pinkroom.marketsight.domain.use_case.assets +package dev.pinkroom.marketsight.domain.use_case.market import dev.pinkroom.marketsight.common.Constants import dev.pinkroom.marketsight.common.SortType @@ -7,7 +7,7 @@ import dev.pinkroom.marketsight.domain.repository.AssetsRepository import java.time.LocalDateTime import javax.inject.Inject -class GetTradesAssets @Inject constructor( +class GetTradesAsset @Inject constructor( private val assetsRepository: AssetsRepository, ){ suspend operator fun invoke( diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/SetSubscribeRealTimeAsset.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/SetSubscribeRealTimeAsset.kt new file mode 100644 index 0000000..d2efafd --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/SetSubscribeRealTimeAsset.kt @@ -0,0 +1,19 @@ +package dev.pinkroom.marketsight.domain.use_case.market + +import dev.pinkroom.marketsight.common.ActionAlpaca +import dev.pinkroom.marketsight.domain.model.assets.TypeAsset +import dev.pinkroom.marketsight.domain.repository.AssetsRepository +import javax.inject.Inject + +class SetSubscribeRealTimeAsset @Inject constructor( + private val assetsRepository: AssetsRepository, +) { + suspend operator fun invoke( + symbol: String, + typeAsset: TypeAsset, + ) = assetsRepository.subscribeUnsubscribeRealTimeFinancialData( + symbol = symbol, + typeAsset = typeAsset, + action = ActionAlpaca.Subscribe, + ) +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/SetUnsubscribeRealTimeAsset.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/SetUnsubscribeRealTimeAsset.kt new file mode 100644 index 0000000..d33ebc0 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/use_case/market/SetUnsubscribeRealTimeAsset.kt @@ -0,0 +1,19 @@ +package dev.pinkroom.marketsight.domain.use_case.market + +import dev.pinkroom.marketsight.common.ActionAlpaca +import dev.pinkroom.marketsight.domain.model.assets.TypeAsset +import dev.pinkroom.marketsight.domain.repository.AssetsRepository +import javax.inject.Inject + +class SetUnsubscribeRealTimeAsset @Inject constructor( + private val assetsRepository: AssetsRepository, +) { + suspend operator fun invoke( + symbol: String, + typeAsset: TypeAsset, + ) = assetsRepository.subscribeUnsubscribeRealTimeFinancialData( + symbol = symbol, + typeAsset = typeAsset, + action = ActionAlpaca.Unsubscribe, + ) +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/presentation/MainActivity.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/MainActivity.kt index d9d66a3..9441105 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/presentation/MainActivity.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/MainActivity.kt @@ -28,7 +28,7 @@ class MainActivity : ComponentActivity() { setContent { val navController = rememberNavController() - val startDestination = Route.NewsScreen + val startDestination = Route.HomeScreen val snackBarHostState = remember { SnackbarHostState() } MarketSightTheme { diff --git a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeViewModel.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeViewModel.kt index abad681..0d078d1 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeViewModel.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeViewModel.kt @@ -6,5 +6,5 @@ import javax.inject.Inject @HiltViewModel class HomeViewModel @Inject constructor( -): ViewModel(){ +): ViewModel() { } \ No newline at end of file From 0616d856c9010a644b4337c016cb98d422e27d77 Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Mon, 6 May 2024 16:16:18 +0100 Subject: [PATCH 29/33] - unit test MarketRemoteDataSource and AssetRemoteDataSource --- .../marketsight/data/mapper/RemoteMapper.kt | 6 +- .../model/dto/alpaca_api/BarAssetDto.kt | 1 + .../model/dto/alpaca_api/QuoteAssetDto.kt | 3 +- .../model/dto/alpaca_api/QuotesResponseDto.kt | 1 + .../model/dto/alpaca_api/TradeAssetDto.kt | 3 +- .../model/dto/alpaca_api/TradesResponseDto.kt | 1 + .../data_source/AssetsRemoteDataSourceTest.kt | 55 ++ .../data_source/MarketRemoteDataSourceTest.kt | 622 ++++++++++++++++++ .../marketsight/factories/AssetDtoFactory.kt | 28 + .../factories/BarAssetDtoFactory.kt | 23 + .../factories/QuoteAssetDtoFactory.kt | 21 + .../factories/TradeAssetDtoFactory.kt | 20 + 12 files changed, 780 insertions(+), 4 deletions(-) create mode 100644 app/src/test/java/dev/pinkroom/marketsight/data/data_source/AssetsRemoteDataSourceTest.kt create mode 100644 app/src/test/java/dev/pinkroom/marketsight/data/data_source/MarketRemoteDataSourceTest.kt create mode 100644 app/src/test/java/dev/pinkroom/marketsight/factories/AssetDtoFactory.kt create mode 100644 app/src/test/java/dev/pinkroom/marketsight/factories/BarAssetDtoFactory.kt create mode 100644 app/src/test/java/dev/pinkroom/marketsight/factories/QuoteAssetDtoFactory.kt create mode 100644 app/src/test/java/dev/pinkroom/marketsight/factories/TradeAssetDtoFactory.kt diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt b/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt index f945415..82d0e19 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/mapper/RemoteMapper.kt @@ -134,13 +134,14 @@ fun QuoteAssetDto.toQuoteAsset() = QuoteAsset( id = tradeId, bidPrice = bidPrice, askPrice = askPrice, - timeStamp = timeStamp.toLocalDateTimeWithNanoSecond(), + timeStamp = requestDate.toLocalDateTimeWithNanoSecond(), symbol = symbol, ) fun QuotesCryptoResponseDto.toQuotesResponseDto() = QuotesResponseDto( quotes = quotes.entries.first().value, pageToken = pageToken, + symbol = quotes.entries.first().key, ) fun TradesResponseDto.toTradesResponse() = TradesResponse( @@ -151,11 +152,12 @@ fun TradesResponseDto.toTradesResponse() = TradesResponse( fun TradeAssetDto.toTradeAsset() = TradeAsset( id = tradeId, tradePrice = tradePrice, - timeStamp = timeStamp.toLocalDateTimeWithNanoSecond(), + timeStamp = dateTransaction.toLocalDateTimeWithNanoSecond(), symbol = symbol, ) fun TradesCryptoResponseDto.toTradesResponseDto() = TradesResponseDto( trades = trades.entries.first().value, pageToken = pageToken, + symbol = trades.entries.first().key, ) \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/BarAssetDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/BarAssetDto.kt index c26f329..cfd8890 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/BarAssetDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/BarAssetDto.kt @@ -3,6 +3,7 @@ package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api import com.google.gson.annotations.SerializedName data class BarAssetDto( + @SerializedName("T") val type: String? = null, @SerializedName("c") val closingPrice: Double, @SerializedName("h") val highPrice: Double, @SerializedName("l") val lowPrice: Double, diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/QuoteAssetDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/QuoteAssetDto.kt index 6df421a..46fbdd0 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/QuoteAssetDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/QuoteAssetDto.kt @@ -3,9 +3,10 @@ package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api import com.google.gson.annotations.SerializedName data class QuoteAssetDto( + @SerializedName("T") val type: String? = null, @SerializedName("i") val tradeId: Long, @SerializedName("bp") val bidPrice: Double, @SerializedName("ap") val askPrice: Double, - @SerializedName("t") val timeStamp: String, + @SerializedName("t") val requestDate: String, @SerializedName("S") val symbol: String? = null, ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/QuotesResponseDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/QuotesResponseDto.kt index 3d8e267..b472b58 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/QuotesResponseDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/QuotesResponseDto.kt @@ -5,4 +5,5 @@ import com.google.gson.annotations.SerializedName data class QuotesResponseDto( val quotes: List, @SerializedName("next_page_token") val pageToken: String? = null, + val symbol: String, ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/TradeAssetDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/TradeAssetDto.kt index 55aa615..c3c2d3f 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/TradeAssetDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/TradeAssetDto.kt @@ -3,8 +3,9 @@ package dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api import com.google.gson.annotations.SerializedName data class TradeAssetDto( + @SerializedName("T") val type: String? = null, @SerializedName("i") val tradeId: Long, @SerializedName("p") val tradePrice: Double, - @SerializedName("t") val timeStamp: String, + @SerializedName("t") val dateTransaction: String, @SerializedName("S") val symbol: String? = null, ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/TradesResponseDto.kt b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/TradesResponseDto.kt index aa6bed6..3da5ebf 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/TradesResponseDto.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/data/remote/model/dto/alpaca_api/TradesResponseDto.kt @@ -5,4 +5,5 @@ import com.google.gson.annotations.SerializedName data class TradesResponseDto( val trades: List, @SerializedName("next_page_token") val pageToken: String? = null, + val symbol: String, ) diff --git a/app/src/test/java/dev/pinkroom/marketsight/data/data_source/AssetsRemoteDataSourceTest.kt b/app/src/test/java/dev/pinkroom/marketsight/data/data_source/AssetsRemoteDataSourceTest.kt new file mode 100644 index 0000000..7e0cfef --- /dev/null +++ b/app/src/test/java/dev/pinkroom/marketsight/data/data_source/AssetsRemoteDataSourceTest.kt @@ -0,0 +1,55 @@ +package dev.pinkroom.marketsight.data.data_source + +import assertk.assertThat +import assertk.assertions.isEqualTo +import assertk.assertions.isNotEmpty +import dev.pinkroom.marketsight.data.remote.AlpacaPaperApi +import dev.pinkroom.marketsight.domain.model.assets.TypeAsset +import dev.pinkroom.marketsight.factories.AssetDtoFactory +import dev.pinkroom.marketsight.util.MainCoroutineRule +import io.mockk.coEvery +import io.mockk.coVerify +import io.mockk.mockk +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.test.runTest +import org.junit.Rule +import org.junit.Test + +@OptIn(ExperimentalCoroutinesApi::class) +class AssetsRemoteDataSourceTest{ + @get:Rule + val coroutineRule = MainCoroutineRule() + + private val assetDtoFactory = AssetDtoFactory() + private val alpacaPaperApi = mockk() + private val assetsRemoteDataSource = AssetsRemoteDataSource( + alpacaPaperApi = alpacaPaperApi + ) + + @Test + fun `When call getAllAssets, Then return list of assets`() = runTest { + // GIVEN + val type = TypeAsset.Stock + mockResponseGetAssetsPaperApi(typeAsset = type) + + // WHEN + val response = assetsRemoteDataSource.getAllAssets(typeAsset = type) + + // THEN + coVerify { alpacaPaperApi.getAssets(typeAsset = type.value, status = any()) } + assertThat(response).isNotEmpty() + response.forEach { + assertThat(it.type).isEqualTo(type.value) + } + } + + private fun mockResponseGetAssetsPaperApi( + typeAsset: TypeAsset, + ){ + coEvery { + alpacaPaperApi.getAssets(typeAsset = any(), status = any()) + }.returns( + assetDtoFactory.listAssets(number = 250, type = typeAsset) + ) + } +} \ No newline at end of file diff --git a/app/src/test/java/dev/pinkroom/marketsight/data/data_source/MarketRemoteDataSourceTest.kt b/app/src/test/java/dev/pinkroom/marketsight/data/data_source/MarketRemoteDataSourceTest.kt new file mode 100644 index 0000000..1e8e8f9 --- /dev/null +++ b/app/src/test/java/dev/pinkroom/marketsight/data/data_source/MarketRemoteDataSourceTest.kt @@ -0,0 +1,622 @@ +package dev.pinkroom.marketsight.data.data_source + +import assertk.assertFailure +import assertk.assertThat +import assertk.assertions.hasMessage +import assertk.assertions.isEqualTo +import assertk.assertions.isNotEmpty +import com.google.gson.Gson +import com.tinder.scarlet.Message +import com.tinder.scarlet.WebSocket +import dev.pinkroom.marketsight.common.ActionAlpaca +import dev.pinkroom.marketsight.common.HelperIdentifierMessagesAlpacaService +import dev.pinkroom.marketsight.data.remote.AlpacaCryptoApi +import dev.pinkroom.marketsight.data.remote.AlpacaService +import dev.pinkroom.marketsight.data.remote.AlpacaStockApi +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.BarsResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.QuotesResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.TradesResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_crypto_api.BarsCryptoResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_crypto_api.QuotesCryptoResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_crypto_api.TradesCryptoResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.ErrorMessageDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.SubscriptionMessageDto +import dev.pinkroom.marketsight.domain.model.assets.TypeAsset +import dev.pinkroom.marketsight.factories.BarAssetDtoFactory +import dev.pinkroom.marketsight.factories.QuoteAssetDtoFactory +import dev.pinkroom.marketsight.factories.TradeAssetDtoFactory +import dev.pinkroom.marketsight.util.MainCoroutineRule +import dev.pinkroom.marketsight.util.TestDispatcherProvider +import io.mockk.coEvery +import io.mockk.coVerify +import io.mockk.mockk +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.last +import kotlinx.coroutines.flow.toList +import kotlinx.coroutines.launch +import kotlinx.coroutines.test.runTest +import org.junit.Rule +import org.junit.Test +import java.time.LocalDateTime + +@OptIn(ExperimentalCoroutinesApi::class) +class MarketRemoteDataSourceTest{ + @get:Rule + val coroutineRule = MainCoroutineRule() + + private val gson = Gson() + private val barAssetDtoFactory = BarAssetDtoFactory() + private val tradeAssetDtoFactory = TradeAssetDtoFactory() + private val quoteAssetDtoFactory = QuoteAssetDtoFactory() + private val dispatchers = TestDispatcherProvider() + private val alpacaStockApi = mockk() + private val alpacaCryptoApi = mockk() + private val alpacaServiceStock = mockk(relaxed = true, relaxUnitFun = true) + private val alpacaServiceCrypto = mockk(relaxed = true, relaxUnitFun = true) + private val marketRemoteDataSource = MarketRemoteDataSource( + alpacaStockApi = alpacaStockApi, + gson = gson, + alpacaCryptoApi = alpacaCryptoApi, + dispatchers = dispatchers, + alpacaServiceStock = alpacaServiceStock, + alpacaServiceCrypto = alpacaServiceCrypto, + ) + + @Test + fun `When getBars on asset of type Stock, Then return a list of BarAssetDto`() = runTest { + // GIVEN + val type = TypeAsset.Stock + val symbol = "AAPL" + mockGetBarsApi(symbol = symbol) + + // WHEN + val response = marketRemoteDataSource.getBars( + symbol = symbol, typeAsset = type, + startDate = LocalDateTime.now().minusDays(1), endDate = LocalDateTime.now(), + ) + + // THEN + coVerify { + alpacaStockApi.getHistoricalBarsStock( + symbol = symbol, + endDate = any(), startDate = any(), + limit = any(), timeFrame = any(), + sort = any(), feed = any(), + ) + } + assertThat(response).isNotEmpty() + } + + @Test + fun `When getBars on asset of type Crypto, Then return a list of BarAssetDto`() = runTest { + // GIVEN + val type = TypeAsset.Crypto + val symbol = "TSLA" + mockGetBarsApi(symbol = symbol) + + // WHEN + val response = marketRemoteDataSource.getBars( + symbol = symbol, typeAsset = type, + startDate = LocalDateTime.now().minusDays(1), endDate = LocalDateTime.now(), + ) + + // THEN + coVerify { + alpacaCryptoApi.getHistoricalBarsCrypto( + symbol = symbol, + endDate = any(), startDate = any(), + limit = any(), timeFrame = any(), + sort = any(), + ) + } + assertThat(response).isNotEmpty() + } + + @Test + fun `When getRealTimeBars on asset of type Stock, Then return a list of BarAssetDto`() = runTest { + // GIVEN + val type = TypeAsset.Stock + val symbol = "TSLA" + mockGetRealTimeBarsService(symbol = symbol) + + // WHEN + val response = marketRemoteDataSource.getRealTimeBars(typeAsset = type).last() + + // THEN + coVerify { + alpacaServiceStock.observeResponse() + } + assertThat(response).isNotEmpty() + println(response) + response.map { + assertThat(it.symbol).isEqualTo(symbol) + } + } + + @Test + fun `When getRealTimeBars on asset of type Crypto, Then return a list of BarAssetDto`() = runTest { + // GIVEN + val type = TypeAsset.Crypto + val symbol = "AAPL" + mockGetRealTimeBarsService(symbol = symbol) + + // WHEN + val response = marketRemoteDataSource.getRealTimeBars(typeAsset = type).last() + + // THEN + coVerify { + alpacaServiceCrypto.observeResponse() + } + assertThat(response).isNotEmpty() + response.map { + assertThat(it.symbol).isEqualTo(symbol) + } + } + + @Test + fun `When getTrades on asset of type Stock, Then return a TradesResponseDto`() = runTest { + // GIVEN + val type = TypeAsset.Stock + val symbol = "AAPL" + mockGetTradesApi(symbol = symbol) + + // WHEN + val response = marketRemoteDataSource.getTrades(symbol = symbol, typeAsset = type) + + // THEN + coVerify { + alpacaStockApi.getHistoricalTradesStock( + symbol = symbol, + endDate = any(), startDate = any(), + limit = any(), sort = any(), + pageToken = any(), feed = any(), + ) + } + assertThat(response.symbol).isEqualTo(symbol) + assertThat(response.trades).isNotEmpty() + } + + @Test + fun `When getTrades on asset of type Crypto, Then return a TradesResponseDto`() = runTest { + // GIVEN + val type = TypeAsset.Crypto + val symbol = "TSLA" + mockGetTradesApi(symbol = symbol) + + // WHEN + val response = marketRemoteDataSource.getTrades(symbol = symbol, typeAsset = type) + + // THEN + coVerify { + alpacaCryptoApi.getHistoricalTradesCrypto( + symbol = symbol, + endDate = any(), startDate = any(), + limit = any(), sort = any(), + pageToken = any(), + ) + } + assertThat(response.symbol).isEqualTo(symbol) + assertThat(response.trades).isNotEmpty() + } + + @Test + fun `When getRealTimeTrades on asset of type Stock, Then return a List of TradeAssetDto`() = runTest { + // GIVEN + val type = TypeAsset.Stock + val symbol = "TSLA" + mockGetRealTimeTradesService(symbol = symbol) + + // WHEN + val response = marketRemoteDataSource.getRealTimeTrades(typeAsset = type).last() + + // THEN + coVerify { + alpacaServiceStock.observeResponse() + } + assertThat(response).isNotEmpty() + response.forEach { + assertThat(it.symbol).isEqualTo(symbol) + } + } + + @Test + fun `When getRealTimeTrades on asset of type Crypto, Then return a List of TradeAssetDto`() = runTest { + // GIVEN + val type = TypeAsset.Crypto + val symbol = "BTC" + mockGetRealTimeTradesService(symbol = symbol) + + // WHEN + val response = marketRemoteDataSource.getRealTimeTrades(typeAsset = type).last() + + // THEN + coVerify { + alpacaServiceCrypto.observeResponse() + } + assertThat(response).isNotEmpty() + response.forEach { + assertThat(it.symbol).isEqualTo(symbol) + } + } + + @Test + fun `When getQuotes on asset of type Stock, Then return a QuotesResponseDto`() = runTest { + // GIVEN + val type = TypeAsset.Stock + val symbol = "AAPL" + mockGetQuotesApi(symbol = symbol) + + // WHEN + val response = marketRemoteDataSource.getQuotes(symbol = symbol, typeAsset = type) + + // THEN + coVerify { + alpacaStockApi.getHistoricalQuotesStock( + symbol = symbol, + endDate = any(), startDate = any(), + limit = any(), sort = any(), + pageToken = any(), feed = any(), + ) + } + assertThat(response.symbol).isEqualTo(symbol) + assertThat(response.quotes).isNotEmpty() + } + + @Test + fun `When getQuotes on asset of type Crypto, Then return a QuotesResponseDto`() = runTest { + // GIVEN + val type = TypeAsset.Crypto + val symbol = "BTC" + mockGetQuotesApi(symbol = symbol) + + // WHEN + val response = marketRemoteDataSource.getQuotes(symbol = symbol, typeAsset = type) + + // THEN + coVerify { + alpacaCryptoApi.getHistoricalQuotesCrypto( + symbol = symbol, + endDate = any(), startDate = any(), + limit = any(), sort = any(), + pageToken = any(), + ) + } + assertThat(response.symbol).isEqualTo(symbol) + assertThat(response.quotes).isNotEmpty() + } + + @Test + fun `When getRealTimeQuotes on asset of type Stock, Then return a List of QuoteAssetDto`() = runTest { + // GIVEN + val type = TypeAsset.Stock + val symbol = "TSLA" + mockGetRealTimeQuotesService(symbol = symbol) + + // WHEN + val response = marketRemoteDataSource.getRealTimeQuotes(typeAsset = type).last() + + // THEN + coVerify { + alpacaServiceStock.observeResponse() + } + assertThat(response).isNotEmpty() + response.forEach { + assertThat(it.symbol).isEqualTo(symbol) + } + } + + @Test + fun `When getRealTimeQuotes on asset of type Crypto, Then return a List of QuoteAssetDto`() = runTest { + // GIVEN + val type = TypeAsset.Crypto + val symbol = "BTC" + mockGetRealTimeQuotesService(symbol = symbol) + + // WHEN + val response = marketRemoteDataSource.getRealTimeQuotes(typeAsset = type).last() + + // THEN + coVerify { + alpacaServiceCrypto.observeResponse() + } + assertThat(response).isNotEmpty() + response.forEach { + assertThat(it.symbol).isEqualTo(symbol) + } + } + + @Test + fun `When statusService, Then return a WebSocket Event`() = runTest { + // GIVEN + mockObserveOnConnectionEvent() + + // WHEN + val response = marketRemoteDataSource.statusService( + typeAsset = TypeAsset.Stock, + ).toList() + + // THEN + coVerify { + alpacaServiceStock.observeOnConnectionEvent() + } + assertThat(response).isNotEmpty() + } + + @Test + fun `When subscribeUnsubscribeRealTimeFinancialData on asset, Then return a SubscriptionMessageDto`() = runTest { + // GIVEN + val type = TypeAsset.Stock + val symbol = "TSLA" + mockResponseSubscribeUnsubscribeSymbolRealTime(symbol = symbol) + + // WHEN + val response = mutableListOf() + launch { + marketRemoteDataSource.subscribeUnsubscribeRealTimeFinancialData( + typeAsset = type, + action = ActionAlpaca.Subscribe, + symbol = symbol + ).toList(response) + }.join() + + // THEN + coVerify { + alpacaServiceStock.observeResponse() + } + assertThat(response).isNotEmpty() + assertThat(response.size).isEqualTo(1) + assertThat(response.first().type).isEqualTo(HelperIdentifierMessagesAlpacaService.Subscription.identifier) + } + + @Test + fun `When subscribeUnsubscribeRealTimeFinancialData on asset, Then throw error`() = runTest { + // GIVEN + val type = TypeAsset.Stock + val symbol = "TSLA" + mockResponseSubscribeUnsubscribeSymbolRealTime(isToSendError = true) + + // WHEN + val response = mutableListOf() + assertFailure { + marketRemoteDataSource.subscribeUnsubscribeRealTimeFinancialData( + typeAsset = type, + action = ActionAlpaca.Unsubscribe, + symbol = symbol, + ).toList(response) + }.hasMessage("Error on Subscription") + + // THEN + coVerify { + alpacaServiceStock.observeResponse() + } + } + + private fun mockResponseSubscribeUnsubscribeSymbolRealTime(symbol: String? = null, isToSendError: Boolean = false) { + val symbols = symbol?.let { listOf(symbol) } ?: run { emptyList() } + val returnedMessageService = listOf( + gson.toJsonTree( + SubscriptionMessageDto( + type = "subscription", + bars = symbols, + quotes = symbols, + trades = symbols, + ) + ) + ) + val errorMessage = listOf( + gson.toJsonTree( + ErrorMessageDto( + type = "error", + msg = "Not Found", + code = 404, + ) + ) + ) + + coEvery { + alpacaServiceStock.observeResponse() + }.returns( + flow { + val listBar = buildMessageResponseServiceBar(symbol = symbol ?: "TSLA") + emit(listBar) + emit(listBar) + if (isToSendError) emit(errorMessage) + else emit(returnedMessageService) + } + ) + + coEvery { + alpacaServiceCrypto.observeResponse() + }.returns( + flow { + val listBar = buildMessageResponseServiceBar(symbol = symbol ?: "BTC") + emit(listBar) + emit(listBar) + if (isToSendError) emit(errorMessage) + else emit(returnedMessageService) + } + ) + } + + private fun mockObserveOnConnectionEvent(){ + coEvery { + alpacaServiceStock.observeOnConnectionEvent() + }.returns( + flow { + emit(WebSocket.Event.OnConnectionOpened(webSocket = Any())) + emit(WebSocket.Event.OnMessageReceived(message = Message.Text(value = "TEST"))) + } + ) + } + + private fun mockGetBarsApi(symbol: String) { + coEvery { + alpacaCryptoApi.getHistoricalBarsCrypto( + symbol = any(), + endDate = any(), startDate = any(), + limit = any(), timeFrame = any(), + sort = any(), + ) + }.returns( + BarsCryptoResponseDto( + bars = barAssetDtoFactory.buildList( + number = 20, symbol = symbol, + ).groupBy { it.symbol!! }, + nextPageToken = null, + ) + ) + + coEvery { + alpacaStockApi.getHistoricalBarsStock( + symbol = any(), + endDate = any(), startDate = any(), + limit = any(), timeFrame = any(), + sort = any(), feed = any() + ) + }.returns( + BarsResponseDto( + bars = barAssetDtoFactory.buildList(number = 10), + symbol = symbol, + nextPageToken = null, + ) + ) + } + + private fun mockGetRealTimeBarsService(symbol: String) { + coEvery { + alpacaServiceStock.observeResponse() + }.returns( + flow { + val listBar = buildMessageResponseServiceBar(symbol = symbol) + emit(listBar) + } + ) + + coEvery { + alpacaServiceCrypto.observeResponse() + }.returns( + flow { + val listBar = buildMessageResponseServiceBar(symbol = symbol) + emit(listBar) + } + ) + } + + private fun mockGetTradesApi(symbol: String) { + coEvery { + alpacaStockApi.getHistoricalTradesStock( + symbol = any(), + endDate = any(), startDate = any(), + limit = any(), sort = any(), + feed = any(), pageToken = any(), + ) + }.returns( + TradesResponseDto( + trades = tradeAssetDtoFactory.buildList(number = 20), + pageToken = null, + symbol = symbol, + ) + ) + + coEvery { + alpacaCryptoApi.getHistoricalTradesCrypto( + symbol = any(), + endDate = any(), startDate = any(), + limit = any(), sort = any(), + pageToken = any(), + ) + }.returns( + TradesCryptoResponseDto( + trades = tradeAssetDtoFactory.buildList(number = 20, symbol = symbol).groupBy { it.symbol!! }, + pageToken = null, + ) + ) + } + + private fun mockGetRealTimeTradesService(symbol: String) { + coEvery { + alpacaServiceStock.observeResponse() + }.returns( + flow { + val listTrade = buildMessageResponseServiceTrade(symbol = symbol) + emit(listTrade) + } + ) + + coEvery { + alpacaServiceCrypto.observeResponse() + }.returns( + flow { + val listTrade = buildMessageResponseServiceTrade(symbol = symbol) + emit(listTrade) + } + ) + } + + private fun mockGetQuotesApi(symbol: String) { + coEvery { + alpacaStockApi.getHistoricalQuotesStock( + symbol = any(), + endDate = any(), startDate = any(), + limit = any(), sort = any(), + feed = any(), pageToken = any(), + ) + }.returns( + QuotesResponseDto( + quotes = quoteAssetDtoFactory.buildList(number = 20), + pageToken = null, + symbol = symbol, + ) + ) + + coEvery { + alpacaCryptoApi.getHistoricalQuotesCrypto( + symbol = any(), + endDate = any(), startDate = any(), + limit = any(), sort = any(), + pageToken = any(), + ) + }.returns( + QuotesCryptoResponseDto( + quotes = quoteAssetDtoFactory.buildList(number = 20, symbol = symbol).groupBy { it.symbol!! }, + pageToken = null, + ) + ) + } + + private fun mockGetRealTimeQuotesService(symbol: String) { + coEvery { + alpacaServiceStock.observeResponse() + }.returns( + flow { + val listQuotes = buildMessageResponseServiceQuote(symbol = symbol) + emit(listQuotes) + } + ) + + coEvery { + alpacaServiceCrypto.observeResponse() + }.returns( + flow { + val listQuotes = buildMessageResponseServiceQuote(symbol = symbol) + emit(listQuotes) + } + ) + } + + private fun buildMessageResponseServiceBar(symbol: String) = barAssetDtoFactory.buildList( + number = 20, symbol = symbol, + type = HelperIdentifierMessagesAlpacaService.Bars.identifier, + ).map { gson.toJsonTree(it) } + + private fun buildMessageResponseServiceTrade(symbol: String) = tradeAssetDtoFactory.buildList( + number = 20, symbol = symbol, + type = HelperIdentifierMessagesAlpacaService.Trades.identifier, + ).map { gson.toJsonTree(it) } + + private fun buildMessageResponseServiceQuote(symbol: String) = quoteAssetDtoFactory.buildList( + number = 20, symbol = symbol, + type = HelperIdentifierMessagesAlpacaService.Quotes.identifier, + ).map { gson.toJsonTree(it) } +} \ No newline at end of file diff --git a/app/src/test/java/dev/pinkroom/marketsight/factories/AssetDtoFactory.kt b/app/src/test/java/dev/pinkroom/marketsight/factories/AssetDtoFactory.kt new file mode 100644 index 0000000..255c2d5 --- /dev/null +++ b/app/src/test/java/dev/pinkroom/marketsight/factories/AssetDtoFactory.kt @@ -0,0 +1,28 @@ +package dev.pinkroom.marketsight.factories + +import com.github.javafaker.Faker +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_paper_api.AssetDto +import dev.pinkroom.marketsight.domain.model.assets.TypeAsset +import kotlin.random.Random + +class AssetDtoFactory: BaseFactory { + + private val faker = Faker() + override fun build() = AssetDto( + id = faker.number().randomNumber().toString(), + type = if (Random.nextInt() % 2 == 0) "us_equity" else "crypto", + symbol = faker.stock().nsdqSymbol(), + name = faker.stock().nsdqSymbol(), + exchange = "NASDAQ", + ) + + fun listAssets(number: Int, type: TypeAsset) = List(number) { build(type = type) } + + private fun build(type: TypeAsset) = AssetDto( + id = faker.number().randomNumber().toString(), + type = type.value, + symbol = faker.stock().nsdqSymbol(), + name = faker.stock().nsdqSymbol(), + exchange = "NASDAQ", + ) +} \ No newline at end of file diff --git a/app/src/test/java/dev/pinkroom/marketsight/factories/BarAssetDtoFactory.kt b/app/src/test/java/dev/pinkroom/marketsight/factories/BarAssetDtoFactory.kt new file mode 100644 index 0000000..1da1bb1 --- /dev/null +++ b/app/src/test/java/dev/pinkroom/marketsight/factories/BarAssetDtoFactory.kt @@ -0,0 +1,23 @@ +package dev.pinkroom.marketsight.factories + +import com.github.javafaker.Faker +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.BarAssetDto + +class BarAssetDtoFactory: BaseFactory { + + private val faker = Faker() + override fun build() = BarAssetDto( + tradeCountInBar = faker.number().randomDigit(), + barVolume = faker.number().randomDouble(10,1,1000), + timestamp = "2024-04-11T13:45:17.0231232021Z", + lowPrice = faker.number().randomDouble(10,1,1000), + highPrice = faker.number().randomDouble(10,1,1000), + closingPrice = faker.number().randomDouble(10,1,1000), + openingPrice = faker.number().randomDouble(10,1,1000), + volumeWeightedAvgPrice = faker.number().randomDouble(10,1,1000), + ) + + fun buildList(number: Int, symbol: String, type: String? = null) = List(number){ + build().copy(symbol = symbol, type = type) + } +} \ No newline at end of file diff --git a/app/src/test/java/dev/pinkroom/marketsight/factories/QuoteAssetDtoFactory.kt b/app/src/test/java/dev/pinkroom/marketsight/factories/QuoteAssetDtoFactory.kt new file mode 100644 index 0000000..1820c69 --- /dev/null +++ b/app/src/test/java/dev/pinkroom/marketsight/factories/QuoteAssetDtoFactory.kt @@ -0,0 +1,21 @@ +package dev.pinkroom.marketsight.factories + +import com.github.javafaker.Faker +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.QuoteAssetDto +import kotlin.random.Random + +class QuoteAssetDtoFactory: BaseFactory { + + private val faker = Faker() + override fun build() = QuoteAssetDto( + type = if (Random.nextInt() % 2 == 0) "us_equity" else "crypto", + tradeId = faker.number().randomNumber(), + bidPrice = faker.number().randomDouble(100,1,1000000), + askPrice = faker.number().randomDouble(100,1,1000000), + requestDate = "2024-05-03T16:58:38.422833437Z", + ) + + fun buildList(number: Int, type: String? = null, symbol: String? = null) = List(number) { + build().copy(type = type, symbol = symbol) + } +} \ No newline at end of file diff --git a/app/src/test/java/dev/pinkroom/marketsight/factories/TradeAssetDtoFactory.kt b/app/src/test/java/dev/pinkroom/marketsight/factories/TradeAssetDtoFactory.kt new file mode 100644 index 0000000..7e06bd2 --- /dev/null +++ b/app/src/test/java/dev/pinkroom/marketsight/factories/TradeAssetDtoFactory.kt @@ -0,0 +1,20 @@ +package dev.pinkroom.marketsight.factories + +import com.github.javafaker.Faker +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.TradeAssetDto +import kotlin.random.Random + +class TradeAssetDtoFactory: BaseFactory { + + private val faker = Faker() + override fun build() = TradeAssetDto( + type = if (Random.nextInt() % 2 == 0) "us_equity" else "crypto", + tradePrice = faker.number().randomDouble(1000,1,10000000), + tradeId = faker.number().randomNumber(), + dateTransaction = "2024-05-03T16:58:38.422833437Z", + ) + + fun buildList(number: Int, type: String? = null, symbol: String? = null) = List(number) { + build().copy(type = type, symbol = symbol) + } +} \ No newline at end of file From b6235b67bbbe7dae95a6a7911bc37f11467d1673 Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Mon, 6 May 2024 18:03:54 +0100 Subject: [PATCH 30/33] - unit test AssetsRepository --- .../repository/AssetsRepositoryImpTest.kt | 544 ++++++++++++++++++ 1 file changed, 544 insertions(+) create mode 100644 app/src/test/java/dev/pinkroom/marketsight/data/repository/AssetsRepositoryImpTest.kt diff --git a/app/src/test/java/dev/pinkroom/marketsight/data/repository/AssetsRepositoryImpTest.kt b/app/src/test/java/dev/pinkroom/marketsight/data/repository/AssetsRepositoryImpTest.kt new file mode 100644 index 0000000..aaeaa60 --- /dev/null +++ b/app/src/test/java/dev/pinkroom/marketsight/data/repository/AssetsRepositoryImpTest.kt @@ -0,0 +1,544 @@ +package dev.pinkroom.marketsight.data.repository + +import assertk.assertThat +import assertk.assertions.isEqualTo +import assertk.assertions.isInstanceOf +import assertk.assertions.isNotEmpty +import com.tinder.scarlet.Message +import com.tinder.scarlet.WebSocket +import dev.pinkroom.marketsight.common.ActionAlpaca +import dev.pinkroom.marketsight.common.HelperIdentifierMessagesAlpacaService +import dev.pinkroom.marketsight.common.Resource +import dev.pinkroom.marketsight.data.data_source.AssetsRemoteDataSource +import dev.pinkroom.marketsight.data.data_source.MarketRemoteDataSource +import dev.pinkroom.marketsight.data.mapper.toAsset +import dev.pinkroom.marketsight.data.mapper.toBarAsset +import dev.pinkroom.marketsight.data.mapper.toQuoteAsset +import dev.pinkroom.marketsight.data.mapper.toTradeAsset +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.BarAssetDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.QuoteAssetDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.QuotesResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.TradeAssetDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_api.TradesResponseDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_news_service.SubscriptionMessageDto +import dev.pinkroom.marketsight.data.remote.model.dto.alpaca_paper_api.AssetDto +import dev.pinkroom.marketsight.domain.model.assets.TypeAsset +import dev.pinkroom.marketsight.factories.AssetDtoFactory +import dev.pinkroom.marketsight.factories.BarAssetDtoFactory +import dev.pinkroom.marketsight.factories.QuoteAssetDtoFactory +import dev.pinkroom.marketsight.factories.TradeAssetDtoFactory +import dev.pinkroom.marketsight.util.MainCoroutineRule +import dev.pinkroom.marketsight.util.TestDispatcherProvider +import io.mockk.coEvery +import io.mockk.mockk +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.toList +import kotlinx.coroutines.test.runTest +import org.junit.Rule +import org.junit.Test +import java.time.LocalDateTime + +@OptIn(ExperimentalCoroutinesApi::class) +class AssetsRepositoryImpTest{ + @get:Rule + val coroutineRule = MainCoroutineRule() + + private val assetDtoFactory = AssetDtoFactory() + private val barAssetDtoFactory = BarAssetDtoFactory() + private val tradeAssetDtoFactory = TradeAssetDtoFactory() + private val quoteAssetDtoFactory = QuoteAssetDtoFactory() + private val dispatchers = TestDispatcherProvider() + private val assetsRemoteDataSource = mockk() + private val marketRemoteDataSource = mockk() + private val assetsRepository = AssetsRepositoryImp( + assetsRemoteDataSource = assetsRemoteDataSource, + marketRemoteDataSource = marketRemoteDataSource, + dispatchers = dispatchers, + ) + + @Test + fun `When getAllAssets of type Stock, Then on Success return a List of Asset`() = runTest { + // GIVEN + val typeAsset = TypeAsset.Stock + val assetsDto = assetDtoFactory.listAssets(number = 250, type = typeAsset) + mockResponseGetAssetsAssetsRemoteDataSource( + assetsToReturn = assetsDto, + ) + + // WHEN + val response = assetsRepository.getAllAssets(typeAsset = typeAsset) + + // THEN + val expectedResponse = assetsDto.map { it.toAsset() } + assertThat(response).isInstanceOf(Resource.Success::class) + assertThat((response as Resource.Success).data).isEqualTo(expectedResponse) + } + + @Test + fun `When getAllAssets of type Stock, Then on Error return a Resource Error`() = runTest { + // GIVEN + val typeAsset = TypeAsset.Stock + val errorMessage = "Error" + + mockResponseGetAssetsAssetsRemoteDataSource( + messageError = errorMessage, + isToThrowError = true, + ) + + // WHEN + val response = assetsRepository.getAllAssets(typeAsset = typeAsset) + + // THEN + assertThat(response).isInstanceOf(Resource.Error::class) + assertThat((response as Resource.Error).message).isEqualTo(errorMessage) + } + + @Test + fun `When getBars of type Stock, Then on Success return a List of BarAsset`() = runTest { + // GIVEN + val typeAsset = TypeAsset.Stock + val symbol = "TSLA" + val barsDto = barAssetDtoFactory.buildList(number = 10) + mockResponseGetBarsMarketRemoteDataSource( + barsToReturn = barsDto, + ) + + // WHEN + val response = assetsRepository.getBars( + symbol = symbol, typeAsset = typeAsset, + endDate = LocalDateTime.now(), startDate = LocalDateTime.now().minusDays(1), + ) + + // THEN + val expectedResponse = barsDto.map { it.toBarAsset() } + assertThat(response).isInstanceOf(Resource.Success::class) + assertThat((response as Resource.Success).data).isEqualTo(expectedResponse) + } + + @Test + fun `When getBars of type Stock, Then on Error return a Resource Error`() = runTest { + // GIVEN + val typeAsset = TypeAsset.Stock + val errorMessage = "Error" + val symbol = "TSLA" + mockResponseGetBarsMarketRemoteDataSource( + messageError = errorMessage, + isToThrowError = true, + ) + + // WHEN + val response = assetsRepository.getBars( + symbol = symbol, typeAsset = typeAsset, + startDate = LocalDateTime.now().minusDays(1), endDate = LocalDateTime.now(), + ) + + // THEN + assertThat(response).isInstanceOf(Resource.Error::class) + assertThat((response as Resource.Error).message).isEqualTo(errorMessage) + } + + @Test + fun `When getTrades of type Stock, Then on Success return a TradeResponse`() = runTest { + // GIVEN + val typeAsset = TypeAsset.Stock + val symbol = "TSLA" + val tradesDto = tradeAssetDtoFactory.buildList(number = 10) + mockResponseGetTradesMarketRemoteDataSource( + tradesToReturn = tradesDto, + symbol = symbol, + ) + + // WHEN + val response = assetsRepository.getTrades( + symbol = symbol, typeAsset = typeAsset, + endDate = LocalDateTime.now(), startDate = LocalDateTime.now().minusDays(1), + ) + + // THEN + val expectedResponse = tradesDto.map { it.toTradeAsset() } + assertThat(response).isInstanceOf(Resource.Success::class) + assertThat((response as Resource.Success).data.trades).isEqualTo(expectedResponse) + } + + @Test + fun `When getTrades of type Stock, Then on Error return a Resource Error`() = runTest { + // GIVEN + val typeAsset = TypeAsset.Stock + val errorMessage = "Error" + val symbol = "TSLA" + mockResponseGetTradesMarketRemoteDataSource( + isToThrowError = true, + messageError = errorMessage, + symbol = symbol, + ) + + // WHEN + val response = assetsRepository.getTrades( + symbol = symbol, typeAsset = typeAsset, + startDate = LocalDateTime.now().minusDays(1), endDate = LocalDateTime.now(), + ) + + // THEN + assertThat(response).isInstanceOf(Resource.Error::class) + assertThat((response as Resource.Error).message).isEqualTo(errorMessage) + } + + @Test + fun `When getQuotes of type Stock, Then on Success return a TradeResponse`() = runTest { + // GIVEN + val typeAsset = TypeAsset.Stock + val symbol = "TSLA" + val quotesDto = quoteAssetDtoFactory.buildList(number = 10) + mockResponseGetQuotesMarketRemoteDataSource( + quotesToReturn = quotesDto, + symbol = symbol, + ) + + // WHEN + val response = assetsRepository.getQuotes( + symbol = symbol, typeAsset = typeAsset, + endDate = LocalDateTime.now(), startDate = LocalDateTime.now().minusDays(1), + ) + + // THEN + val expectedResponse = quotesDto.map { it.toQuoteAsset() } + assertThat(response).isInstanceOf(Resource.Success::class) + assertThat((response as Resource.Success).data.quotes).isEqualTo(expectedResponse) + } + + @Test + fun `When getQuotes of type Stock, Then on Error return a Resource Error`() = runTest { + // GIVEN + val typeAsset = TypeAsset.Stock + val errorMessage = "Error" + val symbol = "TSLA" + mockResponseGetQuotesMarketRemoteDataSource( + isToThrowError = true, + messageError = errorMessage, + symbol = symbol, + ) + + // WHEN + val response = assetsRepository.getQuotes( + symbol = symbol, typeAsset = typeAsset, + startDate = LocalDateTime.now().minusDays(1), endDate = LocalDateTime.now(), + ) + + // THEN + assertThat(response).isInstanceOf(Resource.Error::class) + assertThat((response as Resource.Error).message).isEqualTo(errorMessage) + } + + @Test + fun `When getRealTimeBars of type Stock, Then on Success return a List of BarAsset`() = runTest { + // GIVEN + val typeAsset = TypeAsset.Stock + val symbol = "TSLA" + val barsDto = barAssetDtoFactory.buildList(number = 10, symbol = symbol, type = TypeAsset.Stock.value) + mockResponseGetRealTimeBarsMarketRemoteDataSource( + barToReturn = barsDto, + ) + + // WHEN + val response = assetsRepository.getRealTimeBars( + symbol = symbol, typeAsset = typeAsset, + ).toList() + + // THEN + val expectedResponse = barsDto.map { it.toBarAsset() } + assertThat(response).isNotEmpty() + assertThat(response.size).isEqualTo(1) + assertThat(response.first()).isEqualTo(expectedResponse) + } + + @Test + fun `When getRealTimeTrades of type Stock, Then on Success return a List of TradeAsset`() = runTest { + // GIVEN + val typeAsset = TypeAsset.Stock + val symbol = "TSLA" + val tradesDto = tradeAssetDtoFactory.buildList(number = 10, symbol = symbol, type = TypeAsset.Stock.value) + mockResponseGetRealTimeTradesMarketRemoteDataSource( + tradesToReturn = tradesDto, + ) + + // WHEN + val response = assetsRepository.getRealTimeTrades( + symbol = symbol, typeAsset = typeAsset, + ).toList() + + // THEN + val expectedResponse = tradesDto.map { it.toTradeAsset() } + assertThat(response).isNotEmpty() + assertThat(response.size).isEqualTo(1) + assertThat(response.first()).isEqualTo(expectedResponse) + } + + @Test + fun `When getRealTimeQuotes of type Stock, Then on Success return a List of QuoteAsset`() = runTest { + // GIVEN + val typeAsset = TypeAsset.Stock + val symbol = "TSLA" + val quotesDto = quoteAssetDtoFactory.buildList(number = 10, symbol = symbol, type = TypeAsset.Stock.value) + mockResponseGetRealTimeQuotesMarketRemoteDataSource( + quotesToReturn = quotesDto, + ) + + // WHEN + val response = assetsRepository.getRealTimeQuotes( + symbol = symbol, typeAsset = typeAsset, + ).toList() + + // THEN + val expectedResponse = quotesDto.map { it.toQuoteAsset() } + assertThat(response).isNotEmpty() + assertThat(response.size).isEqualTo(1) + assertThat(response.first()).isEqualTo(expectedResponse) + } + + @Test + fun `When statusService of type Stock, Then return a WebSocket Event`() = runTest { + // GIVEN + val typeAsset = TypeAsset.Stock + mockResponseGetStatusServiceMarketRemoteDataSource() + + // WHEN + val response = assetsRepository.statusService(typeAsset = typeAsset).toList() + + // THEN + assertThat(response).isNotEmpty() + response.forEach { + assertThat(it).isInstanceOf(WebSocket.Event::class.java) + } + } + + @Test + fun `When subscribeUnsubscribeRealTimeFinancialData of type Stock, Then on Success return a SubscriptionMessage`() = runTest { + // GIVEN + val typeAsset = TypeAsset.Stock + val symbol = "TSLA" + mockResponseSubscribeUnsubscribeRealTimeFinancialDataRemoteDataSource( + symbol = symbol + ) + + // WHEN + val response = assetsRepository.subscribeUnsubscribeRealTimeFinancialData( + action = ActionAlpaca.Subscribe, + typeAsset = typeAsset, + symbol = symbol, + ) + + // THEN + assertThat(response).isInstanceOf(Resource.Success::class.java) + } + + @Test + fun `When subscribeUnsubscribeRealTimeFinancialData of type Stock, Then on Error return a Resource Error`() = runTest { + // GIVEN + val typeAsset = TypeAsset.Stock + val symbol = "AAPL" + mockResponseSubscribeUnsubscribeRealTimeFinancialDataRemoteDataSource( + symbol = symbol, + isToThrowError = true + ) + + // WHEN + val response = assetsRepository.subscribeUnsubscribeRealTimeFinancialData( + action = ActionAlpaca.Subscribe, + typeAsset = typeAsset, + symbol = symbol, + ) + + // THEN + assertThat(response).isInstanceOf(Resource.Error::class.java) + } + + private fun mockResponseGetAssetsAssetsRemoteDataSource( + assetsToReturn: List = emptyList(), + isToThrowError: Boolean = false, + messageError: String? = null, + ) { + if (isToThrowError) + coEvery { + assetsRemoteDataSource.getAllAssets(typeAsset = any()) + } throws Exception(messageError ?: "") + else + coEvery { + assetsRemoteDataSource.getAllAssets(typeAsset = any()) + } returns assetsToReturn + } + + private fun mockResponseGetBarsMarketRemoteDataSource( + barsToReturn: List = emptyList(), + isToThrowError: Boolean = false, + messageError: String? = null, + ) { + if (isToThrowError) + coEvery { + marketRemoteDataSource.getBars( + typeAsset = any(), symbol = any(), + sort = any(), timeFrame = any(), + limit = any(), startDate = any(), + endDate = any(), + ) + } throws Exception(messageError ?: "") + else + coEvery { + marketRemoteDataSource.getBars( + typeAsset = any(), symbol = any(), + sort = any(), timeFrame = any(), + limit = any(), startDate = any(), + endDate = any(), + ) + } returns barsToReturn + } + + private fun mockResponseGetTradesMarketRemoteDataSource( + tradesToReturn: List = emptyList(), + isToThrowError: Boolean = false, + messageError: String? = null, + symbol: String, + ) { + if (isToThrowError) + coEvery { + marketRemoteDataSource.getTrades( + typeAsset = any(), symbol = any(), + sort = any(), limit = any(), + startDate = any(), endDate = any(), + ) + } throws Exception(messageError ?: "") + else + coEvery { + marketRemoteDataSource.getTrades( + typeAsset = any(), symbol = any(), + sort = any(), limit = any(), + startDate = any(), endDate = any(), + ) + } returns TradesResponseDto( + trades = tradesToReturn, + symbol = symbol, + pageToken = null, + ) + } + + private fun mockResponseGetQuotesMarketRemoteDataSource( + quotesToReturn: List = emptyList(), + isToThrowError: Boolean = false, + messageError: String? = null, + symbol: String, + ) { + if (isToThrowError) + coEvery { + marketRemoteDataSource.getQuotes( + typeAsset = any(), symbol = any(), + sort = any(), limit = any(), + startDate = any(), endDate = any(), + ) + } throws Exception(messageError ?: "") + else + coEvery { + marketRemoteDataSource.getQuotes( + typeAsset = any(), symbol = any(), + sort = any(), limit = any(), + startDate = any(), endDate = any(), + ) + } returns QuotesResponseDto( + quotes = quotesToReturn, + symbol = symbol, + pageToken = null, + ) + } + + private fun mockResponseGetRealTimeBarsMarketRemoteDataSource( + barToReturn: List = emptyList(), + ) { + coEvery { + marketRemoteDataSource.getRealTimeBars( + typeAsset = any(), + ) + } returns ( + flow { + emit(listOf(barToReturn.first().copy(symbol="AAPL"))) + emit(barToReturn) + emit(listOf(barToReturn.first().copy(symbol="AAPL"))) + } + ) + } + + private fun mockResponseGetRealTimeTradesMarketRemoteDataSource( + tradesToReturn: List = emptyList(), + ) { + coEvery { + marketRemoteDataSource.getRealTimeTrades( + typeAsset = any(), + ) + } returns ( + flow { + emit(listOf(tradesToReturn.first().copy(symbol="AAPL"))) + emit(tradesToReturn) + emit(listOf(tradesToReturn.first().copy(symbol="AAPL"))) + } + ) + } + + private fun mockResponseGetRealTimeQuotesMarketRemoteDataSource( + quotesToReturn: List = emptyList(), + ) { + coEvery { + marketRemoteDataSource.getRealTimeQuotes( + typeAsset = any(), + ) + }.returns( + flow { + emit(listOf(quotesToReturn.first().copy(symbol="AAPL"))) + emit(quotesToReturn) + emit(listOf(quotesToReturn.first().copy(symbol="AAPL"))) + } + ) + } + + private fun mockResponseGetStatusServiceMarketRemoteDataSource() { + coEvery { + marketRemoteDataSource.statusService( + typeAsset = any(), + ) + }.returns( + flow { + emit(WebSocket.Event.OnConnectionOpened(webSocket = Any())) + emit(WebSocket.Event.OnMessageReceived(message = Message.Text("HELLO"))) + } + ) + } + + private fun mockResponseSubscribeUnsubscribeRealTimeFinancialDataRemoteDataSource( + symbol: String, + isToThrowError: Boolean = false, + ) { + val symbols = listOf(symbol) + if (isToThrowError) + coEvery { + marketRemoteDataSource.subscribeUnsubscribeRealTimeFinancialData( + typeAsset = any(), action = any(), + symbol = any() + ) + } throws Exception() + else + coEvery { + marketRemoteDataSource.subscribeUnsubscribeRealTimeFinancialData( + typeAsset = any(), action = any(), + symbol = any() + ) + }.returns( + flow { + emit( + SubscriptionMessageDto( + type = HelperIdentifierMessagesAlpacaService.Subscription.identifier, + quotes = symbols, + trades = symbols, + bars = symbols, + ) + ) + } + ) + } +} \ No newline at end of file From 107ed0d7dffece02818c56890cc51663a1a1eddd Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Wed, 8 May 2024 11:18:35 +0100 Subject: [PATCH 31/33] - search input assets - assets filter by stock or crypto --- .../dev/pinkroom/marketsight/common/Utils.kt | 19 +++- .../domain/model/assets/AssetFilter.kt | 10 ++ .../core/components/ButtonFilter.kt | 5 +- .../core/navigation/NavigationAppHost.kt | 10 +- .../presentation/core/theme/Dimensions.kt | 3 + .../presentation/home_screen/HomeEvent.kt | 8 ++ .../presentation/home_screen/HomeScreen.kt | 92 +++++++++++++++++-- .../presentation/home_screen/HomeUiState.kt | 13 +++ .../presentation/home_screen/HomeViewModel.kt | 26 ++++++ .../home_screen/components/FilterAssets.kt | 59 ++++++++++++ .../home_screen/components/SearchInput.kt | 84 +++++++++++++++++ app/src/main/res/drawable/icon_search.xml | 5 + app/src/main/res/values/strings.xml | 4 + 13 files changed, 328 insertions(+), 10 deletions(-) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/domain/model/assets/AssetFilter.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeEvent.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeUiState.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/components/FilterAssets.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/components/SearchInput.kt create mode 100644 app/src/main/res/drawable/icon_search.xml diff --git a/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt b/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt index 4aad853..10024f0 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/common/Utils.kt @@ -4,6 +4,8 @@ import androidx.annotation.StringRes import dev.pinkroom.marketsight.BuildConfig import dev.pinkroom.marketsight.R import dev.pinkroom.marketsight.common.Constants.ALL_SYMBOLS +import dev.pinkroom.marketsight.domain.model.assets.AssetFilter +import dev.pinkroom.marketsight.domain.model.assets.TypeAsset import dev.pinkroom.marketsight.domain.model.common.SubInfoSymbols import okhttp3.OkHttpClient import okhttp3.logging.HttpLoggingInterceptor @@ -50,7 +52,7 @@ fun LocalDate.toReadableDate(): String { fun LocalDateTime.formatToStandardIso(): String = format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")) -fun LocalDate.atEndOfTheDay() = atTime(23,59,59).atOffset(ZoneOffset.UTC).toLocalDateTime() +fun LocalDate.atEndOfTheDay(): LocalDateTime = atTime(23,59,59).atOffset(ZoneOffset.UTC).toLocalDateTime() sealed class ActionAlpaca(val action: String) { data object Subscribe: ActionAlpaca(action = "subscribe") @@ -67,6 +69,21 @@ sealed interface DateMomentType{ data object End: DateMomentType } +val assetFilters = listOf( + AssetFilter( + typeAsset = TypeAsset.Stock, + isSelected = true, + stringId = R.string.stock, + placeHolder = R.string.place_holder_stock, + ), + AssetFilter( + typeAsset = TypeAsset.Crypto, + isSelected = false, + stringId = R.string.crypto, + placeHolder = R.string.place_holder_crypto, + ), +) + val popularSymbols = listOf( SubInfoSymbols( stringResource = R.string.all, diff --git a/app/src/main/java/dev/pinkroom/marketsight/domain/model/assets/AssetFilter.kt b/app/src/main/java/dev/pinkroom/marketsight/domain/model/assets/AssetFilter.kt new file mode 100644 index 0000000..2411f53 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/domain/model/assets/AssetFilter.kt @@ -0,0 +1,10 @@ +package dev.pinkroom.marketsight.domain.model.assets + +import androidx.annotation.StringRes + +data class AssetFilter( + val typeAsset: TypeAsset, + val isSelected: Boolean, + @StringRes val stringId: Int, + @StringRes val placeHolder: Int, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/presentation/core/components/ButtonFilter.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/components/ButtonFilter.kt index 3f7bcd4..a30ab61 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/presentation/core/components/ButtonFilter.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/components/ButtonFilter.kt @@ -23,7 +23,9 @@ import dev.pinkroom.marketsight.presentation.core.theme.dimens @Composable fun ButtonFilter( + modifier: Modifier = Modifier, isSelected: Boolean, + showLeadingIcon: Boolean = true, text: String, onClick: () -> Unit, ){ @@ -31,6 +33,7 @@ fun ButtonFilter( val colorContent = if (isSelected) Blue else MaterialTheme.colorScheme.onBackground val colorBorder = if (isSelected) Color.Transparent else MaterialTheme.colorScheme.onBackground Button( + modifier = modifier, shape = RoundedCornerShape(dimens.smallShape), border = BorderStroke( width = dimens.smallWidth, color = colorBorder, @@ -47,7 +50,7 @@ fun ButtonFilter( horizontalArrangement = Arrangement.spacedBy(dimens.xSmallPadding), verticalAlignment = Alignment.CenterVertically, ) { - if (isSelected) + if (isSelected && showLeadingIcon) Icon( modifier = Modifier .size(dimens.smallIconSize), diff --git a/app/src/main/java/dev/pinkroom/marketsight/presentation/core/navigation/NavigationAppHost.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/navigation/NavigationAppHost.kt index 804e920..053ecf4 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/presentation/core/navigation/NavigationAppHost.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/navigation/NavigationAppHost.kt @@ -42,7 +42,15 @@ fun NavigationAppHost( route = Route.HomeScreen.route, ) { val viewModel = hiltViewModel() - HomeScreen() + val uiState = viewModel.uiState.collectAsStateWithLifecycle().value + + HomeScreen( + isLoading = uiState.isLoading, + placeHolder = uiState.placeHolder, + searchInput = uiState.searchInput, + filters = uiState.filters, + onEvent = viewModel::onEvent + ) } composable( route = Route.NewsScreen.route, diff --git a/app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/Dimensions.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/Dimensions.kt index 129a7e5..e1b9834 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/Dimensions.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/Dimensions.kt @@ -65,6 +65,9 @@ class Dimensions( val menuHeight: Dp = 100.dp, val liveNewsCardWidth: Dp = 270.dp, val liveNewsCardHeight: Dp = 100.dp, + val searchInputHeight: Dp = 60.dp, + val filterAssetCardWidth: Dp = 90.dp, + val filterAssetCardHeight: Dp = 40.dp, val emptyContentMaxHeight: Float = 0.95f, val bottomSheetHeight: Float = 0.45f, ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeEvent.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeEvent.kt new file mode 100644 index 0000000..4f2daf3 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeEvent.kt @@ -0,0 +1,8 @@ +package dev.pinkroom.marketsight.presentation.home_screen + +import dev.pinkroom.marketsight.domain.model.assets.AssetFilter + +sealed class HomeEvent { + data class NewSearchInput(val value: String): HomeEvent() + data class ChangeAssetFilter(val assetSelected: AssetFilter): HomeEvent() +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeScreen.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeScreen.kt index 81b69f3..0a0d666 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeScreen.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeScreen.kt @@ -1,23 +1,95 @@ package dev.pinkroom.marketsight.presentation.home_screen -import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.foundation.clickable +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.material3.Text +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier +import androidx.compose.ui.focus.FocusRequester +import androidx.compose.ui.focus.focusRequester +import androidx.compose.ui.platform.LocalFocusManager +import androidx.compose.ui.platform.LocalSoftwareKeyboardController +import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview +import dev.pinkroom.marketsight.R +import dev.pinkroom.marketsight.common.assetFilters +import dev.pinkroom.marketsight.domain.model.assets.AssetFilter +import dev.pinkroom.marketsight.presentation.core.theme.dimens +import dev.pinkroom.marketsight.presentation.home_screen.components.FilterAssets +import dev.pinkroom.marketsight.presentation.home_screen.components.SearchInput +@OptIn(ExperimentalFoundationApi::class) @Composable fun HomeScreen( modifier: Modifier = Modifier, + isLoading: Boolean, + searchInput: String?, + placeHolder: Int, + filters: List, + onEvent: (HomeEvent) -> Unit, ){ - Column( + val focusRequester = remember { FocusRequester() } + val focusManager = LocalFocusManager.current + val keyboardController = LocalSoftwareKeyboardController.current + + fun closeKeyboardAndClearFocus() { + keyboardController?.hide() + focusManager.clearFocus() + } + + LazyColumn( modifier = modifier + .clickable( + indication = null, + interactionSource = remember { MutableInteractionSource() }, + onClick = { + closeKeyboardAndClearFocus() + } + ) .fillMaxSize(), + contentPadding = PaddingValues( + top = dimens.contentTopPadding, + bottom = dimens.contentBottomPadding, + ), ) { - Text( - text = "Home Screen", - ) + stickyHeader { + SearchInput( + modifier = Modifier + .focusRequester(focusRequester) + .fillMaxWidth() + .padding(horizontal = dimens.horizontalPadding), + value = searchInput ?: "", + placeHolder = stringResource(id = placeHolder), + isLoading = isLoading, + onChangeInput = { + onEvent(HomeEvent.NewSearchInput(value = it)) + }, + closeInput = { + closeKeyboardAndClearFocus() + } + ) + Spacer(modifier = Modifier.height(dimens.smallPadding)) + FilterAssets( + modifier = Modifier + .fillMaxWidth(), + filters = filters, + isLoading = isLoading, + onFilterClick = { + onEvent(HomeEvent.ChangeAssetFilter(assetSelected = it)) + }, + ) + } + item { + + } } } @@ -27,5 +99,11 @@ fun HomeScreen( ) @Composable fun HomeScreenPreview(){ - HomeScreen() + HomeScreen( + isLoading = true, + searchInput = null, + placeHolder = R.string.place_holder_stock, + filters = assetFilters, + onEvent = {}, + ) } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeUiState.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeUiState.kt new file mode 100644 index 0000000..23a45ff --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeUiState.kt @@ -0,0 +1,13 @@ +package dev.pinkroom.marketsight.presentation.home_screen + +import androidx.annotation.StringRes +import dev.pinkroom.marketsight.R +import dev.pinkroom.marketsight.common.assetFilters +import dev.pinkroom.marketsight.domain.model.assets.AssetFilter + +data class HomeUiState( + val isLoading: Boolean = true, + val searchInput: String? = null, + @StringRes val placeHolder: Int = R.string.place_holder_stock, + val filters: List = assetFilters, +) diff --git a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeViewModel.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeViewModel.kt index 0d078d1..a07b109 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeViewModel.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeViewModel.kt @@ -2,9 +2,35 @@ package dev.pinkroom.marketsight.presentation.home_screen import androidx.lifecycle.ViewModel import dagger.hilt.android.lifecycle.HiltViewModel +import dev.pinkroom.marketsight.domain.model.assets.AssetFilter +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.flow.update import javax.inject.Inject @HiltViewModel class HomeViewModel @Inject constructor( ): ViewModel() { + private val _uiState = MutableStateFlow(HomeUiState()) + val uiState = _uiState.asStateFlow() + + fun onEvent(event: HomeEvent) { + when(event){ + is HomeEvent.NewSearchInput -> changeSearchInput(newInput = event.value) + is HomeEvent.ChangeAssetFilter -> changeAssetFilter(filterToBeSelected = event.assetSelected) + } + } + + private fun changeSearchInput(newInput: String) { + _uiState.update { it.copy(searchInput = newInput) } + // TODO UPDATE LIST TO SHOW RESULTS RELATED TO INPUT + } + + private fun changeAssetFilter(filterToBeSelected: AssetFilter) { + val newFilters = uiState.value.filters.map { + if (it == filterToBeSelected) it.copy(isSelected = true) + else it.copy(isSelected = false) + } + _uiState.update { it.copy(filters = newFilters, placeHolder = filterToBeSelected.placeHolder) } + } } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/components/FilterAssets.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/components/FilterAssets.kt new file mode 100644 index 0000000..8bc4b3a --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/components/FilterAssets.kt @@ -0,0 +1,59 @@ +package dev.pinkroom.marketsight.presentation.home_screen.components + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.ExperimentalLayoutApi +import androidx.compose.foundation.layout.FlowRow +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.res.stringResource +import dev.pinkroom.marketsight.domain.model.assets.AssetFilter +import dev.pinkroom.marketsight.presentation.core.components.ButtonFilter +import dev.pinkroom.marketsight.presentation.core.theme.dimens +import dev.pinkroom.marketsight.presentation.core.theme.shimmerEffect + +@OptIn(ExperimentalLayoutApi::class) +@Composable +fun FilterAssets( + modifier: Modifier = Modifier, + filters: List, + isLoading: Boolean, + onFilterClick: (AssetFilter) -> Unit +){ + FlowRow( + modifier = modifier + .fillMaxWidth() + .padding(horizontal = dimens.horizontalPadding, vertical = dimens.xSmallPadding), + horizontalArrangement = Arrangement.Center, + ) { + if (!isLoading) + filters.forEach { filter -> + ButtonFilter( + modifier = Modifier + .padding(horizontal = dimens.smallPadding), + isSelected = filter.isSelected, + text = stringResource(id = filter.stringId), + onClick = { + onFilterClick(filter) + } + ) + } + else + (0 until 2).forEach{ _ -> + Box( + modifier = Modifier + .padding(horizontal = dimens.smallPadding) + .width(dimens.filterAssetCardWidth) + .height(dimens.filterAssetCardHeight) + .clip(RoundedCornerShape(dimens.normalShape)) + .shimmerEffect(), + ) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/components/SearchInput.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/components/SearchInput.kt new file mode 100644 index 0000000..fe5f154 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/components/SearchInput.kt @@ -0,0 +1,84 @@ +package dev.pinkroom.marketsight.presentation.home_screen.components + +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.text.KeyboardActions +import androidx.compose.foundation.text.KeyboardOptions +import androidx.compose.foundation.text.selection.TextSelectionColors +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.OutlinedTextFieldDefaults +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.input.ImeAction +import dev.pinkroom.marketsight.R +import dev.pinkroom.marketsight.presentation.core.theme.Gray +import dev.pinkroom.marketsight.presentation.core.theme.GrayAthens +import dev.pinkroom.marketsight.presentation.core.theme.dimens +import dev.pinkroom.marketsight.presentation.core.theme.shimmerEffect + +@Composable +fun SearchInput( + modifier: Modifier = Modifier, + value: String, + placeHolder: String, + isLoading: Boolean, + onChangeInput: (String) -> Unit, + closeInput: () -> Unit, +){ + if (!isLoading) + OutlinedTextField( + modifier = modifier, + value = value, + onValueChange = onChangeInput, + singleLine = true, + shape = CircleShape, + leadingIcon = { + val colorIcon = if (isSystemInDarkTheme()) GrayAthens else Gray + Icon( + painter = painterResource(id = R.drawable.icon_search), + contentDescription = null, + tint = colorIcon, + ) + }, + placeholder = { + val colorText = if (isSystemInDarkTheme()) GrayAthens else Gray + Text( + text = placeHolder, + color = colorText, + ) + }, + keyboardOptions = KeyboardOptions.Default.copy( + imeAction = ImeAction.Search, + ), + keyboardActions = KeyboardActions( + onAny = { + closeInput() + } + ), + colors = OutlinedTextFieldDefaults.colors( + unfocusedContainerColor = MaterialTheme.colorScheme.primary, + focusedContainerColor = MaterialTheme.colorScheme.primary, + focusedBorderColor = MaterialTheme.colorScheme.onPrimary, + unfocusedBorderColor = MaterialTheme.colorScheme.background, + cursorColor = MaterialTheme.colorScheme.onPrimary, + selectionColors = TextSelectionColors( + handleColor = MaterialTheme.colorScheme.onPrimary, + backgroundColor = MaterialTheme.colorScheme.background, + ) + ), + ) + else + Box( + modifier = modifier + .height(dimens.searchInputHeight) + .clip(CircleShape) + .shimmerEffect() + ) +} \ No newline at end of file diff --git a/app/src/main/res/drawable/icon_search.xml b/app/src/main/res/drawable/icon_search.xml new file mode 100644 index 0000000..d29c6ea --- /dev/null +++ b/app/src/main/res/drawable/icon_search.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8900f77..c3a96a1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -24,4 +24,8 @@ Clear All Apply An error occurred when trying to get news in real time. + Search Stock + Search Crypto + Stock + Crypto \ No newline at end of file From 5f26ec937a11403b810e99700d250015c5845391 Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Mon, 13 May 2024 11:06:43 +0100 Subject: [PATCH 32/33] - handle error assets list - empty content layout - search input logic --- app/build.gradle.kts | 1 + .../dev/pinkroom/marketsight/di/Navigation.kt | 22 +++++ .../core/navigation/NavigationAppHost.kt | 10 ++- .../presentation/core/theme/Dimensions.kt | 1 + .../presentation/core/theme/Theme.kt | 2 + .../detail_screen/DetailViewModel.kt | 18 ++++ .../presentation/home_screen/HomeEvent.kt | 1 + .../presentation/home_screen/HomeScreen.kt | 88 +++++++++++++------ .../presentation/home_screen/HomeUiState.kt | 4 + .../presentation/home_screen/HomeViewModel.kt | 81 ++++++++++++++++- .../home_screen/components/AssetItem.kt | 69 +++++++++++++++ .../home_screen/components/EmptyListAssets.kt | 54 ++++++++++++ .../home_screen/components/ListAssets.kt | 63 +++++++++++++ .../home_screen/components/SearchInput.kt | 13 ++- app/src/main/res/values/strings.xml | 2 + gradle/libs.versions.toml | 4 +- 16 files changed, 395 insertions(+), 38 deletions(-) create mode 100644 app/src/main/java/dev/pinkroom/marketsight/di/Navigation.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/presentation/detail_screen/DetailViewModel.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/components/AssetItem.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/components/EmptyListAssets.kt create mode 100644 app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/components/ListAssets.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 0fbebae..3960bf7 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -6,6 +6,7 @@ plugins { alias(libs.plugins.jetbrainsKotlinAndroid) alias(libs.plugins.hiltAndroid) alias(libs.plugins.jsonSerialization) + id("kotlin-parcelize") } android { diff --git a/app/src/main/java/dev/pinkroom/marketsight/di/Navigation.kt b/app/src/main/java/dev/pinkroom/marketsight/di/Navigation.kt new file mode 100644 index 0000000..e431193 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/di/Navigation.kt @@ -0,0 +1,22 @@ +package dev.pinkroom.marketsight.di + +import androidx.lifecycle.SavedStateHandle +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.android.components.ViewModelComponent +import dagger.hilt.android.scopes.ViewModelScoped + +@Module +@InstallIn(ViewModelComponent::class) +object DetailScreenArgModule { + @Provides + @SymbolId + @ViewModelScoped + fun providePersonName( + savedStatedHandle: SavedStateHandle, + ): String? { + return ""//savedStatedHandle[NAME_ARG] + } + annotation class SymbolId +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/presentation/core/navigation/NavigationAppHost.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/navigation/NavigationAppHost.kt index 053ecf4..5e2a3b5 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/presentation/core/navigation/NavigationAppHost.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/navigation/NavigationAppHost.kt @@ -15,6 +15,7 @@ import androidx.navigation.navArgument import dev.pinkroom.marketsight.presentation.core.navigation.Args.SYMBOL_ID import dev.pinkroom.marketsight.presentation.core.util.ObserveAsEvents import dev.pinkroom.marketsight.presentation.detail_screen.DetailScreen +import dev.pinkroom.marketsight.presentation.detail_screen.DetailViewModel import dev.pinkroom.marketsight.presentation.home_screen.HomeScreen import dev.pinkroom.marketsight.presentation.home_screen.HomeViewModel import dev.pinkroom.marketsight.presentation.news_screen.NewsAction @@ -49,7 +50,13 @@ fun NavigationAppHost( placeHolder = uiState.placeHolder, searchInput = uiState.searchInput, filters = uiState.filters, - onEvent = viewModel::onEvent + assets = uiState.assets, + isEmptyOnSearch = uiState.isEmptyOnSearch, + hasError = uiState.hasError, + onEvent = viewModel::onEvent, + navigateToAssetDetailScreen = { + navController.navigate(Route.DetailScreen.withSymbol(it.symbol)) + } ) } composable( @@ -96,6 +103,7 @@ fun NavigationAppHost( }, ) ) { + val viewModel = hiltViewModel() DetailScreen() } } diff --git a/app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/Dimensions.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/Dimensions.kt index e1b9834..6158b64 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/Dimensions.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/Dimensions.kt @@ -68,6 +68,7 @@ class Dimensions( val searchInputHeight: Dp = 60.dp, val filterAssetCardWidth: Dp = 90.dp, val filterAssetCardHeight: Dp = 40.dp, + val assetCardHeight: Dp = 90.dp, val emptyContentMaxHeight: Float = 0.95f, val bottomSheetHeight: Float = 0.45f, ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/Theme.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/Theme.kt index 4779b42..64091fc 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/Theme.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/core/theme/Theme.kt @@ -25,6 +25,7 @@ private val DarkColorScheme = darkColorScheme( onBackground = White, tertiaryContainer = Gray, outline = GrayAthens, + secondaryContainer = Gray, ) private val LightColorScheme = lightColorScheme( @@ -37,6 +38,7 @@ private val LightColorScheme = lightColorScheme( onBackground = Black, tertiaryContainer = Black, outline = Manatee, + secondaryContainer = WoodSmoke, ) @Composable diff --git a/app/src/main/java/dev/pinkroom/marketsight/presentation/detail_screen/DetailViewModel.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/detail_screen/DetailViewModel.kt new file mode 100644 index 0000000..e1c1933 --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/detail_screen/DetailViewModel.kt @@ -0,0 +1,18 @@ +package dev.pinkroom.marketsight.presentation.detail_screen + +import android.util.Log +import androidx.lifecycle.SavedStateHandle +import androidx.lifecycle.ViewModel +import dagger.hilt.android.lifecycle.HiltViewModel +import dev.pinkroom.marketsight.presentation.core.navigation.Args.SYMBOL_ID +import javax.inject.Inject + +@HiltViewModel +class DetailViewModel @Inject constructor( + savedStateHandle: SavedStateHandle, +): ViewModel() { + init { + val id = savedStateHandle.get(SYMBOL_ID) + Log.d("TESTE",id.toString()) + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeEvent.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeEvent.kt index 4f2daf3..fb6bbc0 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeEvent.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeEvent.kt @@ -5,4 +5,5 @@ import dev.pinkroom.marketsight.domain.model.assets.AssetFilter sealed class HomeEvent { data class NewSearchInput(val value: String): HomeEvent() data class ChangeAssetFilter(val assetSelected: AssetFilter): HomeEvent() + data object RetryToGetAssetList: HomeEvent() } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeScreen.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeScreen.kt index 0a0d666..0e44dba 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeScreen.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeScreen.kt @@ -1,8 +1,10 @@ package dev.pinkroom.marketsight.presentation.home_screen import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize @@ -10,6 +12,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier @@ -21,9 +24,11 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import dev.pinkroom.marketsight.R import dev.pinkroom.marketsight.common.assetFilters +import dev.pinkroom.marketsight.domain.model.assets.Asset import dev.pinkroom.marketsight.domain.model.assets.AssetFilter import dev.pinkroom.marketsight.presentation.core.theme.dimens import dev.pinkroom.marketsight.presentation.home_screen.components.FilterAssets +import dev.pinkroom.marketsight.presentation.home_screen.components.ListAssets import dev.pinkroom.marketsight.presentation.home_screen.components.SearchInput @OptIn(ExperimentalFoundationApi::class) @@ -34,7 +39,11 @@ fun HomeScreen( searchInput: String?, placeHolder: Int, filters: List, + assets: List, + isEmptyOnSearch: Boolean, + hasError: Boolean, onEvent: (HomeEvent) -> Unit, + navigateToAssetDetailScreen: (Asset) -> Unit, ){ val focusRequester = remember { FocusRequester() } val focusManager = LocalFocusManager.current @@ -58,38 +67,57 @@ fun HomeScreen( contentPadding = PaddingValues( top = dimens.contentTopPadding, bottom = dimens.contentBottomPadding, - ), + ) ) { stickyHeader { - SearchInput( + Column( modifier = Modifier - .focusRequester(focusRequester) .fillMaxWidth() - .padding(horizontal = dimens.horizontalPadding), - value = searchInput ?: "", - placeHolder = stringResource(id = placeHolder), - isLoading = isLoading, - onChangeInput = { - onEvent(HomeEvent.NewSearchInput(value = it)) - }, - closeInput = { - closeKeyboardAndClearFocus() - } - ) - Spacer(modifier = Modifier.height(dimens.smallPadding)) - FilterAssets( - modifier = Modifier - .fillMaxWidth(), - filters = filters, - isLoading = isLoading, - onFilterClick = { - onEvent(HomeEvent.ChangeAssetFilter(assetSelected = it)) - }, - ) - } - item { - + .background( + color = MaterialTheme.colorScheme.background, + ), + ) { + SearchInput( + modifier = Modifier + .focusRequester(focusRequester) + .fillMaxWidth() + .padding(horizontal = dimens.horizontalPadding), + value = searchInput ?: "", + placeHolder = stringResource(id = placeHolder), + isLoading = isLoading, + isEnabled = !hasError, + onChangeInput = { + onEvent(HomeEvent.NewSearchInput(value = it)) + }, + closeInput = { + closeKeyboardAndClearFocus() + } + ) + Spacer(modifier = Modifier.height(dimens.smallPadding)) + FilterAssets( + modifier = Modifier + .fillMaxWidth(), + filters = filters, + isLoading = isLoading, + onFilterClick = { + closeKeyboardAndClearFocus() + onEvent(HomeEvent.ChangeAssetFilter(assetSelected = it)) + }, + ) + } } + ListAssets( + modifier = Modifier + .fillMaxSize(), + assets = assets, + isLoading = isLoading, + isEmptyOnSearch = isEmptyOnSearch, + hasError = hasError, + onAssetClick = navigateToAssetDetailScreen, + onRetry = { + onEvent(HomeEvent.RetryToGetAssetList) + } + ) } } @@ -100,10 +128,14 @@ fun HomeScreen( @Composable fun HomeScreenPreview(){ HomeScreen( - isLoading = true, + isLoading = false, + assets = emptyList(), searchInput = null, placeHolder = R.string.place_holder_stock, filters = assetFilters, + isEmptyOnSearch = false, + hasError = true, onEvent = {}, + navigateToAssetDetailScreen = {}, ) } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeUiState.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeUiState.kt index 23a45ff..1fda58f 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeUiState.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeUiState.kt @@ -3,6 +3,7 @@ package dev.pinkroom.marketsight.presentation.home_screen import androidx.annotation.StringRes import dev.pinkroom.marketsight.R import dev.pinkroom.marketsight.common.assetFilters +import dev.pinkroom.marketsight.domain.model.assets.Asset import dev.pinkroom.marketsight.domain.model.assets.AssetFilter data class HomeUiState( @@ -10,4 +11,7 @@ data class HomeUiState( val searchInput: String? = null, @StringRes val placeHolder: Int = R.string.place_holder_stock, val filters: List = assetFilters, + val assets: List = emptyList(), + val isEmptyOnSearch: Boolean = false, + val hasError: Boolean = false, ) diff --git a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeViewModel.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeViewModel.kt index a07b109..05e2a25 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeViewModel.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeViewModel.kt @@ -1,29 +1,50 @@ package dev.pinkroom.marketsight.presentation.home_screen import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel +import dev.pinkroom.marketsight.common.DispatcherProvider +import dev.pinkroom.marketsight.common.Resource +import dev.pinkroom.marketsight.domain.model.assets.Asset import dev.pinkroom.marketsight.domain.model.assets.AssetFilter +import dev.pinkroom.marketsight.domain.model.assets.TypeAsset +import dev.pinkroom.marketsight.domain.use_case.assets.GetAllAssets +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.async +import kotlinx.coroutines.awaitAll import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.update +import kotlinx.coroutines.launch import javax.inject.Inject @HiltViewModel class HomeViewModel @Inject constructor( + private val getAllAssets: GetAllAssets, + private val dispatchers: DispatcherProvider, ): ViewModel() { private val _uiState = MutableStateFlow(HomeUiState()) val uiState = _uiState.asStateFlow() + private var stocksList: List = emptyList() + private var cryptosList: List = emptyList() + private var selectedFilter = uiState.value.filters.find { it.isSelected } ?: uiState.value.filters.first() + + init { + getAllAssets() + } + fun onEvent(event: HomeEvent) { when(event){ is HomeEvent.NewSearchInput -> changeSearchInput(newInput = event.value) is HomeEvent.ChangeAssetFilter -> changeAssetFilter(filterToBeSelected = event.assetSelected) + HomeEvent.RetryToGetAssetList -> retryToGetAssetList() } } private fun changeSearchInput(newInput: String) { - _uiState.update { it.copy(searchInput = newInput) } - // TODO UPDATE LIST TO SHOW RESULTS RELATED TO INPUT + val newList = selectedFilter.getAssets().filter { it.name.lowercase().startsWith(newInput.lowercase()) || it.symbol.startsWith(newInput.uppercase()) } + _uiState.update { it.copy(searchInput = newInput, assets = newList, isEmptyOnSearch = newList.isEmpty()) } } private fun changeAssetFilter(filterToBeSelected: AssetFilter) { @@ -31,6 +52,60 @@ class HomeViewModel @Inject constructor( if (it == filterToBeSelected) it.copy(isSelected = true) else it.copy(isSelected = false) } - _uiState.update { it.copy(filters = newFilters, placeHolder = filterToBeSelected.placeHolder) } + selectedFilter = filterToBeSelected + val assets = filterToBeSelected.getAssets() + _uiState.update { + it.copy( + filters = newFilters, + placeHolder = filterToBeSelected.placeHolder, + searchInput = null, + isEmptyOnSearch = false, + hasError = assets.isEmpty(), + assets = assets, + ) + } + } + + @OptIn(ExperimentalCoroutinesApi::class) + private fun getAllAssets() { + viewModelScope.launch(dispatchers.IO) { + _uiState.update { it.copy(isLoading = true) } + val allStocksAssetsRequest = async { getAllAssets(typeAsset = TypeAsset.Stock) } + val allCryptoAssetsRequest = async { getAllAssets(typeAsset = TypeAsset.Crypto) } + awaitAll(allStocksAssetsRequest, allCryptoAssetsRequest) + + stocksList = extractAssetsFromResult(result = allStocksAssetsRequest.getCompleted()) + cryptosList = extractAssetsFromResult(result = allCryptoAssetsRequest.getCompleted()) + val assets = selectedFilter.getAssets() + + _uiState.update { it.copy(isLoading = false, assets = assets, hasError = assets.isEmpty()) } + } } + + private fun extractAssetsFromResult(result: Resource>): List { + return when(result){ + is Resource.Success -> result.data + is Resource.Error -> emptyList() + } + } + + private fun AssetFilter.getAssets() = when(typeAsset) { + TypeAsset.Crypto -> cryptosList + TypeAsset.Stock -> stocksList + } + + private fun retryToGetAssetList() { + viewModelScope.launch(dispatchers.IO) { + _uiState.update { it.copy(isLoading = true) } + val response = getAllAssets(typeAsset = selectedFilter.typeAsset) + val assets = extractAssetsFromResult(result = response) + + when(selectedFilter.typeAsset) { + TypeAsset.Crypto -> cryptosList = assets + TypeAsset.Stock -> stocksList = assets + } + _uiState.update { it.copy(isLoading = false, assets = assets, hasError = assets.isEmpty()) } + } + } + } \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/components/AssetItem.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/components/AssetItem.kt new file mode 100644 index 0000000..f6a59cb --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/components/AssetItem.kt @@ -0,0 +1,69 @@ +package dev.pinkroom.marketsight.presentation.home_screen.components + +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.tooling.preview.Preview +import dev.pinkroom.marketsight.domain.model.assets.Asset +import dev.pinkroom.marketsight.presentation.core.theme.dimens + +@Composable +fun AssetItem( + modifier: Modifier = Modifier, + asset: Asset, + onAssetClick: (Asset) -> Unit, +){ + Card( + modifier = modifier + .fillMaxWidth(), + elevation = CardDefaults.cardElevation( + defaultElevation = dimens.lowElevation, + ), + ) { + Column( + modifier = Modifier + .fillMaxWidth() + .clickable { + onAssetClick(asset) + } + .padding(vertical = dimens.normalPadding, horizontal = dimens.normalPadding) + ) { + Text( + text = asset.name, + style = MaterialTheme.typography.titleMedium, + fontWeight = FontWeight.Bold, + maxLines = 2, + ) + Text( + text = asset.symbol, + fontWeight = FontWeight.Medium, + ) + } + } +} + +@Preview( + showBackground = true, + showSystemUi = true +) +@Composable +fun AssetItemPreview(){ + AssetItem( + asset = Asset( + id = "asasas", + symbol = "TSLA", + exchange = "us_equetity", + name = "Tesla, Inc. Common Stock", + isStock = true, + ), + onAssetClick = {} + ) +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/components/EmptyListAssets.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/components/EmptyListAssets.kt new file mode 100644 index 0000000..dc51c4b --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/components/EmptyListAssets.kt @@ -0,0 +1,54 @@ +package dev.pinkroom.marketsight.presentation.home_screen.components + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.height +import androidx.compose.material3.Button +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontStyle +import androidx.compose.ui.text.style.TextAlign +import dev.pinkroom.marketsight.R +import dev.pinkroom.marketsight.presentation.core.theme.dimens + +@Composable +fun EmptyListAssets( + modifier: Modifier = Modifier, + isEmptyOnSearch: Boolean, + hasError: Boolean, + onRetry: () -> Unit, +) { + Column( + modifier = modifier, + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally, + ) { + if (isEmptyOnSearch) { + Text( + text = stringResource(id = R.string.empty_assets), + textAlign = TextAlign.Center, + style = MaterialTheme.typography.titleMedium, + fontStyle = FontStyle.Italic, + ) + } else if (hasError) { + Text( + text = stringResource(id = R.string.error_on_getting_assets), + textAlign = TextAlign.Center, + style = MaterialTheme.typography.titleMedium, + ) + Spacer(modifier = Modifier.height(dimens.smallPadding)) + Button( + onClick = onRetry, + ) { + Text( + text = stringResource(id = R.string.retry) + ) + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/components/ListAssets.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/components/ListAssets.kt new file mode 100644 index 0000000..5eeb26b --- /dev/null +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/components/ListAssets.kt @@ -0,0 +1,63 @@ +package dev.pinkroom.marketsight.presentation.home_screen.components + +import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyListScope +import androidx.compose.foundation.lazy.items +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import dev.pinkroom.marketsight.domain.model.assets.Asset +import dev.pinkroom.marketsight.presentation.core.theme.dimens +import dev.pinkroom.marketsight.presentation.core.theme.shimmerEffect + +@OptIn(ExperimentalFoundationApi::class) +fun LazyListScope.ListAssets( + modifier: Modifier = Modifier, + assets: List, + isEmptyOnSearch: Boolean, + hasError: Boolean, + isLoading: Boolean, + onAssetClick: (Asset) -> Unit, + onRetry: () -> Unit, +){ + if (isLoading) + items(4) { + Box( + modifier = modifier + .fillMaxWidth() + .height(dimens.assetCardHeight) + .padding(horizontal = dimens.horizontalPadding, vertical = dimens.smallPadding) + .clip(RoundedCornerShape(dimens.normalShape)) + .shimmerEffect(), + ) + } + else if (assets.isNotEmpty()) + items( + items = assets, + key = { it.symbol } + ){ + AssetItem( + modifier = modifier + .padding(horizontal = dimens.horizontalPadding, vertical = dimens.smallPadding) + .animateItemPlacement(), + asset = it, + onAssetClick = onAssetClick, + ) + } + else + item { + EmptyListAssets( + modifier = modifier + .fillParentMaxWidth() + .fillParentMaxHeight(0.8f) + .padding(horizontal = dimens.horizontalPadding), + isEmptyOnSearch = isEmptyOnSearch, + hasError = hasError, + onRetry = onRetry, + ) + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/components/SearchInput.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/components/SearchInput.kt index fe5f154..4061dee 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/components/SearchInput.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/components/SearchInput.kt @@ -29,29 +29,33 @@ fun SearchInput( value: String, placeHolder: String, isLoading: Boolean, + isEnabled: Boolean, onChangeInput: (String) -> Unit, closeInput: () -> Unit, ){ + val colorPlaceHolder = when(isEnabled) { + true -> if (isSystemInDarkTheme()) GrayAthens else Gray + false -> Gray + } if (!isLoading) OutlinedTextField( modifier = modifier, value = value, onValueChange = onChangeInput, + enabled = isEnabled, singleLine = true, shape = CircleShape, leadingIcon = { - val colorIcon = if (isSystemInDarkTheme()) GrayAthens else Gray Icon( painter = painterResource(id = R.drawable.icon_search), contentDescription = null, - tint = colorIcon, + tint = colorPlaceHolder, ) }, placeholder = { - val colorText = if (isSystemInDarkTheme()) GrayAthens else Gray Text( text = placeHolder, - color = colorText, + color = colorPlaceHolder, ) }, keyboardOptions = KeyboardOptions.Default.copy( @@ -65,6 +69,7 @@ fun SearchInput( colors = OutlinedTextFieldDefaults.colors( unfocusedContainerColor = MaterialTheme.colorScheme.primary, focusedContainerColor = MaterialTheme.colorScheme.primary, + disabledContainerColor = MaterialTheme.colorScheme.secondaryContainer.copy(alpha = 0.4f), focusedBorderColor = MaterialTheme.colorScheme.onPrimary, unfocusedBorderColor = MaterialTheme.colorScheme.background, cursorColor = MaterialTheme.colorScheme.onPrimary, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c3a96a1..f940893 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -28,4 +28,6 @@ Search Crypto Stock Crypto + There are no assets for the search performed. + An error occurred, try again. \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e298319..81d6869 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,12 +1,12 @@ [versions] agp = "8.3.2" kotlin = "1.9.23" -coreKtx = "1.13.0" +coreKtx = "1.13.1" junitVersion = "1.1.5" espressoCore = "3.5.1" lifecycleRuntimeKtx = "2.7.0" activityCompose = "1.9.0" -composeBom = "2024.04.01" +composeBom = "2024.05.00" retrofitVersion = "2.11.0" okHttpVersion = "4.12.0" scarletVersion = "0.1.12" From cda4490dcd18b34017ea18472f01c97833fe42c2 Mon Sep 17 00:00:00 2001 From: LucasPrioste Date: Mon, 13 May 2024 12:21:01 +0100 Subject: [PATCH 33/33] - ui test HomeViewModel --- .../presentation/home_screen/HomeViewModel.kt | 4 +- .../home_screen/HomeViewModelTest.kt | 219 ++++++++++++++++++ 2 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 app/src/test/java/dev/pinkroom/marketsight/presentation/home_screen/HomeViewModelTest.kt diff --git a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeViewModel.kt b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeViewModel.kt index 05e2a25..9dc3b2a 100644 --- a/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeViewModel.kt +++ b/app/src/main/java/dev/pinkroom/marketsight/presentation/home_screen/HomeViewModel.kt @@ -43,7 +43,9 @@ class HomeViewModel @Inject constructor( } private fun changeSearchInput(newInput: String) { - val newList = selectedFilter.getAssets().filter { it.name.lowercase().startsWith(newInput.lowercase()) || it.symbol.startsWith(newInput.uppercase()) } + val newList = selectedFilter.getAssets().filter { + it.name.lowercase().startsWith(newInput.lowercase()) || it.symbol.startsWith(newInput.uppercase()) + } _uiState.update { it.copy(searchInput = newInput, assets = newList, isEmptyOnSearch = newList.isEmpty()) } } diff --git a/app/src/test/java/dev/pinkroom/marketsight/presentation/home_screen/HomeViewModelTest.kt b/app/src/test/java/dev/pinkroom/marketsight/presentation/home_screen/HomeViewModelTest.kt new file mode 100644 index 0000000..15e2d98 --- /dev/null +++ b/app/src/test/java/dev/pinkroom/marketsight/presentation/home_screen/HomeViewModelTest.kt @@ -0,0 +1,219 @@ +package dev.pinkroom.marketsight.presentation.home_screen + +import assertk.assertThat +import assertk.assertions.isEmpty +import assertk.assertions.isEqualTo +import assertk.assertions.isFalse +import assertk.assertions.isLessThan +import assertk.assertions.isNotEmpty +import assertk.assertions.isNull +import assertk.assertions.isTrue +import dev.pinkroom.marketsight.common.Resource +import dev.pinkroom.marketsight.data.mapper.toAsset +import dev.pinkroom.marketsight.domain.model.assets.Asset +import dev.pinkroom.marketsight.domain.model.assets.TypeAsset +import dev.pinkroom.marketsight.domain.use_case.assets.GetAllAssets +import dev.pinkroom.marketsight.factories.AssetDtoFactory +import dev.pinkroom.marketsight.util.MainCoroutineRule +import dev.pinkroom.marketsight.util.TestDispatcherProvider +import io.mockk.coEvery +import io.mockk.coVerify +import io.mockk.mockk +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.test.advanceUntilIdle +import kotlinx.coroutines.test.runTest +import org.junit.Rule +import org.junit.Test + +@OptIn(ExperimentalCoroutinesApi::class) +class HomeViewModelTest { + + @get:Rule + val coroutineRule = MainCoroutineRule() + + private val dispatchers = TestDispatcherProvider() + private val assetFactory = AssetDtoFactory() + private val getAllAssets = mockk(relaxed = true, relaxUnitFun = true) + private lateinit var homeViewModel: HomeViewModel + + private fun initViewModel() { + homeViewModel = HomeViewModel( + getAllAssets = getAllAssets, + dispatchers = dispatchers, + ) + } + + @Test + fun `When init VM, Then Success on GetAllAssets`() = runTest { + // GIVEN + val assets = assetFactory.buildList(number = 500).map { it.toAsset() } + mockResponseGetAllAssetsSuccess(assets) + + // WHEN + initViewModel() + advanceUntilIdle() + + // THEN + val uiState = homeViewModel.uiState.value + + coVerify(exactly = 2) { + getAllAssets.invoke(typeAsset = any()) + } + assertThat(uiState.assets).isNotEmpty() + assertThat(uiState.isLoading).isFalse() + assertThat(uiState.hasError).isFalse() + assertThat(uiState.isEmptyOnSearch).isFalse() + } + + @Test + fun `When init VM, Then Success on GetAllAssets of type stock`() = runTest { + // GIVEN + val assets = assetFactory.buildList(number = 500).map { it.toAsset() } + mockResponseGetAllAssetsOfTypeStockSuccess(assets) + + // WHEN + initViewModel() + advanceUntilIdle() + + // THEN + var uiState = homeViewModel.uiState.value + val activeFilter = uiState.filters.find { it.isSelected } ?: uiState.filters.first() + if (activeFilter.typeAsset == TypeAsset.Stock){ + assertThat(uiState.assets).isNotEmpty() + assertThat(uiState.isLoading).isFalse() + assertThat(uiState.hasError).isFalse() + val filterCrypto = uiState.filters.find { it.typeAsset == TypeAsset.Crypto }!! + homeViewModel.onEvent(HomeEvent.ChangeAssetFilter(assetSelected = filterCrypto)) + advanceUntilIdle() + } + + uiState = homeViewModel.uiState.value + assertThat(uiState.assets).isEmpty() + assertThat(uiState.isLoading).isFalse() + assertThat(uiState.hasError).isTrue() + + coVerify { + getAllAssets.invoke(typeAsset = any()) + } + } + + @Test + fun `Given new search input, When Assets is not empty, Then update values based on input`() = runTest { + // GIVEN + val inputSearch = "AA" + val assets = assetFactory.buildList(number = 500).map { it.toAsset() } + mockResponseGetAllAssetsSuccess(assets) + initViewModel() + advanceUntilIdle() + + // WHEN + homeViewModel.onEvent(HomeEvent.NewSearchInput(value = inputSearch)) + advanceUntilIdle() + + // THEN + val uiState = homeViewModel.uiState.value + assertThat(uiState.searchInput).isEqualTo(inputSearch) + assertThat(uiState.assets).isNotEmpty() + assertThat(uiState.isEmptyOnSearch).isFalse() + assertThat(uiState.assets.size).isLessThan(assets.size) + } + + @Test + fun `Given new search input, When Assets is not empty, Then no response for the given search input`() = runTest { + // GIVEN + val inputSearch = "AABXMAOPIASMMABSYNAONS123" + val assets = assetFactory.buildList(number = 500).map { it.toAsset() } + mockResponseGetAllAssetsSuccess(assets) + initViewModel() + advanceUntilIdle() + + // WHEN + homeViewModel.onEvent(HomeEvent.NewSearchInput(value = inputSearch)) + advanceUntilIdle() + + // THEN + val uiState = homeViewModel.uiState.value + assertThat(uiState.searchInput).isEqualTo(inputSearch) + assertThat(uiState.assets).isEmpty() + assertThat(uiState.isEmptyOnSearch).isTrue() + } + + @Test + fun `When change Asset filter, Then show assets related to filter selected`() = runTest { + // GIVEN + val assets = assetFactory.buildList(number = 500).map { it.toAsset() } + mockResponseGetAllAssetsSuccess(assets) + initViewModel() + advanceUntilIdle() + val filterCrypto = homeViewModel.uiState.value.filters.find { it.typeAsset == TypeAsset.Crypto }!! + + // WHEN + homeViewModel.onEvent(HomeEvent.ChangeAssetFilter(assetSelected = filterCrypto)) + advanceUntilIdle() + + // THEN + val uiState = homeViewModel.uiState.value + val newSelectedFilter = uiState.filters.find { it.isSelected } + assertThat(uiState.searchInput).isNull() + assertThat(uiState.assets).isNotEmpty() + assertThat(uiState.isEmptyOnSearch).isFalse() + assertThat(uiState.hasError).isFalse() + assertThat(uiState.isLoading).isFalse() + assertThat(uiState.assets.first().isStock).isFalse() + assertThat(newSelectedFilter!!.typeAsset).isEqualTo(TypeAsset.Crypto) + assertThat(uiState.filters.filter { it.isSelected }.size).isEqualTo(1) + } + + @Test + fun `When Retry To Get Assets, Then on Success update assets`() = runTest { + // GIVEN + val assets = assetFactory.buildList(number = 500).map { it.toAsset() } + mockResponseGetAllAssetsFirstWithErrorAndThenSuccess(assets) + initViewModel() + advanceUntilIdle() + + // WHEN + var uiState = homeViewModel.uiState.value + assertThat(uiState.assets).isEmpty() + assertThat(uiState.hasError).isTrue() + assertThat(uiState.isEmptyOnSearch).isFalse() + homeViewModel.onEvent(HomeEvent.RetryToGetAssetList) + advanceUntilIdle() + + // THEN + uiState = homeViewModel.uiState.value + assertThat(uiState.assets).isNotEmpty() + assertThat(uiState.hasError).isFalse() + assertThat(uiState.isLoading).isFalse() + } + + private fun mockResponseGetAllAssetsSuccess(assets: List) { + coEvery { + getAllAssets.invoke(typeAsset = TypeAsset.Crypto) + } returns Resource.Success(data = assets.filter { !it.isStock }) + + coEvery { + getAllAssets.invoke(typeAsset = TypeAsset.Stock) + } returns Resource.Success(data = assets.filter { it.isStock }) + } + + private fun mockResponseGetAllAssetsOfTypeStockSuccess(assets: List) { + coEvery { + getAllAssets.invoke(typeAsset = TypeAsset.Crypto) + } returns Resource.Error() + + coEvery { + getAllAssets.invoke(typeAsset = TypeAsset.Stock) + } returns Resource.Success(data = assets.filter { it.isStock }) + } + + private fun mockResponseGetAllAssetsFirstWithErrorAndThenSuccess(assets: List) { + coEvery { + getAllAssets.invoke(typeAsset = any()) + }.returnsMany( + Resource.Error(), + Resource.Success(data = assets), + ) + } + +} \ No newline at end of file