Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added scaffold paddingValues to Dialog items #160

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions app/src/main/java/com/guru/composecookbook/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@ import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.animation.Crossfade
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.BottomNavigation
import androidx.compose.material.BottomNavigationItem
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material.ModalBottomSheetLayout
Expand All @@ -29,7 +25,6 @@ import androidx.compose.material3.NavigationRail
import androidx.compose.material3.NavigationRailItem
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.contentColorFor
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -69,9 +64,6 @@ import com.guru.fontawesomecomposelib.FaIcon
import kotlinx.coroutines.launch

class MainActivity : ComponentActivity() {
@OptIn(ExperimentalAnimationApi::class,
ExperimentalFoundationApi::class,
ExperimentalMaterialApi::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
//for adView demo
Expand Down Expand Up @@ -108,9 +100,8 @@ fun BaseView(
}
}

@OptIn(ExperimentalAnimationApi::class,
ExperimentalFoundationApi::class,
ExperimentalMaterialApi::class)
@OptIn(
ExperimentalMaterialApi::class)
@Composable
fun HomeScreenContent(
homeScreen: BottomNavType,
Expand All @@ -134,9 +125,7 @@ fun HomeScreenContent(
}
}

@OptIn(ExperimentalAnimationApi::class,
ExperimentalFoundationApi::class,
ExperimentalMaterialApi::class)
@OptIn(ExperimentalMaterialApi::class)
@Composable
fun MainAppContent(appThemeState: MutableState<AppThemeState>) {
//Default home screen state is always HOME
Expand Down Expand Up @@ -445,9 +434,6 @@ private fun NavigationRailContent(
}
}

@OptIn(ExperimentalAnimationApi::class,
ExperimentalFoundationApi::class,
ExperimentalMaterialApi::class)
@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,16 @@ fun DialogScreen(onBack: () -> Unit) {

)
},
content = {
DialogsOptionList()
content = {paddingValues->
DialogsOptionList(
paddingValues = paddingValues
)
}
)
}

@Composable
fun DialogsOptionList() {
fun DialogsOptionList(paddingValues: PaddingValues) {
//Here we are using power of making simple data classes act as stateful when using `by state`
var dialogState by remember { mutableStateOf(DialogState(false, DialogType.SIMPLE)) }

Expand All @@ -98,7 +100,7 @@ fun DialogsOptionList() {
Column(
modifier = Modifier
.verticalScroll(rememberScrollState())
.padding(16.dp)
.padding(paddingValues)
) {
Button(
onClick = { dialogState = dialogState.copy(showDialog = true) },
Expand Down Expand Up @@ -348,8 +350,10 @@ fun ShowDialog(type: DialogType, onDismiss: () -> Unit) {

@Preview(showBackground = true)
@Composable
fun DefaultPreview3() {
fun DefaultPreview3(
paddingValues:PaddingValues = PaddingValues()
) {
ComposeCookBookTheme {
DialogsOptionList()
DialogsOptionList(paddingValues)
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
package com.guru.composecookbook.twitter.components.icons

import androidx.compose.animation.animateColor
import androidx.compose.animation.core.animateDp
import androidx.compose.animation.core.keyframes
import androidx.compose.animation.core.tween
import androidx.compose.animation.core.updateTransition
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.*
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Favorite
import androidx.compose.material.icons.filled.FavoriteBorder
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.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.res.painterResource
Expand Down