-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into ben-improve-emoji-ux
- Loading branch information
Showing
52 changed files
with
1,391 additions
and
650 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Chat: fix bug where text disappears when try to tap on field in edit/reply state. |
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
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
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,217 @@ | ||
import 'package:acter/common/toolkit/errors/util.dart'; | ||
import 'package:acter/features/bug_report/actions/open_bug_report.dart'; | ||
import 'package:acter/features/bug_report/providers/bug_report_providers.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:quickalert/widgets/quickalert_buttons.dart'; | ||
import 'package:quickalert/widgets/quickalert_container.dart'; | ||
import 'package:quickalert/models/quickalert_options.dart'; | ||
import 'package:quickalert/quickalert.dart'; | ||
import 'package:flutter_gen/gen_l10n/l10n.dart'; | ||
|
||
class ActerErrorDialog extends StatelessWidget { | ||
static const retryBtn = Key('error-dialog-retry-btn'); | ||
|
||
final Object error; | ||
final StackTrace stack; | ||
final VoidCallback? onRetryTap; | ||
|
||
final String? title; | ||
final String? text; | ||
final String Function(Object error)? textBuilder; | ||
final bool includeBugReportButton; | ||
|
||
/// Dialog Border Radius | ||
final double borderRadius; | ||
|
||
const ActerErrorDialog({ | ||
super.key, | ||
required this.error, | ||
required this.stack, | ||
this.onRetryTap, | ||
this.title, | ||
this.text, | ||
this.textBuilder, | ||
this.includeBugReportButton = true, | ||
this.borderRadius = 15.0, | ||
}); | ||
|
||
static Future show({ | ||
/// BuildContext | ||
required BuildContext context, | ||
required Object error, | ||
required StackTrace stack, | ||
|
||
/// Title of the dialog | ||
String? title, | ||
|
||
/// Text of the dialog | ||
String? text, | ||
VoidCallback? onRetryTap, | ||
String Function(Object error)? textBuilder, | ||
bool includeBugReportButton = true, | ||
|
||
/// Dialog Border Radius | ||
double borderRadius = 15.0, | ||
}) { | ||
return showGeneralDialog( | ||
context: context, | ||
pageBuilder: (context, anim1, __) => ActerErrorDialog( | ||
error: error, | ||
stack: stack, | ||
title: title, | ||
text: text, | ||
textBuilder: textBuilder, | ||
onRetryTap: onRetryTap, | ||
borderRadius: borderRadius, | ||
includeBugReportButton: includeBugReportButton, | ||
), | ||
); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return AlertDialog( | ||
contentPadding: EdgeInsets.zero, | ||
shape: RoundedRectangleBorder( | ||
borderRadius: BorderRadius.circular(borderRadius), | ||
), | ||
content: errorDialog(context), | ||
); | ||
} | ||
|
||
Widget errorDialog(BuildContext context) { | ||
final theme = Theme.of(context); | ||
final lang = L10n.of(context); | ||
final err = ErrorCode.guessFromError(error); | ||
QuickAlertOptions options = QuickAlertOptions( | ||
title: title ?? | ||
switch (err) { | ||
ErrorCode.notFound => lang.notFound, | ||
_ => lang.fatalError, | ||
}, | ||
text: text ?? (textBuilder != null ? textBuilder!(error) : null), | ||
type: switch (err) { | ||
ErrorCode.notFound => QuickAlertType.warning, | ||
_ => QuickAlertType.error, | ||
}, | ||
showCancelBtn: true, | ||
showConfirmBtn: false, | ||
cancelBtnText: lang.back, | ||
borderRadius: borderRadius, | ||
); | ||
if (onRetryTap != null) { | ||
options.showConfirmBtn = true; | ||
options.confirmBtnColor = theme.primaryColor; | ||
options.confirmBtnText = lang.retry; | ||
options.onConfirmBtnTap = () { | ||
onRetryTap!(); | ||
}; | ||
} | ||
|
||
return _ActerErrorAlert( | ||
error: error, | ||
stack: stack, | ||
options: options, | ||
includeBugReportButton: includeBugReportButton, | ||
); | ||
} | ||
} | ||
|
||
class _ActerErrorAlert extends QuickAlertContainer { | ||
final bool includeBugReportButton; | ||
final Object error; | ||
final StackTrace stack; | ||
|
||
const _ActerErrorAlert({ | ||
required super.options, | ||
required this.error, | ||
required this.stack, | ||
this.includeBugReportButton = true, | ||
}); | ||
|
||
@override | ||
Widget buildButtons() { | ||
return _ActerErrorActionButtons(options: options); | ||
} | ||
|
||
@override | ||
Widget buildHeader(context) { | ||
final orginalHeader = super.buildHeader(context); | ||
if (!includeBugReportButton || !isBugReportingEnabled) { | ||
return orginalHeader; | ||
} | ||
return Stack( | ||
children: [ | ||
orginalHeader, | ||
Positioned( | ||
right: 10, | ||
top: 10, | ||
child: TextButton( | ||
child: Text(L10n.of(context).reportBug), | ||
onPressed: () => openBugReport( | ||
context, | ||
queryParams: { | ||
'error': error.toString(), | ||
'stack': stack.toString(), | ||
}, | ||
), | ||
), | ||
), | ||
], | ||
); | ||
} | ||
} | ||
|
||
class _ActerErrorActionButtons extends QuickAlertButtons { | ||
const _ActerErrorActionButtons({required super.options}); | ||
|
||
@override | ||
Widget buildButton({ | ||
BuildContext? context, | ||
required bool isOkayBtn, | ||
required String text, | ||
VoidCallback? onTap, | ||
}) { | ||
final btnText = Text( | ||
text, | ||
style: defaultTextStyle(isOkayBtn), | ||
); | ||
if (isOkayBtn) { | ||
return buildOkayBtn(context: context, btnText: btnText, onTap: onTap); | ||
} | ||
return buildCancelBtn(btnText: btnText, onTap: onTap); | ||
} | ||
|
||
Widget buildOkayBtn({ | ||
BuildContext? context, | ||
required Widget btnText, | ||
VoidCallback? onTap, | ||
}) { | ||
return MaterialButton( | ||
key: ActerErrorDialog.retryBtn, | ||
shape: RoundedRectangleBorder( | ||
borderRadius: BorderRadius.circular(15.0), | ||
), | ||
color: options.confirmBtnColor ?? Theme.of(context!).primaryColor, | ||
onPressed: onTap, | ||
child: Center( | ||
child: Padding( | ||
padding: const EdgeInsets.all(7.5), | ||
child: btnText, | ||
), | ||
), | ||
); | ||
} | ||
|
||
Widget buildCancelBtn({ | ||
required Widget btnText, | ||
VoidCallback? onTap, | ||
}) { | ||
return GestureDetector( | ||
onTap: onTap, | ||
child: Center( | ||
child: btnText, | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.