Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 41 additions & 12 deletions packages/ecosystem-native/src/components/home-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@ export class HomeButton extends LitElement {
static override styles = css`
:host {
display: contents;
touch-action: pan-x;
-webkit-touch-callout: none;
-webkit-user-select: none;
user-select: none;
}

.home-button-wrapper {
slot {
display: contents;
}

::slotted(*) {
touch-action: pan-x;
-webkit-touch-callout: none;
-webkit-user-select: none;
Expand Down Expand Up @@ -49,11 +56,30 @@ export class HomeButton extends LitElement {

override connectedCallback(): void {
super.connectedCallback();

// Update detector with current thresholds
this.swipeDetector = createUpSwipeDetector({
threshold: this.swipeThreshold,
velocityThreshold: this.velocityThreshold,
});

// NOTE: Listen on host element instead of shadow DOM.
// Touch events are not reliably delivered through shadow boundaries in Safari,
// which may cause swipe-up to silently fail.
// Capture phase: avoid child components (e.g. Swiper) stopping propagation.
this.addEventListener('touchstart', this.handleTouchStart, { capture: true });
this.addEventListener('touchend', this.handleTouchEnd, { capture: true });
this.addEventListener('touchcancel', this.handleTouchCancel, { capture: true });
this.addEventListener('click', this.handleClick);
}

override disconnectedCallback(): void {
this.removeEventListener('touchstart', this.handleTouchStart, { capture: true });
this.removeEventListener('touchend', this.handleTouchEnd, { capture: true });
this.removeEventListener('touchcancel', this.handleTouchCancel, { capture: true });
this.removeEventListener('click', this.handleClick);

super.disconnectedCallback();
}

override updated(changedProperties: Map<string, unknown>): void {
Expand All @@ -66,11 +92,23 @@ export class HomeButton extends LitElement {
}

private handleTouchStart = (e: TouchEvent): void => {
if (!this.hasRunningApps) {
this.swipeDetector.reset();
return;
}

this.swipeDetector.handleTouchStart(e);
};

private handleTouchCancel = (): void => {
this.swipeDetector.reset();
};

private handleTouchEnd = (e: TouchEvent): void => {
if (!this.hasRunningApps) return;
if (!this.hasRunningApps) {
this.swipeDetector.reset();
return;
}

const result = this.swipeDetector.handleTouchEnd(e);

Expand Down Expand Up @@ -101,16 +139,7 @@ export class HomeButton extends LitElement {
};

override render() {
return html`
<div
class="home-button-wrapper"
@touchstart=${this.handleTouchStart}
@touchend=${this.handleTouchEnd}
@click=${this.handleClick}
>
<slot></slot>
</div>
`;
return html`<slot></slot>`;
}
}

Expand Down
9 changes: 7 additions & 2 deletions src/components/ecosystem/my-apps-page.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@

/* beta miniapp:桌面图标名称带轻微“危险色”提示 */
.betaAppName {
color: color-mix(in oklab, var(--foreground) 88%, var(--destructive) 12%);
opacity: 0.9;
/*
* 使用 foreground 与 destructive 做 mix:
* - 深色主题(前景偏白)→ 淡红
* - 浅色主题(前景偏黑)→ 暗红
*/
color: var(--foreground);
color: color-mix(in srgb, var(--foreground) 78%, var(--destructive) 22%);
}