renderSyncingState method

dynamic renderSyncingState(
  1. dynamic context,
  2. dynamic ref
)

Implementation

Widget? renderSyncingState(BuildContext context, WidgetRef ref) {
  final syncState = ref.watch(syncStateProvider);
  final errorMsg = syncState.errorMsg;
  final retryDuration = syncState.countDown != null
      ? Duration(seconds: syncState.countDown!)
      : null;
  if (!ref.watch(hasFirstSyncedProvider)) {
    return SliverToBoxAdapter(
      child: Card(
        child: ListTile(
          leading: const Icon(Atlas.arrows_dots_rotate),
          title: Text(L10n.of(context).renderSyncingTitle),
          subtitle: Text(L10n.of(context).renderSyncingSubTitle),
        ),
      ),
    );
  } else if (errorMsg != null) {
    return SliverToBoxAdapter(
      child: Card(
        child: ListTile(
          leading: const Icon(Atlas.warning),
          title: Text(L10n.of(context).errorSyncing(errorMsg)),
          subtitle: Text(
            retryDuration == null
                ? L10n.of(context).retrying
                : L10n.of(context).retryIn(
                    retryDuration.inMinutes
                        .remainder(60)
                        .toString()
                        .padLeft(2, '0'),
                    retryDuration.inSeconds
                        .remainder(60)
                        .toString()
                        .padLeft(2, '0'),
                  ),
          ),
        ),
      ),
    );
  }
  return null;
}