implemented a central haptic feedback system with configurable levels (off, reduced, full), added a Haptics facade providing semantic feedback methods, integrated haptic cues across navigation, settings toggles, and async action results, and updated version to 1.1.0+54
This commit is contained in:
+11
-1
@@ -23,6 +23,7 @@ import 'state/app/modules/timetable/bloc/timetable_bloc.dart';
|
||||
import 'state/app/modules/timetable/bloc/timetable_state.dart';
|
||||
import 'storage/settings.dart' as model;
|
||||
import 'utils/debouncer.dart';
|
||||
import 'utils/haptics.dart';
|
||||
import 'view/pages/overhang.dart';
|
||||
import 'widget/breaker/breaker.dart';
|
||||
import 'widget_data/widget_navigation.dart';
|
||||
@@ -42,13 +43,19 @@ class _AppState extends State<App> with WidgetsBindingObserver {
|
||||
StreamSubscription<RemoteMessage>? _onMessageOpenedAppSub;
|
||||
StreamSubscription<String>? _fcmTokenRefreshSub;
|
||||
int _knownTotalTabs = 1;
|
||||
int _lastTabIndex = 0;
|
||||
bool _userOnLastTab = false;
|
||||
|
||||
static const Duration _chatListActiveInterval = Duration(seconds: 15);
|
||||
static const Duration _chatListIdleInterval = Duration(seconds: 60);
|
||||
|
||||
void _onTabControllerChanged() {
|
||||
_userOnLastTab = Main.bottomNavigator.index == _knownTotalTabs - 1;
|
||||
final newIndex = Main.bottomNavigator.index;
|
||||
if (newIndex != _lastTabIndex) {
|
||||
Haptics.selection();
|
||||
_lastTabIndex = newIndex;
|
||||
}
|
||||
_userOnLastTab = newIndex == _knownTotalTabs - 1;
|
||||
_syncChatListPolling();
|
||||
}
|
||||
|
||||
@@ -107,7 +114,9 @@ class _AppState extends State<App> with WidgetsBindingObserver {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
Haptics.bind(context.read<SettingsCubit>());
|
||||
Main.bottomNavigator = PersistentTabController(initialIndex: 0);
|
||||
_lastTabIndex = Main.bottomNavigator.index;
|
||||
Main.bottomNavigator.addListener(_onTabControllerChanged);
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
|
||||
@@ -230,6 +239,7 @@ class _AppState extends State<App> with WidgetsBindingObserver {
|
||||
Main.bottomNavigator = PersistentTabController(
|
||||
initialIndex: targetIndex,
|
||||
);
|
||||
_lastTabIndex = targetIndex;
|
||||
Main.bottomNavigator.addListener(_onTabControllerChanged);
|
||||
_userOnLastTab = targetIndex == totalTabs - 1;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../../utils/haptics.dart';
|
||||
import '../../../../../widget/conditional_wrapper.dart';
|
||||
import '../../utility_widgets/bloc_module.dart';
|
||||
import '../../utility_widgets/loadable_hydrated_bloc/loadable_hydrated_bloc_event.dart';
|
||||
@@ -86,6 +87,7 @@ class LoadableStateConsumer<
|
||||
final childWidget = enablePullToRefresh
|
||||
? RefreshIndicator(
|
||||
onRefresh: () {
|
||||
Haptics.refresh();
|
||||
loadableState.reFetch?.call();
|
||||
return Future.value();
|
||||
},
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'haptic_settings.g.dart';
|
||||
|
||||
enum HapticLevel { off, reduced, full }
|
||||
|
||||
@JsonSerializable()
|
||||
class HapticSettings {
|
||||
HapticLevel level;
|
||||
|
||||
HapticSettings({required this.level});
|
||||
|
||||
factory HapticSettings.fromJson(Map<String, dynamic> json) =>
|
||||
_$HapticSettingsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$HapticSettingsToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'haptic_settings.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
HapticSettings _$HapticSettingsFromJson(Map<String, dynamic> json) =>
|
||||
HapticSettings(level: $enumDecode(_$HapticLevelEnumMap, json['level']));
|
||||
|
||||
Map<String, dynamic> _$HapticSettingsToJson(HapticSettings instance) =>
|
||||
<String, dynamic>{'level': _$HapticLevelEnumMap[instance.level]!};
|
||||
|
||||
const _$HapticLevelEnumMap = {
|
||||
HapticLevel.off: 'off',
|
||||
HapticLevel.reduced: 'reduced',
|
||||
HapticLevel.full: 'full',
|
||||
};
|
||||
@@ -4,6 +4,7 @@ import 'package:json_annotation/json_annotation.dart';
|
||||
import 'dev_tools_settings.dart';
|
||||
import 'file_settings.dart';
|
||||
import 'file_view_settings.dart';
|
||||
import 'haptic_settings.dart';
|
||||
import 'holidays_settings.dart';
|
||||
import 'modules_settings.dart';
|
||||
import 'notification_settings.dart';
|
||||
@@ -26,6 +27,7 @@ class Settings {
|
||||
FileViewSettings fileViewSettings;
|
||||
NotificationSettings notificationSettings;
|
||||
DevToolsSettings devToolsSettings;
|
||||
HapticSettings hapticSettings;
|
||||
|
||||
Settings({
|
||||
required this.appTheme,
|
||||
@@ -38,6 +40,7 @@ class Settings {
|
||||
required this.fileViewSettings,
|
||||
required this.notificationSettings,
|
||||
required this.devToolsSettings,
|
||||
required this.hapticSettings,
|
||||
});
|
||||
|
||||
static String _themeToJson(ThemeMode m) => m.name;
|
||||
|
||||
@@ -33,6 +33,9 @@ Settings _$SettingsFromJson(Map<String, dynamic> json) => Settings(
|
||||
devToolsSettings: DevToolsSettings.fromJson(
|
||||
json['devToolsSettings'] as Map<String, dynamic>,
|
||||
),
|
||||
hapticSettings: HapticSettings.fromJson(
|
||||
json['hapticSettings'] as Map<String, dynamic>,
|
||||
),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$SettingsToJson(Settings instance) => <String, dynamic>{
|
||||
@@ -46,4 +49,5 @@ Map<String, dynamic> _$SettingsToJson(Settings instance) => <String, dynamic>{
|
||||
'fileViewSettings': instance.fileViewSettings.toJson(),
|
||||
'notificationSettings': instance.notificationSettings.toJson(),
|
||||
'devToolsSettings': instance.devToolsSettings.toJson(),
|
||||
'hapticSettings': instance.hapticSettings.toJson(),
|
||||
};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'haptics.dart';
|
||||
|
||||
/// Copies [text] to the system clipboard and shows a SnackBar.
|
||||
Future<void> copyToClipboard(
|
||||
BuildContext context,
|
||||
@@ -8,6 +10,7 @@ Future<void> copyToClipboard(
|
||||
String successMessage = 'In Zwischenablage kopiert',
|
||||
}) async {
|
||||
await Clipboard.setData(ClipboardData(text: text));
|
||||
Haptics.selection();
|
||||
if (!context.mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../state/app/modules/settings/bloc/settings_cubit.dart';
|
||||
import '../storage/haptic_settings.dart';
|
||||
import '../storage/settings.dart';
|
||||
|
||||
/// App-weite Haptik-Fassade. Liest die aktive Stufe aus einem in-memory Cache,
|
||||
/// der einmal an den SettingsCubit gebunden wird — damit sind die Aufrufe
|
||||
/// kontextfrei (egal ob aus Widget oder Util).
|
||||
///
|
||||
/// Semantische Methoden statt roher Impacts, damit Call-Sites die Intention
|
||||
/// transportieren, nicht die Stärke.
|
||||
class Haptics {
|
||||
static HapticLevel _level = HapticLevel.full;
|
||||
static StreamSubscription<Settings>? _sub;
|
||||
|
||||
/// Einmal aus App-Root aufrufen, sobald der [SettingsCubit] verfügbar ist.
|
||||
static void bind(SettingsCubit cubit) {
|
||||
_level = cubit.state.hapticSettings.level;
|
||||
_sub?.cancel();
|
||||
_sub = cubit.stream.listen((s) => _level = s.hapticSettings.level);
|
||||
}
|
||||
|
||||
// --- reduced + full ---
|
||||
|
||||
/// Long-Press, der ein Bottom-Sheet / Action-Menü öffnet.
|
||||
static void longPress() {
|
||||
if (_level == HapticLevel.off) return;
|
||||
HapticFeedback.mediumImpact();
|
||||
}
|
||||
|
||||
/// Bestätigen eines ConfirmDialogs (nicht das Abbrechen).
|
||||
static void confirm() {
|
||||
if (_level == HapticLevel.off) return;
|
||||
HapticFeedback.mediumImpact();
|
||||
}
|
||||
|
||||
/// Fehler einer Async-Aktion / Dialog-Fehler.
|
||||
static void error() {
|
||||
if (_level == HapticLevel.off) return;
|
||||
HapticFeedback.mediumImpact();
|
||||
}
|
||||
|
||||
/// Seltener Dopamin-Moment — z.B. erfolgreicher Login.
|
||||
static void heavyAccent() {
|
||||
if (_level == HapticLevel.off) return;
|
||||
HapticFeedback.heavyImpact();
|
||||
}
|
||||
|
||||
// --- nur full ---
|
||||
|
||||
/// Erfolg einer Async-Aktion (Senden, Reagieren, Speichern, …).
|
||||
static void success() {
|
||||
if (_level != HapticLevel.full) return;
|
||||
HapticFeedback.lightImpact();
|
||||
}
|
||||
|
||||
/// Pull-to-Refresh ausgelöst.
|
||||
static void refresh() {
|
||||
if (_level != HapticLevel.full) return;
|
||||
HapticFeedback.selectionClick();
|
||||
}
|
||||
|
||||
/// Tab-Wechsel, Toggle-Switch, Clipboard-Copy — alles, was eine
|
||||
/// subtile Quittung verdient.
|
||||
static void selection() {
|
||||
if (_level != HapticLevel.full) return;
|
||||
HapticFeedback.selectionClick();
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import '../../state/app/modules/settings/bloc/settings_cubit.dart';
|
||||
import '../../storage/dev_tools_settings.dart';
|
||||
import '../../storage/settings.dart' as model;
|
||||
import '../../theming/light_app_theme.dart';
|
||||
import '../../utils/haptics.dart';
|
||||
import '../pages/settings/widgets/endpoint_picker.dart';
|
||||
import 'login_controller.dart';
|
||||
import 'widgets/login_branding.dart';
|
||||
@@ -40,6 +41,7 @@ class _LoginState extends State<Login> {
|
||||
}
|
||||
|
||||
void _onLoginSuccess() {
|
||||
Haptics.heavyAccent();
|
||||
context.read<AccountBloc>().setStatus(AccountStatus.loggedIn);
|
||||
// Re-register the periodic refresh (cancelAll runs on logout) and kick
|
||||
// off an immediate one-off so the widget populates within seconds
|
||||
|
||||
@@ -10,6 +10,7 @@ import '../../../../routing/app_routes.dart';
|
||||
import '../../../../share_intent/remote_file_ref.dart';
|
||||
import '../../../../utils/download_manager.dart';
|
||||
import '../../../../utils/file_clipboard.dart';
|
||||
import '../../../../utils/haptics.dart';
|
||||
import '../../../../widget/centered_leading.dart';
|
||||
import '../../../../widget/confirm_dialog.dart';
|
||||
import '../../../../widget/details_bottom_sheet.dart';
|
||||
@@ -83,6 +84,7 @@ class _FileElementState extends State<FileElement> {
|
||||
if (job == null) return;
|
||||
final status = job.status.value;
|
||||
if (status is DownloadDone) {
|
||||
Haptics.success();
|
||||
DownloadManager.instance.clear(widget.file.path);
|
||||
_detachJob();
|
||||
AppRoutes.openFileViewer(
|
||||
@@ -288,6 +290,7 @@ class _FileElementState extends State<FileElement> {
|
||||
}
|
||||
|
||||
void _showActionSheet() {
|
||||
Haptics.longPress();
|
||||
showDetailsBottomSheet(
|
||||
context,
|
||||
children: (sheetCtx) => [
|
||||
|
||||
@@ -6,6 +6,7 @@ import '../../../../state/app/modules/app_modules.dart';
|
||||
import '../../../../storage/dev_tools_settings.dart';
|
||||
import '../../../../storage/file_settings.dart';
|
||||
import '../../../../storage/file_view_settings.dart';
|
||||
import '../../../../storage/haptic_settings.dart';
|
||||
import '../../../../storage/holidays_settings.dart';
|
||||
import '../../../../storage/modules_settings.dart';
|
||||
import '../../../../storage/notification_settings.dart';
|
||||
@@ -65,5 +66,6 @@ class DefaultSettings {
|
||||
marianumConnectEndpoint: MarianumConnectEndpoint.live,
|
||||
marianumConnectCustomUrl: '',
|
||||
),
|
||||
hapticSettings: HapticSettings(level: HapticLevel.full),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../../state/app/modules/app_modules.dart';
|
||||
import '../../../state/app/modules/settings/bloc/settings_cubit.dart';
|
||||
import '../../../storage/settings.dart' as model;
|
||||
import '../../../utils/haptics.dart';
|
||||
import '../../../widget/confirm_dialog.dart';
|
||||
import 'data/default_settings.dart';
|
||||
|
||||
@@ -23,6 +24,7 @@ class ModuleSortBody extends StatelessWidget {
|
||||
final modulesSettings = settings.val().modulesSettings;
|
||||
|
||||
void changeVisibility(Modules module) {
|
||||
Haptics.selection();
|
||||
var hidden = settings.val(write: true).modulesSettings.hiddenModules;
|
||||
if (hidden.contains(module)) {
|
||||
hidden.remove(module);
|
||||
@@ -48,9 +50,11 @@ class ModuleSortBody extends StatelessWidget {
|
||||
'Auf größeren Bildschirmen werden mehr Module direkt angezeigt',
|
||||
),
|
||||
value: modulesSettings.autoFillBottomBar,
|
||||
onChanged: (value) =>
|
||||
settings.val(write: true).modulesSettings.autoFillBottomBar =
|
||||
value,
|
||||
onChanged: (value) {
|
||||
Haptics.selection();
|
||||
settings.val(write: true).modulesSettings.autoFillBottomBar =
|
||||
value;
|
||||
},
|
||||
),
|
||||
if (!modulesSettings.autoFillBottomBar)
|
||||
ListTile(
|
||||
|
||||
@@ -2,7 +2,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../state/app/modules/settings/bloc/settings_cubit.dart';
|
||||
import '../../../../storage/haptic_settings.dart';
|
||||
import '../../../../theming/app_theme.dart';
|
||||
import '../../../../utils/haptics.dart';
|
||||
|
||||
class AppearanceSection extends StatelessWidget {
|
||||
const AppearanceSection({super.key});
|
||||
@@ -10,29 +12,83 @@ class AppearanceSection extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final settings = context.watch<SettingsCubit>();
|
||||
return ListTile(
|
||||
leading: const Icon(Icons.dark_mode_outlined),
|
||||
title: const Text('Farbgebung'),
|
||||
trailing: DropdownButton<ThemeMode>(
|
||||
value: settings.val().appTheme,
|
||||
icon: const Icon(Icons.arrow_drop_down),
|
||||
items: ThemeMode.values
|
||||
.map(
|
||||
(e) => DropdownMenuItem<ThemeMode>(
|
||||
value: e,
|
||||
enabled: e != settings.val().appTheme,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(AppTheme.getDisplayOptions(e).icon),
|
||||
const SizedBox(width: 10),
|
||||
Text(AppTheme.getDisplayOptions(e).displayName),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
onChanged: (e) => settings.val(write: true).appTheme = e!,
|
||||
),
|
||||
return Column(
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.dark_mode_outlined),
|
||||
title: const Text('Farbgebung'),
|
||||
trailing: DropdownButton<ThemeMode>(
|
||||
value: settings.val().appTheme,
|
||||
icon: const Icon(Icons.arrow_drop_down),
|
||||
items: ThemeMode.values
|
||||
.map(
|
||||
(e) => DropdownMenuItem<ThemeMode>(
|
||||
value: e,
|
||||
enabled: e != settings.val().appTheme,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(AppTheme.getDisplayOptions(e).icon),
|
||||
const SizedBox(width: 10),
|
||||
Text(AppTheme.getDisplayOptions(e).displayName),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
onChanged: (e) => settings.val(write: true).appTheme = e!,
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.vibration_outlined),
|
||||
title: const Text('Haptisches Feedback'),
|
||||
trailing: DropdownButton<HapticLevel>(
|
||||
value: settings.val().hapticSettings.level,
|
||||
icon: const Icon(Icons.arrow_drop_down),
|
||||
items: HapticLevel.values
|
||||
.map(
|
||||
(e) => DropdownMenuItem<HapticLevel>(
|
||||
value: e,
|
||||
enabled: e != settings.val().hapticSettings.level,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(_hapticIcon(e)),
|
||||
const SizedBox(width: 10),
|
||||
Text(_hapticLabel(e)),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
settings.val(write: true).hapticSettings.level = e!;
|
||||
// Sofortiges Probe-Feedback in der neu gewählten Stufe.
|
||||
Haptics.longPress();
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
IconData _hapticIcon(HapticLevel level) {
|
||||
switch (level) {
|
||||
case HapticLevel.off:
|
||||
return Icons.notifications_off_outlined;
|
||||
case HapticLevel.reduced:
|
||||
return Icons.notifications_paused_outlined;
|
||||
case HapticLevel.full:
|
||||
return Icons.notifications_active_outlined;
|
||||
}
|
||||
}
|
||||
|
||||
String _hapticLabel(HapticLevel level) {
|
||||
switch (level) {
|
||||
case HapticLevel.off:
|
||||
return 'Aus';
|
||||
case HapticLevel.reduced:
|
||||
return 'Reduziert';
|
||||
case HapticLevel.full:
|
||||
return 'Vollständig';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:hydrated_bloc/hydrated_bloc.dart';
|
||||
import '../../../../routing/app_routes.dart';
|
||||
import '../../../../state/app/modules/settings/bloc/settings_cubit.dart';
|
||||
import '../../../../storage/settings.dart' as model;
|
||||
import '../../../../utils/haptics.dart';
|
||||
import '../../../../widget/centered_leading.dart';
|
||||
import '../../../../widget/confirm_dialog.dart';
|
||||
import '../../../../widget/debug/cache_view.dart';
|
||||
@@ -45,12 +46,13 @@ class _DevToolsSectionState extends State<DevToolsSection> {
|
||||
title: const Text('Performance graph'),
|
||||
trailing: Checkbox(
|
||||
value: dev.showPerformanceOverlay,
|
||||
onChanged: (e) =>
|
||||
widget.settings
|
||||
.val(write: true)
|
||||
.devToolsSettings
|
||||
.showPerformanceOverlay =
|
||||
e!,
|
||||
onChanged: (e) {
|
||||
Haptics.selection();
|
||||
widget.settings
|
||||
.val(write: true)
|
||||
.devToolsSettings
|
||||
.showPerformanceOverlay = e!;
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
@@ -60,12 +62,13 @@ class _DevToolsSectionState extends State<DevToolsSection> {
|
||||
title: const Text('Indicate offscreen layers'),
|
||||
trailing: Checkbox(
|
||||
value: dev.checkerboardOffscreenLayers,
|
||||
onChanged: (e) =>
|
||||
widget.settings
|
||||
.val(write: true)
|
||||
.devToolsSettings
|
||||
.checkerboardOffscreenLayers =
|
||||
e!,
|
||||
onChanged: (e) {
|
||||
Haptics.selection();
|
||||
widget.settings
|
||||
.val(write: true)
|
||||
.devToolsSettings
|
||||
.checkerboardOffscreenLayers = e!;
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
@@ -73,12 +76,13 @@ class _DevToolsSectionState extends State<DevToolsSection> {
|
||||
title: const Text('Indicate raster cache images'),
|
||||
trailing: Checkbox(
|
||||
value: dev.checkerboardRasterCacheImages,
|
||||
onChanged: (e) =>
|
||||
widget.settings
|
||||
.val(write: true)
|
||||
.devToolsSettings
|
||||
.checkerboardRasterCacheImages =
|
||||
e!,
|
||||
onChanged: (e) {
|
||||
Haptics.selection();
|
||||
widget.settings
|
||||
.val(write: true)
|
||||
.devToolsSettings
|
||||
.checkerboardRasterCacheImages = e!;
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../state/app/modules/settings/bloc/settings_cubit.dart';
|
||||
import '../../../../utils/haptics.dart';
|
||||
|
||||
class FilesSection extends StatelessWidget {
|
||||
const FilesSection({super.key});
|
||||
@@ -16,8 +17,10 @@ class FilesSection extends StatelessWidget {
|
||||
title: const Text('Ordner in Dateien nach oben sortieren'),
|
||||
trailing: Checkbox(
|
||||
value: settings.val().fileSettings.sortFoldersToTop,
|
||||
onChanged: (e) =>
|
||||
settings.val(write: true).fileSettings.sortFoldersToTop = e!,
|
||||
onChanged: (e) {
|
||||
Haptics.selection();
|
||||
settings.val(write: true).fileSettings.sortFoldersToTop = e!;
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
@@ -25,12 +28,13 @@ class FilesSection extends StatelessWidget {
|
||||
title: const Text('Dateien immer mit Systemdialog öffnen'),
|
||||
trailing: Checkbox(
|
||||
value: settings.val().fileViewSettings.alwaysOpenExternally,
|
||||
onChanged: (e) =>
|
||||
settings
|
||||
.val(write: true)
|
||||
.fileViewSettings
|
||||
.alwaysOpenExternally =
|
||||
e!,
|
||||
onChanged: (e) {
|
||||
Haptics.selection();
|
||||
settings
|
||||
.val(write: true)
|
||||
.fileViewSettings
|
||||
.alwaysOpenExternally = e!;
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../notification/notify_updater.dart';
|
||||
import '../../../../state/app/modules/settings/bloc/settings_cubit.dart';
|
||||
import '../../../../utils/haptics.dart';
|
||||
import '../../../../widget/centered_leading.dart';
|
||||
import '../../../../widget/info_dialog.dart';
|
||||
|
||||
@@ -21,8 +22,10 @@ class TalkSection extends StatelessWidget {
|
||||
title: const Text('Favoriten im Talk nach oben sortieren'),
|
||||
trailing: Checkbox(
|
||||
value: talkSettings.sortFavoritesToTop,
|
||||
onChanged: (e) =>
|
||||
settings.val(write: true).talkSettings.sortFavoritesToTop = e!,
|
||||
onChanged: (e) {
|
||||
Haptics.selection();
|
||||
settings.val(write: true).talkSettings.sortFavoritesToTop = e!;
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
@@ -30,8 +33,10 @@ class TalkSection extends StatelessWidget {
|
||||
title: const Text('Ungelesene Chats nach oben sortieren'),
|
||||
trailing: Checkbox(
|
||||
value: talkSettings.sortUnreadToTop,
|
||||
onChanged: (e) =>
|
||||
settings.val(write: true).talkSettings.sortUnreadToTop = e!,
|
||||
onChanged: (e) {
|
||||
Haptics.selection();
|
||||
settings.val(write: true).talkSettings.sortUnreadToTop = e!;
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
@@ -43,6 +48,7 @@ class TalkSection extends StatelessWidget {
|
||||
trailing: Checkbox(
|
||||
value: notificationSettings.enabled,
|
||||
onChanged: (e) {
|
||||
Haptics.selection();
|
||||
if (e!) {
|
||||
NotifyUpdater.enableAfterDisclaimer(settings).asDialog(context);
|
||||
} else {
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../state/app/modules/settings/bloc/settings_cubit.dart';
|
||||
import '../../../../utils/haptics.dart';
|
||||
import '../../../../view/pages/timetable/data/timetable_name_mode.dart';
|
||||
|
||||
class TimetableSection extends StatelessWidget {
|
||||
@@ -46,12 +47,13 @@ class TimetableSection extends StatelessWidget {
|
||||
title: const Text('Doppelstunden zusammenhängend anzeigen'),
|
||||
trailing: Checkbox(
|
||||
value: timetableSettings.connectDoubleLessons,
|
||||
onChanged: (e) =>
|
||||
settings
|
||||
.val(write: true)
|
||||
.timetableSettings
|
||||
.connectDoubleLessons =
|
||||
e!,
|
||||
onChanged: (e) {
|
||||
Haptics.selection();
|
||||
settings
|
||||
.val(write: true)
|
||||
.timetableSettings
|
||||
.connectDoubleLessons = e!;
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -9,6 +9,7 @@ import '../../../../routing/app_routes.dart';
|
||||
import '../../../../share_intent/remote_file_ref.dart';
|
||||
import '../../../../state/app/modules/chat/bloc/chat_bloc.dart';
|
||||
import '../../../../utils/download_manager.dart';
|
||||
import '../../../../utils/haptics.dart';
|
||||
import '../../../../widget/confirm_dialog.dart';
|
||||
import '../../../../widget/info_dialog.dart';
|
||||
import '../data/chat_bubble_styles.dart';
|
||||
@@ -63,6 +64,7 @@ class _ChatBubbleState extends State<ChatBubble>
|
||||
|
||||
Offset _position = Offset.zero;
|
||||
Offset _dragStartPosition = Offset.zero;
|
||||
bool _swipeActionArmed = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -97,6 +99,7 @@ class _ChatBubbleState extends State<ChatBubble>
|
||||
if (job == null) return;
|
||||
final status = job.status.value;
|
||||
if (status is DownloadDone) {
|
||||
Haptics.success();
|
||||
DownloadManager.instance.clear(job.remotePath);
|
||||
_detachJob();
|
||||
final talkFile = message.file;
|
||||
@@ -197,13 +200,16 @@ class _ChatBubbleState extends State<ChatBubble>
|
||||
}
|
||||
}
|
||||
|
||||
void _showOptionsDialog() => showChatMessageOptionsDialog(
|
||||
context,
|
||||
chatData: widget.chatData,
|
||||
bubbleData: widget.bubbleData,
|
||||
isSender: widget.isSender,
|
||||
onRefetch: widget.refetch,
|
||||
);
|
||||
void _showOptionsDialog() {
|
||||
Haptics.longPress();
|
||||
showChatMessageOptionsDialog(
|
||||
context,
|
||||
chatData: widget.chatData,
|
||||
bubbleData: widget.bubbleData,
|
||||
isSender: widget.isSender,
|
||||
onRefetch: widget.refetch,
|
||||
);
|
||||
}
|
||||
|
||||
/// True only for messages whose body has a meaningful tap action (poll
|
||||
/// dialog or file download/cancel). For plain text messages we leave
|
||||
@@ -302,10 +308,16 @@ class _ChatBubbleState extends State<ChatBubble>
|
||||
? Offset(_position.dx, 0)
|
||||
: Offset(_position.dx + dx, 0);
|
||||
});
|
||||
// Beim Überqueren der Action-Schwelle einmalig Haptik feuern,
|
||||
// damit der User physisch spürt: "jetzt löst's beim Loslassen aus".
|
||||
final isArmed = _position.dx.abs() > 50;
|
||||
if (isArmed && !_swipeActionArmed) Haptics.longPress();
|
||||
_swipeActionArmed = isArmed;
|
||||
},
|
||||
onHorizontalDragEnd: (_) {
|
||||
final isAction = _position.dx.abs() > 50;
|
||||
setState(() => _position = Offset.zero);
|
||||
_swipeActionArmed = false;
|
||||
if (widget.bubbleData.isReplyable && isAction) {
|
||||
context.read<ChatBloc>().setReferenceMessageId(
|
||||
widget.bubbleData.id,
|
||||
|
||||
@@ -13,6 +13,7 @@ import '../../../../notification/notification_tasks.dart';
|
||||
import '../../../../routing/app_routes.dart';
|
||||
import '../../../../state/app/modules/chat/bloc/chat_bloc.dart';
|
||||
import '../../../../state/app/modules/chat_list/bloc/chat_list_bloc.dart';
|
||||
import '../../../../utils/haptics.dart';
|
||||
import '../../../../widget/async_action_button.dart';
|
||||
import '../../../../widget/confirm_dialog.dart';
|
||||
import '../../../../widget/debug/debug_tile.dart';
|
||||
@@ -166,6 +167,7 @@ class _ChatTileState extends State<ChatTile> {
|
||||
},
|
||||
onLongPress: () {
|
||||
if (widget.disableContextActions) return;
|
||||
Haptics.longPress();
|
||||
showDetailsBottomSheet(
|
||||
context,
|
||||
children: (sheetCtx) => [
|
||||
|
||||
@@ -242,7 +242,7 @@ class _DayColumn extends StatelessWidget {
|
||||
);
|
||||
if (_overlapsExistingAppointment(start, end, dayAppts)) return;
|
||||
|
||||
HapticFeedback.mediumImpact();
|
||||
Haptics.longPress();
|
||||
onCreateEvent!(start, end);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,11 +9,11 @@ import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:syncfusion_flutter_calendar/calendar.dart';
|
||||
|
||||
import '../../../../extensions/date_time.dart';
|
||||
import '../../../../utils/haptics.dart';
|
||||
import '../../../../widget/details_bottom_sheet.dart';
|
||||
import '../data/calendar_layout.dart';
|
||||
import '../data/calendar_logic.dart';
|
||||
|
||||
@@ -7,6 +7,7 @@ library;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../api/errors/error_mapper.dart';
|
||||
import '../utils/haptics.dart';
|
||||
import 'app_progress_indicator.dart';
|
||||
import 'info_dialog.dart';
|
||||
|
||||
|
||||
@@ -13,8 +13,10 @@ Future<bool> runWithErrorDialog(
|
||||
}) async {
|
||||
try {
|
||||
await action();
|
||||
Haptics.success();
|
||||
return true;
|
||||
} catch (e) {
|
||||
Haptics.error();
|
||||
if (!context.mounted) return false;
|
||||
final message = errorBuilder != null
|
||||
? errorBuilder(e)
|
||||
|
||||
@@ -66,9 +66,11 @@ class _AsyncMixinState extends State<_AsyncMixin> {
|
||||
);
|
||||
if (!mounted) return;
|
||||
if (success) {
|
||||
Haptics.success();
|
||||
widget.onSuccess?.call();
|
||||
} else if (widget.onError != null && _controller.error != null) {
|
||||
widget.onError!(_controller.error!);
|
||||
} else if (_controller.error != null) {
|
||||
Haptics.error();
|
||||
widget.onError?.call(_controller.error!);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../utils/haptics.dart';
|
||||
import 'async_action_button.dart';
|
||||
|
||||
class ConfirmDialog extends StatelessWidget {
|
||||
@@ -53,6 +54,7 @@ class ConfirmDialog extends StatelessWidget {
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Haptics.confirm();
|
||||
Navigator.of(context).pop();
|
||||
onConfirm!();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user