@@ -990,15 +990,33 @@ Future<void> _uploadFiles({
990
990
}
991
991
}
992
992
993
- abstract class _AttachUploadsButton extends StatelessWidget {
994
- const _AttachUploadsButton ({required this .controller, required this .enabled});
993
+ abstract class _ComposeButton extends StatelessWidget {
994
+ const _ComposeButton ({required this .controller, required this .enabled});
995
995
996
996
final ComposeBoxController controller;
997
997
final bool enabled;
998
998
999
999
IconData get icon;
1000
1000
String tooltip (ZulipLocalizations zulipLocalizations);
1001
1001
1002
+ void handlePress (BuildContext context);
1003
+
1004
+ @override
1005
+ Widget build (BuildContext context) {
1006
+ final designVariables = DesignVariables .of (context);
1007
+ final zulipLocalizations = ZulipLocalizations .of (context);
1008
+ return SizedBox (
1009
+ width: _composeButtonSize,
1010
+ child: IconButton (
1011
+ icon: Icon (icon, color: designVariables.foreground.withFadedAlpha (0.5 )),
1012
+ tooltip: tooltip (zulipLocalizations),
1013
+ onPressed: enabled ? () => handlePress (context) : null ));
1014
+ }
1015
+ }
1016
+
1017
+ abstract class _AttachUploadsButton extends _ComposeButton {
1018
+ const _AttachUploadsButton ({required super .controller, required super .enabled});
1019
+
1002
1020
/// Request files from the user, in the way specific to this upload type.
1003
1021
///
1004
1022
/// Subclasses should manage the interaction completely, e.g., by catching and
@@ -1008,7 +1026,8 @@ abstract class _AttachUploadsButton extends StatelessWidget {
1008
1026
/// return an empty [Iterable] after showing user feedback as appropriate.
1009
1027
Future <Iterable <_File >> getFiles (BuildContext context);
1010
1028
1011
- void _handlePress (BuildContext context) async {
1029
+ @override
1030
+ void handlePress (BuildContext context) async {
1012
1031
final files = await getFiles (context);
1013
1032
if (files.isEmpty) {
1014
1033
return ; // Nothing to do (getFiles handles user feedback)
@@ -1026,18 +1045,6 @@ abstract class _AttachUploadsButton extends StatelessWidget {
1026
1045
contentFocusNode: controller.contentFocusNode,
1027
1046
files: files);
1028
1047
}
1029
-
1030
- @override
1031
- Widget build (BuildContext context) {
1032
- final designVariables = DesignVariables .of (context);
1033
- final zulipLocalizations = ZulipLocalizations .of (context);
1034
- return SizedBox (
1035
- width: _composeButtonSize,
1036
- child: IconButton (
1037
- icon: Icon (icon, color: designVariables.foreground.withFadedAlpha (0.5 )),
1038
- tooltip: tooltip (zulipLocalizations),
1039
- onPressed: enabled ? () => _handlePress (context) : null ));
1040
- }
1041
1048
}
1042
1049
1043
1050
Future <Iterable <_File >> _getFilePickerFiles (BuildContext context, FileType type) async {
0 commit comments