show static method

Future<void> show(
  1. BuildContext context, {
  2. bool onlyIfUnseen = false,
  3. bool autoMarkSeen = true,
})

Presents the overlay if new entries are available.

If onlyIfUnseen is true, suppresses presentation if the latest release has already been seen. If autoMarkSeen is true, automatically records the latest release as seen upon presentation/dismissal.

Implementation

static Future<void> show(
  BuildContext context, {
  bool onlyIfUnseen = false,
  bool autoMarkSeen = true,
}) async {
  final client = CupThreadTheme.clientOf(context);
  final data = await client.prepareChangelogOverlay(onlyIfUnseen: onlyIfUnseen);
  if (data == null || data.entries.isEmpty) return;

  if (!context.mounted) return;

  final token = CupThreadTheme.userTokenOf(context);

  await showModalBottomSheet(
    context: context,
    isScrollControlled: true,
    backgroundColor: Colors.transparent,
    builder: (ctx) => CupThreadTheme(
      client: client,
      userToken: token,
      child: DraggableScrollableSheet(
        initialChildSize: 0.75,
        minChildSize: 0.5,
        maxChildSize: 0.9,
        builder: (sheetCtx, scrollController) => Container(
          decoration: BoxDecoration(
            color: CupThreadTheme.of(sheetCtx).card,
            borderRadius: const BorderRadius.vertical(top: Radius.circular(20)),
          ),
          child: ChangelogOverlay(
            entries: data.entries,
            config: data.appearance.changelogOverlay,
            autoMarkSeen: autoMarkSeen,
          ),
        ),
      ),
    ),
  );

  if (autoMarkSeen && data.entries.isNotEmpty) {
    final latest = data.entries.first;
    final key = latest.versionLabel ?? latest.id;
    if (key.isNotEmpty) {
      await client.markChangelogSeen(key);
    }
  }
}