diff --git a/app/src/main/java/com/guru/composecookbook/App.kt b/app/src/main/java/com/guru/composecookbook/App.kt index b4b28c02..632ef9c4 100644 --- a/app/src/main/java/com/guru/composecookbook/App.kt +++ b/app/src/main/java/com/guru/composecookbook/App.kt @@ -3,27 +3,15 @@ package com.guru.composecookbook import android.app.Application import android.content.Context -/** - * Custom Application class for initializing global application state. - */ class App : Application() { - /** - * Initializes the singleton instance of the App class and ensuring it is non-null. - */ init { instance = requireNotNull(this) } companion object { - // Singleton instance of the App class private lateinit var instance: App - /** - * Provides the application context. - * - * @return Context of the application. - */ fun applicationContext(): Context { return instance } diff --git a/app/src/main/java/com/guru/composecookbook/BottomNavType.kt b/app/src/main/java/com/guru/composecookbook/BottomNavType.kt index 042e6a14..a7d18dad 100644 --- a/app/src/main/java/com/guru/composecookbook/BottomNavType.kt +++ b/app/src/main/java/com/guru/composecookbook/BottomNavType.kt @@ -1,27 +1,9 @@ package com.guru.composecookbook -/** - * Enum class representing the different types of bottom navigation items. - */ enum class BottomNavType { - /** - * Represents the Home screen in the bottom navigation. - */ HOME, - /** - * Represents the Widgets screen in the bottom navigation. - */ WIDGETS, - /** - * Represents the Animation screen in the bottom navigation. - */ ANIMATION, - /** - * Represents the Demo UI screen in the bottom navigation. - */ DEMOUI, - /** - * Represents the Template screen in the bottom navigation. - */ TEMPLATE } \ No newline at end of file diff --git a/app/src/main/java/com/guru/composecookbook/MainActivity.kt b/app/src/main/java/com/guru/composecookbook/MainActivity.kt index f0b4666b..63fbba1c 100644 --- a/app/src/main/java/com/guru/composecookbook/MainActivity.kt +++ b/app/src/main/java/com/guru/composecookbook/MainActivity.kt @@ -65,17 +65,7 @@ import com.guru.fontawesomecomposelib.FaIcon import com.guru.fontawesomecomposelib.FaIcons import kotlinx.coroutines.launch -/** - * Main activity of the application. - */ class MainActivity : ComponentActivity() { - - /** - * Sets up the main activity. Initializes the mobile ads and sets the content view. - * - * @param savedInstanceState Saved instance state. - */ - @OptIn(ExperimentalAnimationApi::class, ExperimentalFoundationApi::class, ExperimentalMaterialApi::class) @@ -93,14 +83,6 @@ class MainActivity : ComponentActivity() { } } - -/** - * Composable function for the base view of the app. - * - * @param appThemeState Current app theme state. - * @param systemUiController Controller for system UI. - * @param content Composable content to be displayed. - */ @Composable fun BaseView( appThemeState: AppThemeState, @@ -123,15 +105,6 @@ fun BaseView( } } - -/** - * Composable function for the home screen content. - * - * @param homeScreen Current home screen type. - * @param appThemeState Current app theme state. - * @param chooseColorBottomModalState State of the bottom modal sheet for color selection. - * @param modifier Modifier to be applied to the layout. - */ @OptIn(ExperimentalAnimationApi::class, ExperimentalFoundationApi::class, ExperimentalMaterialApi::class) @@ -158,12 +131,6 @@ fun HomeScreenContent( } } - -/** - * Composable function for the main app content. - * - * @param appThemeState Current app theme state. - */ @OptIn(ExperimentalAnimationApi::class, ExperimentalFoundationApi::class, ExperimentalMaterialApi::class) @@ -227,13 +194,6 @@ fun MainAppContent(appThemeState: MutableState) { } - -/** - * Composable function for the bottom navigation content. - * - * @param modifier Modifier to be applied to the layout. - * @param homeScreenState Current home screen state. - */ @Composable fun BottomNavigationContent( modifier: Modifier = Modifier, @@ -358,13 +318,6 @@ fun BottomNavigationContent( } } - -/** - * Composable function for the navigation rail content. - * - * @param modifier Modifier to be applied to the layout. - * @param homeScreenState Current home screen state. - */ @Composable private fun NavigationRailContent( modifier: Modifier, @@ -489,10 +442,6 @@ private fun NavigationRailContent( } } - -/** - * Preview function for the main app content. - */ @OptIn(ExperimentalAnimationApi::class, ExperimentalFoundationApi::class, ExperimentalMaterialApi::class) diff --git a/app/src/main/java/com/guru/composecookbook/ui/home/HomeScreen.kt b/app/src/main/java/com/guru/composecookbook/ui/home/HomeScreen.kt index dbcdfcba..d5b5dc17 100644 --- a/app/src/main/java/com/guru/composecookbook/ui/home/HomeScreen.kt +++ b/app/src/main/java/com/guru/composecookbook/ui/home/HomeScreen.kt @@ -71,14 +71,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch import java.util.* -/** - * Sets up the home screen UI with a top bar and content area. - * The top bar includes buttons for toggling the dark theme and opening a color selection menu. - * The content area displays the home screen content, including a list of items and a color palette menu. - * - * @param appThemeState: A mutable state holding the current theme state (light or dark) and color palette. - * @param chooseColorBottomModalState: State for controlling the bottom modal sheet used for choosing colors. - */ + @OptIn( ExperimentalMaterialApi::class, ExperimentalMaterial3Api::class @@ -126,14 +119,7 @@ fun HomeScreen( ) } -/** - * Adds an icon button that, when clicked, toggles the visibility of the color palette menu or - * shows the modal bottom sheet for color selection if accessibility settings are enabled. - * - * @param coroutineScope: Scope for launching coroutines. - * @param chooseColorBottomModalState: State for controlling the color selection modal bottom sheet. - * @param showMenu: Mutable state to control the visibility of the color palette menu. - */ + @SuppressLint("ServiceCast") @OptIn(ExperimentalMaterialApi::class) @Composable @@ -162,15 +148,6 @@ private fun ChangeColorIconButton( } } -/** - * Displays a list of home screen items, adapting the layout based on screen width. - * Shows a color palette menu if showMenu is true. - * - * @param isDarkTheme: Boolean indicating whether the dark theme is active. - * @param showMenu: Mutable state to control the visibility of the color palette menu. - * @param onPalletChange: Callback invoked when a new color palette is selected. - * @param modifier: Modifier for styling the composable. - */ @Composable fun HomeScreenContent( isDarkTheme: Boolean, @@ -214,12 +191,6 @@ fun HomeScreenContent( } } -/** - * Displays a list of color options for the user to choose from, invoking onPalletChange when a selection is made. - * - * @param modifier: Modifier for styling the composable. - * @param onPalletChange: Callback invoked when a new color palette is selected. - */ @Composable fun PalletMenu( modifier: Modifier, @@ -253,13 +224,6 @@ fun PalletMenu( } } -/** - * Displays a row with an icon and text, triggering the onPalletChange callback when clicked. - * - * @param color: Color of the icon representing the palette. - * @param name: Name of the color palette. - * @param onPalletChange: Callback invoked when the menu item is clicked. - */ @Composable fun MenuItem(color: Color, name: String, onPalletChange: () -> Unit) { Row( @@ -277,14 +241,7 @@ fun MenuItem(color: Color, name: String, onPalletChange: () -> Unit) { } } -/** - * Displays a card or button for each home screen item, adjusting the layout based on screen width. - * - * @param homeScreenItems: Item to display in the list. - * @param context: Context for starting activities. - * @param isDarkTheme: Boolean indicating whether the dark theme is active. - * @param isWiderScreen: Boolean indicating if the screen width is wider than a certain threshold. - */ + @Composable fun HomeScreenListView( homeScreenItems: HomeScreenItems, context: Context, isDarkTheme: Boolean, @@ -324,13 +281,6 @@ fun HomeScreenListView( } } -/** - * Starts a new activity based on the clicked home screen item, passing the theme state to the new activity. - * - * @param homeScreenItems: Item that was clicked. - * @param context: Context for starting activities. - * @param isDarkTheme: Boolean indicating whether the dark theme is active. - */ fun homeItemClicked(homeScreenItems: HomeScreenItems, context: Context, isDarkTheme: Boolean) { //TODO pass theme to following screens val intent = when (homeScreenItems) { @@ -390,9 +340,6 @@ fun homeItemClicked(homeScreenItems: HomeScreenItems, context: Context, isDarkTh context.startActivity(intent) } -/** - * Provides a preview of the HomeScreen composable with default theme state and modal bottom sheet state. - */ @OptIn(ExperimentalMaterialApi::class) @Preview @Composable diff --git a/app/src/main/java/com/guru/composecookbook/ui/home/lists/GridListItem.kt b/app/src/main/java/com/guru/composecookbook/ui/home/lists/GridListItem.kt index bacdc466..8359b471 100644 --- a/app/src/main/java/com/guru/composecookbook/ui/home/lists/GridListItem.kt +++ b/app/src/main/java/com/guru/composecookbook/ui/home/lists/GridListItem.kt @@ -24,12 +24,6 @@ import com.guru.composecookbook.theme.ComposeCookBookTheme import com.guru.composecookbook.theme.components.Material3Card import com.guru.composecookbook.ui.utils.TestTags -/** - * Composable function to display a grid list item. - * - * @param item The item to display, which contains information such as title, subtitle, source, and image. - * @param modifier The modifier to be applied to the layout of the grid list item. - */ @Composable fun GridListItem( item: Item, @@ -76,9 +70,6 @@ fun GridListItem( } } -/** - * Preview function for GridListItem composable. - */ @Preview @Composable fun PreviewGridListItem() { diff --git a/app/src/main/java/com/guru/composecookbook/ui/home/lists/HorizontalListItem.kt b/app/src/main/java/com/guru/composecookbook/ui/home/lists/HorizontalListItem.kt index 7626b253..58fe896c 100644 --- a/app/src/main/java/com/guru/composecookbook/ui/home/lists/HorizontalListItem.kt +++ b/app/src/main/java/com/guru/composecookbook/ui/home/lists/HorizontalListItem.kt @@ -23,12 +23,6 @@ import com.guru.composecookbook.theme.ComposeCookBookTheme import com.guru.composecookbook.theme.components.Material3Card import com.guru.composecookbook.ui.utils.TestTags -/** - * Composable function to display a horizontal list item. - * - * @param item The item to display, which contains information such as title, subtitle, source, and image. - * @param modifier The modifier to be applied to the layout of the grid list item. - */ @Composable fun HorizontalListItem( item: Item, @@ -73,9 +67,6 @@ fun HorizontalListItem( } } -/** - * Preview function for HorizontalListItem composable. - */ @Preview @Composable fun PreviewHorizontalListItem() { diff --git a/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/AllButtons.kt b/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/AllButtons.kt index 13167c0e..74c22ae7 100644 --- a/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/AllButtons.kt +++ b/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/AllButtons.kt @@ -38,16 +38,12 @@ import com.guru.composecookbook.theme.typography import kotlinx.coroutines.delay import kotlinx.coroutines.launch -/** - * Composable function demonstrating various types of buttons and their customization options. - */ @OptIn(ExperimentalMaterialApi::class, ExperimentalAnimationApi::class) @Composable fun AllButtons() { Text(text = "Buttons", style = typography.h5, modifier = Modifier.padding(8.dp)) - // Row 1: Basic Buttons Row { Button(onClick = {}, modifier = Modifier.padding(8.dp)) { Text(text = "Main Button") @@ -59,8 +55,6 @@ fun AllButtons() { Text(text = "Text Disabled") } } - - // Row 2: More Button Variations Row { Button(onClick = {}, modifier = Modifier.padding(8.dp), enabled = false) { Text(text = "Disabled") @@ -80,8 +74,6 @@ fun AllButtons() { Text(text = "Rounded") } } - - // Row 3: Other Button Types Row { OutlinedButton(onClick = {}, modifier = Modifier.padding(8.dp)) { Text(text = "Outline") @@ -125,8 +117,6 @@ fun AllButtons() { Text(text = "Custom colors") } } - - // Gradient Background Buttons Row { val horizontalGradient = Brush.horizontalGradient( colors = listOf(MaterialTheme.colorScheme.primary, MaterialTheme.colorScheme.inversePrimary), @@ -160,7 +150,6 @@ fun AllButtons() { ) } - // Swipe Button Examples val swipeButtonState = remember { mutableStateOf(SwipeButtonState.INITIAL) } @@ -197,10 +186,6 @@ fun AllButtons() { } } - -/** - * A Composable function to preview the AllButtons Composable. - */ @OptIn(ExperimentalAnimationApi::class, ExperimentalMaterialApi::class) @Preview diff --git a/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/AppBars.kt b/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/AppBars.kt index 3b04db73..08bd6050 100644 --- a/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/AppBars.kt +++ b/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/AppBars.kt @@ -43,10 +43,6 @@ import com.guru.composecookbook.theme.typography import com.guru.composecookbook.ui.utils.SubtitleText import com.guru.composecookbook.ui.utils.TitleText - -/** - * Composable function demonstrating various types of app bars and navigation bars. - */ @Composable fun AppBars() { Text(text = "App Bars", style = typography.h5, modifier = Modifier.padding(8.dp)) @@ -56,17 +52,11 @@ fun AppBars() { NavigationBarDemo() } - -/** - * Composable function demonstrating different configurations of top app bars. - */ @OptIn(ExperimentalMaterial3Api::class) @Composable fun TopAppBarsDemo() { - // Subtitle for top app bar section SubtitleText(subtitle = "Top App bar") - // Small top app bar with back navigation icon SmallTopAppBar( title = { Text(text = "Home") }, navigationIcon = { @@ -81,7 +71,6 @@ fun TopAppBarsDemo() { Spacer(modifier = Modifier.height(8.dp)) - // Top app bar with title "Instagram" and custom navigation and action icons TopAppBar( title = { Text(text = "Instagram") }, backgroundColor = MaterialTheme.colorScheme.surface, @@ -104,7 +93,6 @@ fun TopAppBarsDemo() { Spacer(modifier = Modifier.height(8.dp)) - // Top app bar with Twitter icon, custom navigation icon, and action icon TopAppBar( title = { Icon( @@ -138,16 +126,11 @@ fun TopAppBarsDemo() { Spacer(modifier = Modifier.height(8.dp)) } - -/** - * Composable function demonstrating usage of Bottom App Bar. - */ @Composable fun BottomAppBarDemo() { Spacer(modifier = Modifier.height(16.dp)) SubtitleText("Bottom app bars: Note bottom app bar support FAB cutouts when used with scafolds see demoUI crypto app") - // Bottom app bar with an IconButton and a TitleText BottomAppBar( cutoutShape = CircleShape ) { @@ -158,19 +141,11 @@ fun BottomAppBarDemo() { } } - -/** - * Composable function demonstrating usage of Bottom Navigation Bar. - */ @Composable fun NavigationBarDemo() { Spacer(modifier = Modifier.height(16.dp)) SubtitleText(subtitle = "Bottom Navigation Bars") - - // State to manage selected navigation item in Bottom Navigation Bar val spotifyNavItemState = remember { mutableStateOf(SpotifyNavType.HOME) } - - // Bottom Navigation Bar with three items: Home, Search, and Library BottomNavigation(backgroundColor = MaterialTheme.colorScheme.surface) { BottomNavigationItem( icon = { Icon(imageVector = Icons.Outlined.Home, contentDescription = null) }, @@ -194,7 +169,6 @@ fun NavigationBarDemo() { Spacer(modifier = Modifier.height(16.dp)) - // Bottom Navigation Bar without labels, showcasing more icons BottomNavigation { BottomNavigationItem( icon = { Icon(imageVector = Icons.Outlined.ReadMore, contentDescription = null) }, @@ -215,9 +189,6 @@ fun NavigationBarDemo() { } -/** - * Preview function for AppBars composable. - */ @Preview @Composable fun PreviewAppBars() { diff --git a/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/Chips.kt b/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/Chips.kt index 0deea340..dfee81c0 100644 --- a/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/Chips.kt +++ b/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/Chips.kt @@ -23,17 +23,11 @@ import com.guru.composecookbook.theme.typography import com.guru.composecookbook.ui.utils.SubtitleText import com.guru.composecookbook.youtube.components.YoutubeChip -/** - * Composable function demonstrating custom chips and chip-like buttons. - */ @Composable fun Chips() { // There is no in-built chips but you can make yours like below Text(text = "Custom Chips", style = typography.h6, modifier = Modifier.padding(8.dp)) - SubtitleText(subtitle = "Custom chips with surface") - - // Row displaying custom chips with different configurations Row(modifier = Modifier.padding(8.dp)) { YoutubeChip(selected = true, text = "Chip", modifier = Modifier.padding(horizontal = 8.dp)) YoutubeChip( @@ -45,10 +39,7 @@ fun Chips() { Spacer(modifier = Modifier.padding(8.dp)) CustomImageChip(text = "custom2", imageId = com.guru.composecookbook.data.R.drawable.p6, selected = false) } - SubtitleText(subtitle = "Buttons with circle clipping.") - - // Row displaying chip-like buttons with circular clipping Row(modifier = Modifier.padding(8.dp)) { Button( onClick = {}, @@ -71,18 +62,8 @@ fun Chips() { } -/** - * Private composable function representing a custom image chip. - * - * Inspired from jetcaster sample. I hope compose can add simple Chip UI element that can - * support images or icons with multiple states. - * - * @param text The text content of the chip. - * @param imageId The resource ID of the image/icon to be displayed in the chip. - * @param selected The selected state of the chip. - * @param modifier Modifier for styling and layout customization. - */ - +//Inspired from jetcaster sample. I hope compose can add simple Chip UI element that can +// support images or icons with multiple states. @Composable private fun CustomImageChip( text: String, @@ -110,8 +91,6 @@ private fun CustomImageChip( modifier = modifier ) { Row(modifier = Modifier) { - - // Image/icon displayed in the chip, clipped with CircleShape Image( painter = painterResource(imageId), contentDescription = null, @@ -120,8 +99,6 @@ private fun CustomImageChip( .size(20.dp) .clip(CircleShape) ) - - // Text content of the chip Text( text = text, style = MaterialTheme.typography.bodyMedium, diff --git a/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/Layouts.kt b/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/Layouts.kt index d8f02929..dfbee05f 100644 --- a/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/Layouts.kt +++ b/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/Layouts.kt @@ -29,11 +29,6 @@ import com.guru.composecookbook.theme.green700 import com.guru.composecookbook.theme.typography import com.guru.composecookbook.ui.utils.TestTags - -/** - * Composable function demonstrating different types of layouts including Rows, Columns, Boxes, - * and ConstraintLayout. - */ @Composable fun Layouts() { Column(modifier = Modifier.verticalScroll(rememberScrollState())) { @@ -44,9 +39,6 @@ fun Layouts() { } } -/** - * Composable function demonstrating different horizontal arrangements in Rows. - */ @Composable fun TypesOfRows() { Text(text = "Rows", style = typography.h6, modifier = Modifier.padding(8.dp)) @@ -54,7 +46,6 @@ fun TypesOfRows() { text = "Arrangement.Start ", style = typography.caption, modifier = Modifier.padding(8.dp) ) - // Row with Arrangement.Start Row( horizontalArrangement = Arrangement.Start, modifier = Modifier @@ -68,7 +59,6 @@ fun TypesOfRows() { text = "Arrangement.End ", style = typography.caption, modifier = Modifier.padding(8.dp) ) - // Row with Arrangement.End Row( horizontalArrangement = Arrangement.End, modifier = Modifier .padding(8.dp) @@ -81,7 +71,6 @@ fun TypesOfRows() { text = "Arrangement.Center ", style = typography.caption, modifier = Modifier.padding(8.dp) ) - // Row with Arrangement.Center Row( horizontalArrangement = Arrangement.Center, modifier = Modifier @@ -95,7 +84,6 @@ fun TypesOfRows() { text = "Arrangement.SpaceAround ", style = typography.caption, modifier = Modifier.padding(8.dp) ) - // Row with Arrangement.SpaceAround Row( horizontalArrangement = Arrangement.SpaceAround, modifier = Modifier @@ -109,7 +97,6 @@ fun TypesOfRows() { text = "Arrangement.SpaceBetween ", style = typography.caption, modifier = Modifier.padding(8.dp) ) - // Row with Arrangement.SpaceBetween Row( horizontalArrangement = Arrangement.SpaceBetween, modifier = Modifier @@ -123,7 +110,6 @@ fun TypesOfRows() { text = "Arrangement.SpaceEvenly ", style = typography.caption, modifier = Modifier.padding(8.dp) ) - // Row with Arrangement.SpaceEvenly Row( horizontalArrangement = Arrangement.SpaceEvenly, modifier = Modifier @@ -135,9 +121,6 @@ fun TypesOfRows() { } } -/** - * Composable function demonstrating different vertical arrangements in Columns. - */ @Composable fun TypeOfColumns() { val columnModifier = Modifier @@ -146,25 +129,20 @@ fun TypeOfColumns() { .height(150.dp) .background(MaterialTheme.colorScheme.surfaceVariant) Text(text = "Column", style = typography.h6, modifier = Modifier.padding(8.dp)) - Text( text = "Arrangement.Top", style = typography.caption, modifier = Modifier.padding(8.dp) ) - // Column with Arrangement.Top Column( verticalArrangement = Arrangement.Top, modifier = columnModifier .testTag(TestTags.HOME_LAYOUTS_COLUMN_TOP) ) { MultipleTexts() } - - Text( text = "Arrangement.Bottom", style = typography.caption, modifier = Modifier.padding(8.dp) ) - // Column with Arrangement.Bottom Column( verticalArrangement = Arrangement.Bottom, modifier = columnModifier @@ -173,13 +151,10 @@ fun TypeOfColumns() { ) { MultipleTexts() } - - Text( text = "Arrangement.Center + Alignment.CenterHorizontally", style = typography.caption, modifier = Modifier.padding(8.dp) ) - // Column with Arrangement.Center + Alignment.CenterHorizontally Column( verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally, @@ -188,13 +163,10 @@ fun TypeOfColumns() { ) { MultipleTexts() } - - Text( text = "Arrangement.SpaceAround", style = typography.caption, modifier = Modifier.padding(8.dp) ) - // Column with Arrangement.SpaceAround Column( verticalArrangement = Arrangement.SpaceAround, modifier = columnModifier @@ -202,13 +174,10 @@ fun TypeOfColumns() { ) { MultipleTexts() } - - Text( text = "Arrangement.SpaceEvenly", style = typography.caption, modifier = Modifier.padding(8.dp) ) - // Column with Arrangement.SpaceEvenly Column( verticalArrangement = Arrangement.SpaceEvenly, modifier = columnModifier @@ -216,13 +185,10 @@ fun TypeOfColumns() { ) { MultipleTexts() } - - Text( text = "Arrangement.SpaceBetween", style = typography.caption, modifier = Modifier.padding(8.dp) ) - // Column with Arrangement.SpaceBetween Column( verticalArrangement = Arrangement.SpaceBetween, modifier = columnModifier @@ -232,10 +198,6 @@ fun TypeOfColumns() { } } - -/** - * Composable function demonstrating usage of Box layout with different alignments. - */ @Composable fun TypeOfBoxs() { Text(text = "Box", style = typography.h6, modifier = Modifier.padding(8.dp)) @@ -244,18 +206,14 @@ fun TypeOfBoxs() { .background(MaterialTheme.colorScheme.surfaceVariant) .fillMaxWidth() .height(250.dp) - Text( text = "Children with no align", style = typography.caption, modifier = Modifier.padding(8.dp) ) - - // Box with children having no alignment specified Box( modifier = boxModifier .testTag(TestTags.HOME_LAYOUTS_BOX_NO_ALIGN) ) { - // Nested Material3Card elements inside the Box Material3Card( backgroundColor = green700, elevation = 4.dp, @@ -272,13 +230,10 @@ fun TypeOfBoxs() { modifier = Modifier.size(100.dp) ) {} } - - Text( text = "Children with Topstart, center & bottomEnd align", style = typography.caption, modifier = Modifier.padding(8.dp) ) - // Box with children aligned to TopStart, Center, and BottomEnd respectively Box( modifier = boxModifier @@ -302,15 +257,10 @@ fun TypeOfBoxs() { } } - -/** - * Composable function demonstrating usage of ConstraintLayout. - */ @Composable fun ConstraintLayouts() { Text(text = "ConstraintLayouts", style = typography.h6, modifier = Modifier.padding(8.dp)) - // ConstraintLayout with multiple elements constrained to each other ConstraintLayout( modifier = Modifier .background(MaterialTheme.colorScheme.surfaceVariant) @@ -318,10 +268,9 @@ fun ConstraintLayouts() { .height(150.dp) .testTag(TestTags.HOME_LAYOUTS_CONSTRAINT_LAYOUT) ) { - // References for ConstraintLayout elements + //refs creations val (mainButton, mainText, seconderyText, outlineButton) = createRefs() - // Main button constrained to parent top Button( onClick = { }, modifier = Modifier.constrainAs(mainButton) { @@ -331,19 +280,15 @@ fun ConstraintLayouts() { Text("Main button") } - // Main text constrained below main button and to the start of main button Text("Main Text", Modifier.constrainAs(mainText) { top.linkTo(parent.top, margin = 16.dp) absoluteLeft.linkTo(mainButton.end, margin = 16.dp) }) - - // Secondary text constrained below main text and to the start of main button Text("Secondary Text", Modifier.constrainAs(seconderyText) { top.linkTo(mainText.bottom, margin = 16.dp) absoluteLeft.linkTo(mainButton.end, margin = 16.dp) }) - // Outline button constrained below secondary text and to the start of secondary text OutlinedButton( onClick = { /* Do something */ }, modifier = Modifier.constrainAs(outlineButton) { @@ -356,21 +301,14 @@ fun ConstraintLayouts() { } } - -/** - * Composable function used for showing sample data. - */ @Composable fun MultipleTexts() { Text(text = "First", modifier = Modifier.padding(8.dp)) Text(text = "Second", modifier = Modifier.padding(8.dp)) Text(text = "Third", modifier = Modifier.padding(8.dp)) -} +} -/** - * Preview function for the Layouts content. - */ @Preview @Composable fun PreviewLayouts() { diff --git a/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/Loaders.kt b/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/Loaders.kt index db5abc93..0ed79b2d 100644 --- a/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/Loaders.kt +++ b/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/Loaders.kt @@ -13,29 +13,23 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import com.guru.composecookbook.theme.typography - -/** - * Composable function demonstrating various types of progress indicators. - */ @Composable fun Loaders() { Text(text = "Progress bars", style = typography.h6, modifier = Modifier.padding(8.dp)) - // Row displaying LinearProgressIndicator and two CircularProgressIndicators Row(modifier = Modifier.padding(8.dp)) { LinearProgressIndicator() CircularProgressIndicator() CircularProgressIndicator(strokeWidth = 8.dp) } - // Column displaying LinearProgressIndicator and text with loading message Column( modifier = Modifier .fillMaxWidth() .padding(16.dp), horizontalAlignment = Alignment.CenterHorizontally ) { - LinearProgressIndicator() // Default LinearProgressIndicator + LinearProgressIndicator() Text(text = "Loading with text...", modifier = Modifier.padding(8.dp)) } diff --git a/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/Snackbars.kt b/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/Snackbars.kt index bba46bd7..eea418c0 100644 --- a/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/Snackbars.kt +++ b/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/Snackbars.kt @@ -11,19 +11,12 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.guru.composecookbook.theme.typography -/** - * Composable function demonstrating usage of Snackbar in Jetpack Compose. - */ @Composable fun SnackBars() { Text(text = "Snackbars", style = typography.h6, modifier = Modifier.padding(8.dp)) - - // Basic Snackbar without an action Snackbar(modifier = Modifier.padding(4.dp)) { Text(text = "This is a basic snackbar") } - - // Snackbar with an action item Snackbar( modifier = Modifier.padding(4.dp), action = { @@ -34,8 +27,6 @@ fun SnackBars() { ) { Text(text = "This is a basic Snackbar with action item") } - - // Snackbar with action item placed below text Snackbar( modifier = Modifier.padding(4.dp), actionOnNewLine = true, @@ -49,10 +40,6 @@ fun SnackBars() { } } - -/** - * Preview function for the SnackBars content. - */ @Preview @Composable fun ShowSnackbars() { diff --git a/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/SwipeButton.kt b/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/SwipeButton.kt index 53b8f154..977a195b 100644 --- a/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/SwipeButton.kt +++ b/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/SwipeButton.kt @@ -33,25 +33,6 @@ import androidx.compose.ui.unit.dp import com.guru.composecookbook.login.HorizontalDottedProgressBar import kotlin.math.roundToInt - -/** - * A customizable swipe button that supports dragging and swiping gestures. - * - * @param onSwiped Callback invoked when the button is fully swiped. - * @param modifier The modifier to be applied to the button. - * @param swipeButtonState The current state of the swipe button. - * @param enabled Whether the button is enabled for user interaction. - * @param interactionSource The [MutableInteractionSource] that collects interaction events. - * @param elevation The elevation of the button. - * @param shape The shape of the button. - * @param border The border stroke of the button. - * @param colors The colors used for the button's background and content. - * @param contentPadding The padding around the button's content. - * @param icon The icon to display on the button. - * @param rotateIcon Whether to rotate the icon based on drag position. - * @param iconPadding The padding around the icon. - * @param content The content of the button composed with [RowScope]. - */ @OptIn(ExperimentalAnimationApi::class, ExperimentalMaterialApi::class) @Composable @@ -92,11 +73,8 @@ fun SwipeButton( // Content val maxWidth = this.constraints.maxWidth.toFloat() - // Display different components based on the button state when { collapsed -> { - - // Animated IconButton when collapsed val animatedProgress = remember { Animatable(initialValue = 0f) } LaunchedEffect(Unit) { animatedProgress.animateTo( @@ -124,11 +102,9 @@ fun SwipeButton( } } swiped -> { - // Display horizontal progress bar when fully swiped HorizontalDottedProgressBar() } else -> { - // Default state with draggable IconButton dragOffset.value = 0f // when button goes to inital state CompositionLocalProvider() { ProvideTextStyle( @@ -146,8 +122,7 @@ fun SwipeButton( } } } - - // IconButton that supports dragging for swiping action + // Swipe Component AnimatedVisibility(visible = !swiped) { IconButton(onClick = { }, enabled = enabled, modifier = Modifier .padding(iconPadding) @@ -187,23 +162,6 @@ fun SwipeButton( } } - -/** - * Represents the state of the SwipeButton. - */ enum class SwipeButtonState { - /** - * Initial state of the SwipeButton. - */ - INITIAL, - - /** - * Swipe action completed state. - */ - SWIPED, - - /** - * Collapsed state of the SwipeButton. - */ - COLLAPSED + INITIAL, SWIPED, COLLAPSED } \ No newline at end of file diff --git a/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/TextInputs.kt b/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/TextInputs.kt index 7a04b384..432fa4fe 100644 --- a/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/TextInputs.kt +++ b/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/TextInputs.kt @@ -24,17 +24,10 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.guru.composecookbook.theme.typography -/** - * A collection of text input fields including TextField and OutlinedTextField examples. - * - * @see TextField - * @see OutlinedTextField - */ @Composable fun TextInputs() { Text(text = "Text Inputs", style = typography.h6, modifier = Modifier.padding(8.dp)) - // Mutable state for text input var text by remember { mutableStateOf(TextFieldValue("")) } // TODO Explore CoreTextField @@ -44,9 +37,6 @@ fun TextInputs() { // modifier = Modifier.padding(8.dp).size(0.dp), // cursorColor = Color.Magenta // ) - - - // Basic TextField example TextField( value = text, onValueChange = { newValue -> text = newValue }, @@ -57,7 +47,6 @@ fun TextInputs() { placeholder = { Text("placeholder") }, ) - // OutlinedTextField example with password input OutlinedTextField( value = text, modifier = Modifier @@ -72,7 +61,6 @@ fun TextInputs() { keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password) ) - // OutlinedTextField example with leading icon OutlinedTextField( value = text, leadingIcon = { Icon(imageVector = Icons.Default.Email, contentDescription = null) }, @@ -86,8 +74,6 @@ fun TextInputs() { text = it } ) - - // OutlinedTextField example with leading and trailing icons OutlinedTextField( value = text, leadingIcon = { Icon(imageVector = Icons.Default.Email, contentDescription = null) }, @@ -103,10 +89,7 @@ fun TextInputs() { } ) - // Mutable state for number input var numberText by remember { mutableStateOf(TextFieldValue("")) } - - // OutlinedTextField example for numeric input (phone number) OutlinedTextField(value = numberText, modifier = Modifier .padding(8.dp) @@ -120,10 +103,6 @@ fun TextInputs() { ) } - -/** - * Preview function for the TextInputs content. - */ @InternalTextApi @Preview @Composable diff --git a/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/Texts.kt b/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/Texts.kt index 2357662e..3678feaf 100644 --- a/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/Texts.kt +++ b/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/Texts.kt @@ -15,12 +15,6 @@ import androidx.compose.ui.unit.dp import com.guru.composecookbook.theme.typography import com.guru.composecookbook.ui.utils.SubtitleText -/** - * Demonstrates various configurations and styles of Text composable in Jetpack Compose. - * - * @see Text - * @see SubtitleText - */ @Composable fun TextDemo() { Text(text = "Text Views", style = typography.h5, modifier = Modifier.padding(8.dp)) @@ -106,10 +100,6 @@ fun TextDemo() { } - -/** - * Preview function for the TextDemo content. - */ @Preview @Composable fun PreviewTextDemo() { diff --git a/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/Toggles.kt b/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/Toggles.kt index 00d8176c..2848e178 100644 --- a/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/Toggles.kt +++ b/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/Toggles.kt @@ -22,31 +22,21 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import com.guru.composecookbook.theme.typography -/** - * Composable function `Toggles` demonstrates various UI elements such as Checkbox, Switch, RadioButtons, and Sliders. - */ @Composable fun Toggles() { - - // Display header text with custom style and padding Text( text = "Toggles, Switch, Sliders", style = typography.h6, modifier = Modifier.padding(8.dp) ) - // Checkbox with mutable state var checked by remember { mutableStateOf(true) } var switched by remember { mutableStateOf(true) } Row { - - // Checkbox with mutable state Checkbox( checked = checked, modifier = Modifier.padding(8.dp), onCheckedChange = { checked = !checked }) - - // Switch with mutable state and custom color for checked state Switch( checked = switched, colors = SwitchDefaults.colors(checkedThumbColor = MaterialTheme.colorScheme.primary), @@ -55,7 +45,6 @@ fun Toggles() { ) } - // RadioButtons example with selectable options var selected by remember { mutableStateOf("Kotlin") } Row { RadioButton(selected = selected == "Kotlin", onClick = { selected = "Kotlin" }) @@ -84,10 +73,8 @@ fun Toggles() { } - // Sliders examples with different configurations var sliderState by remember { mutableStateOf(0f) } - // Basic Slider with continuous range from 0 to 1 Slider(value = sliderState, modifier = Modifier .fillMaxWidth() .padding(8.dp), @@ -97,8 +84,6 @@ fun Toggles() { ) var sliderState2 by remember { mutableStateOf(20f) } - - // Slider with defined value range (0 to 100) and 5 discrete steps Slider(value = sliderState2, modifier = Modifier .fillMaxWidth() .padding(8.dp), diff --git a/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/UICards.kt b/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/UICards.kt index 52d59262..61f8233a 100644 --- a/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/UICards.kt +++ b/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/UICards.kt @@ -25,10 +25,6 @@ import com.guru.composecookbook.data.R import com.guru.composecookbook.theme.components.Material3Card import com.guru.composecookbook.theme.typography -/** - * Composable function `UICards` demonstrates the usage of UI Cards, Boxes, and ListItems with Jetpack Compose. - * Utilizes experimental Material3 components. - */ @OptIn(ExperimentalMaterialApi::class) @Composable fun UICards() { @@ -38,10 +34,8 @@ fun UICards() { modifier = Modifier.padding(8.dp) ) - // Accessing demo item data from DemoDataProvider val item = remember { DemoDataProvider.item } - // Section demonstrating Material3Card as a container Text( text = "Inbuilt box as container for any Clipping/Alignment controls", style = typography.subtitle1, @@ -69,7 +63,6 @@ fun UICards() { } Divider() - // Section demonstrating an Inbuilt Card Text(text = "Inbuilt Card", style = typography.subtitle1, modifier = Modifier.padding(8.dp)) Material3Card( modifier = Modifier diff --git a/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/WidgetScreen.kt b/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/WidgetScreen.kt index 8b20c2f1..3f33ebbb 100644 --- a/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/WidgetScreen.kt +++ b/app/src/main/java/com/guru/composecookbook/ui/learnwidgets/WidgetScreen.kt @@ -13,14 +13,9 @@ import androidx.compose.ui.platform.testTag import androidx.compose.ui.tooling.preview.Preview import com.guru.composecookbook.ui.utils.TestTags -/** - * Composable function `WidgetScreen` displays a screen scaffolded with a top app bar and a scrollable list of material widgets. - * Uses ExperimentalMaterial3Api for experimental Material3 components. - */ @OptIn(ExperimentalMaterial3Api::class) @Composable fun WidgetScreen() { - // Scaffold with a top app bar and content Scaffold( modifier = Modifier.testTag(TestTags.WIDGET_SCREEN_ROOT), topBar = { @@ -36,16 +31,10 @@ fun WidgetScreen() { ) } - -/** - * Composable function `WidgetScreenContent` displays a lazy column containing various material widgets. - * @param modifier Modifier for layout customization. - */ @Composable fun WidgetScreenContent( modifier: Modifier = Modifier, ) { - // LazyColumn for displaying a scrollable list of widgets LazyColumn( state = rememberLazyListState(), modifier = modifier, @@ -63,9 +52,6 @@ fun WidgetScreenContent( } -/** - * Preview function for the WidgetScreen content. - */ @Preview @Composable fun PreviewScreen() { diff --git a/app/src/main/java/com/guru/composecookbook/ui/templates/TemplateScreen.kt b/app/src/main/java/com/guru/composecookbook/ui/templates/TemplateScreen.kt index bab9a9ab..26f47711 100644 --- a/app/src/main/java/com/guru/composecookbook/ui/templates/TemplateScreen.kt +++ b/app/src/main/java/com/guru/composecookbook/ui/templates/TemplateScreen.kt @@ -14,12 +14,6 @@ import androidx.compose.ui.platform.testTag import androidx.compose.ui.unit.dp import com.guru.composecookbook.ui.utils.TestTags -/** - * A Composable function that displays a screen with a list of templates in a LazyColumn. - * Each item in the list is a button that, when clicked, starts the corresponding template activity. - * - * @param darkTheme A Boolean indicating whether the dark theme is enabled. - */ @OptIn(ExperimentalFoundationApi::class) @Composable fun TemplateScreen(darkTheme: Boolean) { @@ -47,9 +41,6 @@ fun TemplateScreen(darkTheme: Boolean) { } -/** - * A list of template names to be displayed in the TemplateScreen. - */ val templates = listOf( "Login", "Profiles", diff --git a/app/src/main/java/com/guru/composecookbook/ui/templates/TemplatesActivity.kt b/app/src/main/java/com/guru/composecookbook/ui/templates/TemplatesActivity.kt index 48b33cf2..d5f80ccb 100644 --- a/app/src/main/java/com/guru/composecookbook/ui/templates/TemplatesActivity.kt +++ b/app/src/main/java/com/guru/composecookbook/ui/templates/TemplatesActivity.kt @@ -26,21 +26,12 @@ import com.guru.composecookbook.ui.home.clock.ClockDemo import com.guru.composecookbook.ui.home.timer.TimerDemo import com.guru.pinlock.PinLockView -/** - * Activity responsible for displaying different templates based on the provided template type and dark theme setting. - * - * @property templateType The type of template to display, defaults to "Profiles" if not provided. - * @property darkTheme Boolean indicating whether to use dark theme for the templates. - */ @OptIn(ExperimentalFoundationApi::class) class TemplatesActivity : ComponentActivity() { private val templateType: String by lazy { intent.getStringExtra(TYPE) ?: "Profiles" } private val darkTheme: Boolean by lazy { intent.getBooleanExtra(DARK_THEME, true) } - /** - * Creates the activity UI and sets up the necessary configurations and theme. - */ @OptIn(ExperimentalMaterial3Api::class, ExperimentalAnimationApi::class, ExperimentalMaterialApi::class) @@ -61,14 +52,6 @@ class TemplatesActivity : ComponentActivity() { private const val TYPE = "type" private const val DARK_THEME = "darkTheme" - /** - * Creates an intent to launch TemplatesActivity with the specified parameters. - * - * @param context The context from which the activity is launched. - * @param templateType The type of template to display. - * @param isDarkTheme Boolean indicating whether to use dark theme. - * @return Intent to launch TemplatesActivity. - */ fun newIntent(context: Context, templateType: String, isDarkTheme: Boolean) = Intent(context, TemplatesActivity::class.java).apply { putExtra(TYPE, templateType) @@ -77,12 +60,6 @@ class TemplatesActivity : ComponentActivity() { } } - -/** - * Composable function that displays a specific template based on the provided template type. - * - * @param templateType The type of template to display. - */ @OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class, ExperimentalAnimationApi::class, @@ -103,13 +80,6 @@ fun TemplateApp(templateType: String) { } } - -/** - * Creates and returns a BiometricPrompt instance for biometric authentication. - * - * @param activity The FragmentActivity context to create BiometricPrompt. - * @return BiometricPrompt instance. - */ private fun createBiometricPrompt(activity: FragmentActivity): BiometricPrompt { val executor = ContextCompat.getMainExecutor(activity) diff --git a/app/src/main/java/com/guru/composecookbook/ui/utils/CommomComponents.kt b/app/src/main/java/com/guru/composecookbook/ui/utils/CommomComponents.kt index ee46cc5e..3ff5946e 100644 --- a/app/src/main/java/com/guru/composecookbook/ui/utils/CommomComponents.kt +++ b/app/src/main/java/com/guru/composecookbook/ui/utils/CommomComponents.kt @@ -20,13 +20,7 @@ import com.guru.composecookbook.theme.typography import com.guru.fontawesomecomposelib.FaIcon import com.guru.fontawesomecomposelib.FaIcons -/** - * A Composable function that displays a heading section with a title, subtitle, and a divider. - * - * @param modifier Modifier to apply to the Column layout. - * @param title The title text to display. - * @param subtitle The subtitle text to display. - */ + @Composable fun HeadingSection(modifier: Modifier = Modifier, title: String = "", subtitle: String = "") { Column( @@ -44,13 +38,6 @@ fun HeadingSection(modifier: Modifier = Modifier, title: String = "", subtitle: } } - -/** - * A Composable function that displays a title text with a specific style. - * - * @param modifier Modifier to apply to the Text component. - * @param title The title text to display. - */ @Composable fun TitleText(modifier: Modifier = Modifier, title: String) { androidx.compose.material3.Text( @@ -60,28 +47,11 @@ fun TitleText(modifier: Modifier = Modifier, title: String) { ) } - -/** - * A Composable function that displays a subtitle text with a specific style. - * - * @param subtitle The subtitle text to display. - * @param modifier Modifier to apply to the Text component. - */ @Composable fun SubtitleText(subtitle: String, modifier: Modifier = Modifier) { androidx.compose.material3.Text(text = subtitle, style = typography.subtitle2, modifier = modifier.padding(8.dp)) } - -/** - * A Composable function that displays a rotating icon. - * - * @param state A Boolean to control the rotation state of the icon. - * @param asset The ImageVector asset to use as the icon. - * @param angle The angle in degrees to rotate the icon. - * @param duration The duration of the rotation animation in milliseconds. - * @param modifier Modifier to apply to the icon. - */ @Composable fun RotateIcon( state: Boolean, @@ -107,10 +77,6 @@ fun RotateIcon( ) } - -/** - * A Composable function to preview the HeadingSection Composable. - */ @Preview @Composable fun PreviewHeading() {