mirror of
https://github.com/bulwarkmail/native.git
synced 2026-11-01 16:05:39 +00:00
Back inside a Files subfolder switched to the Mail tab. It now closes an open preview, then leaves selection mode, then goes up one folder, and only switches tabs at the root. `filesBackStep` holds that order.
20 lines
735 B
TypeScript
20 lines
735 B
TypeScript
/** What Android back does in the Files tab. */
|
|
export type FilesBackStep = 'close-preview' | 'clear-selection' | 'folder-up' | 'leave';
|
|
|
|
/**
|
|
* Back works through the tab's own layers, innermost first: an open preview
|
|
* closes, then selection mode ends (like the header's X), then the folder
|
|
* goes up one level. Only at the root with nothing open does it `leave`,
|
|
* i.e. fall through to navigation, which switches to the Mail tab.
|
|
*/
|
|
export function filesBackStep(state: {
|
|
previewOpen: boolean;
|
|
selecting: boolean;
|
|
folderDepth: number;
|
|
}): FilesBackStep {
|
|
if (state.previewOpen) return 'close-preview';
|
|
if (state.selecting) return 'clear-selection';
|
|
if (state.folderDepth > 0) return 'folder-up';
|
|
return 'leave';
|
|
}
|