-
Notifications
You must be signed in to change notification settings - Fork 350
Edit-message (2/n): Implement variant of content input without a typing notifier #1431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
PIG208
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the refactor! This will be helpful for implementing saved snippets as well; left a comment bringing that into the discussion.
lib/widgets/compose_box.dart
Outdated
| // ignore: unused_element | ||
| factory _ContentInput.noTypingNotifier({ | ||
| required Narrow narrow, | ||
| required SendableNarrow destination, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ideally destination shouldn't be needed for this variant, but I can't think of a better alternative without making destination nullable in the base class _ContentInput and having null-checks in the mixin. (I think this—having a default constructor that allows all combinations, and factories with set values and assertions—is how some Flutter upstream widgets (e.g.: SwitchListTile) handle this.)
For editing messages, providing a reasonable value for destination might still be convenient for the caller (and will become a requirement when we get to supporting typing notifications for editing).
Saved snippets might need a variant that does not have typing notifier or autocompletion; in that case neither narrow nor destination should be needed from the caller, as there are no reasonable values other than null for them anyway:
factory _ContentInput.savedSnippet({
required ComposeBoxController controller,
required String hintText,
}) => _ContentInputNoTypingNotifier._(
narrow: null,
destination: null,
controller: controller,
hintText: hintText,
);There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another approach would be dropping the mixin, moving the typing notifier logic to _ContentInputStateWithTypingNotifier, and moving the destination field to _ContentInputWithTypingNotifier. However, that won't help if we need the mixin in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another approach would be dropping the
mixin, moving the typing notifier logic to_ContentInputStateWithTypingNotifier, and moving thedestinationfield to_ContentInputWithTypingNotifier. However, that won't help if we need the mixin in the future.
Interesting! I'll push some wip commits trying this out.
479cf37 to
e67a478
Compare
|
Thanks for the review! I've pushed some NOMERGE commits with a way to have |
PIG208
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This change LGTM. I guess destination might need dartdoc highlighting its relationship with typing notifications.
lib/widgets/compose_box.dart
Outdated
| } | ||
| } | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove extra newline
e67a478 to
6ea1cf6
Compare
|
Thanks for the review! Revision pushed, squashing in those commits. |
|
Thanks! This LGTM. |
gnprice
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
One initial comment below, but then zooming out: this inheritance-based setup feels kind of complicated. I think we can split out the typing-notifier logic in a more idiomatic Flutter way by making it a separate widget:
- return _ContentInput(
- narrow: narrow,
+ return _TypingNotifier(
destination: narrow,
controller: controller,
- hintText: _hintText(context));
+ child: _ContentInput(
+ narrow: narrow,
+ controller: controller,
+ hintText: _hintText(context)));So what this PR revision calls _ContentInput.noTypingNotifier would be just _ContentInput. Does that seem like it would also meet the needs of your later changes?
I've just pushed to the PR branch some additional commits that make that change:
921538f wip nfc separate _TypingNotifier widget
1c69a68 wip nfc simplify inheritance back out
4c0369f wip nfc swap order
8805d48 compose [nfc]: Make _ContentInput stateless
I think the first three are probably best squashed into the main commit. PTAL.
lib/widgets/compose_box.dart
Outdated
| }) => _ContentInputWithTypingNotifier._( | ||
| narrow: narrow, | ||
| destination: destination, | ||
| controller: controller, | ||
| hintText: hintText, | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: handy shorthand:
| }) => _ContentInputWithTypingNotifier._( | |
| narrow: narrow, | |
| destination: destination, | |
| controller: controller, | |
| hintText: hintText, | |
| ); | |
| }) = _ContentInputWithTypingNotifier._; |
8805d48 to
97d67d3
Compare
|
That's great, thanks for the suggestion and those commits! That should work well; revision pushed, PTAL. 🙂 |
…logic This prepares for the edit-message compose box (upcoming), which we'll want to implement without this typing-notifier logic. After this change, we can accomplish that by using _ContentInput without the new helper widget. Co-authored-by: Greg Price <[email protected]>
The state that had been here now lives on the _TypingNotifier widget.
|
Thanks, looks good. Added a Co-authored-by, and merging. |
97d67d3 to
6a75033
Compare
|
Indeed, thanks again! |
The edit-message compose box (#126) shouldn't send typing notifications like the regular compose box does.
(There's actually a different kind of typing notification that we'll want to implement eventually; that's #1350. But that's not for us to do now.)
This PR implements
_ContentInput.noTypingNotifier, as prep for implementing the edit-message compose box.Related: #126