Skip to content

Commit

Permalink
TW-1904: Improve style for backup dialog (#1937)
Browse files Browse the repository at this point in the history
* TW-1904: Create UI for skeleton chat list widget

* TW-1904: Update style for backup dialog on web

* TW-1904: Update style for backup dialog on mobile

* TW-1904: Set timer for bootstrap dialog when get recovery key failed

* TW-1904: Update color and style for textfield on mobile

* TW-1904: Update color and style for textfield on web
  • Loading branch information
nqhhdev authored Jul 11, 2024
1 parent 0d981df commit 1f41373
Show file tree
Hide file tree
Showing 14 changed files with 342 additions and 67 deletions.
2 changes: 1 addition & 1 deletion lib/pages/bootstrap/bootstrap_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ class BootstrapDialogState extends State<BootstrapDialog> {
client: widget.client,
wipe: true,
wipeRecovery: true,
).show().then(
).show(context).then(
(value) => Navigator.of(
context,
rootNavigator: false,
Expand Down
90 changes: 47 additions & 43 deletions lib/pages/bootstrap/tom_bootstrap_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import 'package:fluffychat/domain/model/recovery_words/recovery_words.dart';
import 'package:fluffychat/domain/usecase/recovery/delete_recovery_words_interactor.dart';
import 'package:fluffychat/domain/usecase/recovery/get_recovery_words_interactor.dart';
import 'package:fluffychat/domain/usecase/recovery/save_recovery_words_interactor.dart';
import 'package:fluffychat/pages/bootstrap/tom_bootstrap_dialog_mobile_view.dart';
import 'package:fluffychat/pages/bootstrap/tom_bootstrap_dialog_style.dart';
import 'package:fluffychat/resource/image_paths.dart';
import 'package:fluffychat/pages/bootstrap/tom_bootstrap_dialog_web_view.dart';
import 'package:fluffychat/utils/dialog/twake_dialog.dart';
import 'package:fluffychat/utils/responsive/responsive_utils.dart';
import 'package:fluffychat/utils/twake_snackbar.dart';
import 'package:fluffychat/widgets/matrix.dart';
import 'package:flutter/material.dart';
import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:linagora_design_flutter/colors/linagora_sys_colors.dart';
import 'package:lottie/lottie.dart';
import 'package:matrix/encryption.dart';
import 'package:matrix/encryption/utils/bootstrap.dart';
import 'package:matrix/matrix.dart';
Expand All @@ -29,9 +30,9 @@ class TomBootstrapDialog extends StatefulWidget {
this.wipeRecovery = false,
});

Future<bool?> show() => TwakeDialog.showDialogFullScreen(
Future<bool?> show(BuildContext context) => TwakeDialog.showDialogFullScreen(
builder: () => this,
barrierColor: TomBootstrapDialogStyle.barrierColor,
barrierColor: TomBootstrapDialogStyle.barrierColor(context),
);

@override
Expand All @@ -46,6 +47,14 @@ class TomBootstrapDialogState extends State<TomBootstrapDialog>

final _deleteRecoveryWordsInteractor =
getIt.get<DeleteRecoveryWordsInteractor>();

static const breakpointMobileDialogKey = Key('BreakPointMobileDialog');

static const breakpointWebAndDesktopDialogKey =
Key('BreakpointWebAndDesktopKeyDialog');

static const Duration getRecoveryWordsDelay = Duration(seconds: 5);

Bootstrap? bootstrap;

UploadRecoveryKeyState _uploadRecoveryKeyState =
Expand All @@ -64,6 +73,8 @@ class TomBootstrapDialogState extends State<TomBootstrapDialog>

void _createBootstrap() async {
WidgetsBinding.instance.addPostFrameCallback((_) async {
Matrix.of(context).showToMBootstrap.value = true;

await _loadingData();
});
}
Expand Down Expand Up @@ -123,7 +134,14 @@ class TomBootstrapDialogState extends State<TomBootstrapDialog>
Logs().d(
'TomBootstrapDialog::_initializeRecoveryKeyState(): no recovery existed then call bootstrap',
);
Navigator.of(context, rootNavigator: false).pop<bool>(false);

Future.delayed(
getRecoveryWordsDelay,
() {
Matrix.of(context).showToMBootstrap.value = false;
Navigator.of(context, rootNavigator: false).pop<bool>(false);
},
);
}
}
} else {
Expand Down Expand Up @@ -181,6 +199,8 @@ class TomBootstrapDialogState extends State<TomBootstrapDialog>
case UploadRecoveryKeyState.wipeRecoveryFailed:
WidgetsBinding.instance.addPostFrameCallback((_) {
TwakeSnackBar.show(context, L10n.of(context)!.cannotEnableKeyBackup);
Matrix.of(context).showToMBootstrap.value = false;

Navigator.of(context, rootNavigator: false).pop<bool>();
});
break;
Expand Down Expand Up @@ -212,12 +232,16 @@ class TomBootstrapDialogState extends State<TomBootstrapDialog>
break;
case UploadRecoveryKeyState.unlockError:
WidgetsBinding.instance.addPostFrameCallback((_) async {
Matrix.of(context).showToMBootstrap.value = false;

Navigator.of(context, rootNavigator: false).pop<bool>(false);
});
break;
case UploadRecoveryKeyState.uploadError:
Logs().e('TomBootstrapDialogState::build(): upload recovery key error');
WidgetsBinding.instance.addPostFrameCallback((_) {
Matrix.of(context).showToMBootstrap.value = false;

Navigator.of(context, rootNavigator: false).pop<bool>();
});
break;
Expand All @@ -226,45 +250,25 @@ class TomBootstrapDialogState extends State<TomBootstrapDialog>
break;
}

