Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Add dismissible tips with a reset setting

Barnabas776071a3f4b1
diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb
index a8dae702..e52506fb 100644
--- a/lib/l10n/app_en.arb
+++ b/lib/l10n/app_en.arb
@@ -1611,5 +1611,8 @@
"androidAutoTabDownloads": "Downloads",
"androidAutoCatBooks": "Books",
"androidAutoCatSeries": "Series",
- "androidAutoCatAuthors": "Authors"
+ "androidAutoCatAuthors": "Authors",
+ "showTipsAgain": "Show tips again",
+ "showTipsAgainSubtitle": "Bring back feature tips you've dismissed",
+ "tipsRestored": "Tips restored"
}
diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart
index d8018666..6ad5d683 100644
--- a/lib/l10n/app_localizations.dart
+++ b/lib/l10n/app_localizations.dart
@@ -7983,6 +7983,24 @@ abstract class AppLocalizations {
/// In en, this message translates to:
/// **'Authors'**
String get androidAutoCatAuthors;
+
+ /// No description provided for @showTipsAgain.
+ ///
+ /// In en, this message translates to:
+ /// **'Show tips again'**
+ String get showTipsAgain;
+
+ /// No description provided for @showTipsAgainSubtitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Bring back feature tips you\'ve dismissed'**
+ String get showTipsAgainSubtitle;
+
+ /// No description provided for @tipsRestored.
+ ///
+ /// In en, this message translates to:
+ /// **'Tips restored'**
+ String get tipsRestored;
}
class _AppLocalizationsDelegate
diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart
index 79acf639..5a089faf 100644
--- a/lib/l10n/app_localizations_en.dart
+++ b/lib/l10n/app_localizations_en.dart
@@ -4632,4 +4632,13 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get androidAutoCatAuthors => 'Authors';
+
+ @override
+ String get showTipsAgain => 'Show tips again';
+
+ @override
+ String get showTipsAgainSubtitle => 'Bring back feature tips you\'ve dismissed';
+
+ @override
+ String get tipsRestored => 'Tips restored';
}
diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart
index 963ceba7..a5f9ad20 100644
--- a/lib/l10n/app_localizations_zh.dart
+++ b/lib/l10n/app_localizations_zh.dart
@@ -4551,4 +4551,13 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get androidAutoCatAuthors => 'Authors';
+
+ @override
+ String get showTipsAgain => '再次显示提示';
+
+ @override
+ String get showTipsAgainSubtitle => '恢复你已关闭的功能提示';
+
+ @override
+ String get tipsRestored => '已恢复提示';
}
diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb
index 3088e268..f22fda06 100644
--- a/lib/l10n/app_zh.arb
+++ b/lib/l10n/app_zh.arb
@@ -792,5 +792,8 @@
"audible": "Audible",
"iTunes": "iTunes",
- "openLibrary": "打开媒体库"
+ "openLibrary": "打开媒体库",
+ "showTipsAgain": "再次显示提示",
+ "showTipsAgainSubtitle": "恢复你已关闭的功能提示",
+ "tipsRestored": "已恢复提示"
}
diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart
index 4e341625..089d54fa 100644
--- a/lib/screens/home_screen.dart
+++ b/lib/screens/home_screen.dart
@@ -18,6 +18,7 @@ import '../widgets/home_customize_sheet.dart';
import '../widgets/playlist_detail_sheet.dart';
import '../widgets/collection_detail_sheet.dart';
import '../widgets/section_detail_sheet.dart';
+import '../widgets/feature_hint.dart';
import 'app_shell.dart';
import '../l10n/app_localizations.dart';
@@ -586,6 +587,13 @@ class HomeScreenState extends State<HomeScreen> {
),
),
),
+ const SliverToBoxAdapter(
+ child: FeatureHint(
+ prefKey: 'hint_continue_listening_gestures',
+ message:
+ 'Tap a card to resume. Press and hold to see details.',
+ ),
+ ),
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.only(top: 12),
diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart
index 22555112..846a6cc3 100644
--- a/lib/screens/settings_screen.dart
+++ b/lib/screens/settings_screen.dart
@@ -8,6 +8,7 @@ import 'package:file_picker/file_picker.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:just_audio/just_audio.dart' show AudioPlayer;
+import 'package:shared_preferences/shared_preferences.dart';
import '../providers/auth_provider.dart';
import '../providers/library_provider.dart';
import '../services/audio_player_service.dart';
@@ -1764,6 +1765,26 @@ class _SettingsScreenState extends State<SettingsScreen> {
isExpanded: _expandedSection == 'Issues & Support',
onExpansionChanged: (v) => _onSectionExpanded('Issues & Support', v),
children: [
+ ListTile(
+ leading: Icon(Icons.lightbulb_outline_rounded,
+ color: cs.onSurfaceVariant),
+ title: Text(l.showTipsAgain),
+ subtitle: Text(l.showTipsAgainSubtitle,
+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
+ onTap: () async {
+ final prefs = await SharedPreferences.getInstance();
+ for (final key in prefs.getKeys()) {
+ if (key.startsWith('hint_')) {
+ await prefs.remove(key);
+ }
+ }
+ if (mounted) {
+ showOverlayToast(context, l.tipsRestored,
+ icon: Icons.lightbulb_outline_rounded);
+ }
+ },
+ ),
+ const Divider(height: 1, indent: 16, endIndent: 16),
ListTile(
leading: Icon(Icons.bug_report_outlined, color: cs.onSurfaceVariant),
title: Text(l.bugsAndFeatureRequests),
diff --git a/lib/widgets/feature_hint.dart b/lib/widgets/feature_hint.dart
new file mode 100644
index 00000000..55cec8f4
--- /dev/null
+++ b/lib/widgets/feature_hint.dart
@@ -0,0 +1,88 @@
+import 'package:flutter/material.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+
+/// Small, dismissible in-context tip. Used for progressive feature discovery
+/// (e.g. "Tap a card to resume, hold for details"). Each instance is gated on
+/// its own [prefKey] so different hints can live and retire independently.
+///
+/// Returns an empty widget once the user has dismissed the hint, so it's safe
+/// to inline inside a layout without branching.
+class FeatureHint extends StatefulWidget {
+ final String prefKey;
+ final IconData icon;
+ final String message;
+ final EdgeInsetsGeometry padding;
+
+ const FeatureHint({
+ super.key,
+ required this.prefKey,
+ required this.message,
+ this.icon = Icons.lightbulb_outline_rounded,
+ this.padding = const EdgeInsets.fromLTRB(20, 8, 20, 4),
+ });
+
+ @override
+ State<FeatureHint> createState() => _FeatureHintState();
+}
+
+class _FeatureHintState extends State<FeatureHint> {
+ bool? _dismissed;
+
+ @override
+ void initState() {
+ super.initState();
+ SharedPreferences.getInstance().then((prefs) {
+ if (!mounted) return;
+ setState(() => _dismissed = prefs.getBool(widget.prefKey) ?? false);
+ });
+ }
+
+ Future<void> _dismiss() async {
+ final prefs = await SharedPreferences.getInstance();
+ await prefs.setBool(widget.prefKey, true);
+ if (mounted) setState(() => _dismissed = true);
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ if (_dismissed != false) return const SizedBox.shrink();
+ final cs = Theme.of(context).colorScheme;
+ final tt = Theme.of(context).textTheme;
+ return Padding(
+ padding: widget.padding,
+ child: Container(
+ decoration: BoxDecoration(
+ color: cs.primaryContainer.withValues(alpha: 0.45),
+ borderRadius: BorderRadius.circular(10),
+ border: Border.all(
+ color: cs.primary.withValues(alpha: 0.25),
+ width: 0.5,
+ ),
+ ),
+ padding: const EdgeInsets.fromLTRB(12, 8, 4, 8),
+ child: Row(
+ children: [
+ Icon(widget.icon, size: 16, color: cs.primary),
+ const SizedBox(width: 10),
+ Expanded(
+ child: Text(widget.message,
+ style: tt.bodySmall?.copyWith(
+ color: cs.onPrimaryContainer,
+ height: 1.25,
+ )),
+ ),
+ IconButton(
+ icon: const Icon(Icons.close_rounded, size: 16),
+ color: cs.onPrimaryContainer.withValues(alpha: 0.7),
+ padding: EdgeInsets.zero,
+ constraints: const BoxConstraints(minWidth: 32, minHeight: 32),
+ visualDensity: VisualDensity.compact,
+ tooltip: 'Dismiss',
+ onPressed: _dismiss,
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+}