-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2.2.4 release prep - CI and readme improvements (#48)
* 2.2.4 release prep - CI and readme improvements * Refactoring, gradle config improvements
- Loading branch information
Showing
19 changed files
with
130 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.togitech.ccp.component | ||
|
||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.ui.ExperimentalComposeUiApi | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.autofill.AutofillNode | ||
import androidx.compose.ui.autofill.AutofillType | ||
import androidx.compose.ui.composed | ||
import androidx.compose.ui.focus.FocusRequester | ||
import androidx.compose.ui.focus.onFocusChanged | ||
import androidx.compose.ui.layout.boundsInWindow | ||
import androidx.compose.ui.layout.onGloballyPositioned | ||
import androidx.compose.ui.platform.LocalAutofill | ||
import androidx.compose.ui.platform.LocalAutofillTree | ||
|
||
@ExperimentalComposeUiApi | ||
internal fun Modifier.autofill( | ||
autofillTypes: List<AutofillType>, | ||
onFill: (String) -> Unit, | ||
focusRequester: FocusRequester, | ||
): Modifier = this then composed { | ||
val autofill = LocalAutofill.current | ||
val autofillNode = AutofillNode(onFill = onFill, autofillTypes = autofillTypes) | ||
LocalAutofillTree.current += autofillNode | ||
|
||
LaunchedEffect(Unit) { | ||
focusRequester.requestFocus() | ||
} | ||
|
||
this | ||
.onGloballyPositioned { | ||
autofillNode.boundingBox = it.boundsInWindow() | ||
} | ||
.onFocusChanged { focusState -> | ||
autofill?.run { | ||
if (focusState.isFocused) { | ||
requestAutofillForNode(autofillNode) | ||
} else { | ||
cancelAutofillForNode(autofillNode) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.