@@ -928,7 +928,7 @@ class FileToUpload {
928
928
Future <void > _uploadFiles ({
929
929
required BuildContext context,
930
930
required ComposeContentController contentController,
931
- required FocusNode contentFocusNode,
931
+ required FocusNode ? contentFocusNode,
932
932
required Iterable <FileToUpload > files,
933
933
}) async {
934
934
assert (context.mounted);
@@ -965,7 +965,7 @@ Future<void> _uploadFiles({
965
965
zulipLocalizations);
966
966
uploadsInProgress.add ((tag, file));
967
967
}
968
- if (! contentFocusNode.hasFocus) {
968
+ if (contentFocusNode != null && ! contentFocusNode.hasFocus) {
969
969
contentFocusNode.requestFocus ();
970
970
}
971
971
@@ -1869,6 +1869,24 @@ abstract class ComposeBoxState extends State<ComposeBox> {
1869
1869
1870
1870
/// Switch the compose box back to regular non-edit mode, with no content.
1871
1871
void endEditInteraction ();
1872
+
1873
+ /// Uploads the provided files, populating the compose box with their links.
1874
+ ///
1875
+ /// If any of the file is larger than maximum file size allowed by the
1876
+ /// server, an error dialog is shown mentioning their names and actual
1877
+ /// file sizes.
1878
+ ///
1879
+ /// While uploading, a placeholder link is inserted in the compose box and
1880
+ /// if [contentFocusNode] is non-null it will be focused. And then after
1881
+ /// uploading completes successfully the placeholder link will be replaced
1882
+ /// with an actual link.
1883
+ ///
1884
+ /// If there is an error while uploading a file, then an error dialog is
1885
+ /// shown mentioning the corresponding file name.
1886
+ Future <void > uploadFiles ({
1887
+ required Iterable <FileToUpload > files,
1888
+ required FocusNode ? contentFocusNode,
1889
+ });
1872
1890
}
1873
1891
1874
1892
class _ComposeBoxState extends State <ComposeBox > with PerAccountStoreAwareStateMixin <ComposeBox > implements ComposeBoxState {
@@ -2021,6 +2039,18 @@ class _ComposeBoxState extends State<ComposeBox> with PerAccountStoreAwareStateM
2021
2039
});
2022
2040
}
2023
2041
2042
+ @override
2043
+ Future <void > uploadFiles ({
2044
+ required Iterable <FileToUpload > files,
2045
+ required FocusNode ? contentFocusNode,
2046
+ }) async {
2047
+ await _uploadFiles (
2048
+ context: context,
2049
+ contentController: controller.content,
2050
+ contentFocusNode: contentFocusNode,
2051
+ files: files);
2052
+ }
2053
+
2024
2054
@override
2025
2055
void onNewStore () {
2026
2056
final newStore = PerAccountStoreWidget .of (context);
0 commit comments