Skip to content

Commit

Permalink
Improve style for error dialog (#2136)
Browse files Browse the repository at this point in the history
  • Loading branch information
nqhhdev authored Nov 20, 2024
1 parent 65bdb06 commit becacdd
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 9 deletions.
47 changes: 39 additions & 8 deletions lib/utils/dialog/twake_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';
import 'package:animations/animations.dart';
import 'package:fluffychat/di/global/get_it_initializer.dart';
import 'package:fluffychat/pages/bootstrap/init_client_dialog.dart';
import 'package:fluffychat/resource/image_paths.dart';
import 'package:fluffychat/utils/platform_infos.dart';
Expand All @@ -22,6 +23,8 @@ class TwakeDialog {

static const double lottieSizeMobile = 48;

static ResponsiveUtils responsiveUtils = getIt.get<ResponsiveUtils>();

static void hideLoadingDialog(BuildContext context) {
if (PlatformInfos.isWeb) {
if (TwakeApp.routerKey.currentContext != null) {
Expand Down Expand Up @@ -96,15 +99,21 @@ class TwakeDialog {
loadingTitleStyle: Theme.of(context).textTheme.titleLarge,
maxWidth: maxWidthLoadingDialogWeb,
errorTitle: L10n.of(context)!.errorDialogTitle,
errorTitleStyle: Theme.of(context).textTheme.titleLarge,
errorTitleStyle: Theme.of(context).textTheme.titleLarge?.copyWith(
color: LinagoraSysColors.material().onSurfaceVariant,
),
errorDescriptionStyle: Theme.of(context).textTheme.titleSmall?.copyWith(
color: LinagoraSysColors.material().onSurfaceVariant,
),
errorBackLabel: L10n.of(context)!.cancel,
errorBackLabelStyle: Theme.of(context).textTheme.titleLarge?.copyWith(
errorBackLabelStyle: Theme.of(context).textTheme.labelLarge?.copyWith(
color: Theme.of(context).colorScheme.primary,
),
errorNextLabel: L10n.of(context)!.next,
errorNextLabelStyle: Theme.of(context).textTheme.titleLarge?.copyWith(
color: Theme.of(context).colorScheme.onPrimary,
errorNextLabelStyle: Theme.of(context).textTheme.labelLarge?.copyWith(
color: LinagoraSysColors.material().onPrimary,
),
backgroundErrorDialog: LinagoraSysColors.material().onPrimary,
backgroundNextLabel: Theme.of(context).colorScheme.primary,
);
}
Expand All @@ -116,6 +125,7 @@ class TwakeDialog {
return await showFutureLoadingDialog(
context: context,
future: future,
maxWidth: double.infinity,
loadingIcon: LottieBuilder.asset(
ImagePaths.lottieTwakeLoading,
width: lottieSizeMobile,
Expand All @@ -125,16 +135,23 @@ class TwakeDialog {
loadingTitle: L10n.of(context)!.loading,
loadingTitleStyle: Theme.of(context).textTheme.titleMedium,
errorTitle: L10n.of(context)!.errorDialogTitle,
errorTitleStyle: Theme.of(context).textTheme.titleMedium,
errorTitleStyle: Theme.of(context).textTheme.headlineSmall?.copyWith(
color: LinagoraSysColors.material().onSurfaceVariant,
),
errorDescriptionStyle: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: LinagoraSysColors.material().onSurfaceVariant,
),
errorBackLabel: L10n.of(context)!.cancel,
errorBackLabelStyle: Theme.of(context).textTheme.titleMedium?.copyWith(
errorBackLabelStyle: Theme.of(context).textTheme.labelLarge?.copyWith(
color: Theme.of(context).colorScheme.primary,
),
errorNextLabel: L10n.of(context)!.next,
errorNextLabelStyle: Theme.of(context).textTheme.titleMedium?.copyWith(
color: Theme.of(context).colorScheme.onPrimary,
errorNextLabelStyle: Theme.of(context).textTheme.labelLarge?.copyWith(
color: LinagoraSysColors.material().onPrimary,
),
backgroundNextLabel: Theme.of(context).colorScheme.primary,
backgroundErrorDialog: LinagoraSysColors.material().onPrimary,
isMobileResponsive: true,
);
}

Expand Down Expand Up @@ -340,6 +357,8 @@ Future<ConfirmResult> showConfirmAlertDialog({
color: LinagoraSysColors.material()
.onSurfaceVariant,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
SizedBox(
height: responsiveUtils.isMobile(context) ? 16 : 27,
Expand All @@ -362,6 +381,8 @@ Future<ConfirmResult> showConfirmAlertDialog({
color: LinagoraSysColors.material()
.onSurfaceVariant,
),
maxLines: 3,
overflow: TextOverflow.ellipsis,
),
SizedBox(
height: responsiveUtils.isMobile(context) ? 24 : 65,
Expand All @@ -375,6 +396,11 @@ Future<ConfirmResult> showConfirmAlertDialog({
),
message:
cancelLabel ?? L10n.of(context)!.cancel,
constraints: BoxConstraints(
maxWidth: responsiveUtils.isMobile(context)
? 96
: 112,
),
styleMessage: Theme.of(context)
.textTheme
.labelLarge
Expand All @@ -397,6 +423,11 @@ Future<ConfirmResult> showConfirmAlertDialog({
Radius.circular(100),
),
),
constraints: BoxConstraints(
maxWidth: responsiveUtils.isMobile(context)
? 96
: 112,
),
margin: const EdgeInsetsDirectional.symmetric(
horizontal: 24.0,
),
Expand Down
5 changes: 5 additions & 0 deletions lib/widgets/twake_components/twake_text_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class TwakeTextButton extends StatelessWidget {

final double? borderHover;

final BoxConstraints? constraints;

const TwakeTextButton({
super.key,
required this.message,
Expand All @@ -44,6 +46,7 @@ class TwakeTextButton extends StatelessWidget {
this.margin = const EdgeInsetsDirectional.all(0),
this.buttonDecoration,
this.borderHover,
this.constraints,
});

@override
Expand All @@ -58,6 +61,7 @@ class TwakeTextButton extends StatelessWidget {
hoverColor: hoverColor,
borderRadius: BorderRadius.circular(borderHover ?? 0),
child: Container(
constraints: constraints,
height: 48,
padding: margin,
decoration:
Expand All @@ -74,6 +78,7 @@ class TwakeTextButton extends StatelessWidget {
Theme.of(context).textTheme.labelLarge?.copyWith(
color: LinagoraSysColors.material().onPrimary,
),
overflow: TextOverflow.ellipsis,
),
),
),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ packages:
description:
path: "."
ref: main
resolved-ref: "08e1e697919615410f8a855e500ef5617f90333b"
resolved-ref: "549ad29ac7153964e89ebf04b5693e5a6e50a64a"
url: "[email protected]:linagora/future-loading-dialog.git"
source: git
version: "0.3.0"
Expand Down

0 comments on commit becacdd

Please sign in to comment.