Skip to content

Commit

Permalink
refactor: Update FutureLoadingDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
krille-chan committed Oct 28, 2023
1 parent 072c4db commit f028b12
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 47 deletions.
34 changes: 10 additions & 24 deletions lib/pages/chat/events/message_reactions.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'package:collection/collection.dart' show IterableExtension;
import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:matrix/matrix.dart';

import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/widgets/avatar.dart';
import 'package:fluffychat/widgets/matrix.dart';
import 'package:fluffychat/widgets/mxc_image.dart';
Expand Down Expand Up @@ -191,19 +189,12 @@ class _AdaptableReactorsDialog extends StatelessWidget {
this.reactionEntry,
});

Future<bool?> show(BuildContext context) => PlatformInfos.isCupertinoStyle
? showCupertinoDialog(
context: context,
builder: (context) => this,
barrierDismissible: true,
useRootNavigator: false,
)
: showDialog(
context: context,
builder: (context) => this,
barrierDismissible: true,
useRootNavigator: false,
);
Future<bool?> show(BuildContext context) => showAdaptiveDialog(
context: context,
builder: (context) => this,
barrierDismissible: true,
useRootNavigator: false,
);

@override
Widget build(BuildContext context) {
Expand All @@ -228,14 +219,9 @@ class _AdaptableReactorsDialog extends StatelessWidget {

final title = Center(child: Text(reactionEntry!.key!));

return PlatformInfos.isCupertinoStyle
? CupertinoAlertDialog(
title: title,
content: body,
)
: AlertDialog(
title: title,
content: body,
);
return AlertDialog.adaptive(
title: title,
content: body,
);
}
}
20 changes: 2 additions & 18 deletions lib/pages/key_verification/key_verification_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:convert';
import 'dart:ui';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

Expand All @@ -14,7 +13,7 @@ import 'package:matrix/matrix.dart';
import 'package:fluffychat/widgets/avatar.dart';

class KeyVerificationDialog extends StatefulWidget {
Future<void> show(BuildContext context) => showDialog(
Future<void> show(BuildContext context) => showAdaptiveDialog(
context: context,
builder: (context) => this,
barrierDismissible: false,
Expand Down Expand Up @@ -342,23 +341,8 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
);
break;
}
if ({TargetPlatform.iOS, TargetPlatform.macOS}
.contains(Theme.of(context).platform)) {
return CupertinoAlertDialog(
title: title,
content: SizedBox(
height: 256,
width: 256,
child: ListView(
padding: const EdgeInsets.only(top: 16),
children: [body],
),
),
actions: buttons,
);
}

return AlertDialog(
return AlertDialog.adaptive(
title: title,
content: SizedBox(
height: 256,
Expand Down
3 changes: 2 additions & 1 deletion lib/utils/matrix_sdk_extensions/event_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import 'dart:developer';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import 'package:async/async.dart' as async;
import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:matrix/matrix.dart';

import 'package:fluffychat/utils/size_string.dart';
import 'matrix_file_extension.dart';

extension LocalizedBody on Event {
Future<LoadingDialogResult<MatrixFile?>> _getFile(BuildContext context) =>
Future<async.Result<MatrixFile?>> _getFile(BuildContext context) =>
showFutureLoadingDialog(
context: context,
future: downloadAndDecryptAttachment,
Expand Down
6 changes: 3 additions & 3 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ packages:
source: hosted
version: "2.4.2"
async:
dependency: transitive
dependency: "direct main"
description:
name: async
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
Expand Down Expand Up @@ -739,10 +739,10 @@ packages:
dependency: "direct main"
description:
name: future_loading_dialog
sha256: "6227dddb32ad5c7d233a54668f862acb4beb5a5e0dde072de372347cc0799e63"
sha256: "2718b1a308db452da32ab9bca9ad496ff92b683e217add9e92cf50520f90537e"
url: "https://pub.dev"
source: hosted
version: "0.2.4"
version: "0.3.0"
geolocator:
dependency: "direct main"
description:
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ dependencies:
adaptive_dialog: ^1.9.0+2
animations: ^2.0.7
archive: ^3.3.9
async: ^2.11.0
badges: ^3.1.1
blurhash_dart: ^1.1.0
callkeep: ^0.3.2
Expand Down Expand Up @@ -49,7 +50,7 @@ dependencies:
flutter_typeahead: ^4.3.2
flutter_web_auth_2: ^3.0.3
flutter_webrtc: ^0.9.37
future_loading_dialog: ^0.2.3
future_loading_dialog: ^0.3.0
geolocator: ^7.6.2
go_router: ^12.0.1
hive: ^2.2.3
Expand Down

0 comments on commit f028b12

Please sign in to comment.