Skip to content

Commit 22f9620

Browse files
update demos
1 parent a5247ef commit 22f9620

File tree

3 files changed

+35
-33
lines changed

3 files changed

+35
-33
lines changed

app/src/main/java/com/smarttoolfactory/composebeforeafter/MainActivity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ private fun HomeContent() {
8383
HorizontalPager(
8484
modifier = Modifier.padding(it),
8585
state = pagerState,
86+
userScrollEnabled = false,
8687
count = tabList.size
8788
) { page: Int ->
8889

app/src/main/java/com/smarttoolfactory/composebeforeafter/demo/BeforeAfterImageDemo.kt

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import androidx.compose.material3.Text
1111
import androidx.compose.runtime.*
1212
import androidx.compose.ui.Modifier
1313
import androidx.compose.ui.draw.clip
14-
import androidx.compose.ui.draw.shadow
1514
import androidx.compose.ui.graphics.Color
1615
import androidx.compose.ui.graphics.ImageBitmap
1716
import androidx.compose.ui.layout.ContentScale
@@ -22,6 +21,7 @@ import androidx.compose.ui.unit.dp
2221
import androidx.compose.ui.unit.sp
2322
import com.smarttoolfactory.beforeafter.BeforeAfterImage
2423
import com.smarttoolfactory.beforeafter.ContentOrder
24+
import com.smarttoolfactory.beforeafter.OverlayStyle
2525
import com.smarttoolfactory.composebeforeafter.ContentScaleSelectionMenu
2626
import com.smarttoolfactory.composebeforeafter.R
2727

@@ -83,28 +83,29 @@ fun BeforeAfterImageDemo() {
8383

8484
BeforeAfterImage(
8585
modifier = Modifier
86-
.shadow(1.dp, RoundedCornerShape(10.dp))
86+
.clip( RoundedCornerShape(10.dp))
8787
.fillMaxWidth()
8888
.aspectRatio(4 / 3f),
8989
beforeImage = imageBefore,
9090
afterImage = imageAfter,
9191
contentScale = contentScale
9292
)
9393

94-
Spacer(modifier = Modifier.height(40.dp))
94+
Spacer(modifier = Modifier.height(50.dp))
9595

9696
BeforeAfterImage(
9797
modifier = Modifier
98-
.shadow(1.dp, RoundedCornerShape(10.dp))
98+
.clip( RoundedCornerShape(10.dp))
9999
.fillMaxWidth()
100100
.aspectRatio(4 / 3f),
101101
beforeImage = imageBefore,
102102
afterImage = imageAfter,
103103
contentOrder = ContentOrder.AfterBefore,
104-
contentScale = contentScale
104+
contentScale = contentScale,
105+
overlayStyle = OverlayStyle()
105106
)
106107

107-
Spacer(modifier = Modifier.height(40.dp))
108+
Spacer(modifier = Modifier.height(50.dp))
108109
Text(
109110
text = "Zoom(Pinch gesture)",
110111
fontSize = 16.sp,
@@ -115,7 +116,7 @@ fun BeforeAfterImageDemo() {
115116

116117
BeforeAfterImage(
117118
modifier = Modifier
118-
.shadow(1.dp, RoundedCornerShape(10.dp))
119+
.clip( RoundedCornerShape(10.dp))
119120
.fillMaxWidth()
120121
.aspectRatio(4 / 3f),
121122
beforeImage = imageBefore2,
@@ -125,7 +126,7 @@ fun BeforeAfterImageDemo() {
125126
)
126127

127128

128-
Spacer(modifier = Modifier.height(40.dp))
129+
Spacer(modifier = Modifier.height(50.dp))
129130
Text(
130131
text = "Progress animation",
131132
fontSize = 16.sp,
@@ -149,26 +150,26 @@ fun BeforeAfterImageDemo() {
149150
)
150151
)
151152

152-
BeforeAfterImage(
153-
modifier = Modifier
154-
.clip(RoundedCornerShape(10.dp))
155-
.border(3.dp, Color(0xffE91E63), RoundedCornerShape(10.dp))
156-
.fillMaxWidth()
157-
.aspectRatio(4 / 3f),
158-
beforeImage = imageBefore3,
159-
afterImage = imageAfter3,
160-
progress = progress,
161-
onProgressChange = {},
162-
contentScale = contentScale,
163-
beforeLabel = {},
164-
afterLabel = {},
165-
) {
166-
Text(
167-
"${(progress).roundToInt()}%",
168-
fontSize = 50.sp,
169-
fontWeight = FontWeight.Bold,
170-
color = Color(0xff03A9F4)
171-
)
172-
}
153+
BeforeAfterImage(
154+
modifier = Modifier
155+
.clip(RoundedCornerShape(10.dp))
156+
.border(3.dp, Color(0xffE91E63), RoundedCornerShape(10.dp))
157+
.fillMaxWidth()
158+
.aspectRatio(4 / 3f),
159+
beforeImage = imageBefore3,
160+
afterImage = imageAfter3,
161+
progress = progress,
162+
onProgressChange = {},
163+
contentScale = contentScale,
164+
beforeLabel = {},
165+
afterLabel = {},
166+
) {
167+
Text(
168+
"${(progress).roundToInt()}%",
169+
fontSize = 50.sp,
170+
fontWeight = FontWeight.Bold,
171+
color = Color(0xff03A9F4)
172+
)
173+
}
173174
}
174175
}

app/src/main/java/com/smarttoolfactory/composebeforeafter/demo/BeforeAfterLayoutDemo.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ fun BeforeAfterLayoutDemo() {
8888
)
8989

9090

91-
Spacer(modifier = Modifier.height(40.dp))
91+
Spacer(modifier = Modifier.height(50.dp))
9292
Text(
9393
text = "Zoom(Pinch gesture)",
9494
fontSize = 16.sp,
@@ -111,7 +111,7 @@ fun BeforeAfterLayoutDemo() {
111111
contentOrder = ContentOrder.AfterBefore
112112
)
113113

114-
Spacer(modifier = Modifier.height(40.dp))
114+
Spacer(modifier = Modifier.height(50.dp))
115115

116116
val transition: InfiniteTransition = rememberInfiniteTransition()
117117

@@ -154,7 +154,7 @@ fun BeforeAfterLayoutDemo() {
154154
overlay = null
155155
)
156156

157-
Spacer(modifier = Modifier.height(40.dp))
157+
Spacer(modifier = Modifier.height(50.dp))
158158

159159
Text(
160160
text = "Layout",
@@ -186,7 +186,7 @@ fun BeforeAfterLayoutDemo() {
186186
// If you find an answer feel free to open a PR or answer question below
187187
// https://stackoverflow.com/questions/73061216/exoplayer2-with-before-after-videos-changes-first-video-when-clip-and-shape-used
188188

189-
Spacer(modifier = Modifier.height(40.dp))
189+
Spacer(modifier = Modifier.height(50.dp))
190190
Text(
191191
text = "Video",
192192
fontSize = 16.sp,

0 commit comments

Comments
 (0)