Skip to content

Commit

Permalink
chore: update formatting to line length 90
Browse files Browse the repository at this point in the history
  • Loading branch information
Merrit committed Sep 6, 2024
1 parent a0c458c commit f9b3410
Show file tree
Hide file tree
Showing 19 changed files with 48 additions and 60 deletions.
10 changes: 8 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,11 @@
"git.ignoredRepositories": [
"packaging/linux/flatpak/shared-modules"
],
"git.detectSubmodules": false
}
"git.detectSubmodules": false,
"dart.lineLength": 90,
"[dart]": {
"editor.rulers": [
90
]
}
}
3 changes: 1 addition & 2 deletions lib/app/cubit/app_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ Otherwise, [consider signing in using X11 instead](https://docs.fedoraproject.or
runningVersion: versionInfo.currentVersion,
updateVersion: versionInfo.latestVersion,
updateAvailable: versionInfo.updateAvailable,
showUpdateButton:
(defaultTargetPlatform.isDesktop && versionInfo.updateAvailable),
showUpdateButton: (defaultTargetPlatform.isDesktop && versionInfo.updateAvailable),
));
}

Expand Down
2 changes: 1 addition & 1 deletion lib/apps_list/apps_list_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class _FloatingActionButton extends StatelessWidget {
? BlocBuilder<ThemeCubit, ThemeState>(
builder: (context, state) {
return FloatingActionButton(
backgroundColor: (state.appTheme == AppTheme.pitchBlack)
backgroundColor: (state.appTheme == AppTheme.pitchBlack) //
? Colors.black
: null,
onPressed: () {
Expand Down
3 changes: 1 addition & 2 deletions lib/apps_list/widgets/custom_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ class _WaylandWarningButton extends StatelessWidget {

return IconButton(
icon: const Icon(Icons.warning),
onPressed: () =>
_showWarningDialog(context, state.linuxSessionMessage!),
onPressed: () => _showWarningDialog(context, state.linuxSessionMessage!),
);
},
);
Expand Down
3 changes: 1 addition & 2 deletions lib/core/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ const String websiteUrl = 'https://nyrna.merritt.codes/';
///
/// This is distinct from the package name the Microsoft Store uses, and is
/// required for some things like creating shortcuts.
const String kWindowsAppPackageName =
'33694MerrittCodes.Nyrna_9kjrd3yy77d9e!nyrna';
const String kWindowsAppPackageName = '33694MerrittCodes.Nyrna_9kjrd3yy77d9e!nyrna';
4 changes: 1 addition & 3 deletions lib/core/widgets/input_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ Future<String?> showInputDialog({
keyboardType = TextInputType.number;
break;
case InputDialogs.onlyDouble:
formatter = [
FilteringTextInputFormatter.allow(RegExp(r'^(\d+)?\.?\d{0,2}'))
];
formatter = [FilteringTextInputFormatter.allow(RegExp(r'^(\d+)?\.?\d{0,2}'))];
keyboardType = TextInputType.number;
break;
case InputDialogs.multiLine:
Expand Down
3 changes: 1 addition & 2 deletions lib/hotkey/global/hotkey_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ class HotkeyService {
/// Stream that fires when a hotkey is triggered.
///
/// Allows dependent services to react when a hotkey is triggered.
Stream<HotKey> get hotkeyTriggeredStream =>
_hotkeyTriggeredStreamController.stream;
Stream<HotKey> get hotkeyTriggeredStream => _hotkeyTriggeredStreamController.stream;

/// Controller for the hotkey triggered stream.
final _hotkeyTriggeredStreamController = StreamController<HotKey>.broadcast();
Expand Down
12 changes: 5 additions & 7 deletions lib/logs/log_file_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class LogFileService {

final List<FileSystemEntity> files = _logDir.listSync();

final List<File> logFiles = files
final List<File> logFiles = files //
.whereType<File>()
.where((file) => file.path.endsWith('.txt'))
.toList();
Expand Down Expand Up @@ -135,8 +135,7 @@ $currentTime
Future<void> _deleteOldLogFiles() async {
final List<File> logFiles = await getAllLogFiles()
// Remove any numbered log files.
..removeWhere(
(file) => file.path.split(Platform.pathSeparator).last.contains('_'));
..removeWhere((file) => file.path.split(Platform.pathSeparator).last.contains('_'));

if (logFiles.length <= 7) {
return;
Expand All @@ -160,8 +159,8 @@ $currentTime
}

// Remove any log files that are not numbered.
todayLogFiles.removeWhere((file) =>
file.path.split(Platform.pathSeparator).last.contains('_') == false);
todayLogFiles.removeWhere(
(file) => file.path.split(Platform.pathSeparator).last.contains('_') == false);

final int highestNumber = todayLogFiles
.map((file) => int.parse(file.path.split('_').last.split('.').first))
Expand Down Expand Up @@ -195,8 +194,7 @@ $currentTime
final int highestNumber = _getHighestNumber(todayLogFiles);
final String newFileName = '${_today}_${highestNumber + 1}.txt';

final File newLogFile =
File('${_logDir.path}${Platform.pathSeparator}$newFileName');
final File newLogFile = File('${_logDir.path}${Platform.pathSeparator}$newFileName');

await newLogFile.create();

Expand Down
4 changes: 2 additions & 2 deletions lib/native_platform/src/linux/linux.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ class Linux implements NativePlatform {

// Which virtual desktop this window is on.
final windowDesktop = int.tryParse(parts[1]);
final windowOnCurrentDesktop = (windowDesktop == _desktop ||
windowDesktop == _kStickyWindowIdentifier);
final windowOnCurrentDesktop =
(windowDesktop == _desktop || windowDesktop == _kStickyWindowIdentifier);
if (!windowOnCurrentDesktop && !showHidden) return null;

final pid = int.tryParse(parts[2]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ class Win32ProcessRepository extends ProcessRepository {
/// Load the native library.
final String nativeLibraryPath;
if (kReleaseMode) {
nativeLibraryPath =
r'data\flutter_assets\assets\lib\windows\NativeLibrary.dll';
nativeLibraryPath = r'data\flutter_assets\assets\lib\windows\NativeLibrary.dll';
} else {
nativeLibraryPath = r'assets\lib\windows\NativeLibrary.dll';
}
Expand Down
3 changes: 1 addition & 2 deletions lib/native_platform/src/win32/ffi/user32.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ final _user32 = DynamicLibrary.open('user32.dll');
int GetWindowThreadProcessId(int hWnd, Pointer<Uint32> lpdwProcessId) {
final _GetWindowThreadProcessId = _user32.lookupFunction<
Uint32 Function(Int32 hWnd, Pointer<Uint32> lpdwProcessId),
int Function(
int hWnd, Pointer<Uint32> lwpdProcessId)>('GetWindowThreadProcessId');
int Function(int hWnd, Pointer<Uint32> lwpdProcessId)>('GetWindowThreadProcessId');
return _GetWindowThreadProcessId(hWnd, lpdwProcessId);
}
4 changes: 3 additions & 1 deletion lib/native_platform/src/win32/win32.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ class WindowBuilder {
/// duration of the current isolate's lifetime."
/// https://api.flutter.dev/flutter/dart-ffi/Pointer/fromFunction.html
static final _callback = Pointer.fromFunction<EnumWindowsProc>(
WindowBuilder.enumWindowsCallback, 0);
WindowBuilder.enumWindowsCallback,
0,
);

/// Callback for each window found by `EnumWindows()`.
///
Expand Down
12 changes: 5 additions & 7 deletions lib/settings/cubit/settings_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,12 @@ class SettingsCubit extends Cubit<SettingsState> {
hotkey = defaultHotkey;
}

final bool minimizeWindows =
await storage.getValue('minimizeWindows') ?? true;
final bool minimizeWindows = await storage.getValue('minimizeWindows') ?? true;
final bool pinSuspendedWindows =
await storage.getValue('pinSuspendedWindows') ?? false;
final int refreshInterval = await storage.getValue('refreshInterval') ?? 5;
final bool showHiddenWindows =
await storage.getValue('showHiddenWindows') ?? false;
final bool startHiddenInTray =
await storage.getValue('startHiddenInTray') ?? false;
final bool showHiddenWindows = await storage.getValue('showHiddenWindows') ?? false;
final bool startHiddenInTray = await storage.getValue('startHiddenInTray') ?? false;

return SettingsCubit._(
autostartService,
Expand Down Expand Up @@ -165,7 +162,8 @@ class SettingsCubit extends Cubit<SettingsState> {
final AppSpecificHotkey appSpecificHotkey =
state.appSpecificHotKeys.firstWhere((e) => e.executable == executable);

final List<AppSpecificHotkey> appSpecificHotkeys = state.appSpecificHotKeys
final List<AppSpecificHotkey> appSpecificHotkeys = state //
.appSpecificHotKeys
.where((e) => e.executable != executable)
.toList();

Expand Down
3 changes: 1 addition & 2 deletions lib/settings/widgets/behaviour_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ class _PinSuspendedWindowsTile extends StatelessWidget {
),
WidgetSpan(
child: Tooltip(
message:
AppLocalizations.of(context)!.pinSuspendedWindowsTooltip,
message: AppLocalizations.of(context)!.pinSuspendedWindowsTooltip,
child: const Icon(
Icons.help_outline,
size: 18,
Expand Down
11 changes: 6 additions & 5 deletions lib/settings/widgets/integration_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,9 @@ class _AppSpecificHotkeys extends StatelessWidget {
backgroundColor: Colors.grey.shade700,
padding: const EdgeInsets.all(10),
),
onPressed: () => settingsCubit
.removeAppSpecificHotkey(hotkey.executable),
onPressed: () => settingsCubit.removeAppSpecificHotkey(
hotkey.executable,
),
child: const Icon(Icons.delete),
),
),
Expand Down Expand Up @@ -299,7 +300,8 @@ class _AddAppSpecificHotkeyDialog extends StatelessWidget {
return AlertDialog(
content: BlocBuilder<AppsListCubit, AppsListState>(
builder: (context, state) {
final executables = state.windows
final executables = state //
.windows
.map((window) => window.process.executable)
.toSet()
.toList();
Expand Down Expand Up @@ -354,8 +356,7 @@ class _RecordAppSpecificHotkeyDialog extends StatefulWidget {
_RecordAppSpecificHotkeyDialogState();
}

class _RecordAppSpecificHotkeyDialogState
extends State<_RecordAppSpecificHotkeyDialog> {
class _RecordAppSpecificHotkeyDialogState extends State<_RecordAppSpecificHotkeyDialog> {
HotKey? _hotKey;

@override
Expand Down
16 changes: 6 additions & 10 deletions test/active_window/src/active_window_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,9 @@ void main() {

test('explorer.exe executable aborts on Win32', () async {
debugDefaultTargetPlatformOverride = TargetPlatform.windows;
when(nativePlatform.activeWindow())
.thenAnswer((_) async => testWindow.copyWith(
process: testProcess.copyWith(executable: 'explorer.exe'),
));
when(nativePlatform.activeWindow()).thenAnswer((_) async => testWindow.copyWith(
process: testProcess.copyWith(executable: 'explorer.exe'),
));
final successful = await activeWindow.toggle();
expect(successful, false);
verifyNever(processRepository.suspend(any));
Expand Down Expand Up @@ -135,18 +134,15 @@ void main() {
verifyNever(nativePlatform.minimizeWindow(any));
});

test('no-minimize flag received & no preference does not minimize',
() async {
test('no-minimize flag received & no preference does not minimize', () async {
when(argParser.minimize).thenReturn(false);
final successful = await activeWindow.toggle();
expect(successful, true);
verifyNever(nativePlatform.minimizeWindow(any));
});

test('no-minimize flag received & preference=true does not minimize',
() async {
when(storageRepository.getValue('minimizeWindows'))
.thenAnswer((_) async => true);
test('no-minimize flag received & preference=true does not minimize', () async {
when(storageRepository.getValue('minimizeWindows')).thenAnswer((_) async => true);
when(argParser.minimize).thenReturn(false);
final successful = await activeWindow.toggle();
expect(successful, true);
Expand Down
3 changes: 1 addition & 2 deletions test/app/cubit/app_cubit_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ void main() {
reset(mockSystemTrayManager);
reset(mockUpdateService);

when(mockUpdateService.getVersionInfo())
.thenAnswer((_) async => VersionInfo.empty());
when(mockUpdateService.getVersionInfo()).thenAnswer((_) async => VersionInfo.empty());

cubit = AppCubit(
mockAppWindow,
Expand Down
3 changes: 1 addition & 2 deletions test/apps_list/widgets/window_tile_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ void main() {
when(mockSettingsCubit.state).thenReturn(SettingsState.initial());
});

testWidgets('Clicking more actions button shows context menu',
(tester) async {
testWidgets('Clicking more actions button shows context menu', (tester) async {
final appsListCubit = AppsListCubit(
appVersion: mockAppVersion,
hotkeyService: mockHotkeyService,
Expand Down
6 changes: 2 additions & 4 deletions test/theme/cubit/theme_cubit_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,12 @@ void main() {
});

test('saved dark theme preference loads dark theme', () async {
when(mockStorageRepo.getValue('appTheme'))
.thenAnswer((_) async => 'AppTheme.dark');
when(mockStorageRepo.getValue('appTheme')).thenAnswer((_) async => 'AppTheme.dark');
cubit = await ThemeCubit.init(mockStorageRepo);
expect(state.appTheme, AppTheme.dark);
});

test('saved pitch black theme preference loads pitch black theme',
() async {
test('saved pitch black theme preference loads pitch black theme', () async {
when(mockStorageRepo.getValue('appTheme'))
.thenAnswer((_) async => 'AppTheme.pitchBlack');
cubit = await ThemeCubit.init(mockStorageRepo);
Expand Down

0 comments on commit f9b3410

Please sign in to comment.