syncStatusPresentation function

SyncStatusPresentation syncStatusPresentation(
  1. WalletLocalizations l10n,
  2. SyncStatus status, {
  3. required bool driving,
  4. bool startFailed = false,
  5. bool syncDisabled = false,
})

Implementation

SyncStatusPresentation syncStatusPresentation(
  WalletLocalizations l10n,
  SyncStatus status, {
  required bool driving,
  bool startFailed = false,
  bool syncDisabled = false,
}) {
  // #383 R1: the host's sync policy is OFF ([WalletSyncDrive.disabledByHost])
  // — this owns the WHOLE presentation, over any retained status arm: a
  // retained "Up to date"/"Scanning" would claim liveness while nothing is
  // checking the chain, and the Idle default's "starts automatically" would
  // be a lie. Mutually exclusive with [startFailed] by the drive enum (a
  // disabled host never issues the start that could fail).
  if (syncDisabled) {
    return SyncStatusPresentation(
      icon: WalletGlyph.syncOff,
      headline: l10n.walletSyncDisabled,
      details: [l10n.walletSyncDisabledDetail],
    );
  }
  final p = _statusPresentation(
    l10n,
    status,
    driving: driving,
    startFailed: startFailed,
  );
  // A failed START under a retained NON-Idle status (#356-F8, second half):
  // the stream keeps the last good value across a pause, so a resume-time
  // start fault can sit under "Up to date"/"Scanning" — the badge's a11y
  // label and the sheet must carry the failure line there too, never a pure
  // healthy story beside the retry notice. (The Idle arm already swaps its
  // own copy inside the mapping.)
  if (startFailed && status is! SyncStatus_Idle) {
    return SyncStatusPresentation(
      // The icon agrees with the capped (caution) color — an orange
      // check-circle under a retained "Up to date" would be a contradictory
      // glyph/color pair (UX LOW); the Idle arm already swaps its own.
      icon: WalletGlyph.syncProblem,
      headline: p.headline,
      trailing: p.trailing,
      details: [...p.details, l10n.walletSyncStartFailed],
      scanning: p.scanning,
      progress: p.progress,
    );
  }
  return p;
}