renderSessions method

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

Implementation

Widget? renderSessions(BuildContext context, WidgetRef ref) {
  final allSessions = ref.watch(unknownSessionsProvider);
  if (allSessions.error != null) {
    return SliverToBoxAdapter(
      child: Text(
        L10n.of(context)
            .errorUnverifiedSessions(allSessions.error.toString()),
      ),
    );
  } else if (!allSessions.hasValue) {
    // we can ignore
    return null;
  }

  final sessions =
      allSessions.value!.where((session) => !session.isVerified()).toList();
  if (sessions.isEmpty) {
    return null;
  } else if (sessions.length == 1) {
    return SliverToBoxAdapter(
      child: SessionCard(
        key: oneUnverifiedSessionsCard,
        deviceRecord: sessions[0],
      ),
    );
  } else {
    return SliverToBoxAdapter(
      child: Card(
        key: unverifiedSessionsCard,
        child: ListTile(
          leading: const Icon(Atlas.warning_bold),
          title: Text(
            L10n.of(context).unverifiedSessionsTitle(sessions.length),
            style: Theme.of(context).textTheme.headlineSmall,
          ),
          trailing: OutlinedButton(
            onPressed: () {
              context.pushNamed(Routes.settingSessions.name);
            },
            child: Text(L10n.of(context).review),
          ),
        ),
      ),
    );
  }
}