Skip to content

Commit 3b407e3

Browse files
committed
Update dialog for key verification
1 parent f973a70 commit 3b407e3

File tree

3 files changed

+140
-37
lines changed

3 files changed

+140
-37
lines changed

lib/pages/key_verification/key_verification_dialog.dart

+113-36
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import 'dart:convert';
22
import 'dart:ui';
33

4+
import 'package:fluffychat/pages/key_verification/key_verification_styles.dart';
45
import 'package:fluffychat/utils/dialog/twake_dialog.dart';
56
import 'package:fluffychat/widgets/avatar/avatar_style.dart';
7+
import 'package:fluffychat/widgets/twake_components/twake_text_button.dart';
68
import 'package:flutter/material.dart';
79
import 'package:flutter/services.dart';
810

911
import 'package:adaptive_dialog/adaptive_dialog.dart';
1012
import 'package:flutter_gen/gen_l10n/l10n.dart';
13+
import 'package:linagora_design_flutter/colors/linagora_sys_colors.dart';
1114

1215
import 'package:matrix/encryption.dart';
1316
import 'package:matrix/matrix.dart';
@@ -149,19 +152,37 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
149152
),
150153
);
151154
buttons.add(
152-
TextButton(
153-
child: Text(
154-
L10n.of(context)!.submit,
155+
TwakeTextButton(
156+
onTap: () => checkInput(textEditingController.text),
157+
message: L10n.of(context)!.submit,
158+
borderHover: KeyVerificationStyles.borderHoverButtonWaningBanner,
159+
styleMessage: Theme.of(context).textTheme.labelLarge?.copyWith(
160+
color: Theme.of(context).colorScheme.primary,
161+
),
162+
margin: KeyVerificationStyles.marginButtonWarningBanner,
163+
buttonDecoration: BoxDecoration(
164+
color: LinagoraSysColors.material().onPrimary,
165+
borderRadius: const BorderRadius.all(
166+
Radius.circular(100),
167+
),
155168
),
156-
onPressed: () => checkInput(textEditingController.text),
157169
),
158170
);
159171
buttons.add(
160-
TextButton(
161-
child: Text(
162-
L10n.of(context)!.skip,
172+
TwakeTextButton(
173+
onTap: () => widget.request.openSSSS(skip: true),
174+
message: L10n.of(context)!.skip,
175+
borderHover: KeyVerificationStyles.borderHoverButtonWaningBanner,
176+
styleMessage: Theme.of(context).textTheme.labelLarge?.copyWith(
177+
color: Theme.of(context).colorScheme.primary,
178+
),
179+
margin: KeyVerificationStyles.marginButtonWarningBanner,
180+
buttonDecoration: BoxDecoration(
181+
color: LinagoraSysColors.material().onPrimary,
182+
borderRadius: const BorderRadius.all(
183+
Radius.circular(100),
184+
),
163185
),
164-
onPressed: () => widget.request.openSSSS(skip: true),
165186
),
166187
);
167188
break;
@@ -183,20 +204,37 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
183204
],
184205
);
185206
buttons.add(
186-
TextButton.icon(
187-
icon: const Icon(Icons.close),
188-
style: TextButton.styleFrom(foregroundColor: Colors.red),
189-
label: Text(L10n.of(context)!.reject),
190-
onPressed: () => widget.request
207+
TwakeTextButton(
208+
onTap: () => widget.request
191209
.rejectVerification()
192-
.then((_) => Navigator.of(context, rootNavigator: false).pop()),
210+
.then((_) => Navigator.maybePop(context)),
211+
message: L10n.of(context)!.reject,
212+
borderHover: KeyVerificationStyles.borderHoverButtonWaningBanner,
213+
styleMessage: Theme.of(context).textTheme.labelLarge?.copyWith(
214+
color: Theme.of(context).colorScheme.primary,
215+
),
216+
margin: KeyVerificationStyles.marginButtonWarningBanner,
217+
buttonDecoration: BoxDecoration(
218+
color: LinagoraSysColors.material().onPrimary,
219+
borderRadius: const BorderRadius.all(
220+
Radius.circular(100),
221+
),
222+
),
193223
),
194224
);
195225
buttons.add(
196-
TextButton.icon(
197-
icon: const Icon(Icons.check),
198-
label: Text(L10n.of(context)!.accept),
199-
onPressed: () => widget.request.acceptVerification(),
226+
TwakeTextButton(
227+
onTap: () => widget.request.acceptVerification(),
228+
message: L10n.of(context)!.accept,
229+
borderHover: KeyVerificationStyles.borderHoverButtonWaningBanner,
230+
styleMessage: Theme.of(context).textTheme.labelLarge?.copyWith(
231+
color: LinagoraSysColors.material().onPrimary,
232+
),
233+
margin: KeyVerificationStyles.marginButtonWarningBanner,
234+
buttonDecoration: BoxDecoration(
235+
color: Theme.of(context).colorScheme.primary,
236+
borderRadius: BorderRadius.circular(100),
237+
),
200238
),
201239
);
202240
break;
@@ -262,20 +300,41 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
262300
],
263301
);
264302
buttons.add(
265-
TextButton.icon(
266-
icon: const Icon(Icons.close),
267-
style: TextButton.styleFrom(
268-
foregroundColor: Colors.red,
303+
TwakeTextButton(
304+
onTap: () => widget.request.rejectSas(),
305+
message: L10n.of(context)!.theyDontMatch,
306+
borderHover: KeyVerificationStyles.borderHoverButtonWaningBanner,
307+
styleMessage: Theme.of(context).textTheme.labelLarge?.copyWith(
308+
color: Theme.of(context).colorScheme.primary,
309+
),
310+
margin: KeyVerificationStyles.marginButtonWarningBanner,
311+
buttonDecoration: BoxDecoration(
312+
color: LinagoraSysColors.material().onPrimary,
313+
borderRadius: const BorderRadius.all(
314+
Radius.circular(100),
315+
),
316+
),
317+
constraints: BoxConstraints(
318+
maxWidth: KeyVerificationStyles.maxWidthMatchButton(context),
269319
),
270-
label: Text(L10n.of(context)!.theyDontMatch),
271-
onPressed: () => widget.request.rejectSas(),
272320
),
273321
);
274322
buttons.add(
275-
TextButton.icon(
276-
icon: const Icon(Icons.check_outlined),
277-
label: Text(L10n.of(context)!.theyMatch),
278-
onPressed: () => widget.request.acceptSas(),
323+
TwakeTextButton(
324+
onTap: () => widget.request.acceptSas(),
325+
message: L10n.of(context)!.theyMatch,
326+
borderHover: KeyVerificationStyles.borderHoverButtonWaningBanner,
327+
styleMessage: Theme.of(context).textTheme.labelLarge?.copyWith(
328+
color: LinagoraSysColors.material().onPrimary,
329+
),
330+
margin: KeyVerificationStyles.marginButtonWarningBanner,
331+
buttonDecoration: BoxDecoration(
332+
color: Theme.of(context).colorScheme.primary,
333+
borderRadius: BorderRadius.circular(100),
334+
),
335+
constraints: BoxConstraints(
336+
maxWidth: KeyVerificationStyles.maxWidthMatchButton(context),
337+
),
279338
),
280339
);
281340
break;
@@ -312,11 +371,20 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
312371
],
313372
);
314373
buttons.add(
315-
TextButton(
316-
child: Text(
317-
L10n.of(context)!.close,
374+
TwakeTextButton(
375+
onTap: () => Navigator.maybePop(context),
376+
message: L10n.of(context)!.close,
377+
borderHover: KeyVerificationStyles.borderHoverButtonWaningBanner,
378+
styleMessage: Theme.of(context).textTheme.labelLarge?.copyWith(
379+
color: Theme.of(context).colorScheme.primary,
380+
),
381+
margin: KeyVerificationStyles.marginButtonWarningBanner,
382+
buttonDecoration: BoxDecoration(
383+
color: LinagoraSysColors.material().onPrimary,
384+
borderRadius: const BorderRadius.all(
385+
Radius.circular(100),
386+
),
318387
),
319-
onPressed: () => Navigator.of(context, rootNavigator: false).pop(),
320388
),
321389
);
322390
break;
@@ -333,11 +401,20 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
333401
],
334402
);
335403
buttons.add(
336-
TextButton(
337-
child: Text(
338-
L10n.of(context)!.close,
404+
TwakeTextButton(
405+
onTap: () => Navigator.maybePop(context),
406+
message: L10n.of(context)!.close,
407+
borderHover: KeyVerificationStyles.borderHoverButtonWaningBanner,
408+
styleMessage: Theme.of(context).textTheme.labelLarge?.copyWith(
409+
color: Theme.of(context).colorScheme.primary,
410+
),
411+
margin: KeyVerificationStyles.marginButtonWarningBanner,
412+
buttonDecoration: BoxDecoration(
413+
color: LinagoraSysColors.material().onPrimary,
414+
borderRadius: const BorderRadius.all(
415+
Radius.circular(100),
416+
),
339417
),
340-
onPressed: () => Navigator.of(context, rootNavigator: false).pop(),
341418
),
342419
);
343420
break;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import 'package:fluffychat/di/global/get_it_initializer.dart';
2+
import 'package:fluffychat/utils/responsive/responsive_utils.dart';
3+
import 'package:flutter/material.dart';
4+
5+
class KeyVerificationStyles {
6+
static ResponsiveUtils responsiveUtils = getIt.get<ResponsiveUtils>();
7+
8+
static const double borderHoverButtonWaningBanner = 100.0;
9+
10+
static EdgeInsetsDirectional marginButtonWarningBanner =
11+
const EdgeInsetsDirectional.symmetric(
12+
horizontal: 24.0,
13+
);
14+
15+
static const double maxWidthMatchButtonMobile = 158;
16+
17+
static const double maxWidthMatchButtonWeb = 168;
18+
19+
static double maxWidthMatchButton(BuildContext context) {
20+
return responsiveUtils.isMobile(context)
21+
? maxWidthMatchButtonMobile
22+
: maxWidthMatchButtonWeb;
23+
}
24+
}

lib/widgets/matrix.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,9 @@ class MatrixState extends State<Matrix>
365365
};
366366
request.onUpdate = null;
367367
hidPopup = true;
368-
await KeyVerificationDialog(request: request).show(TwakeApp.router.routerDelegate.navigatorKey.currentContext ?? context);
368+
await KeyVerificationDialog(request: request).show(
369+
TwakeApp.router.routerDelegate.navigatorKey.currentContext ?? context,
370+
);
369371
});
370372
onLoginStateChanged[name] ??= currentClient.onLoginStateChanged.stream
371373
.listen((state) => _listenLoginStateChanged(state, currentClient));

0 commit comments

Comments
 (0)