Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #229

Merged
merged 5 commits into from
Oct 14, 2024
Merged

Dev #229

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,49 @@ assignees: ''

---

**Describe the bug**
<!-- !!! -->
<!-- Before submitting a bug report, please read the troubleshooting guide at https://nyrna.merritt.codes/docs/troubleshooting -->
<!-- !!! -->

### Description
A clear and concise description of what the bug is.

**To Reproduce**
### To Reproduce
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
### Expected behavior
A clear and concise description of what you expected to happen.

**Screenshots**
### Screenshots
If applicable, add screenshots to help explain your problem.

**System Information:**
### System Information
- OS: [e.g. Linux, Windows]
- Desktop Environment (if on Linux): [e.g. KDE, GNOME]
- Nyrna Version [e.g. 2.23.0]

**Application or game affected:**
### Application or game affected
If applicable, list the affected program(s).

**Additional context**
### Logs
- Enable verbose logging in the settings, or by launching Nyrna with the
`--verbose` flag.
- Reproduce the issue.
- Copy the logs from the terminal output or from `Settings` -> `Logs`.
- Paste the logs here:

<details>
<summary>Logs</summary>

```
Paste logs here
```

</details>

### Additional context
Add any other context about the problem here.
68 changes: 31 additions & 37 deletions lib/apps_list/apps_list_page.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
Expand Down Expand Up @@ -100,55 +101,48 @@ class _AppsListPageState extends State<AppsListPage> {

// Show a MaterialBanner with the error message.
void showErrorBanner(BuildContext context, AppsListState state) {
final interactionError = state.interactionErrors.first;

final Window? window = context.read<AppsListCubit>().state.windows.firstWhereOrNull(
(window) => window.id == interactionError.windowId,
);

String errorMessageText =
'Encountered a problem attempting to ${interactionError.interactionType.name} ';

if (window != null) {
errorMessageText += window.process.executable;
}

ScaffoldMessenger.of(context).showMaterialBanner(
MaterialBanner(
leading: const Icon(Icons.error, color: Colors.red),
content: const Text('There was an error...'),
content: Text(errorMessageText),
actions: <Widget>[
TextButton(
onPressed: () {
context.read<AppsListCubit>().clearInteractionErrors();
ScaffoldMessenger.of(context).clearMaterialBanners();
},
child: const Text('Dismiss'),
),
FilledButton(
onPressed: () async {
final scaffoldMessenger = ScaffoldMessenger.of(context);
final appsListCubit = context.read<AppsListCubit>();

// Show a dialog with the error message.
await showDialog(
context: context,
builder: (context) {
return AlertDialog(
actionsPadding: const EdgeInsets.all(8),
title: const Text('Error'),
icon: const Icon(Icons.error, color: Colors.red),
scrollable: true,
content: NyrnaErrorMessage(state.interactionErrors.first),
actions: <Widget>[
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('Close'),
),
TextButton(
onPressed: () {
context.read<AppsListCubit>().clearInteractionErrors();
Navigator.pop(context);
},
child: const Text('Dismiss'),
),
],
);
},
final launched = await AppCubit.instance.launchURL(
kTroubleshootingGuideUrl,
);

if (appsListCubit.state.interactionErrors.isEmpty) {
scaffoldMessenger.clearMaterialBanners();
if (!launched) {
scaffoldMessenger.showSnackBar(
const SnackBar(
content: Text('Error launching browser'),
),
);
}
},
child: const Text('OPEN'),
),
TextButton(
onPressed: () {
context.read<AppsListCubit>().clearInteractionErrors();
ScaffoldMessenger.of(context).clearMaterialBanners();
},
child: const Text('DISMISS'),
child: const Text('Troubleshooting guide'),
),
],
),
Expand Down
7 changes: 5 additions & 2 deletions lib/apps_list/cubit/apps_list_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class AppsListCubit extends Cubit<AppsListState> {
window = await _refreshWindowProcess(window);
log.i('Window after interaction: $window');

if (!successful) await _addInteractionError(window, interaction);
if (!successful) await addInteractionError(window, interaction);

// Create a copy of the state of windows, with this window's info refreshed.
final windows = [...state.windows];
Expand Down Expand Up @@ -327,7 +327,10 @@ class AppsListCubit extends Cubit<AppsListState> {
}

/// Refresh the process status and add an [InteractionError].
Future<void> _addInteractionError(
///
/// Visible so it can be used by the debug menu.
@visibleForTesting
Future<void> addInteractionError(
Window window,
InteractionType interaction,
) async {
Expand Down
41 changes: 41 additions & 0 deletions lib/apps_list/widgets/custom_app_bar.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
Expand Down Expand Up @@ -46,6 +47,7 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
actions: [
updateAvailableButton,
const _WaylandWarningButton(),
const _DebugButton(),
settingsButton,
],
);
Expand Down Expand Up @@ -208,3 +210,42 @@ class _WaylandWarningButton extends StatelessWidget {
);
}
}

/// A button that shows the debug menu.
class _DebugButton extends StatelessWidget {
const _DebugButton();

@override
Widget build(BuildContext context) {
if (!kDebugMode) return const SizedBox();

final appsListCubit = context.read<AppsListCubit>();

return MenuAnchor(
builder: (context, controller, child) {
return IconButton(
onPressed: () {
if (controller.isOpen) {
controller.close();
} else {
controller.open();
}
},
icon: const Icon(Icons.bug_report),
);
},
menuChildren: [
MenuItemButton(
child: const Text('Add Interaction Error'),
onPressed: () async {
// ignore: invalid_use_of_visible_for_testing_member
await appsListCubit.addInteractionError(
appsListCubit.state.windows.first,
InteractionType.suspend,
);
},
),
],
);
}
}
79 changes: 0 additions & 79 deletions lib/apps_list/widgets/nyrna_error_message.dart

This file was deleted.

1 change: 0 additions & 1 deletion lib/apps_list/widgets/widgets.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export 'custom_app_bar.dart';
export 'first_run_dialog.dart';
export 'nyrna_error_message.dart';
export 'window_tile.dart';
3 changes: 3 additions & 0 deletions lib/core/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const String kMicrosoftStorePackageName = '33694MerrittCodes.Nyrna';

const String kPackageId = 'codes.merritt.Nyrna';

const String kTroubleshootingGuideUrl =
'https://nyrna.merritt.codes/docs/troubleshooting';

const String websiteUrl = 'https://nyrna.merritt.codes/';

/// The app's package name / identifier that Windows uses when installed from
Expand Down
Loading
Loading