mirror of
https://github.com/bitwarden/android.git
synced 2025-02-22 16:49:13 +03:00
yeah
This commit is contained in:
parent
f7efe578d3
commit
5b92e81823
3 changed files with 53 additions and 27 deletions
app/src/main/java/com/x8bit/bitwarden/ui
platform/components/coachmark
vault/feature/addedit
|
@ -65,16 +65,35 @@ fun <T : Enum<T>> CoachMarkContainer(
|
|||
.fillMaxSize()
|
||||
.then(modifier),
|
||||
) {
|
||||
|
||||
Timber.i("Coach: I am the full container")
|
||||
CoachMarkScopeInstance(coachMarkState = state).content()
|
||||
val boundedRectangle by state.currentHighlightBounds
|
||||
if (
|
||||
boundedRectangle != Rect.Zero && state.isVisible.value
|
||||
state.currentHighlightBounds.value != Rect.Zero && state.isVisible.value
|
||||
) {
|
||||
|
||||
Timber.i("Coach do I get called? Im trying draw the overlay")
|
||||
val boundedRectangle by state.currentHighlightBounds
|
||||
val highlightArea = Rect(
|
||||
topLeft = boundedRectangle.topLeft,
|
||||
bottomRight = boundedRectangle.bottomRight,
|
||||
)
|
||||
val highlightPath = Path().apply {
|
||||
Timber.i("Coach: I am applying the path for $highlightArea")
|
||||
when (state.currentHighlightShape.value) {
|
||||
CoachMarkHighlightShape.SQUARE -> addRoundRect(
|
||||
RoundRect(
|
||||
rect = highlightArea,
|
||||
cornerRadius = CornerRadius(
|
||||
x = ROUNDED_RECT_RADIUS,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
CoachMarkHighlightShape.OVAL -> addOval(highlightArea)
|
||||
}
|
||||
}
|
||||
val backgroundColor = BitwardenTheme.colorScheme.text.primary
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.pointerInput(Unit) {
|
||||
|
@ -82,7 +101,8 @@ fun <T : Enum<T>> CoachMarkContainer(
|
|||
onTap = {
|
||||
if (state.isVisible.value) {
|
||||
scope.launch {
|
||||
state.showCoachMark()
|
||||
Timber.i("Coach calling it in gestures")
|
||||
state.showToolTipForCurrentCoachMark()
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -91,26 +111,12 @@ fun <T : Enum<T>> CoachMarkContainer(
|
|||
.fillMaxSize()
|
||||
.drawBehind {
|
||||
clipPath(
|
||||
path = Path().apply {
|
||||
Timber.i("Coach I am applying the path for $highlightArea")
|
||||
when (state.currentHighlightShape.value) {
|
||||
CoachMarkHighlightShape.SQUARE -> addRoundRect(
|
||||
RoundRect(
|
||||
rect = highlightArea,
|
||||
cornerRadius = CornerRadius(
|
||||
x = ROUNDED_RECT_RADIUS,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
CoachMarkHighlightShape.OVAL -> addOval(highlightArea)
|
||||
}
|
||||
},
|
||||
path = highlightPath,
|
||||
clipOp = ClipOp.Difference,
|
||||
block = {
|
||||
drawRect(
|
||||
color = Color.Black,
|
||||
alpha = 0.5f,
|
||||
color = backgroundColor,
|
||||
alpha = 0.75f,
|
||||
)
|
||||
},
|
||||
)
|
||||
|
@ -118,9 +124,16 @@ fun <T : Enum<T>> CoachMarkContainer(
|
|||
)
|
||||
}
|
||||
}
|
||||
LaunchedEffect(state.currentHighlightBounds.value, state.currentHighlightShape.value) {
|
||||
if (state.currentHighlightBounds.value != Rect.Zero) {
|
||||
Timber.i("Coach: bounds changed do I get called? Im trying to show the tooltip")
|
||||
state.showToolTipForCurrentCoachMark()
|
||||
}
|
||||
}
|
||||
LaunchedEffect(Unit) {
|
||||
if (state.isVisible.value && (state.currentHighlight.value != null)) {
|
||||
state.showCoachMark()
|
||||
Timber.i("Coach calling it in Launched effect cause state is visible")
|
||||
state.showCoachMark(state.currentHighlight.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,10 +89,10 @@ class CoachMarkState<T : Enum<T>>(
|
|||
}
|
||||
getCurrentHighlight()
|
||||
}
|
||||
Timber.i("Coach: I have been requested to show the highlight for ${highlightToShow?.key} with bounds: ${highlightToShow?.highlightBounds}")
|
||||
Timber.i("Coach: I have been requested to show the highlight for ${highlightToShow?.key} with bounds: ${currentHighlightBounds.value}")
|
||||
if (highlightToShow != null) {
|
||||
updateCoachMarkStateInternal(highlightToShow)
|
||||
_isVisible.value = true
|
||||
highlightToShow.toolTipState.show()
|
||||
} else {
|
||||
showNextCoachMark()
|
||||
}
|
||||
|
@ -105,6 +105,8 @@ class CoachMarkState<T : Enum<T>>(
|
|||
*/
|
||||
suspend fun showNextCoachMark() {
|
||||
val highlightToShow = mutex.withLock {
|
||||
|
||||
Timber.i("Coach: I am trying to determine the next highlight")
|
||||
val previousHighlight = getCurrentHighlight()
|
||||
previousHighlight?.toolTipState?.cleanUp()
|
||||
val index = orderedList.indexOf(previousHighlight?.key)
|
||||
|
@ -115,7 +117,6 @@ class CoachMarkState<T : Enum<T>>(
|
|||
}
|
||||
Timber.i("Coach: I have been requested to show next highlight which is: ${highlightToShow?.key} with bounds: ${highlightToShow?.highlightBounds}")
|
||||
updateCoachMarkStateInternal(highlightToShow)
|
||||
highlightToShow?.toolTipState?.show()
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -138,7 +139,6 @@ class CoachMarkState<T : Enum<T>>(
|
|||
getCurrentHighlight()
|
||||
}
|
||||
updateCoachMarkStateInternal(highlightToShow)
|
||||
highlightToShow?.toolTipState?.show()
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -162,11 +162,22 @@ class CoachMarkState<T : Enum<T>>(
|
|||
}
|
||||
|
||||
private fun updateCoachMarkStateInternal(highlight: CoachMarkHighlightState<T>?) {
|
||||
Timber.i("Coach: I have updated the shape and bounds, the new bounds are ${highlight?.highlightBounds}")
|
||||
_currentHighlightShape.value = highlight?.shape ?: CoachMarkHighlightShape.SQUARE
|
||||
if (currentHighlightBounds.value != highlight?.highlightBounds) {
|
||||
_currentHighlightBounds.value = highlight?.highlightBounds ?: Rect.Zero
|
||||
Timber.i("Coach: I have updated the bounds, the new bounds are ${highlight?.highlightBounds}")
|
||||
}
|
||||
Timber.i("Coach: I have updated the shape and bounds, the new bounds are ${highlight?.highlightBounds}")
|
||||
}
|
||||
|
||||
internal suspend fun showToolTipForCurrentCoachMark() {
|
||||
Timber.i("Coach: I am trying to show")
|
||||
val currentCoachMark = mutex.withLock {
|
||||
getCurrentHighlight()
|
||||
}
|
||||
|
||||
Timber.i("Coach: I am trying to show part 2")
|
||||
currentCoachMark?.toolTipState?.show()
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -260,7 +260,9 @@ fun VaultAddEditScreen(
|
|||
val coroutineScope = rememberCoroutineScope()
|
||||
LaunchedEffect(Unit) {
|
||||
delay(3000L)
|
||||
coachMarkState.showCoachMark()
|
||||
if (coachMarkState.isVisible.value.not()) {
|
||||
coachMarkState.showCoachMark(AddEditItemCoachMark.GENERATE_PASSWORD)
|
||||
}
|
||||
}
|
||||
CoachMarkContainer(
|
||||
state = coachMarkState,
|
||||
|
|
Loading…
Add table
Reference in a new issue