Skip to content

Commit 617ca80

Browse files
committed
added material3 to cryptoapp demo
1 parent 7067e9a commit 617ca80

File tree

10 files changed

+32
-24
lines changed

10 files changed

+32
-24
lines changed

demos/cryptoapp/app/src/main/java/com/guru/composecookbook/cryptoapp/ui/composewear/AndroidWearActivity.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import com.guru.composecookbook.cryptoapp.ui.home.CryptoHomeViewModelFactory
3838
import com.guru.composecookbook.cryptoapp.ui.internal.extensions.roundToThreeDecimals
3939
import com.guru.composecookbook.cryptoapp.ui.internal.extensions.roundToTwoDecimals
4040
import com.guru.composecookbook.data.DemoDataProvider
41+
import com.guru.composecookbook.theme.ComposeCookBookMaterial3Theme
4142
import com.guru.composecookbook.theme.ComposeCookBookTheme
4243
import com.guru.composecookbook.theme.gradientGreenColors
4344
import com.guru.composecookbook.theme.gradientRedColors
@@ -50,7 +51,7 @@ class AndroidWearActivity : ComponentActivity() {
5051
override fun onCreate(savedInstanceState: Bundle?) {
5152
super.onCreate(savedInstanceState)
5253
setContent {
53-
ComposeCookBookTheme(true) {
54+
ComposeCookBookMaterial3Theme(true) {
5455
WearStockApp()
5556
}
5657

demos/cryptoapp/app/src/main/java/com/guru/composecookbook/cryptoapp/ui/detail/CryptoDetailActivity.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import androidx.compose.runtime.Composable
1010
import androidx.compose.ui.tooling.preview.Preview
1111
import com.guru.composecookbook.cryptoapp.data.db.models.Crypto
1212
import com.guru.composecookbook.cryptoapp.ui.detail.components.CryptoDetailScreen
13+
import com.guru.composecookbook.theme.ComposeCookBookMaterial3Theme
1314
import com.guru.composecookbook.theme.ComposeCookBookTheme
1415

1516
class CryptoDetailActivity : ComponentActivity() {
@@ -22,7 +23,7 @@ class CryptoDetailActivity : ComponentActivity() {
2223
super.onCreate(savedInstanceState)
2324
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
2425
setContent {
25-
ComposeCookBookTheme {
26+
ComposeCookBookMaterial3Theme {
2627
CryptoDetailScreen(crypto) {
2728
onBackPressed()
2829
}

demos/cryptoapp/app/src/main/java/com/guru/composecookbook/cryptoapp/ui/detail/components/CryptoDetailScreen.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import androidx.compose.foundation.lazy.LazyRow
88
import androidx.compose.foundation.lazy.items
99
import androidx.compose.foundation.shape.CircleShape
1010
import androidx.compose.foundation.shape.RoundedCornerShape
11-
import androidx.compose.material.*
11+
import androidx.compose.material.BottomAppBar
12+
import androidx.compose.material.Card
13+
import androidx.compose.material3.*
1214
import androidx.compose.material.icons.Icons
1315
import androidx.compose.material.icons.filled.Add
1416
import androidx.compose.material.icons.filled.ArrowBack
@@ -36,13 +38,13 @@ import com.guru.composecookbook.theme.*
3638
import com.guru.composecookbook.theme.modifiers.horizontalGradientBackground
3739

3840

41+
@OptIn(ExperimentalMaterial3Api::class)
3942
@Composable
4043
fun CryptoDetailScreen(crypto: Crypto, onBack: () -> Unit) {
4144
val surfaceGradient = Colors.cryptoSurfaceGradient(isSystemInDarkTheme())
4245
Scaffold(
4346
bottomBar = { CryptoBottomBar(onBack) },
4447
floatingActionButton = { CryptoFloatingActionButton() },
45-
isFloatingActionButtonDocked = true,
4648
floatingActionButtonPosition = FabPosition.Center
4749
) {
4850
Box(modifier = Modifier.horizontalGradientBackground(surfaceGradient)) {
@@ -153,7 +155,7 @@ fun CryptoFloatingActionButton() {
153155
icon = { Icon(imageVector = Icons.Default.Add, contentDescription = "") },
154156
text = { Text(text = "Trade") },
155157
onClick = { pressed = !pressed },
156-
backgroundColor = MaterialTheme.colors.primary,
158+
containerColor = MaterialTheme.colorScheme.primary,
157159
modifier = Modifier.width(animateDpAsState(if (pressed) 200.dp else 120.dp).value)
158160
)
159161
}

demos/cryptoapp/app/src/main/java/com/guru/composecookbook/cryptoapp/ui/home/CryptoHomeActivity.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import androidx.lifecycle.viewmodel.compose.viewModel
1313
import com.guru.composecookbook.cryptoapp.data.db.models.Crypto
1414
import com.guru.composecookbook.cryptoapp.ui.detail.CryptoDetailActivity
1515
import com.guru.composecookbook.cryptoapp.ui.home.components.CryptoHomeScreen
16+
import com.guru.composecookbook.theme.ComposeCookBookMaterial3Theme
1617
import com.guru.composecookbook.theme.ComposeCookBookTheme
1718
import kotlinx.coroutines.ExperimentalCoroutinesApi
1819

@@ -28,7 +29,7 @@ class CryptoHomeActivity : ComponentActivity() {
2829
super.onCreate(savedInstanceState)
2930
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
3031
setContent {
31-
ComposeCookBookTheme {
32+
ComposeCookBookMaterial3Theme {
3233
val viewModel: CryptoHomeViewModel = viewModel(
3334
factory = CryptoHomeViewModelFactory(LocalContext.current)
3435
)

demos/cryptoapp/app/src/main/java/com/guru/composecookbook/cryptoapp/ui/home/components/CryptoHomeScreen.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import androidx.compose.foundation.isSystemInDarkTheme
1010
import androidx.compose.foundation.layout.*
1111
import androidx.compose.foundation.lazy.*
1212
import androidx.compose.foundation.shape.RoundedCornerShape
13-
import androidx.compose.material.*
13+
import androidx.compose.material3.*
1414
import androidx.compose.material.icons.Icons
1515
import androidx.compose.material.icons.filled.Favorite
1616
import androidx.compose.runtime.*
@@ -45,7 +45,7 @@ import com.guru.composecookbook.theme.typography
4545
import kotlinx.coroutines.ExperimentalCoroutinesApi
4646

4747

48-
@OptIn(ExperimentalCoroutinesApi::class)
48+
@OptIn(ExperimentalCoroutinesApi::class, androidx.compose.material3.ExperimentalMaterial3Api::class)
4949
@Composable
5050
fun CryptoHomeScreen(onCryptoHomeInteractionEvents: (CryptoHomeInteractionEvents) -> Unit = {}) {
5151
val viewModel: CryptoHomeViewModel =
@@ -87,7 +87,7 @@ fun CryptoFABButton(count: Int, showFavState: () -> Unit) {
8787
ExtendedFloatingActionButton(
8888
text = { Text(text = "$count coins", modifier = animateRotationModifier) },
8989
onClick = { showFavState.invoke() },
90-
backgroundColor = blue,
90+
containerColor = blue,
9191
icon = {
9292
Icon(
9393
imageVector = Icons.Filled.Favorite,
@@ -149,7 +149,7 @@ fun FavoriteItem(crypto: Crypto, openCryptoDetail: () -> Unit) {
149149
modifier = Modifier
150150
.padding(horizontal = 8.dp)
151151
.height(32.dp),
152-
color = MaterialTheme.colors.onSurface,
152+
color = MaterialTheme.colorScheme.onSurface,
153153
textAlign = TextAlign.Center
154154
)
155155
}

demos/cryptoapp/app/src/main/java/com/guru/composecookbook/cryptoapp/ui/home/components/CryptoListItem.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import androidx.compose.foundation.clickable
55
import androidx.compose.foundation.layout.*
66
import androidx.compose.material.Icon
77
import androidx.compose.material.IconToggleButton
8-
import androidx.compose.material.MaterialTheme
9-
import androidx.compose.material.Text
8+
import androidx.compose.material3.*
109
import androidx.compose.material.icons.Icons
1110
import androidx.compose.material.icons.filled.Favorite
1211
import androidx.compose.material.icons.filled.FavoriteBorder
@@ -106,7 +105,7 @@ fun CryptoListItem(
106105
Icon(
107106
imageVector = if (isFav) Icons.Default.Favorite else Icons.Default.FavoriteBorder,
108107
contentDescription = null,
109-
tint = if (isFav) Color.Red else MaterialTheme.colors.onSurface
108+
tint = if (isFav) Color.Red else MaterialTheme.colorScheme.onSurface
110109
)
111110
}
112111
}

demos/cryptoapp/app/src/main/java/com/guru/composecookbook/cryptoapp/ui/home/components/MyWalletCard.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import androidx.compose.foundation.layout.height
99
import androidx.compose.foundation.layout.padding
1010
import androidx.compose.foundation.layout.size
1111
import androidx.compose.foundation.shape.RoundedCornerShape
12-
import androidx.compose.material.*
12+
import androidx.compose.material3.*
1313
import androidx.compose.material.icons.Icons
1414
import androidx.compose.material.icons.filled.QrCodeScanner
1515
import androidx.compose.material.icons.filled.Send
@@ -118,11 +118,11 @@ fun MyWalletCard() {
118118
Icon(
119119
imageVector = Icons.Default.QrCodeScanner,
120120
contentDescription = null,
121-
tint = MaterialTheme.colors.onSurface
121+
tint = MaterialTheme.colorScheme.onSurface
122122
)
123123
},
124124
text = { Text(text = "Receive") },
125-
backgroundColor = Color.Transparent,
125+
containerColor = Color.Transparent,
126126
elevation = FloatingActionButtonDefaults.elevation()
127127
)
128128
ExtendedFloatingActionButton(
@@ -137,7 +137,7 @@ fun MyWalletCard() {
137137
},
138138
icon = { Icon(imageVector = Icons.Default.Send, contentDescription = null) },
139139
text = { Text(text = "Send") },
140-
backgroundColor = Color.Transparent,
140+
containerColor = Color.Transparent,
141141
elevation = FloatingActionButtonDefaults.elevation()
142142
)
143143
Image(

demos/twitter/src/main/java/com/guru/composecookbook/twitter/TwitterActivity.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import androidx.compose.runtime.remember
1111
import androidx.compose.ui.tooling.preview.Preview
1212
import androidx.core.content.ContextCompat
1313
import com.guru.composecookbook.data.DemoDataProvider
14+
import com.guru.composecookbook.theme.ComposeCookBookMaterial3Theme
1415
import com.guru.composecookbook.theme.ComposeCookBookTheme
1516
import com.guru.composecookbook.twitter.components.TwitterHome
1617

@@ -19,7 +20,7 @@ class TwitterActivity : ComponentActivity() {
1920
super.onCreate(savedInstanceState)
2021
window.statusBarColor = ContextCompat.getColor(this, android.R.color.transparent)
2122
setContent {
22-
ComposeCookBookTheme {
23+
ComposeCookBookMaterial3Theme {
2324
val tweets = remember { DemoDataProvider.tweetList }
2425
TwitterHome(
2526
tweets = tweets,
@@ -42,7 +43,7 @@ class TwitterActivity : ComponentActivity() {
4243
@Preview(showBackground = true)
4344
@Composable
4445
fun DefaultPreview4() {
45-
ComposeCookBookTheme {
46+
ComposeCookBookMaterial3Theme {
4647
TwitterHome(
4748
tweets = DemoDataProvider.tweetList,
4849
onMessagesClick = { /*TODO*/ },

demos/twitter/src/main/java/com/guru/composecookbook/twitter/components/TwitterHome.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import androidx.compose.foundation.layout.fillMaxWidth
44
import androidx.compose.foundation.layout.padding
55
import androidx.compose.foundation.lazy.LazyColumn
66
import androidx.compose.foundation.lazy.items
7-
import androidx.compose.material.*
7+
import androidx.compose.material.TopAppBar
8+
import androidx.compose.material3.*
89
import androidx.compose.material.icons.Icons
910
import androidx.compose.material.icons.filled.StarBorder
1011
import androidx.compose.runtime.Composable
@@ -20,6 +21,7 @@ import com.guru.composecookbook.twitter.components.profiles.ProfilePicture
2021
import com.guru.composecookbook.twitter.components.profiles.ProfilePictureSizes
2122
import com.guru.composecookbook.twitter.components.tweets.TweetItem
2223

24+
@OptIn(ExperimentalMaterial3Api::class)
2325
@Composable
2426
fun TwitterHome(
2527
tweets: List<Tweet>,
@@ -42,8 +44,8 @@ fun TwitterHome(
4244
modifier = Modifier.fillMaxWidth()
4345
)
4446
},
45-
backgroundColor = MaterialTheme.colors.surface,
46-
contentColor = MaterialTheme.colors.onSurface,
47+
backgroundColor = MaterialTheme.colorScheme.surface,
48+
contentColor = MaterialTheme.colorScheme.onSurface,
4749
elevation = 8.dp,
4850
navigationIcon = {
4951
ProfilePicture(
@@ -71,7 +73,7 @@ fun TwitterHome(
7173
)
7274
},
7375
onClick = onNewTweetClicked,
74-
backgroundColor = twitterColor
76+
containerColor = twitterColor
7577
)
7678
},
7779
content = {

demos/twitter/src/main/java/com/guru/composecookbook/twitter/components/tweets/TweetItem.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package com.guru.composecookbook.twitter.components.tweets
22

33
import androidx.compose.foundation.layout.*
4-
import androidx.compose.material.*
4+
import androidx.compose.material.Divider
5+
import androidx.compose.material3.*
56
import androidx.compose.runtime.Composable
67
import androidx.compose.ui.Modifier
78
import androidx.compose.ui.tooling.preview.Preview

0 commit comments

Comments
 (0)