@@ -978,14 +978,32 @@ Future<void> _uploadFiles({
978
978
}
979
979
}
980
980
981
- abstract class _AttachUploadsButton extends StatelessWidget {
982
- const _AttachUploadsButton ({required this .controller});
981
+ abstract class _ComposeButton extends StatelessWidget {
982
+ const _ComposeButton ({required this .controller});
983
983
984
984
final ComposeBoxController controller;
985
985
986
986
IconData get icon;
987
987
String tooltip (ZulipLocalizations zulipLocalizations);
988
988
989
+ void handlePress (BuildContext context);
990
+
991
+ @override
992
+ Widget build (BuildContext context) {
993
+ final designVariables = DesignVariables .of (context);
994
+ final zulipLocalizations = ZulipLocalizations .of (context);
995
+ return SizedBox (
996
+ width: _composeButtonSize,
997
+ child: IconButton (
998
+ icon: Icon (icon, color: designVariables.foreground.withFadedAlpha (0.5 )),
999
+ tooltip: tooltip (zulipLocalizations),
1000
+ onPressed: () => handlePress (context)));
1001
+ }
1002
+ }
1003
+
1004
+ abstract class _AttachUploadsButton extends _ComposeButton {
1005
+ const _AttachUploadsButton ({required super .controller});
1006
+
989
1007
/// Request files from the user, in the way specific to this upload type.
990
1008
///
991
1009
/// Subclasses should manage the interaction completely, e.g., by catching and
@@ -995,7 +1013,8 @@ abstract class _AttachUploadsButton extends StatelessWidget {
995
1013
/// return an empty [Iterable] after showing user feedback as appropriate.
996
1014
Future <Iterable <_File >> getFiles (BuildContext context);
997
1015
998
- void _handlePress (BuildContext context) async {
1016
+ @override
1017
+ void handlePress (BuildContext context) async {
999
1018
final files = await getFiles (context);
1000
1019
if (files.isEmpty) {
1001
1020
return ; // Nothing to do (getFiles handles user feedback)
@@ -1013,18 +1032,6 @@ abstract class _AttachUploadsButton extends StatelessWidget {
1013
1032
contentFocusNode: controller.contentFocusNode,
1014
1033
files: files);
1015
1034
}
1016
-
1017
- @override
1018
- Widget build (BuildContext context) {
1019
- final designVariables = DesignVariables .of (context);
1020
- final zulipLocalizations = ZulipLocalizations .of (context);
1021
- return SizedBox (
1022
- width: _composeButtonSize,
1023
- child: IconButton (
1024
- icon: Icon (icon, color: designVariables.foreground.withFadedAlpha (0.5 )),
1025
- tooltip: tooltip (zulipLocalizations),
1026
- onPressed: () => _handlePress (context)));
1027
- }
1028
1035
}
1029
1036
1030
1037
Future <Iterable <_File >> _getFilePickerFiles (BuildContext context, FileType type) async {
0 commit comments