An open-source cross-platform alternative to AirDrop
feat: group the changelog by release and show what's new after an update (#3755)
Shlomo1be893695737
diff --git a/app/assets/CHANGELOG.md b/app/assets/CHANGELOG.mdindex c5d09edd..a9b2b4d1 100644--- a/app/assets/CHANGELOG.md+++ b/app/assets/CHANGELOG.md@@ -8,6 +8,7 @@- feat: show inbound/outbound reachability per device to help diagnose firewall issues (@Tienisto)- feat: add a copy button to the log screens (@ShlomoCode)- feat: add a Cancel button to the device name dialog (@ShlomoCode)+- feat: group the changelog by release and type, and show what's new after an update (@ShlomoCode)- feat(cli): send text using --text, including input from stdin (@Tienisto)- feat(cli)!: replace `--file` with the `send` command for sending files and directories (@otanim)- feat(desktop): add an option to keep the LocalSend window above other windows (@ShlomoCode)diff --git a/app/assets/i18n/en.json b/app/assets/i18n/en.jsonindex 06e521b4..5659785c 100644--- a/app/assets/i18n/en.json+++ b/app/assets/i18n/en.json@@ -333,7 +333,15 @@"restore": "Restore purchase"},"changelogPage": {- "title": "Changelog"+ "title": "Changelog",+ "categories": {+ "feature": "New features",+ "security": "Security",+ "performance": "Performance",+ "fix": "Bug fixes",+ "other": "Other"+ },+ "breaking": "Breaking change"},"whatsNewPage": {"title": "What's new in {version}",diff --git a/app/lib/config/init.dart b/app/lib/config/init.dartindex 1b6a3ed5..b0526228 100644--- a/app/lib/config/init.dart+++ b/app/lib/config/init.dart@@ -7,6 +7,8 @@ import 'package:flutter/widgets.dart';import 'package:flutter_displaymode/flutter_displaymode.dart';import 'package:localsend_app/config/refena.dart';import 'package:localsend_app/config/theme.dart';+import 'package:localsend_app/gen/assets.gen.dart';+import 'package:localsend_app/pages/changelog_page.dart';import 'package:localsend_app/pages/home_page.dart';import 'package:localsend_app/pages/home_page_controller.dart';import 'package:localsend_app/pages/whats_new_page.dart';@@ -25,6 +27,7 @@ import 'package:localsend_app/provider/settings_provider.dart';import 'package:localsend_app/provider/tv_provider.dart';import 'package:localsend_app/provider/version_provider.dart';import 'package:localsend_app/provider/window_dimensions_provider.dart';+import 'package:localsend_app/util/changelog.dart';import 'package:localsend_app/util/i18n.dart';import 'package:localsend_app/util/native/autostart_helper.dart';import 'package:localsend_app/util/native/cache_helper.dart';@@ -40,6 +43,7 @@ import 'package:localsend_app/util/notification_strings.dart';import 'package:localsend_app/util/ui/dynamic_colors.dart';import 'package:localsend_app/util/ui/snackbar.dart';import 'package:localsend_app/widget/dialogs/local_network_dialog.dart';+import 'package:localsend_app/widget/dialogs/whats_new_dialog.dart';import 'package:localsend_isolates/isolate.dart';import 'package:localsend_isolates/model/dto/file_dto.dart';import 'package:localsend_isolates/model/dto/multicast_dto.dart';@@ -315,17 +319,28 @@ Future<void> postInit(BuildContext context, Ref ref, bool appStart) async {ref.global.dispatchAsync(ClearCacheAction()); // ignore: unawaited_futures}+ final version = (await ref.future(versionProvider)).version;if (!ref.read(persistenceProvider).isFirstAppStart) {- WhatsNewPage? whatsNew = WhatsNewPage.fromLastVersion(lastVersion: ref.read(persistenceProvider).getWhatsNew());+ final lastVersion = ref.read(persistenceProvider).getWhatsNew();+ WhatsNewPage? whatsNew = WhatsNewPage.fromLastVersion(lastVersion: lastVersion);if (whatsNew != null) {// ignore: unawaited_futuresref.global.dispatchAsync(NavigateAction.push(whatsNew));+ } else if (lastVersion != null && isNewerVersion(version, lastVersion)) {+ final releases = parseChangelog(await rootBundle.loadString(Assets.changelog));+ final release = releases.where((release) => release.version == version).firstOrNull;+ if (release != null && context.mounted) {+ // ignore: unawaited_futures+ WhatsNewDialog.open(context, release).then((showChangelog) async {+ if (showChangelog) {+ await ref.global.dispatchAsync(NavigateAction.push(const ChangelogPage()));+ }+ });+ }}}- await ref.future(versionProvider).then((version) async {- await ref.read(persistenceProvider).setWhatsNew(version.version);- });+ await ref.read(persistenceProvider).setWhatsNew(version);// [FOSS_REMOVE_START]if (checkPlatformSupportPayment()) {diff --git a/app/lib/gen/strings.g.dart b/app/lib/gen/strings.g.dartindex 723d1cbd..d09545bf 100644--- a/app/lib/gen/strings.g.dart+++ b/app/lib/gen/strings.g.dart@@ -4,7 +4,7 @@/// To regenerate, run: `dart run slang`////// Locales: 59-/// Strings: 22426 (380 per locale)+/// Strings: 22432 (380 per locale)// coverage:ignore-file// ignore_for_file: type=lint, unused_importdiff --git a/app/lib/gen/strings_en.g.dart b/app/lib/gen/strings_en.g.dartindex efecd412..3c89a1e1 100644--- a/app/lib/gen/strings_en.g.dart+++ b/app/lib/gen/strings_en.g.dart@@ -651,6 +651,11 @@ class Translations$changelogPage$en {/// en: 'Changelog'String get title => 'Changelog';++ late final Translations$changelogPage$categories$en categories = Translations$changelogPage$categories$en.internal(_root);++ /// en: 'Breaking change'+ String get breaking => 'Breaking change';}// Path: whatsNewPage@@ -1448,6 +1453,30 @@ class Translations$progressPage$remainingTime$en {'${_root.progressPage.remainingTime.hoursUnit(h: h)} ${_root.progressPage.remainingTime.minutesUnit(m: m)}';}+// Path: changelogPage.categories+class Translations$changelogPage$categories$en {+ Translations$changelogPage$categories$en.internal(this._root);++ final Translations _root; // ignore: unused_field++ // Translations++ /// en: 'New features'+ String get feature => 'New features';++ /// en: 'Security'+ String get security => 'Security';++ /// en: 'Performance'+ String get performance => 'Performance';++ /// en: 'Bug fixes'+ String get fix => 'Bug fixes';++ /// en: 'Other'+ String get other => 'Other';+}+// Path: whatsNewPage.changesclass Translations$whatsNewPage$changes$en {Translations$whatsNewPage$changes$en.internal(this._root);diff --git a/app/lib/model/changelog.dart b/app/lib/model/changelog.dartnew file mode 100644index 00000000..e7cc1d65--- /dev/null+++ b/app/lib/model/changelog.dart@@ -0,0 +1,25 @@+enum ChangelogCategory { feature, security, performance, fix, other }++class ChangelogEntry {+ final ChangelogCategory category;++ /// The platforms or components the entry is limited to, e.g. `android` and `ios` for `fix(android, ios): ...`.+ final List<String> scopes;++ final bool breaking;+ final String text;++ const ChangelogEntry({required this.category, required this.scopes, required this.breaking, required this.text});+}++class ChangelogRelease {+ final String version;+ final DateTime? date;++ /// Free text between the heading and the entries.+ final String notes;++ final List<ChangelogEntry> entries;++ const ChangelogRelease({required this.version, required this.date, required this.notes, required this.entries});+}diff --git a/app/lib/pages/changelog_page.dart b/app/lib/pages/changelog_page.dartindex e6d4acd3..69f594fb 100644--- a/app/lib/pages/changelog_page.dart+++ b/app/lib/pages/changelog_page.dart@@ -1,9 +1,10 @@import 'package:flutter/material.dart';import 'package:flutter/services.dart' show rootBundle;-import 'package:flutter_markdown/flutter_markdown.dart';import 'package:localsend_app/gen/assets.gen.dart';import 'package:localsend_app/gen/strings.g.dart';-import 'package:localsend_app/util/ui/nav_bar_padding.dart';+import 'package:localsend_app/util/changelog.dart';+import 'package:localsend_app/widget/changelog_release.dart';+import 'package:localsend_app/widget/responsive_list_view.dart';class ChangelogPage extends StatelessWidget {const ChangelogPage();@@ -20,14 +21,27 @@ class ChangelogPage extends StatelessWidget {if (!data.hasData) {return Container();}- return Markdown(- padding: EdgeInsets.only(- left: 15,- right: 15,- top: 15,- bottom: 15 + getNavBarPadding(context),- ),- data: data.data!,+ final releases = parseChangelog(data.data!);+ return ResponsiveListView.builder(+ padding: const EdgeInsets.all(15),+ itemCount: releases.length,+ itemBuilder: (context, index) {+ final release = releases[index];+ return ChangelogReleaseCard(+ margin: const EdgeInsets.only(bottom: 10),+ child: ExpansionTile(+ // Restores the expansion when the card is scrolled out of view and back.+ key: PageStorageKey(release.version),+ initiallyExpanded: index == 0,+ shape: const Border(),+ collapsedShape: const Border(),+ title: ChangelogReleaseTitle(release: release, title: release.version),+ expandedCrossAxisAlignment: CrossAxisAlignment.stretch,+ childrenPadding: const EdgeInsets.fromLTRB(16, 0, 16, 16),+ children: [ChangelogReleaseBody(release: release)],+ ),+ );+ },);},),diff --git a/app/lib/util/changelog.dart b/app/lib/util/changelog.dartnew file mode 100644index 00000000..b6af2d91--- /dev/null+++ b/app/lib/util/changelog.dart@@ -0,0 +1,75 @@+import 'dart:convert';++import 'package:localsend_app/model/changelog.dart';++final _heading = RegExp(r'^(\S+)(?: \((.+)\))?');+final _entry = RegExp(r'^(\w+)(?:\((.+?)\))?(!)?: (.+)$');++const _categories = {+ 'feat': ChangelogCategory.feature,+ 'i18n': ChangelogCategory.feature,+ 'security': ChangelogCategory.security,+ 'perf': ChangelogCategory.performance,+ 'fix': ChangelogCategory.fix,+};++List<ChangelogRelease> parseChangelog(String markdown) {+ return [+ for (final section in markdown.split(RegExp(r'^## ', multiLine: true)).skip(1)) _parseRelease(const LineSplitter().convert(section.trim())),+ ];+}++ChangelogRelease _parseRelease(List<String> lines) {+ final heading = _heading.firstMatch(lines.first)!;+ final notes = <String>[];+ final entries = <String>[];+ for (final line in lines.skip(1).where((line) => line.isNotEmpty)) {+ if (line.startsWith('- ')) {+ entries.add(line.substring(2));+ } else if (line.startsWith(' ') && entries.isNotEmpty) {+ // An indented line continues the entry above it.+ entries.last = '${entries.last} ${line.trim()}';+ } else {+ notes.add(line);+ }+ }+ return ChangelogRelease(+ version: heading.group(1)!,+ date: DateTime.tryParse(heading.group(2) ?? ''),+ notes: notes.join('\n'),+ entries: entries.map(_parseEntry).toList(),+ );+}++ChangelogEntry _parseEntry(String entry) {+ final match = _entry.firstMatch(entry);+ if (match == null) {+ return ChangelogEntry(category: ChangelogCategory.other, scopes: const [], breaking: false, text: entry);+ }+ final type = match.group(1)!;+ final category = _categories[type];+ return ChangelogEntry(+ category: category ?? ChangelogCategory.other,+ scopes: [+ // A translation is a feature to the user, the badge keeps the context that the `i18n:` prefix gave.+ if (type == 'i18n') type,+ ...?match.group(2)?.split(',').map((scope) => scope.trim()),+ ],+ breaking: match.group(3) != null,+ // Types without a group of their own (e.g. `docs:`) keep their prefix, the text is not self-explanatory without it.+ text: category == null ? '$type: ${match.group(4)}' : match.group(4)!,+ );+}++/// Whether [version] is a later release than [other], for dotted numeric versions such as `1.19.0`.+bool isNewerVersion(String version, String other) {+ final [a, b] = [+ for (final v in [version, other]) v.split('.').map((part) => int.tryParse(part) ?? 0).toList(),+ ];+ for (var i = 0; i < a.length && i < b.length; i++) {+ if (a[i] != b[i]) {+ return a[i] > b[i];+ }+ }+ return a.length > b.length;+}diff --git a/app/lib/widget/changelog_release.dart b/app/lib/widget/changelog_release.dartnew file mode 100644index 00000000..db599b51--- /dev/null+++ b/app/lib/widget/changelog_release.dart@@ -0,0 +1,148 @@+import 'package:flutter/material.dart';+import 'package:localsend_app/config/theme.dart';+import 'package:localsend_app/gen/strings.g.dart';+import 'package:localsend_app/model/changelog.dart';+import 'package:localsend_app/util/system_date_time_formatter.dart';+import 'package:localsend_app/widget/device_bage.dart';++class ChangelogReleaseCard extends StatelessWidget {+ final EdgeInsets margin;+ final Widget child;++ const ChangelogReleaseCard({this.margin = EdgeInsets.zero, required this.child, super.key});++ @override+ Widget build(BuildContext context) {+ return Card(+ margin: margin,+ clipBehavior: Clip.antiAlias,+ shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),+ color: Theme.of(context).colorScheme.secondaryContainerIfDark,+ child: child,+ );+ }+}++class ChangelogReleaseTitle extends StatelessWidget {+ final ChangelogRelease release;+ final String title;++ const ChangelogReleaseTitle({required this.release, required this.title, super.key});++ @override+ Widget build(BuildContext context) {+ final textTheme = Theme.of(context).textTheme;+ final date = release.date;+ return Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(title, style: textTheme.titleMedium?.copyWith(fontWeight: FontWeight.bold)),+ if (date != null) Text(SystemDateTimeFormatter.date(context, date), style: textTheme.bodyMedium),+ ],+ );+ }+}++const _scopeLabels = {+ 'android': 'Android',+ 'ios': 'iOS',+ 'macos': 'macOS',+ 'mac': 'macOS',+ 'windows': 'Windows',+ 'linux': 'Linux',+ 'cli': 'CLI',+ 'desktop': 'Desktop',+ 'mobile': 'Mobile',+ 'i18n': 'Translation',+};++class ChangelogReleaseBody extends StatelessWidget {+ final ChangelogRelease release;++ const ChangelogReleaseBody({required this.release, super.key});++ @override+ Widget build(BuildContext context) {+ final theme = Theme.of(context);+ final colors = theme.colorScheme;+ // 'monospace' is a generic family only on Android and Linux.+ final codeStyle = TextStyle(+ fontFamily: switch (theme.platform) {+ TargetPlatform.iOS || TargetPlatform.macOS => 'Menlo',+ TargetPlatform.windows => 'Consolas',+ _ => 'monospace',+ },+ );+ final scopeBadgeColor = Color.lerp(colors.secondaryContainer, Colors.white, 0.3)!;+ return Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ if (release.notes.isNotEmpty) _ltr(Text(release.notes)),+ for (final (category, icon, label) in [+ (ChangelogCategory.feature, Icons.auto_awesome, t.changelogPage.categories.feature),+ (ChangelogCategory.security, Icons.shield_outlined, t.changelogPage.categories.security),+ (ChangelogCategory.performance, Icons.speed, t.changelogPage.categories.performance),+ (ChangelogCategory.fix, Icons.bug_report_outlined, t.changelogPage.categories.fix),+ (ChangelogCategory.other, Icons.more_horiz, t.changelogPage.categories.other),+ ])+ if (release.entries.any((entry) => entry.category == category)) ...[+ Padding(+ padding: const EdgeInsets.only(top: 14, bottom: 2),+ child: Row(+ children: [+ Icon(icon, size: 18, color: colors.primary),+ const SizedBox(width: 8),+ Text(label, style: theme.textTheme.titleSmall?.copyWith(color: colors.primary)),+ ],+ ),+ ),+ for (final entry in release.entries)+ if (entry.category == category)+ Padding(+ padding: const EdgeInsets.only(top: 6),+ child: _ltr(+ Row(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ const Text('•'),+ const SizedBox(width: 8),+ Expanded(+ child: Text.rich(+ TextSpan(+ children: [+ for (final scope in entry.scopes)+ _badge(_scopeLabels[scope.toLowerCase()] ?? scope, scopeBadgeColor, colors.onSecondaryContainer),+ if (entry.breaking) _badge(t.changelogPage.breaking, colors.warning.withValues(alpha: 0.15), colors.warning),+ ..._spansWithInlineCode(entry.text, codeStyle),+ ],+ ),+ ),+ ),+ ],+ ),+ ),+ ),+ ],+ ],+ );+ }+}++/// The changelog is only available in English, so its text is laid out left-to-right in every locale.+Widget _ltr(Widget child) => Directionality(textDirection: TextDirection.ltr, child: child);++InlineSpan _badge(String label, Color backgroundColor, Color foregroundColor) {+ return WidgetSpan(+ alignment: PlaceholderAlignment.middle,+ child: Padding(+ padding: const EdgeInsets.only(right: 6),+ child: DeviceBadge(backgroundColor: backgroundColor, foregroundColor: foregroundColor, label: label),+ ),+ );+}++List<InlineSpan> _spansWithInlineCode(String text, TextStyle codeStyle) {+ return [+ for (final (index, segment) in text.split('`').indexed) TextSpan(text: segment, style: index.isOdd ? codeStyle : null),+ ];+}diff --git a/app/lib/widget/dialogs/whats_new_dialog.dart b/app/lib/widget/dialogs/whats_new_dialog.dartnew file mode 100644index 00000000..00574d11--- /dev/null+++ b/app/lib/widget/dialogs/whats_new_dialog.dart@@ -0,0 +1,67 @@+import 'package:flutter/material.dart';+import 'package:localsend_app/gen/strings.g.dart';+import 'package:localsend_app/model/changelog.dart';+import 'package:localsend_app/widget/changelog_release.dart';+import 'package:routerino/routerino.dart';++class WhatsNewDialog extends StatelessWidget {+ final ChangelogRelease release;++ const WhatsNewDialog({required this.release, super.key});++ /// Returns whether the user asked to see the full changelog.+ static Future<bool> open(BuildContext context, ChangelogRelease release) async {+ final showChangelog = await showDialog<bool>(+ context: context,+ builder: (_) => WhatsNewDialog(release: release),+ );+ return showChangelog ?? false;+ }++ @override+ Widget build(BuildContext context) {+ return Dialog(+ backgroundColor: Colors.transparent,+ elevation: 0,+ child: ConstrainedBox(+ constraints: const BoxConstraints(maxWidth: 500),+ child: ChangelogReleaseCard(+ child: Padding(+ padding: const EdgeInsets.all(16),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ ChangelogReleaseTitle(+ release: release,+ title: t.whatsNewPage.title(version: release.version),+ ),+ Flexible(+ child: SingleChildScrollView(+ child: ChangelogReleaseBody(release: release),+ ),+ ),+ const SizedBox(height: 16),+ OverflowBar(+ alignment: MainAxisAlignment.end,+ overflowAlignment: OverflowBarAlignment.end,+ spacing: 8,+ children: [+ TextButton(+ onPressed: () => context.pop(true),+ child: Text(t.changelogPage.title),+ ),+ FilledButton(+ onPressed: () => context.pop(false),+ child: Text(t.general.close),+ ),+ ],+ ),+ ],+ ),+ ),+ ),+ ),+ );+ }+}diff --git a/app/pubspec.yaml b/app/pubspec.yamlindex b2d9e807..04b4a632 100644--- a/app/pubspec.yaml+++ b/app/pubspec.yaml@@ -27,7 +27,6 @@ dependencies:flutter_displaymode: 0.7.0flutter_localizations:sdk: flutter- flutter_markdown: 0.7.7+1freezed_annotation: 3.1.0glob: 2.1.3image: 4.9.1diff --git a/app/test/unit/util/changelog_test.dart b/app/test/unit/util/changelog_test.dartnew file mode 100644index 00000000..12f667b8--- /dev/null+++ b/app/test/unit/util/changelog_test.dart@@ -0,0 +1,44 @@+import 'package:localsend_app/model/changelog.dart';+import 'package:localsend_app/util/changelog.dart';+import 'package:test/test.dart';++void main() {+ test('parseChangelog splits releases into categorized entries', () {+ final releases = parseChangelog('''+## 1.19.0 (2026-11-21)++- feat(cli)!: replace `--file` with the `send` command (@otanim)+- fix(android, ios): keep file names+ when saving (@Tienisto)+- i18n: add Kyrgyz (@nidara-duo)++## 1.18.1++Android+iOS only hotfix update.++- Initial Release+''');++ expect(releases.map((r) => r.version), ['1.19.0', '1.18.1']);+ expect(releases[0].date, DateTime(2026, 11, 21));+ expect(releases[1].date, null);+ expect(releases[1].notes, 'Android+iOS only hotfix update.');++ final [feature, fix, i18n] = releases[0].entries;+ expect((feature.category, feature.breaking), (ChangelogCategory.feature, true));+ expect(feature.scopes, ['cli']);+ expect(feature.text, 'replace `--file` with the `send` command (@otanim)');+ expect((fix.category, fix.breaking), (ChangelogCategory.fix, false));+ expect(fix.scopes, ['android', 'ios']);+ expect(fix.text, 'keep file names when saving (@Tienisto)');+ expect((i18n.category, i18n.text), (ChangelogCategory.feature, 'add Kyrgyz (@nidara-duo)'));+ expect(i18n.scopes, ['i18n']);+ expect((releases[1].entries.single.category, releases[1].entries.single.text), (ChangelogCategory.other, 'Initial Release'));+ });++ test('isNewerVersion compares numerically', () {+ expect(isNewerVersion('1.10.0', '1.9.2'), true);+ expect(isNewerVersion('1.19.0', '1.19.0'), false);+ expect(isNewerVersion('1.18.2', '1.19.0'), false);+ });+}diff --git a/pubspec.lock b/pubspec.lockindex c9a0afa5..e89d9008 100644--- a/pubspec.lock+++ b/pubspec.lock@@ -524,14 +524,6 @@ packages:description: fluttersource: sdkversion: "0.0.0"- flutter_markdown:- dependency: transitive- description:- name: flutter_markdown- sha256: "08fb8315236099ff8e90cb87bb2b935e0a724a3af1623000a9cec930468e0f27"- url: "https://pub.dev"- source: hosted- version: "0.7.7+1"flutter_plugin_android_lifecycle:dependency: transitivedescription:@@ -902,14 +894,6 @@ packages:url: "https://pub.dev"source: hostedversion: "0.7.0"- markdown:- dependency: transitive- description:- name: markdown- sha256: ee85086ad7698b42522c6ad42fe195f1b9898e4d974a1af4576c1a3a176cada9- url: "https://pub.dev"- source: hosted- version: "7.3.1"matcher:dependency: transitivedescription: