Skip to content

Commit

Permalink
fix(macOS): Traffic light reset after showing file seletor (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
XMLHexagram authored Dec 4, 2024
1 parent 6b4d96b commit 22fb4da
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/screens/home/widgets/welcome.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import 'dart:io';
import 'package:provider/provider.dart';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:file_selector/file_selector.dart';
import 'package:permission_handler/permission_handler.dart';

import '../../../utils/ax_shadow.dart';
import '../../../utils/dialogs/failed_to_initialize_library.dart';
import '../../../providers/library_path.dart';
import '../../../providers/library_manager.dart';
import '../../../providers/responsive_providers.dart';
import '../../../utils/get_dir_path.dart';
import '../../../utils/l10n.dart';

class WelcomePage extends StatelessWidget {
Expand Down Expand Up @@ -79,7 +79,7 @@ class WelcomePage extends StatelessWidget {
// on Android, check for permission
if (!await requestAndroidPermission()) return;

final path = await getDirectoryPath();
final path = await getDirPath();

if (path == null) return;
if (!context.mounted) return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:provider/provider.dart';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:file_selector/file_selector.dart';
import 'package:material_symbols_icons/symbols.dart';

import '../../../utils/api/close_library.dart';
import '../../../utils/get_dir_path.dart';
import '../../../utils/router/navigation.dart';
import '../../../utils/dialogs/failed_to_initialize_library.dart';
import '../../../providers/library_manager.dart';
Expand Down Expand Up @@ -33,7 +33,7 @@ class AddLibrarySettingButton extends StatelessWidget {
title: S.of(context).addLibrary,
subtitle: S.of(context).addLibrarySubtitle,
onPressed: () async {
final path = await getDirectoryPath();
final path = await getDirPath();

if (path == null) return;
if (!context.mounted) return;
Expand Down
15 changes: 15 additions & 0 deletions lib/utils/get_dir_path.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'dart:io';

import 'package:file_selector/file_selector.dart';

import 'macos_window_control_button_manager.dart';

// TODO(hexagram): This is a temporary solution, not the best way to handle this callback.
// Once BitsdojoWindow is forked and rewritten, using NSWindowDelagate to listen for windowDidEndSheet and windowWillBeginSheet will be a more general andbetter solution to handle this.
Future<String?> getDirPath() async {
final path = await getDirectoryPath();
if (Platform.isMacOS) {
MacOSWindowControlButtonManager.setVertical();
}
return path;
}

0 comments on commit 22fb4da

Please sign in to comment.