Skip to content

Commit fa9d185

Browse files
code clean up and small bug fixes
1 parent 02644ce commit fa9d185

25 files changed

+104
-133
lines changed

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ fun HomeScreen(
5454
Column(
5555
modifier = modifier
5656
.fillMaxSize()
57-
// .background(getRandomColor())
5857
.padding(4.dp)
5958
) {
6059

@@ -69,10 +68,6 @@ fun HomeScreen(
6968
viewModel.getTutorials(query.text)
7069
}
7170

72-
// SideEffect {
73-
// println("⛺️ HomeScreen() state: $state")
74-
// }
75-
7671
val focusManager = LocalFocusManager.current
7772
val keyboardController = LocalSoftwareKeyboardController.current
7873

@@ -173,12 +168,10 @@ fun HomeScreen(
173168

174169
SearchDisplay.SearchInProgress -> {
175170
Box(
176-
contentAlignment = Alignment.Center, modifier = Modifier
171+
modifier = Modifier
177172
.background(Color.White)
178173
.fillMaxSize()
179-
) {
180-
// CircularProgressIndicator()
181-
}
174+
)
182175
}
183176
}
184177
}
@@ -218,8 +211,6 @@ private fun HomeContent(
218211
navigateToTutorial: (String) -> Unit
219212
) {
220213

221-
val state = SearchState<Int, Int, Int>(listOf(), listOf(), listOf())
222-
223214
val pagerState: PagerState = rememberPagerState(initialPage = 0)
224215
val coroutineScope = rememberCoroutineScope()
225216

@@ -266,7 +257,6 @@ private fun HomeContent(
266257
}
267258
}
268259

269-
270260
@Composable
271261
fun ComingSoonScreen() {
272262
Column(
@@ -346,7 +336,6 @@ fun TutorialListContent(
346336
},
347337
modifier = Modifier.align(Alignment.BottomEnd)
348338
)
349-
350339
}
351340
}
352341
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class HomeViewModel : ViewModel() {
3333

3434
// println("🤖 ViewModel Query: $query, filteredList: ${filteredList.size}")
3535

36-
return filteredList.toList()
36+
return filteredList.toList()
3737
}
3838
}
3939