return Scaffold(
backgroundColor: Colors.transparent,
body: Center(
child: Container(
height: TomBootstrapDialogStyle.sizedDialogWeb,
width: TomBootstrapDialogStyle.sizedDialogWeb,
decoration: TomBootstrapDialogStyle.decorationDialog,
child: Padding(
padding: TomBootstrapDialogStyle.paddingDialog,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
L10n.of(context)!.settingUpYourTwake,
style: Theme.of(context).textTheme.titleLarge?.copyWith(
color: LinagoraSysColors.material().onBackground,
),
textAlign: TextAlign.center,
),
Padding(
padding: TomBootstrapDialogStyle.lottiePadding,
child: LottieBuilder.asset(
ImagePaths.lottieTwakeLoading,
width: TomBootstrapDialogStyle.lottieSize,
height: TomBootstrapDialogStyle.lottieSize,
),
),
Text(
_description,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: LinagoraSysColors.material().onBackground,
),
textAlign: TextAlign.center,
),
],
),
return SlotLayout(
config: <Breakpoint, SlotLayoutConfig>{
const WidthPlatformBreakpoint(
end: ResponsiveUtils.maxMobileWidth,
): SlotLayout.from(
key: breakpointMobileDialogKey,
builder: (_) => TomBootstrapDialogMobileView(
description: _description,
),
),
const WidthPlatformBreakpoint(
begin: ResponsiveUtils.minTabletWidth,
): SlotLayout.from(
key: breakpointWebAndDesktopDialogKey,
builder: (_) => TomBootstrapDialogWebView(
description: _description,
),
),
),
},
);
}

Expand Down
23 changes: 23 additions & 0 deletions lib/pages/bootstrap/tom_bootstrap_dialog_mobile_style.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:flutter/material.dart';

class TomBootstrapDialogMobileStyle {
static const String backButtonTitle = 'Back';

static const String titleScreen = 'Titlte Screen';

static const String trailing = 'Trailing';

static const EdgeInsets paddingAppbar = EdgeInsets.only(
left: 16,
right: 16,
bottom: 16,
);

static const EdgeInsets paddingTextField = EdgeInsets.only(
left: 16,
right: 16,
bottom: 16,
);

static const EdgeInsets paddingDivider = EdgeInsets.only(bottom: 32);
}
113 changes: 113 additions & 0 deletions lib/pages/bootstrap/tom_bootstrap_dialog_mobile_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import 'package:fluffychat/pages/bootstrap/tom_bootstrap_dialog_mobile_style.dart';
import 'package:fluffychat/pages/bootstrap/tom_bootstrap_dialog_style.dart';
import 'package:fluffychat/pages/chat_list/chat_list_header_style.dart';
import 'package:fluffychat/pages/chat_list/chat_list_skeletonizer_widget.dart';
import 'package:fluffychat/resource/image_paths.dart';
import 'package:skeletonizer/skeletonizer.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:linagora_design_flutter/linagora_design_flutter.dart';
import 'package:lottie/lottie.dart';

