moved stateful variable from text controller to input bar wrapper widget

This commit is contained in:
ggurdin 2024-07-25 11:25:59 -04:00
parent 5569619ba2
commit 6311df0875
3 changed files with 12 additions and 7 deletions

View file

@ -401,9 +401,6 @@ class InputBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
final useShortCuts = (AppConfig.sendOnEnter ?? !PlatformInfos.isMobile);
// #Pangea
controller?.currentlyMaxLength = controller?.isMaxLength ?? false;
// Pangea#
return Shortcuts(
shortcuts: !useShortCuts
? {}

View file

@ -44,6 +44,7 @@ class InputBarWrapper extends StatefulWidget {
class InputBarWrapperState extends State<InputBarWrapper> {
StreamSubscription? _choreoSub;
String _currentText = '';
@override
void initState() {
@ -65,10 +66,18 @@ class InputBarWrapperState extends State<InputBarWrapper> {
if (widget.onChanged != null) {
widget.onChanged!(text);
}
if (widget.controller?.currentlyMaxLength !=
widget.controller?.isMaxLength) {
final bool decreasedFromMaxLength =
_currentText.length >= PangeaTextController.maxLength &&
text.length < PangeaTextController.maxLength;
final bool reachedMaxLength =
_currentText.length < PangeaTextController.maxLength &&
text.length < PangeaTextController.maxLength;
if (decreasedFromMaxLength || reachedMaxLength) {
setState(() {});
}
_currentText = text;
}
@override

View file

@ -26,10 +26,9 @@ class PangeaTextController extends TextEditingController {
this.text = text;
}
static const int maxLength = 1000;
bool get isMaxLength => text.length == 1000;
bool currentlyMaxLength = false;
bool forceKeepOpen = false;
setSystemText(String text, EditType type) {