@@ -2,10 +2,8 @@ package androidx.constraintlayout.compose
22
33import androidx.compose.animation.core.*
44import androidx.compose.foundation.Image
5- import androidx.compose.foundation.layout.Column
6- import androidx.compose.foundation.layout.fillMaxSize
7- import androidx.compose.foundation.layout.fillMaxWidth
8- import androidx.compose.foundation.layout.height
5+ import androidx.compose.foundation.background
6+ import androidx.compose.foundation.layout.*
97import androidx.compose.material.Button
108import androidx.compose.material.MaterialTheme
119import androidx.compose.ui.Modifier
@@ -15,6 +13,7 @@ import androidx.compose.ui.unit.dp
1513import androidx.compose.material.Text
1614import androidx.compose.runtime.*
1715import androidx.compose.ui.geometry.Offset
16+ import androidx.compose.ui.graphics.Color
1817import androidx.compose.ui.layout.layoutId
1918import androidx.compose.ui.tooling.preview.Preview
2019import androidx.constraintlayout.core.widgets.Optimizer
@@ -788,4 +787,167 @@ public fun ScreenExample8() {
788787 }
789788 }
790789 }
791- }
790+ }
791+
792+ @Preview(group = " new5" )
793+ @Composable
794+ public fun ScreenExample9 () {
795+ ConstraintLayout (
796+ ConstraintSet ("""
797+ {
798+ center: {
799+ center: 'parent'
800+ },
801+ h1: { circular: ['center', 30, 100] },
802+ h2: { circular: ['center', 60, 100] },
803+ h3: { circular: ['center', 90, 100] },
804+ h4: { circular: ['center', 120, 100] },
805+ h5: { circular: ['center', 150, 100] },
806+ h6: { circular: ['center', 180, 100] },
807+ h7: { circular: ['center', 210, 100] },
808+ h8: { circular: ['center', 240, 100] },
809+ h9: { circular: ['center', 270, 100] },
810+ h10: { circular: ['center', 300, 100] },
811+ h11: { circular: ['center', 330, 100] },
812+ h12: { circular: ['center', 0, 100] }
813+ }
814+ """ ),
815+ modifier = Modifier
816+ .fillMaxSize()
817+ ) {
818+ Text (modifier = Modifier .layoutId(" center" ), text = " C" )
819+ Text (modifier = Modifier .layoutId(" h1" ), text = " 1" )
820+ Text (modifier = Modifier .layoutId(" h2" ), text = " 2" )
821+ Text (modifier = Modifier .layoutId(" h3" ), text = " 3" )
822+ Text (modifier = Modifier .layoutId(" h4" ), text = " 4" )
823+ Text (modifier = Modifier .layoutId(" h5" ), text = " 5" )
824+ Text (modifier = Modifier .layoutId(" h6" ), text = " 6" )
825+ Text (modifier = Modifier .layoutId(" h7" ), text = " 7" )
826+ Text (modifier = Modifier .layoutId(" h8" ), text = " 8" )
827+ Text (modifier = Modifier .layoutId(" h9" ), text = " 9" )
828+ Text (modifier = Modifier .layoutId(" h10" ), text = " 10" )
829+ Text (modifier = Modifier .layoutId(" h11" ), text = " 11" )
830+ Text (modifier = Modifier .layoutId(" h12" ), text = " 12" )
831+ }
832+ }
833+
834+ @Preview(group = " new6" )
835+ @Composable
836+ public fun ScreenExample10 () {
837+ ConstraintLayout (
838+ ConstraintSet ("""
839+ {
840+ h1: { circular: ['parent', 0, 100] },
841+ h2: { circular: ['parent', 40, 100], rotationZ: 40 },
842+ h3: { circular: ['parent', 80, 100], rotationZ: 80 },
843+ h4: { circular: ['parent', 120, 100], rotationZ: 120 },
844+ h5: { circular: ['parent', 160, 100], rotationZ: 160 },
845+ h6: { circular: ['parent', 200, 100], rotationZ: 200 },
846+ h7: { circular: ['parent', 240, 100], rotationZ: 240 },
847+ h8: { circular: ['parent', 280, 100], rotationZ: 280 },
848+ h9: { circular: ['parent', 320, 100], rotationZ: 320 }
849+ }
850+ """ ),
851+ modifier = Modifier
852+ .fillMaxSize()
853+ ) {
854+ Box (modifier = Modifier .layoutId(" h1" ).width(100 .dp).height(60 .dp).background(Color .Red ))
855+ Box (modifier = Modifier .layoutId(" h2" ).width(100 .dp).height(60 .dp).background(Color .Green ))
856+ Box (modifier = Modifier .layoutId(" h3" ).width(100 .dp).height(60 .dp).background(Color .Blue ))
857+ Box (modifier = Modifier .layoutId(" h4" ).width(100 .dp).height(60 .dp).background(Color .Gray ))
858+ Box (modifier = Modifier .layoutId(" h5" ).width(100 .dp).height(60 .dp).background(Color .Yellow ))
859+ Box (modifier = Modifier .layoutId(" h6" ).width(100 .dp).height(60 .dp).background(Color .Cyan ))
860+ Box (modifier = Modifier .layoutId(" h7" ).width(100 .dp).height(60 .dp).background(Color .Magenta ))
861+ Box (modifier = Modifier .layoutId(" h8" ).width(100 .dp).height(60 .dp).background(Color .Red ))
862+ Box (modifier = Modifier .layoutId(" h9" ).width(100 .dp).height(60 .dp).background(Color .DarkGray ))
863+ }
864+ }
865+
866+ @Preview(group = " motion3" )
867+ @Composable
868+ public fun ScreenExample11 () {
869+ var animateToEnd by remember { mutableStateOf(false ) }
870+ val progress by animateFloatAsState(
871+ targetValue = if (animateToEnd) 1f else 0f ,
872+ animationSpec = tween(4000 )
873+ )
874+ Column {
875+ Button (onClick = { animateToEnd = ! animateToEnd }) {
876+ Text (text = " Run" )
877+ }
878+ MotionLayout (
879+ ConstraintSet ("""
880+ {
881+ h1: { circular: ['parent', 0, 100] },
882+ h2: { circular: ['parent', 40, 100], rotationZ: 40 },
883+ h3: { circular: ['parent', 80, 100], rotationZ: 80 },
884+ h4: { circular: ['parent', 120, 100], rotationZ: 120 },
885+ h5: { circular: ['parent', 160, 100], rotationZ: 160 },
886+ h6: { circular: ['parent', 200, 100], rotationZ: 200 },
887+ h7: { circular: ['parent', 240, 100], rotationZ: 240 },
888+ h8: { circular: ['parent', 280, 100], rotationZ: 280 },
889+ h9: { circular: ['parent', 320, 100], rotationZ: 320 }
890+ }
891+ """ ),
892+ ConstraintSet ("""
893+ {
894+ h1: { circular: ['parent', 0, 100], rotationZ: 360 },
895+ h2: { circular: ['parent', 40, 100], rotationZ: 400 },
896+ h3: { circular: ['parent', 80, 100], rotationZ: 440 },
897+ h4: { circular: ['parent', 120, 100], rotationZ: 480 },
898+ h5: { circular: ['parent', 160, 100], rotationZ: 520 },
899+ h6: { circular: ['parent', 200, 100], rotationZ: 560 },
900+ h7: { circular: ['parent', 240, 100], rotationZ: 600 },
901+ h8: { circular: ['parent', 280, 100], rotationZ: 640 },
902+ h9: { circular: ['parent', 320, 100], rotationZ: 680 }
903+ }
904+ """ ),
905+ progress = progress,
906+ modifier = Modifier
907+ .fillMaxSize().background(Color .White )
908+ ) {
909+ Box (modifier = Modifier .layoutId(" h1" ).width(100 .dp).height(60 .dp).background(Color .Red ))
910+ Box (modifier = Modifier .layoutId(" h2" ).width(100 .dp).height(60 .dp).background(Color .Green ))
911+ Box (modifier = Modifier .layoutId(" h3" ).width(100 .dp).height(60 .dp).background(Color .Blue ))
912+ Box (modifier = Modifier .layoutId(" h4" ).width(100 .dp).height(60 .dp).background(Color .Gray ))
913+ Box (modifier = Modifier .layoutId(" h5" ).width(100 .dp).height(60 .dp).background(Color .Yellow ))
914+ Box (modifier = Modifier .layoutId(" h6" ).width(100 .dp).height(60 .dp).background(Color .Cyan ))
915+ Box (modifier = Modifier .layoutId(" h7" ).width(100 .dp).height(60 .dp).background(Color .Magenta ))
916+ Box (modifier = Modifier .layoutId(" h8" ).width(100 .dp).height(60 .dp).background(Color .Red ))
917+ Box (modifier = Modifier .layoutId(" h9" ).width(100 .dp).height(60 .dp).background(Color .DarkGray ))
918+ }
919+ }
920+ }
921+
922+
923+
924+
925+
926+
927+
928+
929+
930+
931+
932+
933+
934+
935+
936+
937+
938+
939+
940+
941+
942+
943+
944+
945+
946+
947+
948+
949+
950+
951+
952+
953+
0 commit comments