Skip to content

Commit

Permalink
Convert adaptive to m3
Browse files Browse the repository at this point in the history
  • Loading branch information
bentrengrove committed Dec 11, 2024
1 parent a03d4df commit a327d83
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Card
import androidx.compose.material.Text
import androidx.compose.material3.Card
import androidx.compose.material3.Text
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
Expand All @@ -32,13 +32,14 @@ import com.google.accompanist.adaptive.TwoPane
import com.google.accompanist.adaptive.TwoPaneStrategy
import com.google.accompanist.adaptive.VerticalTwoPaneStrategy
import com.google.accompanist.adaptive.calculateDisplayFeatures
import com.google.accompanist.sample.AccompanistM3SampleTheme
import com.google.accompanist.sample.AccompanistSampleTheme

class BasicTwoPaneSample : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
AccompanistSampleTheme {
AccompanistM3SampleTheme {
val displayFeatures = calculateDisplayFeatures(this)

TwoPane(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.FavoriteBorder
import androidx.compose.material3.Surface
import androidx.compose.material3.Icon
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
Expand All @@ -47,15 +47,15 @@ import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import com.google.accompanist.adaptive.FoldAwareColumn
import com.google.accompanist.adaptive.calculateDisplayFeatures
import com.google.accompanist.sample.AccompanistSampleTheme
import com.google.accompanist.sample.AccompanistM3SampleTheme
import com.google.accompanist.sample.R
import kotlin.math.roundToInt

class DraggableFoldAwareColumnSample : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
AccompanistSampleTheme {
AccompanistM3SampleTheme {
Surface(modifier = Modifier.fillMaxSize()) {
DraggableExample(this@DraggableFoldAwareColumnSample)
}
Expand All @@ -77,13 +77,13 @@ fun DraggableExample(activity: Activity) {
}
}
.width(400.dp)
.border(5.dp, MaterialTheme.colors.secondary),
.border(5.dp, MaterialTheme.colorScheme.secondary),
displayFeatures = calculateDisplayFeatures(activity),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Icon(
modifier = Modifier
.border(2.dp, MaterialTheme.colors.primary)
.border(2.dp, MaterialTheme.colorScheme.primary)
.padding(20.dp)
.align(Alignment.Start),
imageVector = Icons.Default.FavoriteBorder,
Expand All @@ -92,14 +92,14 @@ fun DraggableExample(activity: Activity) {
Text(
modifier = Modifier
.align(Alignment.CenterHorizontally)
.border(2.dp, MaterialTheme.colors.primary),
.border(2.dp, MaterialTheme.colorScheme.primary),
text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
)
Image(
modifier = Modifier
.ignoreFold()
.align(Alignment.End)
.border(2.dp, MaterialTheme.colors.primary),
.border(2.dp, MaterialTheme.colorScheme.primary),
painter = painterResource(id = R.drawable.placeholder),
contentDescription = null
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Card
import androidx.compose.material.Text
import androidx.compose.material3.Card
import androidx.compose.material3.Text
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.google.accompanist.adaptive.FoldAwareConfiguration
import com.google.accompanist.adaptive.HorizontalTwoPaneStrategy
import com.google.accompanist.adaptive.TwoPane
import com.google.accompanist.adaptive.calculateDisplayFeatures
import com.google.accompanist.sample.AccompanistSampleTheme
import com.google.accompanist.sample.AccompanistM3SampleTheme

class HorizontalTwoPaneSample : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
AccompanistSampleTheme {
AccompanistM3SampleTheme {
val displayFeatures = calculateDisplayFeatures(this)

TwoPane(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Done
import androidx.compose.material.icons.filled.Face
Expand All @@ -38,9 +34,13 @@ import androidx.compose.material.icons.filled.Star
import androidx.compose.material.icons.filled.ThumbUp
import androidx.compose.material.icons.filled.Warning
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ModalDrawerSheet
import androidx.compose.material3.ModalNavigationDrawer
import androidx.compose.material3.NavigationDrawerItem
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand All @@ -50,13 +50,14 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.google.accompanist.adaptive.FoldAwareColumn
import com.google.accompanist.adaptive.calculateDisplayFeatures
import com.google.accompanist.sample.AccompanistM3SampleTheme
import com.google.accompanist.sample.AccompanistSampleTheme

class NavDrawerFoldAwareColumnSample : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
AccompanistSampleTheme {
AccompanistM3SampleTheme {
NavDrawerExample(this)
}
}
Expand Down Expand Up @@ -89,7 +90,7 @@ fun NavDrawerExample(activity: Activity) {
NavigationDrawerItem(
modifier = Modifier
.padding(5.dp)
.border(2.dp, MaterialTheme.colors.primary, CircleShape),
.border(2.dp, MaterialTheme.colorScheme.primary, CircleShape),
icon = { Icon(imageVector = it, contentDescription = it.name) },
label = { Text(it.name.substringAfter('.')) },
selected = it == selectedIcon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.NavigationRail
import androidx.compose.material.NavigationRailItem
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Done
import androidx.compose.material.icons.filled.Face
Expand All @@ -38,6 +32,12 @@ import androidx.compose.material.icons.filled.Search
import androidx.compose.material.icons.filled.Star
import androidx.compose.material.icons.filled.ThumbUp
import androidx.compose.material.icons.filled.Warning
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.NavigationRail
import androidx.compose.material3.NavigationRailItem
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand All @@ -47,13 +47,13 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.google.accompanist.adaptive.FoldAwareColumn
import com.google.accompanist.adaptive.calculateDisplayFeatures
import com.google.accompanist.sample.AccompanistSampleTheme
import com.google.accompanist.sample.AccompanistM3SampleTheme

class NavRailFoldAwareColumnSample : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
AccompanistSampleTheme {
AccompanistM3SampleTheme {
Row {
NavRail(this@NavRailFoldAwareColumnSample)
Surface(modifier = Modifier.fillMaxSize()) {}
Expand Down Expand Up @@ -83,7 +83,7 @@ fun NavRail(activity: Activity) {
NavigationRailItem(
modifier = Modifier
.padding(5.dp)
.border(2.dp, MaterialTheme.colors.primary),
.border(2.dp, MaterialTheme.colorScheme.primary),
selected = it == selectedIcon,
onClick = { selectedIcon = it },
icon = { Icon(imageVector = it, contentDescription = it.name) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Card
import androidx.compose.material.Text
import androidx.compose.material3.Card
import androidx.compose.material3.Text
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.google.accompanist.adaptive.FoldAwareConfiguration
import com.google.accompanist.adaptive.TwoPane
import com.google.accompanist.adaptive.VerticalTwoPaneStrategy
import com.google.accompanist.adaptive.calculateDisplayFeatures
import com.google.accompanist.sample.AccompanistSampleTheme
import com.google.accompanist.sample.AccompanistM3SampleTheme

class VerticalTwoPaneSample : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
AccompanistSampleTheme {
AccompanistM3SampleTheme {
val displayFeatures = calculateDisplayFeatures(this)

TwoPane(
Expand Down

0 comments on commit a327d83

Please sign in to comment.