@@ -51,7 +51,7 @@ val suggestionList = listOf(
5151
SuggestionModel("Recomposition"),
5252
SuggestionModel("SideEffect"),
5353
SuggestionModel("PointerInput"),
54-
SuggestionModel("AwaitPointerScope"),
54+
SuggestionModel("AwaitPointerEventScope"),
5555
SuggestionModel("Gesture"),
5656
SuggestionModel("Drag"),
5757
SuggestionModel("Transform"),

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,13 @@ fun SearchBar(
4141
modifier: Modifier = Modifier
4242
) {
4343

44-
// SideEffect {
45-
// println("🍭 SearchBar() query: ${query.text}, searching: $searching, focused: $focused")
46-
// }
47-
4844
val focusManager = LocalFocusManager.current
4945
val keyboardController = LocalSoftwareKeyboardController.current
5046

5147
Row(
52-
modifier = modifier.fillMaxWidth().background(Color.White),
48+
modifier = modifier
49+
.fillMaxWidth()
50+
.background(Color.White),
5351
verticalAlignment = Alignment.CenterVertically
5452
) {
5553

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ fun TutorialNavGraph(
4343
mainViewModel.tutorialList.add(graphicsTutorialList)
4444
}
4545

46-
// println("🍏 TutorialNavGraph(): mainViewModel: mainViewModel, list: ${mainViewModel.componentTutorialList.hashCode()}")
47-
4846
// Create Navigation for each Composable Page
4947
NavHost(
5048
modifier = modifier,

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ fun ScrollableTextTabComponent() {
214214

215215
ScrollableTabRow(
216216
edgePadding = 8.dp,
217-
selectedTabIndex = selectedIndex) {
217+
selectedTabIndex = selectedIndex
218+
) {
218219
list.forEachIndexed { index, text ->
219220
Tab(selected = selectedIndex == index,
220221
onClick = { selectedIndex = index },
@@ -256,9 +257,7 @@ fun CustomTabs() {
256257
Tab(
257258
modifier = if (selected) Modifier
258259
.clip(RoundedCornerShape(50))
259-
.background(
260-
Color.White
261-
)
260+
.background(Color.White)
262261
else Modifier
263262
.clip(RoundedCornerShape(50))
264263
.background(Color(0xff1E76DA)),

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ class MaterialShadow internal constructor(
7676
)
7777

7878
/**
79-
*
8079
* Draws customizable shadow behind badge using software layer to have blurred shadow
8180
* or solid shapes only..
8281
*

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ private fun TutorialContent() {
8181

8282
}
8383

84-
84+
/**
85+
* Adding this LaunchedEffect to composition when condition is true
86+
* Same goes for if this was remember(LaunchedEffect under the hood uses `remember(key){}`
87+
* when condition is met remember gets added to composition and it gets removed when it's not met
88+
*/
8589
@Composable
8690
private fun LaunchedEffectExample(scaffoldState: ScaffoldState) {
8791

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ enum class MotionEvent {
1212
Idle, Down, Move, Up
1313
}
1414

15-
1615
/**
1716
* Create a modifier for processing pointer motion input within the region of the modified element.
1817
*
@@ -174,7 +173,6 @@ fun Modifier.pointerMotionEvents(
174173
}
175174
)
176175

177-
178176
/**
179177
* Create a modifier for processing pointer motion input within the region of the modified element.
180178
*
@@ -211,7 +209,6 @@ fun Modifier.pointerMotionEvents(
211209
}
212210
)
213211

214-
215212
/**
216213
* Create a modifier for processing pointer motion input within the region of the modified element.
217214
*
@@ -247,5 +244,3 @@ fun Modifier.pointerMotionEvents(
247244
}
248245
}
249246
)
250-
251-

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ fun CustomRippleExample() {
200200
}
201201
}
202202

203-
204203
@Composable
205204
fun CustomRippleThemeExample() {
206205

@@ -440,7 +439,6 @@ private fun DiscreteInteractionSourceExample() {
440439
}
441440
}
442441

443-
444442
@Composable
445443
private fun InteractionFlowExample() {
446444
Column(
@@ -474,7 +472,6 @@ private fun InteractionFlowExample() {
474472
color = Color.White
475473
)
476474
}
477-
478475
}
479476
}
480477

@@ -553,7 +550,6 @@ private fun DiscreteInteractionSourceFLowExample() {
553550
)
554551
}
555552

556-
557553
// 🔥 This interaction source is for the row we will collect interactions on this one
558554
// and send it to quote to mimic whatsapp message click that highlight also quote
559555
val interactionSourceReceivedRow = MutableInteractionSource()
@@ -569,7 +565,6 @@ private fun DiscreteInteractionSourceFLowExample() {
569565
}
570566
)
571567

572-
573568
Column(
574569
modifier = Modifier
575570
.padding(bottom = 10.dp)
@@ -630,7 +625,6 @@ private fun DiscreteInteractionSourceFLowExample() {
630625
}
631626
}
632627

633-
634628
private class CustomRippleTheme(val color: Color = Color.Black) : RippleTheme {
635629
@Composable
636630
override fun defaultColor(): Color = color

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ private fun DetectTapGesturesExample() {
110110
}
111111
)
112112
}
113-
114-
115113
GestureDisplayBox(pointerModifier, gestureText)
116114
}
117115

@@ -155,8 +153,6 @@ private fun DetectPressAwaitExample() {
155153
}
156154
)
157155
}
158-
159-
160156
GestureDisplayBox(pointerModifier, gestureText)
161157
}
162158

@@ -204,8 +200,6 @@ private fun PointerIteropFilterExample() {
204200
true
205201
}
206202

207-
208-
209203
GestureDisplayBox(pointerModifier, gestureText)
210204
}
211205

@@ -312,7 +306,6 @@ private fun DetectGesturesExample2() {
312306
textAlign = TextAlign.Center
313307
)
314308

315-
316309
Box(
317310
Modifier
318311
// 🔥 We change offset(position) of blue box by dragging it

0 commit comments

Comments
 (0)