class TomBootstrapDialogMobileView extends StatelessWidget {
final String description;
const TomBootstrapDialogMobileView({
super.key,
required this.description,
});

@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
Padding(
padding: TomBootstrapDialogMobileStyle.paddingAppbar,
child: Skeletonizer(
ignoreContainers: true,
child: Card(
child: Row(
children: [
Text(
TomBootstrapDialogMobileStyle.backButtonTitle,
style: Theme.of(context).textTheme.titleLarge,
),
Expanded(
child: Align(
alignment: Alignment.center,
child: Text(
TomBootstrapDialogMobileStyle.titleScreen,
style: Theme.of(context).textTheme.titleLarge,
),
),
),
Text(
TomBootstrapDialogMobileStyle.trailing,
style: Theme.of(context).textTheme.titleLarge,
),
],
),
),
),
),
Padding(
padding: TomBootstrapDialogMobileStyle.paddingTextField,
child: TextField(
textInputAction: TextInputAction.search,
enabled: false,
decoration: ChatListHeaderStyle.searchInputDecoration(
context,
hintText: '',
prefixIconColor: LinagoraRefColors.material().neutral[90],
),
),
),
Padding(
padding: TomBootstrapDialogMobileStyle.paddingDivider,
child: Divider(
height: 1,
color: LinagoraStateLayer(
LinagoraSysColors.material().surfaceTintDark,
).opacityLayer3,
),
),
SizedBox(
height: TomBootstrapDialogStyle.sizedDialogWeb,
width: TomBootstrapDialogStyle.sizedDialogWeb,
child: Padding(
padding: TomBootstrapDialogStyle.paddingDialog,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
L10n.of(context)!.settingUpYourTwake,
style: Theme.of(context).textTheme.titleLarge?.copyWith(
color: LinagoraSysColors.material().onBackground,
),
textAlign: TextAlign.center,
),
Padding(
padding: TomBootstrapDialogStyle.lottiePadding,
child: LottieBuilder.asset(
ImagePaths.lottieTwakeLoading,
width: TomBootstrapDialogStyle.lottieSize,
height: TomBootstrapDialogStyle.lottieSize,
),
),
Text(
description,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: LinagoraSysColors.material().tertiary,
),
textAlign: TextAlign.center,
),
],
),
),
),
const Expanded(child: ChatListSkeletonizerWidget()),
],
),
);
}
}
16 changes: 7 additions & 9 deletions lib/pages/bootstrap/tom_bootstrap_dialog_style.dart
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/utils/responsive/responsive_utils.dart';
import 'package:flutter/material.dart';
import 'package:linagora_design_flutter/linagora_design_flutter.dart';

class TomBootstrapDialogStyle {
static ResponsiveUtils responsiveUtils = ResponsiveUtils();

static EdgeInsets paddingDialog = const EdgeInsets.symmetric(
horizontal: 56,
);

static Color? barrierColor =
PlatformInfos.isMobile ? LinagoraSysColors.material().onPrimary : null;
static Color? barrierColor(BuildContext context) =>
responsiveUtils.isMobile(context)
? LinagoraSysColors.material().onPrimary
: Colors.transparent;

static double? sizedDialogWeb = PlatformInfos.isMobile ? null : 400;

static Decoration? decorationDialog = PlatformInfos.isMobile
? null
: BoxDecoration(
color: LinagoraSysColors.material().surface,
borderRadius: BorderRadius.circular(24),
);

static EdgeInsets lottiePadding = EdgeInsets.symmetric(
vertical: PlatformInfos.isMobile ? 16 : 24,
);
Expand Down
57 changes: 57 additions & 0 deletions lib/pages/bootstrap/tom_bootstrap_dialog_web_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import 'package:fluffychat/pages/bootstrap/tom_bootstrap_dialog_style.dart';
import 'package:fluffychat/resource/image_paths.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:linagora_design_flutter/linagora_design_flutter.dart';
import 'package:lottie/lottie.dart';

class TomBootstrapDialogWebView extends StatelessWidget {
final String description;
const TomBootstrapDialogWebView({
super.key,
required this.description,
});

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.transparent,
body: Center(
child: SizedBox(
height: TomBootstrapDialogStyle.sizedDialogWeb,
width: TomBootstrapDialogStyle.sizedDialogWeb,
child: Padding(
padding: TomBootstrapDialogStyle.paddingDialog,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
L10n.of(context)!.settingUpYourTwake,
style: Theme.of(context).textTheme.titleLarge?.copyWith(
color: LinagoraSysColors.material().onBackground,
),
textAlign: TextAlign.center,
),
Padding(
padding: TomBootstrapDialogStyle.lottiePadding,
child: LottieBuilder.asset(
ImagePaths.lottieTwakeLoading,
width: TomBootstrapDialogStyle.lottieSize,
height: TomBootstrapDialogStyle.lottieSize,
),
),
Text(
description,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: LinagoraSysColors.material().onBackground,
),
textAlign: TextAlign.center,
),
],
),
),
),
),
);
}
}
Loading

0 comments on commit 1f41373

Please sign in to comment.