materialIcon static method

Widget materialIcon(
  1. BuildContext context,
  2. LocordaStatusState state
)

Default icon builder using Material Design icons.

Shows:

  • cloud_off (grey) when not authenticated
  • cloud_off (red) when error
  • CircularProgressIndicator when syncing
  • cloud_done (green) when up to date

Implementation

static Widget materialIcon(BuildContext context, LocordaStatusState state) {
  final colorScheme = Theme.of(context).colorScheme;

  if (!state.isAuthenticated) {
    return Icon(Icons.cloud_off, color: colorScheme.onSurfaceVariant);
  } else if (state.hasError) {
    return Icon(Icons.cloud_off, color: colorScheme.error);
  } else if (state.isSyncing) {
    // Show explicit progress indicator for user-initiated syncs
    final isUserInitiated = state.lastTrigger == SyncTrigger.manual ||
        state.lastTrigger == SyncTrigger.pullToRefresh;

    if (isUserInitiated) {
      // Explicit progress for manual syncs - user expects feedback
      return SizedBox(
        width: 20,
        height: 20,
        child: CircularProgressIndicator(
          strokeWidth: 2,
          valueColor: AlwaysStoppedAnimation<Color>(colorScheme.primary),
        ),
      );
    } else {
      // Subtle feedback for automatic syncs - don't make user think app is slow
      return Icon(Icons.cloud_sync, color: colorScheme.primary);
    }
  } else {
    return Icon(Icons.cloud_done, color: Colors.green);
  }
}