rewrite entire queue system to native

This commit is contained in:
Boof2015
2026-07-29 19:25:54 -04:00
parent d4c88042e0
commit 771d7a034c
29 changed files with 4376 additions and 220 deletions
+97
View File
@@ -0,0 +1,97 @@
import {
requireNativeModule,
requireNativeViewManager,
type NativeModule,
} from 'expo-modules-core';
import { processColor, type ViewProps } from 'react-native';
import type { Palette } from '../../src/theme/palettes';
export interface NativeQueuePalette {
background: number;
surface: number;
elevatedSurface: number;
selectedSurface: number;
nowPlayingSurface: number;
divider: number;
ripple: number;
text: number;
textSecondary: number;
textTertiary: number;
accent: number;
accentText: number;
accentTextStrong: number;
warning: number;
}
export interface NativeQueuePresentationOptions {
palette: NativeQueuePalette;
}
export interface NativeQueuePlaybackRequest {
requestId: string;
kind: 'playEntry';
entryId: number;
queueRevision: number;
}
export interface NativeQueueRevisionEvent {
sessionId: string | null;
queueRevision: number;
activePosition: number;
totalCount: number;
}
type AstraQueueEvents = {
onDismissed: () => void;
onPlaybackRequest: (event: NativeQueuePlaybackRequest) => void;
onQueueRevision: (event: NativeQueueRevisionEvent) => void;
};
declare class AstraQueueModuleType extends NativeModule<AstraQueueEvents> {
present(options: NativeQueuePresentationOptions): Promise<void>;
dismiss(): void;
resolvePlaybackRequest(
requestId: string,
success: boolean,
message?: string | null,
): void;
resolveEntryPosition(
entryId: number,
expectedRevision: number,
): Promise<number | null>;
}
export interface AstraQueueViewProps extends ViewProps {
active: boolean;
palette: NativeQueuePalette;
}
function nativeColor(value: string): number {
const processed = processColor(value);
return typeof processed === 'number' ? processed : 0;
}
export function toNativeQueuePalette(colors: Palette): NativeQueuePalette {
return {
background: nativeColor(colors.bgSecondary),
surface: nativeColor(colors.bgSecondary),
elevatedSurface: nativeColor(colors.bgTertiary),
selectedSurface: nativeColor(colors.glassHighlight),
nowPlayingSurface: nativeColor(colors.glassBg),
divider: nativeColor(colors.glassBorder),
ripple: nativeColor(colors.ripple),
text: nativeColor(colors.textPrimary),
textSecondary: nativeColor(colors.textSecondary),
textTertiary: nativeColor(colors.textTertiary),
accent: nativeColor(colors.accent),
accentText: nativeColor(colors.accentText),
accentTextStrong: nativeColor(colors.accentTextStrong),
// Destructive queue actions are semantically different from Astra's amber
// warning token. Keep remove affordances unmistakably red in every theme.
warning: nativeColor('#ef5350'),
};
}
export const AstraQueue = requireNativeModule<AstraQueueModuleType>('AstraQueue');
export const AstraQueueView =
requireNativeViewManager<AstraQueueViewProps>('AstraQueue');