-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added a file with composable that displays details of one product. * navigation to product details - not pretty but works * compose navigation stuff added to build gradle * started refactoring to get rid of fragments and do only compose navigation * exit to main activity added * navigation to product details added to refactored navigation * navigation to product details added to refactored navigation * removed anused folders * removed accidental comflict resolution duplicates * removed dead code * sight changes in cart screen placeholder
- Loading branch information
Showing
20 changed files
with
344 additions
and
365 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 0 additions & 50 deletions
50
demo-app/src/main/java/io/opentelemetry/android/demo/AstronomyShopActivity.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 0 additions & 52 deletions
52
demo-app/src/main/java/io/opentelemetry/android/demo/ui/cart/CartFragment.kt
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
demo-app/src/main/java/io/opentelemetry/android/demo/ui/cart/CartViewModel.kt
This file was deleted.
Oops, something went wrong.
52 changes: 0 additions & 52 deletions
52
demo-app/src/main/java/io/opentelemetry/android/demo/ui/dashboard/DashboardFragment.kt
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
demo-app/src/main/java/io/opentelemetry/android/demo/ui/dashboard/DashboardViewModel.kt
This file was deleted.
Oops, something went wrong.
95 changes: 95 additions & 0 deletions
95
demo-app/src/main/java/io/opentelemetry/android/demo/ui/shop/AstronomyShopActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.android.demo.ui.shop | ||
|
||
import android.app.Activity | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import androidx.activity.compose.setContent | ||
import androidx.appcompat.app.AppCompatActivity | ||
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.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.navigation.compose.NavHost | ||
import androidx.navigation.compose.composable | ||
import io.opentelemetry.android.demo.MainActivity | ||
import io.opentelemetry.android.demo.clients.ProductCatalogClient | ||
import io.opentelemetry.android.demo.theme.DemoAppTheme | ||
import io.opentelemetry.android.demo.ui.shop.cart.CartScreen | ||
import io.opentelemetry.android.demo.ui.shop.products.ProductDetails | ||
import io.opentelemetry.android.demo.ui.shop.products.ProductList | ||
|
||
class AstronomyShopActivity : AppCompatActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContent { | ||
AstronomyShopScreen() | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
fun AstronomyShopScreen() { | ||
val productsClient = ProductCatalogClient(LocalContext.current) | ||
val products by remember { mutableStateOf(productsClient.get()) } | ||
val context = LocalContext.current | ||
val astronomyShopNavController = rememberAstronomyShopNavController() | ||
|
||
DemoAppTheme { | ||
Surface( | ||
modifier = Modifier.fillMaxSize(), | ||
color = MaterialTheme.colorScheme.background | ||
) { | ||
Scaffold( | ||
bottomBar = { | ||
BottomNavigationBar( | ||
items = listOf(BottomNavItem.Exit, BottomNavItem.List, BottomNavItem.Cart), | ||
currentRoute = astronomyShopNavController.currentRoute, | ||
onItemClicked = { route -> | ||
astronomyShopNavController.navController.navigate(route) { | ||
popUpTo(astronomyShopNavController.navController.graph.startDestinationId) | ||
launchSingleTop = true | ||
} | ||
}, | ||
onExitClicked = { | ||
val intent = Intent(context, MainActivity::class.java) | ||
context.startActivity(intent) | ||
(context as? Activity)?.finish() | ||
} | ||
) | ||
} | ||
) { innerPadding -> | ||
NavHost( | ||
navController = astronomyShopNavController.navController, | ||
startDestination = MainDestinations.HOME_ROUTE, | ||
Modifier.padding(innerPadding) | ||
) { | ||
composable(BottomNavItem.List.route) { | ||
ProductList(products = products) { productId -> | ||
astronomyShopNavController.navigateToProductDetail(productId) | ||
} | ||
} | ||
composable(BottomNavItem.Cart.route) { | ||
CartScreen() | ||
} | ||
composable("${MainDestinations.PRODUCT_DETAIL_ROUTE}/{${MainDestinations.PRODUCT_ID_KEY}}") { backStackEntry -> | ||
val productId = backStackEntry.arguments?.getString(MainDestinations.PRODUCT_ID_KEY) | ||
val product = products.find { it.id == productId } | ||
product?.let { ProductDetails(product = it) } | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.