Skip to content

Commit

Permalink
compose [nfc]: Pass controller down (5/6); _AttachUploadsButton
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbobbe committed Dec 3, 2024
1 parent a42bdc1 commit 6b36b35
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions lib/widgets/compose_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -658,10 +658,9 @@ Future<void> _uploadFiles({
}

abstract class _AttachUploadsButton extends StatelessWidget {
const _AttachUploadsButton({required this.contentController, required this.contentFocusNode});
const _AttachUploadsButton({required this.controller});

final ComposeContentController contentController;
final FocusNode contentFocusNode;
final ComposeBoxController controller;

IconData get icon;
String tooltip(ZulipLocalizations zulipLocalizations);
Expand Down Expand Up @@ -689,8 +688,8 @@ abstract class _AttachUploadsButton extends StatelessWidget {

await _uploadFiles(
context: context,
contentController: contentController,
contentFocusNode: contentFocusNode,
contentController: controller.content,
contentFocusNode: controller.contentFocusNode,
files: files);
}

Expand Down Expand Up @@ -762,7 +761,7 @@ Future<Iterable<_File>> _getFilePickerFiles(BuildContext context, FileType type)
}

class _AttachFileButton extends _AttachUploadsButton {
const _AttachFileButton({required super.contentController, required super.contentFocusNode});
const _AttachFileButton({required super.controller});

@override
IconData get icon => ZulipIcons.attach_file;
Expand All @@ -778,7 +777,7 @@ class _AttachFileButton extends _AttachUploadsButton {
}

class _AttachMediaButton extends _AttachUploadsButton {
const _AttachMediaButton({required super.contentController, required super.contentFocusNode});
const _AttachMediaButton({required super.controller});

@override
IconData get icon => ZulipIcons.image;
Expand All @@ -795,7 +794,7 @@ class _AttachMediaButton extends _AttachUploadsButton {
}

class _AttachFromCameraButton extends _AttachUploadsButton {
const _AttachFromCameraButton({required super.contentController, required super.contentFocusNode});
const _AttachFromCameraButton({required super.controller});

@override
IconData get icon => ZulipIcons.camera;
Expand Down Expand Up @@ -1096,11 +1095,10 @@ abstract class _ComposeBoxBody extends StatelessWidget {
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(4)))));

final ComposeBoxController(:content, :contentFocusNode) = controller;
final composeButtons = [
_AttachFileButton(contentController: content, contentFocusNode: contentFocusNode),
_AttachMediaButton(contentController: content, contentFocusNode: contentFocusNode),
_AttachFromCameraButton(contentController: content, contentFocusNode: contentFocusNode),
_AttachFileButton(controller: controller),
_AttachMediaButton(controller: controller),
_AttachFromCameraButton(controller: controller),
];

final topicInput = this.topicInput();
Expand Down

0 comments on commit 6b36b35

Please sign in to comment.