-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Handle error message on displays
- Loading branch information
Showing
8 changed files
with
120 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | ||
import 'package:wrestling_scoreboard_client/services/network/remote/rest.dart'; | ||
|
||
class OkDialog extends StatelessWidget { | ||
final Widget child; | ||
|
||
const OkDialog({required this.child, super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final localizations = AppLocalizations.of(context)!; | ||
return AlertDialog( | ||
content: SizedBox( | ||
width: 300, | ||
child: child, | ||
), | ||
actions: <Widget>[ | ||
TextButton( | ||
onPressed: () => Navigator.pop(context), | ||
child: Text(localizations.ok), | ||
), | ||
], | ||
); | ||
} | ||
} | ||
|
||
class OkCancelDialog<T extends Object?> extends StatelessWidget { | ||
final Widget child; | ||
final T Function() getResult; | ||
|
||
const OkCancelDialog({required this.child, required this.getResult, super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final localizations = AppLocalizations.of(context)!; | ||
return AlertDialog( | ||
content: SizedBox( | ||
width: 300, | ||
child: child, | ||
), | ||
actions: <Widget>[ | ||
TextButton( | ||
onPressed: () => Navigator.pop(context), | ||
child: Text(localizations.cancel), | ||
), | ||
TextButton( | ||
onPressed: () => Navigator.pop(context, getResult()), | ||
child: Text(localizations.ok), | ||
), | ||
], | ||
); | ||
} | ||
} | ||
|
||
Future<void> showExceptionDialog({required BuildContext context, required Exception exception}) async { | ||
final localizations = AppLocalizations.of(context)!; | ||
await showDialog( | ||
context: context, | ||
builder: (context) => OkDialog( | ||
child: Column( | ||
children: [ | ||
if (exception is RestException) SelectableText(localizations.invalidParameterException), | ||
SelectableText( | ||
exception.toString(), | ||
style: TextStyle(color: Theme.of(context).disabledColor, fontSize: 10), | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
wrestling_scoreboard_client/lib/view/widgets/ok_dialog.dart
This file was deleted.
Oops, something went wrong.