Skip to content

Commit 94da90d

Browse files
move PointerInputScope extensions and pointer modifiers
1 parent 384dec7 commit 94da90d

15 files changed

+369
-382
lines changed

Tutorial1-1Basics/src/main/java/com/smarttoolfactory/tutorial1_1basics/TutorialNavGraph.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,16 @@ fun TutorialNavGraph(
2727

2828
val mainViewModel: HomeViewModel = viewModel()
2929

30-
val componentTutorialList: List<TutorialSectionModel> = createComponentTutorialList {
31-
navController.navigateUp()
32-
}
33-
val layoutTutorialList = createLayoutTutorialList()
34-
val stateTutorialList = createStateTutorialList()
35-
val gestureTutorialList = createGestureTutorialList()
36-
val graphicsTutorialList = createGraphicsTutorialList()
37-
3830
if (mainViewModel.tutorialList.isEmpty()) {
31+
32+
val componentTutorialList: List<TutorialSectionModel> = createComponentTutorialList {
33+
navController.navigateUp()
34+
}
35+
val layoutTutorialList = createLayoutTutorialList()
36+
val stateTutorialList = createStateTutorialList()
37+
val gestureTutorialList = createGestureTutorialList()
38+
val graphicsTutorialList = createGraphicsTutorialList()
39+
3940
mainViewModel.tutorialList.add(componentTutorialList)
4041
mainViewModel.tutorialList.add(layoutTutorialList)
4142
mainViewModel.tutorialList.add(stateTutorialList)

Tutorial1-1Basics/src/main/java/com/smarttoolfactory/tutorial1_1basics/chapter3_layout/Tutorial3_2_2CustomLayout.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,8 @@ private fun TutorialContent() {
6262
color = Color.White
6363
)
6464
}
65-
6665
}
6766
}
68-
6967
}
7068

7169
@Composable

Tutorial1-1Basics/src/main/java/com/smarttoolfactory/tutorial1_1basics/chapter3_layout/Tutorial3_3_1ScopeAndParentDataModifier.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ interface CustomColumnScope {
209209
/*
210210
4- Create extension functions to set this ParentDataModifier in custom Layout using measurable
211211
*/
212-
213212
private val Measurable.childData: CustomColumnData?
214213
get() = parentData as? CustomColumnData
215214

Tutorial1-1Basics/src/main/java/com/smarttoolfactory/tutorial1_1basics/chapter3_layout/Tutorial3_5SubcomposeLayout.kt

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ import com.smarttoolfactory.tutorial1_1basics.ui.*
2828
import com.smarttoolfactory.tutorial1_1basics.ui.components.StyleableTutorialText
2929
import com.smarttoolfactory.tutorial1_1basics.ui.components.TutorialText2
3030

31+
/**
32+
* In this tutorial [SubcomposeLayout] usage is demonstrated with examples.
33+
*
34+
* SubcomposeLayout can compose a layout in parts as name suggest by sub-composing it or
35+
* can be used to remeasure children composables, after initial measurement which you might
36+
* get longest width or height, to set every composable to required property.
37+
* When remeasuring take into consideration that new measurement must be done with new
38+
* [Constraints] that use that property as one of parameters.
39+
*/
3140
@Composable
3241
fun Tutorial3_5Screen() {
3342
TutorialContent()
@@ -36,18 +45,17 @@ fun Tutorial3_5Screen() {
3645
@Composable
3746
private fun TutorialContent() {
3847

39-
4048
Column(
4149
modifier = Modifier
4250
.fillMaxSize()
4351
.verticalScroll(rememberScrollState())
4452
) {
4553

4654
StyleableTutorialText(
47-
text = "1-) **SubcomposeLayout** subcompose the actual content during the measuring " +
55+
text = "1-) **SubcomposeLayout** sub-composes the actual content during the measuring " +
4856
"stage for example to use the values calculated during the measurement " +
4957
"as params for the composition of the children.\n" +
50-
"In this sample below we get main size to add his height as padding to second one."
58+
"In this sample below we get main size to add its height as padding to second one."
5159
)
5260
SubComposeLayoutExample1()
5361

@@ -365,7 +373,7 @@ private fun SubComposeRowExample() {
365373
}
366374

367375
/**
368-
* Layout that[SubcomposeLayout] to pass dimension of [mainContent] to [dependentContent]
376+
* Layout that uses [SubcomposeLayout] to pass dimension of [mainContent] to [dependentContent]
369377
* using [SubcomposeMeasureScope.subcompose] function.
370378
*
371379
* SubcomposeLayout can compose a layout in parts as name suggest by sub-composing it or
@@ -383,10 +391,12 @@ private fun SubComponent(
383391

384392
SubcomposeLayout(modifier = modifier) { constraints ->
385393

394+
// Subcompose(compose only a section) main content and get Placeable
386395
val mainPlaceables: List<Placeable> = subcompose(SlotsEnum.Main, mainContent).map {
387396
it.measure(constraints)
388397
}
389398

399+
// Get max width and height of main component
390400
val maxSize =
391401
mainPlaceables.fold(IntSize.Zero) { currentMax: IntSize, placeable: Placeable ->
392402
IntSize(
@@ -406,15 +416,12 @@ private fun SubComponent(
406416
}.forEach {
407417
it.measure(constraints).placeRelative(0, 0)
408418
}
409-
410419
}
411420
}
412421
}
413422

414423
enum class SlotsEnum { Main, Dependent }
415424

416-
// SubComposeRow
417-
418425
@Composable
419426
private fun Item(
420427
modifier: Modifier = Modifier,

Tutorial1-1Basics/src/main/java/com/smarttoolfactory/tutorial1_1basics/chapter5_gesture/AwaitPointerMotionEvent.kt

Lines changed: 0 additions & 240 deletions
This file was deleted.

0 commit comments

Comments
 (0)