Skip to content

Commit 8aa7b46

Browse files
committed
fix manual mode on ios
1 parent f946500 commit 8aa7b46

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

documentscanner-compose/src/iosMain/kotlin/io/github/kalinjul/easydocumentscan/DocumentScanner.ios.kt

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,24 @@ actual fun rememberDocumentScanner(
6161
}
6262

6363
private fun VNDocumentCameraViewController.setManualMode() {
64+
// iOS < 26
6465
val autoButton = view.findChild {
6566
it.hasChild {
6667
val text = (it as? UILabel)?.text
6768
text == "Auto" || text == "Automatisch"
6869
} != null
6970
}
7071
(autoButton as? UIButton)?.sendActionsForControlEvents(UIControlEventTouchUpInside)
72+
73+
// iOS 26
74+
val shutterButton = view.findChild {
75+
it.hasChild {
76+
val text = (it as? UILabel)?.text
77+
text == "Shutter" || text == "Verschluss"
78+
} != null
79+
}
80+
81+
(shutterButton?.subviews?.firstOrNull() as? UIButton)?.sendActionsForControlEvents(UIControlEventTouchUpInside)
7182
}
7283
}
7384
}
@@ -91,11 +102,11 @@ private fun UIView.findChildren(predicate: (UIView) -> Boolean): List<UIView> {
91102
private fun UIView.findChild(predicate: (UIView) -> Boolean): UIView? {
92103
subviews.forEach {
93104
val view:UIView? = it as? UIView
94-
when(view) {
95-
is UIButton -> println(view)
96-
is UILabel -> println(view.text)
97-
else -> println(view)
98-
}
105+
// when(view) {
106+
// is UIButton -> println(view)
107+
// is UILabel -> println(view.text)
108+
// else -> println(view)
109+
// }
99110

100111
if (view != null && predicate(view)) {
101112
return view

0 commit comments

Comments
 (0)