Files
zarzet 962e582acc chore(flutter): move to Flutter 3.50.0 and the material_ui packages
Flutter 3.50 deprecates its built-in Material and Cupertino libraries in
favour of the material_ui and cupertino_ui packages. The imports move
with the official fix (dart fix, migrate_design_widgets); the app's old
two-library theme bridge collapses into one Theme type.

- MaterialExpressiveScope keeps the complete host theme nearest its
  child. The reduced copy made for the expressive widgets now shares the
  app's Theme type and would hide component themes and extensions.
- LegacyThemeBrightness hands the brightness to the glass package, which
  still reads Flutter's built-in theme.
- appLocalizationsDelegates lists the material_ui localization delegates;
  the generated list still names the built-in ones.
- Tests: findByTooltip and pageBack replace the flutter_test helpers that
  only know the built-in widgets, and several tests that had gone stale
  against earlier app changes are repaired.
2026-11-15 23:33:29 +07:00

71 lines
2.3 KiB
Dart

import 'dart:async';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:mornye/controllers/open_audio_controller.dart';
import 'package:mornye/l10n/l10n.dart';
import 'package:mornye/widgets/app_icon_button.dart';
import 'package:mornye/widgets/desktop/context_menu.dart';
import 'package:mornye/widgets/app_snack_bar.dart';
Future<void> pickOpenAudio(
BuildContext context,
WidgetRef ref, {
required bool folder,
}) async {
try {
final controller = ref.read(openAudioControllerProvider.notifier);
if (folder) {
await controller.pickFolder();
} else {
await controller.pickFiles();
}
} catch (error) {
if (context.mounted) showCannotOpenFileSnackBar(context, error);
}
}
/// A direct playback entry point, separate from adding a Library source.
class OpenAudioButton extends ConsumerWidget {
const OpenAudioButton({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final busy = ref.watch(openAudioControllerProvider);
return AppIconButton(
icon: const Icon(Icons.folder_open_outlined),
tooltip: context.l10n.openAudio,
onPressed: busy
? null
: () {
final box = context.findRenderObject()! as RenderBox;
unawaited(
showContextMenu(
context,
position: box.localToGlobal(Offset(0, box.size.height)),
origin: contextMenuOriginOf(context),
groups: [
[
ContextMenuAction(
icon: Icons.audio_file_outlined,
label: context.l10n.openAudioFiles,
onSelected: () => unawaited(
pickOpenAudio(context, ref, folder: false),
),
),
ContextMenuAction(
icon: Icons.folder_open_outlined,
label: context.l10n.openAudioFolder,
onSelected: () => unawaited(
pickOpenAudio(context, ref, folder: true),
),
),
],
],
),
);
},
);
}
}