Move PageCurlConfig to PageCurl argument

This commit is contained in:
Oleksandr Balan
2023-09-06 21:45:03 +02:00
parent c08c65ec96
commit 9addca8f27
12 changed files with 137 additions and 104 deletions

View File

@@ -52,32 +52,32 @@ fun BackPagePageCurlScreen() {
Box(Modifier.fillMaxSize()) {
val pages = remember { HowToPageData.backPageHowToPages }
var zoomOut by remember { mutableStateOf(false) }
val state = rememberPageCurlState(
config = rememberPageCurlConfig(
onCustomTap = { size, position ->
// When PageCurl is zoomed out then zoom back in
// Else detect tap somewhere in the center with 64 radius and zoom out a PageCurl
if (zoomOut) {
zoomOut = false
true
} else if ((position - size.center.toOffset()).getDistance() < 64.dp.toPx()) {
zoomOut = true
true
} else {
false
}
val state = rememberPageCurlState()
val config = rememberPageCurlConfig(
onCustomTap = { size, position ->
// When PageCurl is zoomed out then zoom back in
// Else detect tap somewhere in the center with 64 radius and zoom out a PageCurl
if (zoomOut) {
zoomOut = false
true
} else if ((position - size.center.toOffset()).getDistance() < 64.dp.toPx()) {
zoomOut = true
true
} else {
false
}
)
}
)
ZoomOutLayout(
zoomOut = zoomOut,
config = state.config,
bottom = { SettingsRow(state.config) },
config = config,
bottom = { SettingsRow(config) },
) {
PageCurl(
count = pages.size,
state = state,
config = config,
) { index ->
HowToPage(index, pages[index])
}

View File

@@ -47,32 +47,32 @@ fun InteractionConfigInPageCurlScreen() {
Box(Modifier.fillMaxSize()) {
val pages = remember { HowToPageData.interactionSettingsHowToPages }
var zoomOut by remember { mutableStateOf(false) }
val state = rememberPageCurlState(
config = rememberPageCurlConfig(
onCustomTap = { size, position ->
// When PageCurl is zoomed out then zoom back in
// Else detect tap somewhere in the center with 64 radius and zoom out a PageCurl
if (zoomOut) {
zoomOut = false
true
} else if ((position - size.center.toOffset()).getDistance() < 64.dp.toPx()) {
zoomOut = true
true
} else {
false
}
val state = rememberPageCurlState()
val config = rememberPageCurlConfig(
onCustomTap = { size, position ->
// When PageCurl is zoomed out then zoom back in
// Else detect tap somewhere in the center with 64 radius and zoom out a PageCurl
if (zoomOut) {
zoomOut = false
true
} else if ((position - size.center.toOffset()).getDistance() < 64.dp.toPx()) {
zoomOut = true
true
} else {
false
}
)
}
)
ZoomOutLayout(
zoomOut = zoomOut,
config = state.config,
bottom = { SettingsRow(state.config) },
config = config,
bottom = { SettingsRow(config) },
) {
PageCurl(
count = pages.size,
state = state,
config = config,
) { index ->
HowToPage(index, pages[index])
}

View File

@@ -33,30 +33,30 @@ fun SettingsPageCurlScreen() {
var showPopup by rememberSaveable { mutableStateOf(false) }
val state = rememberPageCurlState(
config = rememberPageCurlConfig(
onCustomTap = { size, position ->
// Detect tap somewhere in the center with 64 radius and show popup
if ((position - size.center.toOffset()).getDistance() < 64.dp.toPx()) {
showPopup = true
true
} else {
false
}
val state = rememberPageCurlState()
val config = rememberPageCurlConfig(
onCustomTap = { size, position ->
// Detect tap somewhere in the center with 64 radius and show popup
if ((position - size.center.toOffset()).getDistance() < 64.dp.toPx()) {
showPopup = true
true
} else {
false
}
)
}
)
PageCurl(
count = pages.size,
state = state,
config = config,
) { index ->
HowToPage(index, pages[index])
}
if (showPopup) {
SettingsPopup(
config = state.config,
config = config,
onDismiss = {
showPopup = false
}

View File

@@ -39,32 +39,32 @@ fun ShadowInPageCurlScreen() {
Box(Modifier.fillMaxSize()) {
val pages = remember { HowToPageData.shadowHowToPages }
var zoomOut by remember { mutableStateOf(false) }
val state = rememberPageCurlState(
config = rememberPageCurlConfig(
onCustomTap = { size, position ->
// When PageCurl is zoomed out then zoom back in
// Else detect tap somewhere in the center with 64 radius and zoom out a PageCurl
if (zoomOut) {
zoomOut = false
true
} else if ((position - size.center.toOffset()).getDistance() < 64.dp.toPx()) {
zoomOut = true
true
} else {
false
}
val state = rememberPageCurlState()
val config = rememberPageCurlConfig(
onCustomTap = { size, position ->
// When PageCurl is zoomed out then zoom back in
// Else detect tap somewhere in the center with 64 radius and zoom out a PageCurl
if (zoomOut) {
zoomOut = false
true
} else if ((position - size.center.toOffset()).getDistance() < 64.dp.toPx()) {
zoomOut = true
true
} else {
false
}
)
}
)
ZoomOutLayout(
zoomOut = zoomOut,
config = state.config,
bottom = { SettingsRow(state.config) },
config = config,
bottom = { SettingsRow(config) },
) {
PageCurl(
count = pages.size,
state = state,
config = config,
) { index ->
HowToPage(index, pages[index])
}

View File

@@ -44,32 +44,32 @@ fun StateInPageCurlScreen() {
Box(Modifier.fillMaxSize()) {
val pages = remember { HowToPageData.stateHowToPages }
var zoomOut by remember { mutableStateOf(false) }
val state = rememberPageCurlState(
config = rememberPageCurlConfig(
onCustomTap = { size, position ->
// When PageCurl is zoomed out then zoom back in
// Else detect tap somewhere in the center with 64 radius and zoom out a PageCurl
if (zoomOut) {
zoomOut = false
true
} else if ((position - size.center.toOffset()).getDistance() < 64.dp.toPx()) {
zoomOut = true
true
} else {
false
}
val state = rememberPageCurlState()
val config = rememberPageCurlConfig(
onCustomTap = { size, position ->
// When PageCurl is zoomed out then zoom back in
// Else detect tap somewhere in the center with 64 radius and zoom out a PageCurl
if (zoomOut) {
zoomOut = false
true
} else if ((position - size.center.toOffset()).getDistance() < 64.dp.toPx()) {
zoomOut = true
true
} else {
false
}
)
}
)
ZoomOutLayout(
zoomOut = zoomOut,
config = state.config,
config = config,
bottom = { SettingsRow(pages.size, state) },
) {
PageCurl(
count = pages.size,
state = state,
config = config,
) { index ->
HowToPage(index, pages[index])
}