immich/mobile/lib/presentation/actions/asset_debug.action.dart
shenlong fe5c8ed0fb
refactor: base action (#29617)
* refactor: existing actions to new structure

# Conflicts:
#	mobile/lib/presentation/actions/action.widget.dart
#	mobile/lib/presentation/widgets/action_buttons/favorite_action_button.widget.dart
#	mobile/lib/presentation/widgets/action_buttons/unfavorite_action_button.widget.dart
#	mobile/test/unit/presentation/partner_page_test.dart

* rename to actionitem

* more cleanup

* review changes

* lint changes

---------

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
2026-07-30 17:02:14 -04:00

28 lines
1 KiB
Dart

import 'dart:async';
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/generated/translations.g.dart';
import 'package:immich_mobile/presentation/actions/action.dart';
import 'package:immich_mobile/providers/infrastructure/setting.provider.dart';
import 'package:immich_mobile/routing/router.dart';
class AssetDebugAction extends AssetActionBuilder {
const AssetDebugAction({required super.source});
@override
ActionItem? create(BuildContext context, WidgetRef ref) {
final assets = ref.watch(assetsActionProvider(source)).assets;
final troubleshootEnabled = ref.watch(settingsProvider.notifier).get(.advancedTroubleshooting);
if (!troubleshootEnabled || assets.length != 1) {
return null;
}
return .new(
icon: Icons.help_outline_rounded,
label: context.t.troubleshoot,
onAction: () => unawaited(context.pushRoute(AssetTroubleshootRoute(asset: assets.single))),
);
}
}